From 293450ab724a04c45020bb054ec976105386adc0 Mon Sep 17 00:00:00 2001 From: mogemimi Date: Wed, 16 Nov 2016 05:18:30 +0900 Subject: [PATCH] Enable mouse events for Win32 --- src/Platform.Win32/MouseWin32.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/Platform.Win32/MouseWin32.cpp b/src/Platform.Win32/MouseWin32.cpp index 6aa4b2c72..44962106a 100644 --- a/src/Platform.Win32/MouseWin32.cpp +++ b/src/Platform.Win32/MouseWin32.cpp @@ -1,6 +1,7 @@ // Copyright (c) 2013-2016 mogemimi. Distributed under the MIT license. #include "MouseWin32.hpp" +#include "Pomdog/Input/MouseButtons.hpp" #include "Pomdog/Utility/Assert.hpp" namespace Pomdog { @@ -28,6 +29,7 @@ void MouseWin32::HandleMessage(const RAWMOUSE& mouse) GetCursorPos(&cursorPos); ScreenToClient(windowHandle, &cursorPos); state.Position = Point2D{ cursorPos.x, cursorPos.y }; + Mouse::Moved(state.Position); } else if (mouse.usFlags & MOUSE_MOVE_ABSOLUTE) { previousState.Position = state.Position; @@ -37,11 +39,13 @@ void MouseWin32::HandleMessage(const RAWMOUSE& mouse) GetCursorPos(&cursorPos); ScreenToClient(windowHandle, &cursorPos); state.Position = Point2D{ cursorPos.x, cursorPos.y }; + Mouse::Moved(state.Position); } if (mouse.usButtonFlags & RI_MOUSE_WHEEL) { previousState.ScrollWheel = state.ScrollWheel; state.ScrollWheel += *(SHORT*)(&mouse.usButtonData); + Mouse::ScrollWheel(state.ScrollWheel - previousState.ScrollWheel); } // Not implemented @@ -52,46 +56,56 @@ void MouseWin32::HandleMessage(const RAWMOUSE& mouse) if (mouse.usButtonFlags & RI_MOUSE_BUTTON_1_DOWN) { previousState.LeftButton = state.LeftButton; state.LeftButton = ButtonState::Pressed; + Mouse::ButtonDown(MouseButtons::LeftButton); } else if (mouse.usButtonFlags & RI_MOUSE_BUTTON_1_UP) { previousState.LeftButton = state.LeftButton; state.LeftButton = ButtonState::Released; + Mouse::ButtonUp(MouseButtons::LeftButton); } if (mouse.usButtonFlags & RI_MOUSE_BUTTON_2_DOWN) { previousState.RightButton = state.RightButton; state.RightButton = ButtonState::Pressed; + Mouse::ButtonDown(MouseButtons::RightButton); } else if (mouse.usButtonFlags & RI_MOUSE_BUTTON_2_UP) { previousState.RightButton = state.RightButton; state.RightButton = ButtonState::Released; + Mouse::ButtonUp(MouseButtons::RightButton); } if (mouse.usButtonFlags & RI_MOUSE_BUTTON_3_DOWN) { previousState.MiddleButton = state.MiddleButton; state.MiddleButton = ButtonState::Pressed; + Mouse::ButtonDown(MouseButtons::MiddleButton); } else if (mouse.usButtonFlags & RI_MOUSE_BUTTON_3_UP) { previousState.MiddleButton = state.MiddleButton; state.MiddleButton = ButtonState::Released; + Mouse::ButtonUp(MouseButtons::MiddleButton); } if (mouse.usButtonFlags & RI_MOUSE_BUTTON_4_DOWN) { previousState.XButton1 = state.XButton1; state.XButton1 = ButtonState::Pressed; + Mouse::ButtonDown(MouseButtons::XButton1); } else if (mouse.usButtonFlags & RI_MOUSE_BUTTON_4_UP) { previousState.XButton1 = state.XButton1; state.XButton1 = ButtonState::Released; + Mouse::ButtonUp(MouseButtons::XButton1); } if (mouse.usButtonFlags & RI_MOUSE_BUTTON_5_DOWN) { previousState.XButton2 = state.XButton2; state.XButton2 = ButtonState::Pressed; + Mouse::ButtonDown(MouseButtons::XButton2); } else if (mouse.usButtonFlags & RI_MOUSE_BUTTON_5_UP) { previousState.XButton2 = state.XButton2; state.XButton2 = ButtonState::Released; + Mouse::ButtonUp(MouseButtons::XButton2); } }