From da79bc0dd453e7c45b9dacc511f19776697e2167 Mon Sep 17 00:00:00 2001 From: Reece Mackie <20544390+Rover656@users.noreply.github.com> Date: Thu, 25 Apr 2019 19:24:48 +0100 Subject: [PATCH] Cleaning and small tweaks --- projects/VS2017.UWP/raylib.App.UWP/App.cpp | 12 - projects/VS2017.UWP/raylib.App.UWP/BaseApp.h | 506 +++++++++---------- 2 files changed, 250 insertions(+), 268 deletions(-) diff --git a/projects/VS2017.UWP/raylib.App.UWP/App.cpp b/projects/VS2017.UWP/raylib.App.UWP/App.cpp index 7dc318a27..6f5cd6528 100644 --- a/projects/VS2017.UWP/raylib.App.UWP/App.cpp +++ b/projects/VS2017.UWP/raylib.App.UWP/App.cpp @@ -3,18 +3,6 @@ #include "raylib.h" -using namespace Windows::ApplicationModel::Core; -using namespace Windows::ApplicationModel::Activation; -using namespace Windows::UI::Core; -using namespace Windows::UI::Input; -using namespace Windows::Devices::Input; -using namespace Windows::Foundation; -using namespace Windows::Foundation::Collections; -using namespace Windows::Gaming::Input; -using namespace Windows::Graphics::Display; -using namespace Microsoft::WRL; -using namespace Platform; - using namespace raylibUWP; /* OTHER CODE */ diff --git a/projects/VS2017.UWP/raylib.App.UWP/BaseApp.h b/projects/VS2017.UWP/raylib.App.UWP/BaseApp.h index b7794a1d5..ff6f2db41 100644 --- a/projects/VS2017.UWP/raylib.App.UWP/BaseApp.h +++ b/projects/VS2017.UWP/raylib.App.UWP/BaseApp.h @@ -66,10 +66,6 @@ TODO list: #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 -//static char currentGamepadState[MAX_GAMEPADS][MAX_GAMEPAD_BUTTONS]; // Current gamepad buttons state //Mouse cursor locking bool cursorLocked = false; @@ -119,263 +115,261 @@ void DisableCursor() cursorLocked = true; } -namespace raylibUWP +//Base app implementation +ref class BaseApp : public Windows::ApplicationModel::Core::IFrameworkView { - ref class BaseApp : public Windows::ApplicationModel::Core::IFrameworkView +public: + + // IFrameworkView Methods. + virtual void Initialize(Windows::ApplicationModel::Core::CoreApplicationView^ applicationView) { - public: + // Register event handlers for app lifecycle. This example includes Activated, so that we + // can make the CoreWindow active and start rendering on the window. + applicationView->Activated += ref new TypedEventHandler(this, &BaseApp::OnActivated); - // IFrameworkView Methods. - virtual void Initialize(Windows::ApplicationModel::Core::CoreApplicationView^ applicationView) - { - // Register event handlers for app lifecycle. This example includes Activated, so that we - // can make the CoreWindow active and start rendering on the window. - applicationView->Activated += ref new TypedEventHandler(this, &BaseApp::OnActivated); + // Logic for other event handlers could go here. + // Information about the Suspending and Resuming event handlers can be found here: + // http://msdn.microsoft.com/en-us/library/windows/apps/xaml/hh994930.aspx - // Logic for other event handlers could go here. - // Information about the Suspending and Resuming event handlers can be found here: - // http://msdn.microsoft.com/en-us/library/windows/apps/xaml/hh994930.aspx + CoreApplication::Resuming += ref new EventHandler(this, &BaseApp::OnResuming); + } - CoreApplication::Resuming += ref new EventHandler(this, &BaseApp::OnResuming); - } - - virtual void SetWindow(Windows::UI::Core::CoreWindow^ window) - { - window->SizeChanged += ref new TypedEventHandler(this, &BaseApp::OnWindowSizeChanged); - window->VisibilityChanged += ref new TypedEventHandler(this, &BaseApp::OnVisibilityChanged); - window->Closed += ref new TypedEventHandler(this, &BaseApp::OnWindowClosed); - - window->PointerPressed += ref new TypedEventHandler(this, &BaseApp::PointerPressed); - window->PointerReleased += ref new TypedEventHandler(this, &BaseApp::PointerReleased); - window->PointerWheelChanged += ref new TypedEventHandler(this, &BaseApp::PointerWheelChanged); - window->KeyDown += ref new TypedEventHandler(this, &BaseApp::OnKeyDown); - window->KeyUp += ref new TypedEventHandler(this, &BaseApp::OnKeyUp); - - Windows::Devices::Input::MouseDevice::GetForCurrentView()->MouseMoved += ref new TypedEventHandler(this, &BaseApp::MouseMoved); - - DisplayInformation^ currentDisplayInformation = DisplayInformation::GetForCurrentView(); - currentDisplayInformation->DpiChanged += ref new TypedEventHandler(this, &BaseApp::OnDpiChanged); - currentDisplayInformation->OrientationChanged += ref new TypedEventHandler(this, &BaseApp::OnOrientationChanged); - - // The CoreWindow has been created, so EGL can be initialized. - - uwpWindow = (EGLNativeWindowType)window; - - InitWindow(width, height, NULL); - } - - virtual void Load(Platform::String^ entryPoint) {} - - virtual void Run() - { - while (!mWindowClosed) - { - if (mWindowVisible) - { - //Call update function - Update(); - - PollInput(); - - CoreWindow::GetForCurrentThread()->Dispatcher->ProcessEvents(CoreProcessEventsOption::ProcessAllIfPresent); - } - else - { - CoreWindow::GetForCurrentThread()->Dispatcher->ProcessEvents(CoreProcessEventsOption::ProcessOneAndAllPending); - } - } - - CloseWindow(); - } - - //Called every frame (Maybe add draw) - virtual void Update() {} - - virtual void Uninitialize() {} - - protected: - - // Input polling - void PollInput() - { - // Process Mouse - { - CoreWindow ^window = CoreWindow::GetForCurrentThread(); - - if (cursorLocked) - { - // Track cursor movement delta, recenter it on the client - auto curMousePos = GetMousePosition(); - - auto x = curMousePos.x + mouseDelta.x; - auto y = curMousePos.y + mouseDelta.y; - - UWPMousePosition(x, y); - - // Why we're not using UWPSetMousePosition here... - // UWPSetMousePosition changes the "mousePosition" variable to match where the cursor actually is. - // Our cursor is locked to the middle of screen, and we don't want that reflected in "mousePosition" - Vector2 centerClient = { (float)(GetScreenWidth() / 2), (float)(GetScreenHeight() / 2) }; - window->PointerPosition = Point(centerClient.x + window->Bounds.X, centerClient.y + window->Bounds.Y); - } - else - { - // Record the cursor's position relative to the client - auto x = window->PointerPosition.X - window->Bounds.X; - auto y = window->PointerPosition.Y - window->Bounds.Y; - - UWPMousePosition(x, y); - } - - mouseDelta = { 0 ,0 }; - } - - // Process Gamepads - { - // Check if gamepads are ready - for (int i = 0; i < MAX_GAMEPADS; i++) - { - // HACK: UWP keeps a contiguous list of gamepads. For the interest of time I'm just doing a 1:1 mapping of - // connected gamepads with their spot in the list, but this has serious robustness problems - // e.g. player 1, 2, and 3 are playing a game - if player2 disconnects, p3's controller would now be mapped to p2's character since p3 is now second in the list. - - UWPGamepadActive(i, i < Gamepad::Gamepads->Size); - } - - // Get current gamepad state - for (int i = 0; i < MAX_GAMEPADS; i++) - { - if (IsGamepadAvailable(i)) - { - // Get current gamepad state - auto gamepad = Gamepad::Gamepads->GetAt(i); - GamepadReading reading = gamepad->GetCurrentReading(); - - // NOTE: Maybe it would be wiser to redefine the gamepad button mappings in "raylib.h" for the UWP platform instead of remapping them manually - UWPGamepadButton(i, GAMEPAD_XBOX_BUTTON_A, ((reading.Buttons & GamepadButtons::A) == GamepadButtons::A)); - UWPGamepadButton(i, GAMEPAD_XBOX_BUTTON_B, ((reading.Buttons & GamepadButtons::B) == GamepadButtons::B)); - UWPGamepadButton(i, GAMEPAD_XBOX_BUTTON_X, ((reading.Buttons & GamepadButtons::X) == GamepadButtons::X)); - UWPGamepadButton(i, GAMEPAD_XBOX_BUTTON_Y, ((reading.Buttons & GamepadButtons::Y) == GamepadButtons::Y)); - UWPGamepadButton(i, GAMEPAD_XBOX_BUTTON_LB, ((reading.Buttons & GamepadButtons::LeftShoulder) == GamepadButtons::LeftShoulder)); - UWPGamepadButton(i, GAMEPAD_XBOX_BUTTON_RB, ((reading.Buttons & GamepadButtons::RightShoulder) == GamepadButtons::RightShoulder)); - UWPGamepadButton(i, GAMEPAD_XBOX_BUTTON_SELECT, ((reading.Buttons & GamepadButtons::View) == GamepadButtons::View)); // Changed for XB1 Controller - UWPGamepadButton(i, GAMEPAD_XBOX_BUTTON_START, ((reading.Buttons & GamepadButtons::Menu) == GamepadButtons::Menu)); // Changed for XB1 Controller - UWPGamepadButton(i, GAMEPAD_XBOX_BUTTON_UP, ((reading.Buttons & GamepadButtons::DPadUp) == GamepadButtons::DPadUp)); - UWPGamepadButton(i, GAMEPAD_XBOX_BUTTON_RIGHT, ((reading.Buttons & GamepadButtons::DPadRight) == GamepadButtons::DPadRight)); - UWPGamepadButton(i, GAMEPAD_XBOX_BUTTON_DOWN, ((reading.Buttons & GamepadButtons::DPadDown) == GamepadButtons::DPadDown)); - UWPGamepadButton(i, GAMEPAD_XBOX_BUTTON_LEFT, ((reading.Buttons & GamepadButtons::DPadLeft) == GamepadButtons::DPadLeft)); - UWPGamepadButton(i, GAMEPAD_XBOX_BUTTON_HOME, false); // Home button not supported by UWP - - // Get current axis state - UWPGamepadAxis(i, GAMEPAD_XBOX_AXIS_LEFT_X, (float)reading.LeftThumbstickX); - UWPGamepadAxis(i, GAMEPAD_XBOX_AXIS_LEFT_Y, (float)reading.LeftThumbstickY); - UWPGamepadAxis(i, GAMEPAD_XBOX_AXIS_RIGHT_X, (float)reading.RightThumbstickX); - UWPGamepadAxis(i, GAMEPAD_XBOX_AXIS_RIGHT_Y, (float)reading.RightThumbstickY); - UWPGamepadAxis(i, GAMEPAD_XBOX_AXIS_LT, (float)reading.LeftTrigger); - UWPGamepadAxis(i, GAMEPAD_XBOX_AXIS_RT, (float)reading.RightTrigger); - } - } - } - } - - // Application lifecycle event handlers. - void OnActivated(Windows::ApplicationModel::Core::CoreApplicationView^ applicationView, Windows::ApplicationModel::Activation::IActivatedEventArgs^ args) - { - // Run() won't start until the CoreWindow is activated. - CoreWindow::GetForCurrentThread()->Activate(); - } - - void OnResuming(Platform::Object^ sender, Platform::Object^ args) {} - - // Window event handlers. - void OnWindowSizeChanged(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::WindowSizeChangedEventArgs^ args) {} - - void OnVisibilityChanged(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::VisibilityChangedEventArgs^ args) - { - mWindowVisible = args->Visible; - } - - void OnWindowClosed(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::CoreWindowEventArgs^ args) - { - mWindowClosed = true; - } - - // DisplayInformation event handlers. - void OnDpiChanged(Windows::Graphics::Display::DisplayInformation^ sender, Platform::Object^ args) {} - void OnOrientationChanged(Windows::Graphics::Display::DisplayInformation^ sender, Platform::Object^ args) {} - - // Input event handlers - void PointerPressed(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::PointerEventArgs^ args) - { - if (args->CurrentPoint->Properties->IsLeftButtonPressed) - { - UWPRegisterClick(MOUSE_LEFT_BUTTON, 1); - } - if (args->CurrentPoint->Properties->IsRightButtonPressed) - { - UWPRegisterClick(MOUSE_RIGHT_BUTTON, 1); - } - if (args->CurrentPoint->Properties->IsMiddleButtonPressed) - { - UWPRegisterClick(MOUSE_MIDDLE_BUTTON, 1); - } - } - - void PointerReleased(Windows::UI::Core::CoreWindow ^sender, Windows::UI::Core::PointerEventArgs^ args) - { - if (!(args->CurrentPoint->Properties->IsLeftButtonPressed)) - { - UWPRegisterClick(MOUSE_LEFT_BUTTON, 0); - } - if (!(args->CurrentPoint->Properties->IsRightButtonPressed)) - { - UWPRegisterClick(MOUSE_RIGHT_BUTTON, 0); - } - if (!(args->CurrentPoint->Properties->IsMiddleButtonPressed)) - { - UWPRegisterClick(MOUSE_MIDDLE_BUTTON, 0); - } - } - - void PointerWheelChanged(Windows::UI::Core::CoreWindow ^sender, Windows::UI::Core::PointerEventArgs^ args) - { - UWPScrollWheel(args->CurrentPoint->Properties->MouseWheelDelta); - } - - void MouseMoved(Windows::Devices::Input::MouseDevice^ mouseDevice, Windows::Devices::Input::MouseEventArgs^ args) - { - mouseDelta.x += args->MouseDelta.X; - mouseDelta.y += args->MouseDelta.Y; - } - - void OnKeyDown(Windows::UI::Core::CoreWindow ^ sender, Windows::UI::Core::KeyEventArgs ^ args) - { - UWPRegisterKey((int)args->VirtualKey, 1); - } - - void OnKeyUp(Windows::UI::Core::CoreWindow ^ sender, Windows::UI::Core::KeyEventArgs ^ args) - { - //TODO: Fix hold errors - UWPRegisterKey((int)args->VirtualKey, 0); - } - - private: - - bool mWindowClosed = false; - bool mWindowVisible = true; - - int width = 800; - int height = 450; - }; - - - template - ref class ApplicationSource sealed : Windows::ApplicationModel::Core::IFrameworkViewSource + virtual void SetWindow(Windows::UI::Core::CoreWindow^ window) { - public: - virtual Windows::ApplicationModel::Core::IFrameworkView^ CreateView() + window->SizeChanged += ref new TypedEventHandler(this, &BaseApp::OnWindowSizeChanged); + window->VisibilityChanged += ref new TypedEventHandler(this, &BaseApp::OnVisibilityChanged); + window->Closed += ref new TypedEventHandler(this, &BaseApp::OnWindowClosed); + + window->PointerPressed += ref new TypedEventHandler(this, &BaseApp::PointerPressed); + window->PointerReleased += ref new TypedEventHandler(this, &BaseApp::PointerReleased); + window->PointerWheelChanged += ref new TypedEventHandler(this, &BaseApp::PointerWheelChanged); + window->KeyDown += ref new TypedEventHandler(this, &BaseApp::OnKeyDown); + window->KeyUp += ref new TypedEventHandler(this, &BaseApp::OnKeyUp); + + Windows::Devices::Input::MouseDevice::GetForCurrentView()->MouseMoved += ref new TypedEventHandler(this, &BaseApp::MouseMoved); + + DisplayInformation^ currentDisplayInformation = DisplayInformation::GetForCurrentView(); + currentDisplayInformation->DpiChanged += ref new TypedEventHandler(this, &BaseApp::OnDpiChanged); + currentDisplayInformation->OrientationChanged += ref new TypedEventHandler(this, &BaseApp::OnOrientationChanged); + + // The CoreWindow has been created, so EGL can be initialized. + + uwpWindow = (EGLNativeWindowType)window; + + InitWindow(width, height, NULL); + } + + virtual void Load(Platform::String^ entryPoint) {} + + virtual void Run() + { + while (!mWindowClosed) { - return ref new AppType(); + if (mWindowVisible) + { + //Call update function + Update(); + + PollInput(); + + CoreWindow::GetForCurrentThread()->Dispatcher->ProcessEvents(CoreProcessEventsOption::ProcessAllIfPresent); + } + else + { + CoreWindow::GetForCurrentThread()->Dispatcher->ProcessEvents(CoreProcessEventsOption::ProcessOneAndAllPending); + } } - }; -} \ No newline at end of file + + CloseWindow(); + } + + //Called every frame (Maybe add draw) + virtual void Update() {} + + virtual void Uninitialize() {} + +protected: + + // Input polling + void PollInput() + { + // Process Mouse + { + CoreWindow ^window = CoreWindow::GetForCurrentThread(); + + if (cursorLocked) + { + // Track cursor movement delta, recenter it on the client + auto curMousePos = GetMousePosition(); + + auto x = curMousePos.x + mouseDelta.x; + auto y = curMousePos.y + mouseDelta.y; + + UWPMousePosition(x, y); + + // Why we're not using UWPSetMousePosition here... + // UWPSetMousePosition changes the "mousePosition" variable to match where the cursor actually is. + // Our cursor is locked to the middle of screen, and we don't want that reflected in "mousePosition" + Vector2 centerClient = { (float)(GetScreenWidth() / 2), (float)(GetScreenHeight() / 2) }; + window->PointerPosition = Point(centerClient.x + window->Bounds.X, centerClient.y + window->Bounds.Y); + } + else + { + // Record the cursor's position relative to the client + auto x = window->PointerPosition.X - window->Bounds.X; + auto y = window->PointerPosition.Y - window->Bounds.Y; + + UWPMousePosition(x, y); + } + + mouseDelta = { 0 ,0 }; + } + + // Process Gamepads + { + // Check if gamepads are ready + for (int i = 0; i < MAX_GAMEPADS; i++) + { + // HACK: UWP keeps a contiguous list of gamepads. For the interest of time I'm just doing a 1:1 mapping of + // connected gamepads with their spot in the list, but this has serious robustness problems + // e.g. player 1, 2, and 3 are playing a game - if player2 disconnects, p3's controller would now be mapped to p2's character since p3 is now second in the list. + + UWPGamepadActive(i, i < Gamepad::Gamepads->Size); + } + + // Get current gamepad state + for (int i = 0; i < MAX_GAMEPADS; i++) + { + if (IsGamepadAvailable(i)) + { + // Get current gamepad state + auto gamepad = Gamepad::Gamepads->GetAt(i); + GamepadReading reading = gamepad->GetCurrentReading(); + + // NOTE: Maybe it would be wiser to redefine the gamepad button mappings in "raylib.h" for the UWP platform instead of remapping them manually + UWPGamepadButton(i, GAMEPAD_XBOX_BUTTON_A, ((reading.Buttons & GamepadButtons::A) == GamepadButtons::A)); + UWPGamepadButton(i, GAMEPAD_XBOX_BUTTON_B, ((reading.Buttons & GamepadButtons::B) == GamepadButtons::B)); + UWPGamepadButton(i, GAMEPAD_XBOX_BUTTON_X, ((reading.Buttons & GamepadButtons::X) == GamepadButtons::X)); + UWPGamepadButton(i, GAMEPAD_XBOX_BUTTON_Y, ((reading.Buttons & GamepadButtons::Y) == GamepadButtons::Y)); + UWPGamepadButton(i, GAMEPAD_XBOX_BUTTON_LB, ((reading.Buttons & GamepadButtons::LeftShoulder) == GamepadButtons::LeftShoulder)); + UWPGamepadButton(i, GAMEPAD_XBOX_BUTTON_RB, ((reading.Buttons & GamepadButtons::RightShoulder) == GamepadButtons::RightShoulder)); + UWPGamepadButton(i, GAMEPAD_XBOX_BUTTON_SELECT, ((reading.Buttons & GamepadButtons::View) == GamepadButtons::View)); // Changed for XB1 Controller + UWPGamepadButton(i, GAMEPAD_XBOX_BUTTON_START, ((reading.Buttons & GamepadButtons::Menu) == GamepadButtons::Menu)); // Changed for XB1 Controller + UWPGamepadButton(i, GAMEPAD_XBOX_BUTTON_UP, ((reading.Buttons & GamepadButtons::DPadUp) == GamepadButtons::DPadUp)); + UWPGamepadButton(i, GAMEPAD_XBOX_BUTTON_RIGHT, ((reading.Buttons & GamepadButtons::DPadRight) == GamepadButtons::DPadRight)); + UWPGamepadButton(i, GAMEPAD_XBOX_BUTTON_DOWN, ((reading.Buttons & GamepadButtons::DPadDown) == GamepadButtons::DPadDown)); + UWPGamepadButton(i, GAMEPAD_XBOX_BUTTON_LEFT, ((reading.Buttons & GamepadButtons::DPadLeft) == GamepadButtons::DPadLeft)); + UWPGamepadButton(i, GAMEPAD_XBOX_BUTTON_HOME, false); // Home button not supported by UWP + + // Get current axis state + UWPGamepadAxis(i, GAMEPAD_XBOX_AXIS_LEFT_X, (float)reading.LeftThumbstickX); + UWPGamepadAxis(i, GAMEPAD_XBOX_AXIS_LEFT_Y, (float)reading.LeftThumbstickY); + UWPGamepadAxis(i, GAMEPAD_XBOX_AXIS_RIGHT_X, (float)reading.RightThumbstickX); + UWPGamepadAxis(i, GAMEPAD_XBOX_AXIS_RIGHT_Y, (float)reading.RightThumbstickY); + UWPGamepadAxis(i, GAMEPAD_XBOX_AXIS_LT, (float)reading.LeftTrigger); + UWPGamepadAxis(i, GAMEPAD_XBOX_AXIS_RT, (float)reading.RightTrigger); + } + } + } + } + + // Application lifecycle event handlers. + void OnActivated(Windows::ApplicationModel::Core::CoreApplicationView^ applicationView, Windows::ApplicationModel::Activation::IActivatedEventArgs^ args) + { + // Run() won't start until the CoreWindow is activated. + CoreWindow::GetForCurrentThread()->Activate(); + } + + void OnResuming(Platform::Object^ sender, Platform::Object^ args) {} + + // Window event handlers. + void OnWindowSizeChanged(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::WindowSizeChangedEventArgs^ args) {} + + void OnVisibilityChanged(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::VisibilityChangedEventArgs^ args) + { + mWindowVisible = args->Visible; + } + + void OnWindowClosed(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::CoreWindowEventArgs^ args) + { + mWindowClosed = true; + } + + // DisplayInformation event handlers. + void OnDpiChanged(Windows::Graphics::Display::DisplayInformation^ sender, Platform::Object^ args) {} + void OnOrientationChanged(Windows::Graphics::Display::DisplayInformation^ sender, Platform::Object^ args) {} + + // Input event handlers + void PointerPressed(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::PointerEventArgs^ args) + { + if (args->CurrentPoint->Properties->IsLeftButtonPressed) + { + UWPRegisterClick(MOUSE_LEFT_BUTTON, 1); + } + if (args->CurrentPoint->Properties->IsRightButtonPressed) + { + UWPRegisterClick(MOUSE_RIGHT_BUTTON, 1); + } + if (args->CurrentPoint->Properties->IsMiddleButtonPressed) + { + UWPRegisterClick(MOUSE_MIDDLE_BUTTON, 1); + } + } + + void PointerReleased(Windows::UI::Core::CoreWindow ^sender, Windows::UI::Core::PointerEventArgs^ args) + { + if (!(args->CurrentPoint->Properties->IsLeftButtonPressed)) + { + UWPRegisterClick(MOUSE_LEFT_BUTTON, 0); + } + if (!(args->CurrentPoint->Properties->IsRightButtonPressed)) + { + UWPRegisterClick(MOUSE_RIGHT_BUTTON, 0); + } + if (!(args->CurrentPoint->Properties->IsMiddleButtonPressed)) + { + UWPRegisterClick(MOUSE_MIDDLE_BUTTON, 0); + } + } + + void PointerWheelChanged(Windows::UI::Core::CoreWindow ^sender, Windows::UI::Core::PointerEventArgs^ args) + { + UWPScrollWheel(args->CurrentPoint->Properties->MouseWheelDelta); + } + + void MouseMoved(Windows::Devices::Input::MouseDevice^ mouseDevice, Windows::Devices::Input::MouseEventArgs^ args) + { + mouseDelta.x += args->MouseDelta.X; + mouseDelta.y += args->MouseDelta.Y; + } + + void OnKeyDown(Windows::UI::Core::CoreWindow ^ sender, Windows::UI::Core::KeyEventArgs ^ args) + { + UWPRegisterKey((int)args->VirtualKey, 1); + } + + void OnKeyUp(Windows::UI::Core::CoreWindow ^ sender, Windows::UI::Core::KeyEventArgs ^ args) + { + //TODO: Fix hold errors + UWPRegisterKey((int)args->VirtualKey, 0); + } + +private: + + bool mWindowClosed = false; + bool mWindowVisible = true; + + int width = 800; + int height = 450; +}; + +//Application source for creating the program +template +ref class ApplicationSource sealed : Windows::ApplicationModel::Core::IFrameworkViewSource +{ +public: + virtual Windows::ApplicationModel::Core::IFrameworkView^ CreateView() + { + return ref new AppType(); + } +}; \ No newline at end of file