From fde1db540ff47867be623cccc82ec307fcb6c2c5 Mon Sep 17 00:00:00 2001 From: Turanszki Janos Date: Sat, 18 Apr 2020 12:52:54 +0100 Subject: [PATCH] mouse input improvement --- WickedEngine/wiInput.cpp | 8 ++++---- WickedEngine/wiInput.h | 3 +++ WickedEngine/wiProfiler.cpp | 2 +- WickedEngine/wiRawInput.cpp | 13 +++++++++++++ WickedEngine/wiVersion.cpp | 2 +- 5 files changed, 22 insertions(+), 6 deletions(-) diff --git a/WickedEngine/wiInput.cpp b/WickedEngine/wiInput.cpp index 135817607..bdb0bfb80 100644 --- a/WickedEngine/wiInput.cpp +++ b/WickedEngine/wiInput.cpp @@ -242,12 +242,15 @@ namespace wiInput switch (button) { case wiInput::MOUSE_BUTTON_LEFT: + if (mouse.left_button_press) return true; keycode = VK_LBUTTON; break; case wiInput::MOUSE_BUTTON_RIGHT: + if (mouse.right_button_press) return true; keycode = VK_RBUTTON; break; case wiInput::MOUSE_BUTTON_MIDDLE: + if (mouse.middle_button_press) return true; keycode = VK_MBUTTON; break; case wiInput::KEYBOARD_BUTTON_UP: @@ -383,14 +386,11 @@ namespace wiInput } XMFLOAT4 GetPointer() { - MouseState state; - wiRawInput::GetMouseState(&state); - #ifndef WINSTORE_SUPPORT POINT p; GetCursorPos(&p); ScreenToClient(wiPlatform::GetWindow(), &p); - return XMFLOAT4((float)p.x, (float)p.y, state.delta_wheel, 0); + return XMFLOAT4((float)p.x, (float)p.y, mouse.delta_wheel, 0); #else auto& p = Windows::UI::Core::CoreWindow::GetForCurrentThread()->PointerPosition; return XMFLOAT4(p.X, p.Y, 0, 0); diff --git a/WickedEngine/wiInput.h b/WickedEngine/wiInput.h index 871ab0522..4495831d9 100644 --- a/WickedEngine/wiInput.h +++ b/WickedEngine/wiInput.h @@ -86,6 +86,9 @@ namespace wiInput XMINT2 position = XMINT2(0, 0); XMINT2 delta_position = XMINT2(0, 0); float delta_wheel = 0; + bool left_button_press = false; + bool middle_button_press = false; + bool right_button_press = false; }; struct ControllerState { diff --git a/WickedEngine/wiProfiler.cpp b/WickedEngine/wiProfiler.cpp index 05d6a2bf6..761c75ac9 100644 --- a/WickedEngine/wiProfiler.cpp +++ b/WickedEngine/wiProfiler.cpp @@ -234,7 +234,7 @@ namespace wiProfiler fx.pos.y = (float)font.params.posY; fx.siz.x = (float)font.textWidth(); fx.siz.y = (float)font.textHeight(); - fx.color = wiColor(40, 40, 40, 140); + fx.color = wiColor(20, 20, 20, 230); wiImage::Draw(wiTextureHelper::getWhite(), fx, cmd); font.Draw(cmd); diff --git a/WickedEngine/wiRawInput.cpp b/WickedEngine/wiRawInput.cpp index 8e408dab0..3b2dbb4b2 100644 --- a/WickedEngine/wiRawInput.cpp +++ b/WickedEngine/wiRawInput.cpp @@ -111,6 +111,19 @@ namespace wiRawInput mouse.position.x += rawmouse.lLastX; mouse.position.y += rawmouse.lLastY; } + + if (rawmouse.usButtonFlags == RI_MOUSE_LEFT_BUTTON_DOWN) + { + mouse.left_button_press = true; + } + if (rawmouse.usButtonFlags == RI_MOUSE_MIDDLE_BUTTON_DOWN) + { + mouse.middle_button_press = true; + } + if (rawmouse.usButtonFlags == RI_MOUSE_RIGHT_BUTTON_DOWN) + { + mouse.right_button_press = true; + } } else if (raw.header.dwType == RIM_TYPEHID) { diff --git a/WickedEngine/wiVersion.cpp b/WickedEngine/wiVersion.cpp index 1104f6b61..5a7598c3d 100644 --- a/WickedEngine/wiVersion.cpp +++ b/WickedEngine/wiVersion.cpp @@ -9,7 +9,7 @@ namespace wiVersion // minor features, major updates const int minor = 39; // minor bug fixes, alterations, refactors, updates - const int revision = 67; + const int revision = 68; long GetVersion()