mirror of
https://github.com/moonlight-stream/moonlight-chrome.git
synced 2025-08-17 16:46:31 +00:00
Fix scrolling behavior by accumulating partial ticks
This commit is contained in:
parent
e7b45e5b6c
commit
4f6c547e47
15
input.cpp
15
input.cpp
@ -112,14 +112,25 @@ bool MoonlightInstance::HandleInputEvent(const pp::InputEvent& event) {
|
||||
}
|
||||
|
||||
case PP_INPUTEVENT_TYPE_WHEEL: {
|
||||
signed char fullTicks;
|
||||
|
||||
if (!m_MouseLocked) {
|
||||
return false;
|
||||
}
|
||||
|
||||
pp::WheelInputEvent wheelEvent(event);
|
||||
|
||||
// FIXME: Handle fractional scroll ticks
|
||||
LiSendScrollEvent((signed char) wheelEvent.GetTicks().y());
|
||||
// Accumulate the current tick value
|
||||
m_AccumulatedTicks += wheelEvent.GetTicks().y();
|
||||
|
||||
// Compute the number of full ticks
|
||||
fullTicks = (signed char) m_AccumulatedTicks;
|
||||
|
||||
// Send a scroll event if we've completed a full tick
|
||||
if (fullTicks != 0) {
|
||||
LiSendScrollEvent(fullTicks);
|
||||
m_AccumulatedTicks -= fullTicks;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -44,7 +44,8 @@ class MoonlightInstance : public pp::Instance, public pp::MouseLock {
|
||||
m_CallbackFactory(this),
|
||||
m_MouseLocked(false),
|
||||
m_KeyModifiers(0),
|
||||
m_WaitingForAllModifiersUp(false) {
|
||||
m_WaitingForAllModifiersUp(false),
|
||||
m_AccumulatedTicks(0) {
|
||||
// This function MUST be used otherwise sockets don't work (nacl_io_init() doesn't work!)
|
||||
nacl_io_init_ppapi(pp_instance(), pp::Module::Get()->get_browser_interface());
|
||||
|
||||
@ -135,6 +136,7 @@ class MoonlightInstance : public pp::Instance, public pp::MouseLock {
|
||||
bool m_MouseLocked;
|
||||
char m_KeyModifiers;
|
||||
bool m_WaitingForAllModifiersUp;
|
||||
float m_AccumulatedTicks;
|
||||
};
|
||||
|
||||
extern MoonlightInstance* g_Instance;
|
||||
|
Loading…
x
Reference in New Issue
Block a user