Added mouse scroll support to entry_sdl.

This commit is contained in:
Dario Manesku 2015-03-16 15:19:35 +01:00
parent f3c300980d
commit acd4dedfe1

View file

@ -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;
};