mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-11-28 18:45:54 -05:00
Merge pull request #273 from dariomanesku/master
Mouse scroll now works consistently on Linux and Windows.
This commit is contained in:
commit
c69ee80707
2 changed files with 28 additions and 7 deletions
|
@ -706,7 +706,7 @@ namespace entry
|
||||||
ScreenToClient(_hwnd, &pt);
|
ScreenToClient(_hwnd, &pt);
|
||||||
int32_t mx = pt.x;
|
int32_t mx = pt.x;
|
||||||
int32_t my = pt.y;
|
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);
|
m_eventQueue.postMouseEvent(findHandle(_hwnd), mx, my, m_mz);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -267,6 +267,10 @@ namespace entry
|
||||||
initTranslateKey('x', Key::KeyX);
|
initTranslateKey('x', Key::KeyX);
|
||||||
initTranslateKey('y', Key::KeyY);
|
initTranslateKey('y', Key::KeyY);
|
||||||
initTranslateKey('z', Key::KeyZ);
|
initTranslateKey('z', Key::KeyZ);
|
||||||
|
|
||||||
|
m_mx = 0;
|
||||||
|
m_my = 0;
|
||||||
|
m_mz = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t run(int _argc, char** _argv)
|
int32_t run(int _argc, char** _argv)
|
||||||
|
@ -367,18 +371,19 @@ namespace entry
|
||||||
case ButtonRelease:
|
case ButtonRelease:
|
||||||
{
|
{
|
||||||
const XButtonEvent& xbutton = event.xbutton;
|
const XButtonEvent& xbutton = event.xbutton;
|
||||||
MouseButton::Enum mb;
|
MouseButton::Enum mb = MouseButton::None;
|
||||||
switch (xbutton.button)
|
switch (xbutton.button)
|
||||||
{
|
{
|
||||||
case Button1: mb = MouseButton::Left; break;
|
case Button1: mb = MouseButton::Left; break;
|
||||||
case Button2: mb = MouseButton::Middle; break;
|
case Button2: mb = MouseButton::Middle; break;
|
||||||
case Button3: mb = MouseButton::Right; 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)
|
if (MouseButton::None != mb)
|
||||||
{
|
{
|
||||||
WindowHandle handle = findHandle(xbutton.window);
|
|
||||||
m_eventQueue.postMouseEvent(handle
|
m_eventQueue.postMouseEvent(handle
|
||||||
, xbutton.x
|
, xbutton.x
|
||||||
, xbutton.y
|
, xbutton.y
|
||||||
|
@ -387,6 +392,14 @@ namespace entry
|
||||||
, event.type == ButtonPress
|
, event.type == ButtonPress
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_eventQueue.postMouseEvent(handle
|
||||||
|
, m_mx
|
||||||
|
, m_my
|
||||||
|
, m_mz
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -394,10 +407,14 @@ namespace entry
|
||||||
{
|
{
|
||||||
const XMotionEvent& xmotion = event.xmotion;
|
const XMotionEvent& xmotion = event.xmotion;
|
||||||
WindowHandle handle = findHandle(xmotion.window);
|
WindowHandle handle = findHandle(xmotion.window);
|
||||||
|
|
||||||
|
m_mx = xmotion.x;
|
||||||
|
m_my = xmotion.y;
|
||||||
|
|
||||||
m_eventQueue.postMouseEvent(handle
|
m_eventQueue.postMouseEvent(handle
|
||||||
, xmotion.x
|
, m_mx
|
||||||
, xmotion.y
|
, m_my
|
||||||
, 0
|
, m_mz
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -543,6 +560,10 @@ namespace entry
|
||||||
uint8_t m_modifiers;
|
uint8_t m_modifiers;
|
||||||
bool m_exit;
|
bool m_exit;
|
||||||
|
|
||||||
|
int32_t m_mx;
|
||||||
|
int32_t m_my;
|
||||||
|
int32_t m_mz;
|
||||||
|
|
||||||
EventQueue m_eventQueue;
|
EventQueue m_eventQueue;
|
||||||
bx::LwMutex m_lock;
|
bx::LwMutex m_lock;
|
||||||
bx::HandleAllocT<ENTRY_CONFIG_MAX_WINDOWS> m_windowAlloc;
|
bx::HandleAllocT<ENTRY_CONFIG_MAX_WINDOWS> m_windowAlloc;
|
||||||
|
|
Loading…
Reference in a new issue