From 2d7b134b3b75714dbf2bf6e46a00bb1b44975a96 Mon Sep 17 00:00:00 2001 From: Dario Manesku Date: Mon, 2 Mar 2015 16:54:22 +0100 Subject: [PATCH 1/2] Added support for mouse scroll. --- examples/common/entry/entry_x11.cpp | 33 +++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/examples/common/entry/entry_x11.cpp b/examples/common/entry/entry_x11.cpp index 05080671..627263fa 100644 --- a/examples/common/entry/entry_x11.cpp +++ b/examples/common/entry/entry_x11.cpp @@ -267,6 +267,10 @@ namespace entry initTranslateKey('x', Key::KeyX); initTranslateKey('y', Key::KeyY); initTranslateKey('z', Key::KeyZ); + + m_mx = 0; + m_my = 0; + m_mz = 0; } int32_t run(int _argc, char** _argv) @@ -367,18 +371,19 @@ namespace entry case ButtonRelease: { const XButtonEvent& xbutton = event.xbutton; - MouseButton::Enum mb; + MouseButton::Enum mb = MouseButton::None; switch (xbutton.button) { case Button1: mb = MouseButton::Left; break; case Button2: mb = MouseButton::Middle; break; case Button3: mb = MouseButton::Right; break; - default: mb = MouseButton::None; break; + case Button4: ++m_mz; break; + case Button5: --m_mz; break; } + WindowHandle handle = findHandle(xbutton.window); if (MouseButton::None != mb) { - WindowHandle handle = findHandle(xbutton.window); m_eventQueue.postMouseEvent(handle , xbutton.x , xbutton.y @@ -387,6 +392,14 @@ namespace entry , event.type == ButtonPress ); } + else + { + m_eventQueue.postMouseEvent(handle + , m_mx + , m_my + , m_mz + ); + } } break; @@ -394,10 +407,14 @@ namespace entry { const XMotionEvent& xmotion = event.xmotion; WindowHandle handle = findHandle(xmotion.window); + + m_mx = xmotion.x; + m_my = xmotion.y; + m_eventQueue.postMouseEvent(handle - , xmotion.x - , xmotion.y - , 0 + , m_mx + , m_my + , m_mz ); } break; @@ -543,6 +560,10 @@ namespace entry uint8_t m_modifiers; bool m_exit; + int32_t m_mx; + int32_t m_my; + int32_t m_mz; + EventQueue m_eventQueue; bx::LwMutex m_lock; bx::HandleAllocT m_windowAlloc; From 5453b2cf409d49cc8d6a7eda7eabd3f9e9a83abb Mon Sep 17 00:00:00 2001 From: Dario Manesku Date: Mon, 2 Mar 2015 16:07:32 +0100 Subject: [PATCH 2/2] Fixed mouse scroll value on Windows. --- examples/common/entry/entry_windows.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/common/entry/entry_windows.cpp b/examples/common/entry/entry_windows.cpp index 1b3f4f2d..335d5cb4 100644 --- a/examples/common/entry/entry_windows.cpp +++ b/examples/common/entry/entry_windows.cpp @@ -706,7 +706,7 @@ namespace entry ScreenToClient(_hwnd, &pt); int32_t mx = pt.x; int32_t my = pt.y; - m_mz += GET_WHEEL_DELTA_WPARAM(_wparam); + m_mz += GET_WHEEL_DELTA_WPARAM(_wparam)/WHEEL_DELTA; m_eventQueue.postMouseEvent(findHandle(_hwnd), mx, my, m_mz); } break;