From bcfff2bf7f9963e943ef0b3013287be42bcaa174 Mon Sep 17 00:00:00 2001 From: Jack Andersen Date: Fri, 1 Jan 2016 18:15:41 -1000 Subject: [PATCH] Fix Win32 repeat key test --- include/boo/IWindow.hpp | 21 +++++++++++++++++++-- lib/win/WindowWin32.cpp | 12 +++++------- 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/include/boo/IWindow.hpp b/include/boo/IWindow.hpp index e86e37a..f2dc6d5 100644 --- a/include/boo/IWindow.hpp +++ b/include/boo/IWindow.hpp @@ -3,6 +3,10 @@ #include "System.hpp" #include +#include + +#undef min +#undef max namespace boo { @@ -75,9 +79,22 @@ struct SScrollDelta bool isAccelerated = false; /* System performs acceleration computation */ SScrollDelta operator+(const SScrollDelta& other) - {return {{delta[0] + other.delta[0], delta[1] + other.delta[1]}, isFine || other.isFine};} + { + SScrollDelta ret; + ret.delta[0] = delta[0] + other.delta[0]; + ret.delta[1] = delta[1] + other.delta[1]; + ret.isFine = isFine || other.isFine; + ret.isAccelerated = isAccelerated || other.isAccelerated; + return ret; + } SScrollDelta& operator+=(const SScrollDelta& other) - {delta[0] += other.delta[0]; delta[1] += other.delta[1]; isFine |= other.isFine; return *this;} + { + delta[0] += other.delta[0]; + delta[1] += other.delta[1]; + isFine |= other.isFine; + isAccelerated |= other.isAccelerated; + return *this; + } void zeroOut() {delta[0] = 0.0; delta[1] = 0.0;} }; diff --git a/lib/win/WindowWin32.cpp b/lib/win/WindowWin32.cpp index 4766cf1..c468fb7 100644 --- a/lib/win/WindowWin32.cpp +++ b/lib/win/WindowWin32.cpp @@ -1039,11 +1039,11 @@ public: uint32_t charCode = translateKeysym(e.wParam, (e.lParam >> 16) & 0xff, specialKey, modifierKey); EModifierKey modifierMask = translateModifiers(e.uMsg); if (charCode) - m_callback->charKeyDown(charCode, modifierMask, (e.lParam & 0xffff) != 0); + m_callback->charKeyDown(charCode, modifierMask, (HIWORD(e.lParam) & KF_REPEAT) != 0); else if (specialKey != ESpecialKey::None) - m_callback->specialKeyDown(specialKey, modifierMask, (e.lParam & 0xffff) != 0); + m_callback->specialKeyDown(specialKey, modifierMask, (HIWORD(e.lParam) & KF_REPEAT) != 0); else if (modifierKey != EModifierKey::None) - m_callback->modKeyDown(modifierKey, (e.lParam & 0xffff) != 0); + m_callback->modKeyDown(modifierKey, (HIWORD(e.lParam) & KF_REPEAT) != 0); } return; } @@ -1182,10 +1182,8 @@ public: { GET_X_LPARAM(e.lParam), h-GET_Y_LPARAM(e.lParam) }, { float(GET_X_LPARAM(e.lParam)) / float(w), float(h-GET_Y_LPARAM(e.lParam)) / float(h) } }; - SScrollDelta scroll = - { - { 0, GET_WHEEL_DELTA_WPARAM(e.wParam) / double(WHEEL_DELTA) }, false - }; + SScrollDelta scroll = {}; + scroll.delta[1] = GET_WHEEL_DELTA_WPARAM(e.wParam) / double(WHEEL_DELTA); m_callback->scroll(coord, scroll); } return;