From acd4dedfe174648bf24cc63d3ca7b8439b15a123 Mon Sep 17 00:00:00 2001 From: Dario Manesku Date: Mon, 16 Mar 2015 15:19:35 +0100 Subject: [PATCH] Added mouse scroll support to entry_sdl. --- examples/common/entry/entry_sdl.cpp | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/examples/common/entry/entry_sdl.cpp b/examples/common/entry/entry_sdl.cpp index c279f0fd..48a049ea 100644 --- a/examples/common/entry/entry_sdl.cpp +++ b/examples/common/entry/entry_sdl.cpp @@ -211,6 +211,9 @@ namespace entry : m_width(ENTRY_DEFAULT_WIDTH) , m_height(ENTRY_DEFAULT_HEIGHT) , m_aspectRatio(16.0f/9.0f) + , m_mx(0) + , m_my(0) + , m_mz(0) , m_mouseLock(false) , m_fullscreen(false) { @@ -376,10 +379,13 @@ namespace entry case SDL_MOUSEMOTION: { const SDL_MouseMotionEvent& mev = event.motion; + m_mx = mev.x; + m_my = mev.y; + WindowHandle handle = findHandle(mev.windowID); if (isValid(handle) ) { - m_eventQueue.postMouseEvent(handle, mev.x, mev.y, 0); + m_eventQueue.postMouseEvent(handle, m_mx, m_my, m_mz); } } break; @@ -411,6 +417,19 @@ namespace entry } break; + case SDL_MOUSEWHEEL: + { + const SDL_MouseWheelEvent& mev = event.wheel; + m_mz += mev.y; + + WindowHandle handle = findHandle(mev.windowID); + if (isValid(handle) ) + { + m_eventQueue.postMouseEvent(handle, m_mx, m_my, m_mz); + } + } + break; + case SDL_KEYDOWN: { const SDL_KeyboardEvent& kev = event.key; @@ -745,6 +764,7 @@ namespace entry int32_t m_mx; int32_t m_my; + int32_t m_mz; bool m_mouseLock; bool m_fullscreen; };