Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAsher <ThatAsherGuy>2020-03-28 02:58:08 +0300
committerGermano Cavalcante <germano.costa@ig.com.br>2020-03-28 02:59:20 +0300
commite0030d53bc4e8c6f1a173c52652be3737e52fa0e (patch)
tree9f6e8f3c57e09f33775fefeb0cea77a0a50afb7e /intern/ghost
parent1f949121cd3f58ecd2d8a29caad68a618ba4efd3 (diff)
Fix key detection issues introduced by D7229
Removing the GHOST_kKeyUnknown check from processKeyEvent() produces epeated unknown key events whenever a modifier key is held down, due to the way ghost uses GHOST_kKeyUnknown as a filter value for modifier key events. Differential Revision: https://developer.blender.org/D7257
Diffstat (limited to 'intern/ghost')
-rw-r--r--intern/ghost/intern/GHOST_SystemWin32.cpp41
-rw-r--r--intern/ghost/intern/GHOST_SystemWin32.h2
2 files changed, 25 insertions, 18 deletions
diff --git a/intern/ghost/intern/GHOST_SystemWin32.cpp b/intern/ghost/intern/GHOST_SystemWin32.cpp
index e31186bd6a5..e4988d8a0b3 100644
--- a/intern/ghost/intern/GHOST_SystemWin32.cpp
+++ b/intern/ghost/intern/GHOST_SystemWin32.cpp
@@ -620,8 +620,12 @@ GHOST_TSuccess GHOST_SystemWin32::exit()
return GHOST_System::exit();
}
-GHOST_TKey GHOST_SystemWin32::hardKey(RAWINPUT const &raw, int *keyDown, char *vk)
+GHOST_TKey GHOST_SystemWin32::hardKey(RAWINPUT const &raw,
+ bool *r_keyDown,
+ bool *r_is_repeated_modifier)
{
+ bool is_repeated_modifier = false;
+
GHOST_SystemWin32 *system = (GHOST_SystemWin32 *)getSystem();
GHOST_TKey key = GHOST_kKeyUnknown;
GHOST_ModifierKeys modifiers;
@@ -630,7 +634,7 @@ GHOST_TKey GHOST_SystemWin32::hardKey(RAWINPUT const &raw, int *keyDown, char *v
// RI_KEY_BREAK doesn't work for sticky keys release, so we also
// check for the up message
unsigned int msg = raw.data.keyboard.Message;
- *keyDown = !(raw.data.keyboard.Flags & RI_KEY_BREAK) && msg != WM_KEYUP && msg != WM_SYSKEYUP;
+ *r_keyDown = !(raw.data.keyboard.Flags & RI_KEY_BREAK) && msg != WM_KEYUP && msg != WM_SYSKEYUP;
key = this->convertKey(raw.data.keyboard.VKey,
raw.data.keyboard.MakeCode,
@@ -642,32 +646,32 @@ GHOST_TKey GHOST_SystemWin32::hardKey(RAWINPUT const &raw, int *keyDown, char *v
GHOST_TModifierKeyMask modifier;
switch (key) {
case GHOST_kKeyLeftShift: {
- changed = (modifiers.get(GHOST_kModifierKeyLeftShift) != (bool)*keyDown);
+ changed = (modifiers.get(GHOST_kModifierKeyLeftShift) != *r_keyDown);
modifier = GHOST_kModifierKeyLeftShift;
break;
}
case GHOST_kKeyRightShift: {
- changed = (modifiers.get(GHOST_kModifierKeyRightShift) != (bool)*keyDown);
+ changed = (modifiers.get(GHOST_kModifierKeyRightShift) != *r_keyDown);
modifier = GHOST_kModifierKeyRightShift;
break;
}
case GHOST_kKeyLeftControl: {
- changed = (modifiers.get(GHOST_kModifierKeyLeftControl) != (bool)*keyDown);
+ changed = (modifiers.get(GHOST_kModifierKeyLeftControl) != *r_keyDown);
modifier = GHOST_kModifierKeyLeftControl;
break;
}
case GHOST_kKeyRightControl: {
- changed = (modifiers.get(GHOST_kModifierKeyRightControl) != (bool)*keyDown);
+ changed = (modifiers.get(GHOST_kModifierKeyRightControl) != *r_keyDown);
modifier = GHOST_kModifierKeyRightControl;
break;
}
case GHOST_kKeyLeftAlt: {
- changed = (modifiers.get(GHOST_kModifierKeyLeftAlt) != (bool)*keyDown);
+ changed = (modifiers.get(GHOST_kModifierKeyLeftAlt) != *r_keyDown);
modifier = GHOST_kModifierKeyLeftAlt;
break;
}
case GHOST_kKeyRightAlt: {
- changed = (modifiers.get(GHOST_kModifierKeyRightAlt) != (bool)*keyDown);
+ changed = (modifiers.get(GHOST_kModifierKeyRightAlt) != *r_keyDown);
modifier = GHOST_kModifierKeyRightAlt;
break;
}
@@ -676,17 +680,15 @@ GHOST_TKey GHOST_SystemWin32::hardKey(RAWINPUT const &raw, int *keyDown, char *v
}
if (changed) {
- modifiers.set(modifier, (bool)*keyDown);
+ modifiers.set(modifier, *r_keyDown);
system->storeModifierKeys(modifiers);
}
else {
- key = GHOST_kKeyUnknown;
+ is_repeated_modifier = true;
}
}
- if (vk)
- *vk = raw.data.keyboard.VKey;
-
+ *r_is_repeated_modifier = is_repeated_modifier;
return key;
}
@@ -1038,16 +1040,17 @@ void GHOST_SystemWin32::processWheelEvent(GHOST_WindowWin32 *window, WPARAM wPar
GHOST_EventKey *GHOST_SystemWin32::processKeyEvent(GHOST_WindowWin32 *window, RAWINPUT const &raw)
{
- int keyDown = 0;
- char vk;
+ bool keyDown = false;
+ bool is_repeated_modifier = false;
GHOST_SystemWin32 *system = (GHOST_SystemWin32 *)getSystem();
- GHOST_TKey key = system->hardKey(raw, &keyDown, &vk);
+ GHOST_TKey key = system->hardKey(raw, &keyDown, &is_repeated_modifier);
GHOST_EventKey *event;
/* We used to check `if (key != GHOST_kKeyUnknown)`, but since the message
* values `WM_SYSKEYUP`, `WM_KEYUP` and `WM_CHAR` are ignored, we capture
* those events here as well. */
- {
+ if (!is_repeated_modifier) {
+ char vk = raw.data.keyboard.VKey;
char utf8_char[6] = {0};
char ascii = 0;
bool is_repeat = false;
@@ -1105,6 +1108,10 @@ GHOST_EventKey *GHOST_SystemWin32::processKeyEvent(GHOST_WindowWin32 *window, RA
// GHOST_PRINTF("%c\n", ascii); // we already get this info via EventPrinter
}
+ else {
+ event = NULL;
+ }
+
return event;
}
diff --git a/intern/ghost/intern/GHOST_SystemWin32.h b/intern/ghost/intern/GHOST_SystemWin32.h
index e624cc83427..0d9fd268d0f 100644
--- a/intern/ghost/intern/GHOST_SystemWin32.h
+++ b/intern/ghost/intern/GHOST_SystemWin32.h
@@ -278,7 +278,7 @@ class GHOST_SystemWin32 : public GHOST_System {
* \param vk Pointer to virtual key
* \return The GHOST key (GHOST_kKeyUnknown if no match).
*/
- GHOST_TKey hardKey(RAWINPUT const &raw, int *keyDown, char *vk);
+ GHOST_TKey hardKey(RAWINPUT const &raw, bool *r_keyDown, bool *r_is_repeated_modifier);
/**
* Creates mouse button event.