diff --git a/project/vs2015.UWP/raylib.App.UWP/App.cpp b/project/vs2015.UWP/raylib.App.UWP/App.cpp index 375b668c0..6ce6915c1 100644 --- a/project/vs2015.UWP/raylib.App.UWP/App.cpp +++ b/project/vs2015.UWP/raylib.App.UWP/App.cpp @@ -18,16 +18,21 @@ using namespace Platform; using namespace raylibUWP; /* -To-do list +TODO list: - Cache reference to our CoreWindow? - - Implement gestures + - Implement gestures support */ +// Declare uwpWindow as exter to be used by raylib internals +// NOTE: It should be properly assigned before calling InitWindow() +extern "C" { EGLNativeWindowType uwpWindow; }; + /* INPUT CODE */ // Stand-ins for "core.c" variables #define MAX_GAMEPADS 4 // Max number of gamepads supported #define MAX_GAMEPAD_BUTTONS 32 // Max bumber of buttons supported (per gamepad) #define MAX_GAMEPAD_AXIS 8 // Max number of axis supported (per gamepad) + static bool gamepadReady[MAX_GAMEPADS] = { false }; // Flag to know if gamepad is ready static float gamepadAxisState[MAX_GAMEPADS][MAX_GAMEPAD_AXIS]; // Gamepad axis state static char previousGamepadState[MAX_GAMEPADS][MAX_GAMEPAD_BUTTONS]; // Previous gamepad buttons state @@ -36,7 +41,6 @@ static char currentGamepadState[MAX_GAMEPADS][MAX_GAMEPAD_BUTTONS]; // Curre static char previousKeyState[512] = { 0 }; // Contains previous frame keyboard state static char currentKeyState[512] = { 0 }; // Contains current frame keyboard state -//... static char previousMouseState[3] = { 0 }; // Registers previous mouse button state static char currentMouseState[3] = { 0 }; // Registers current mouse button state static int previousMouseWheelY = 0; // Registers previous mouse wheel variation @@ -46,7 +50,7 @@ static bool cursorOnScreen = false; // Tracks if cursor is inside client static bool cursorHidden = false; // Track if cursor is hidden static Vector2 mousePosition; -static Vector2 mouseDelta; // NOTE: Added to keep track of mouse movement while the cursor is locked - no equivalent in "core.c" +static Vector2 mouseDelta; // NOTE: Added to keep track of mouse movement while the cursor is locked - no equivalent in "core.c" static bool toggleCursorLock; CoreCursor ^regularCursor = ref new CoreCursor(CoreCursorType::Arrow, 0); // The "visible arrow" cursor type @@ -122,7 +126,7 @@ void ProcessKeyEvent(Windows::System::VirtualKey key, int action) } } -/* CALLBACKS */ +// Callbacks void App::PointerPressed(CoreWindow^ window, PointerEventArgs^ args) { if (args->CurrentPoint->Properties->IsLeftButtonPressed) @@ -206,6 +210,7 @@ void UWPSetMousePosition(Vector2 position) window->PointerPosition = mousePosScreen; mousePosition = position; } + // Enables cursor (unlock cursor) void UWPEnableCursor() { @@ -321,8 +326,7 @@ bool UWPIsKeyPressed(int key) { bool pressed = false; - if ((currentKeyState[key] != previousKeyState[key]) && (currentKeyState[key] == 1)) - pressed = true; + if ((currentKeyState[key] != previousKeyState[key]) && (currentKeyState[key] == 1)) pressed = true; else pressed = false; return pressed; @@ -422,7 +426,10 @@ void App::SetWindow(CoreWindow^ window) currentDisplayInformation->OrientationChanged += ref new TypedEventHandler(this, &App::OnOrientationChanged); // The CoreWindow has been created, so EGL can be initialized. - InitWindow(800, 450, (EGLNativeWindowType)window); + + uwpWindow = (EGLNativeWindowType)window; + + InitWindow(800, 450, NULL); } // Initializes scene resources @@ -446,7 +453,6 @@ void App::Run() ClearBackground(RAYWHITE); - posX += gamepadAxisState[GAMEPAD_PLAYER1][GAMEPAD_XBOX_AXIS_LEFT_X] * 5; posY += gamepadAxisState[GAMEPAD_PLAYER1][GAMEPAD_XBOX_AXIS_LEFT_Y] * -5; DrawRectangle(posX, posY, 400, 100, RED); @@ -455,38 +461,32 @@ void App::Run() DrawCircle(mousePosition.x, mousePosition.y, 40, BLUE); - if(UWPIsKeyDown(KEY_S)) - { - DrawCircle(100, 100, 100, BLUE); - } + if (UWPIsKeyDown(KEY_S)) DrawCircle(100, 100, 100, BLUE); - if(UWPIsKeyPressed(KEY_A)) + if (UWPIsKeyPressed(KEY_A)) { posX -= 50; UWPEnableCursor(); } + if (UWPIsKeyPressed(KEY_D)) { posX += 50; - UWPDisableCursor(); } - if(currentKeyState[KEY_LEFT_ALT]) - DrawRectangle(250, 250, 20, 20, BLACK); - if (currentKeyState[KEY_BACKSPACE]) - DrawRectangle(280, 250, 20, 20, BLACK); - - if (currentMouseState[MOUSE_LEFT_BUTTON]) - DrawRectangle(280, 250, 20, 20, BLACK); + if (currentKeyState[KEY_LEFT_ALT]) DrawRectangle(250, 250, 20, 20, BLACK); + if (currentKeyState[KEY_BACKSPACE]) DrawRectangle(280, 250, 20, 20, BLACK); + if (currentMouseState[MOUSE_LEFT_BUTTON]) DrawRectangle(280, 250, 20, 20, BLACK); static int pos = 0; pos -= currentMouseWheelY; - DrawRectangle(280, pos + 50, 20, 20, BLACK); + DrawRectangle(280, pos + 50, 20, 20, BLACK); DrawRectangle(250, 280 + (time++ % 60), 10, 10, PURPLE); EndDrawing(); + UWP_PollInput(); CoreWindow::GetForCurrentThread()->Dispatcher->ProcessEvents(CoreProcessEventsOption::ProcessAllIfPresent); diff --git a/project/vs2015.UWP/raylib.App.UWP/Package.appxmanifest b/project/vs2015.UWP/raylib.App.UWP/Package.appxmanifest index f0f568628..56020a505 100644 --- a/project/vs2015.UWP/raylib.App.UWP/Package.appxmanifest +++ b/project/vs2015.UWP/raylib.App.UWP/Package.appxmanifest @@ -4,7 +4,7 @@ raylibUWP - Alumno + raysan5 Assets\StoreLogo.png diff --git a/project/vs2015.UWP/raylib.App.UWP/raylib.App.UWP.vcxproj b/project/vs2015.UWP/raylib.App.UWP/raylib.App.UWP.vcxproj index bc7f27d24..6af9db604 100644 --- a/project/vs2015.UWP/raylib.App.UWP/raylib.App.UWP.vcxproj +++ b/project/vs2015.UWP/raylib.App.UWP/raylib.App.UWP.vcxproj @@ -34,7 +34,7 @@ true Windows Store 10.0.14393.0 - 10.0.10586.0 + 10.0.14393.0 10.0 raylib.App.UWP diff --git a/project/vs2015.UWP/raylib/raylib.vcxproj b/project/vs2015.UWP/raylib/raylib.vcxproj index 32e59759b..c1fbca500 100644 --- a/project/vs2015.UWP/raylib/raylib.vcxproj +++ b/project/vs2015.UWP/raylib/raylib.vcxproj @@ -28,7 +28,7 @@ StaticLibrary true - v141 + v140 Unicode