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:
authorCampbell Barton <campbell@blender.org>2022-03-23 13:30:36 +0300
committerCampbell Barton <campbell@blender.org>2022-03-23 13:30:36 +0300
commitf634010c6ebedc5e64c53f193f1d33958f113c4c (patch)
tree21294d1be2e3c2f3429af91e033bac208e240415 /source/blender/windowmanager/intern/wm_event_system.c
parent8f63dccaa96588bfb35a62ffa7b956fe6a291e9c (diff)
Event System: improve handling of unknown keys
When converting ghost keys to Blender's event system: - All keys that aren't part of the GHOST_TKey enum map to EVENT_NONE (ignored), note that it's an internal error if the value of key isn't a known value. - Modify the switch statement so any missing members of GHOST_TKey warn at compile time (GCC & Clang only). - GHOST_kKeyUnknown maps to EVT_UNKNOWNKEY. We could ignore this key, changing can be evaluated separately.
Diffstat (limited to 'source/blender/windowmanager/intern/wm_event_system.c')
-rw-r--r--source/blender/windowmanager/intern/wm_event_system.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c
index e565b32662a..790b08437bd 100644
--- a/source/blender/windowmanager/intern/wm_event_system.c
+++ b/source/blender/windowmanager/intern/wm_event_system.c
@@ -4565,9 +4565,28 @@ static int convert_key(GHOST_TKey key)
case GHOST_kKeyMediaLast:
return EVT_MEDIALAST;
- default:
+ case GHOST_kKeyUnknown:
return EVT_UNKNOWNKEY;
+
+#if defined(__GNUC__) || defined(__clang__)
+ /* Ensure all members of this enum are handled, otherwise generate a compiler warning.
+ * Note that these members have been handled, these ranges are to satisfy the compiler. */
+ case GHOST_kKeyF1 ... GHOST_kKeyF24:
+ case GHOST_kKeyA ... GHOST_kKeyZ:
+ case GHOST_kKeyNumpad0 ... GHOST_kKeyNumpad9:
+ case GHOST_kKey0 ... GHOST_kKey9: {
+ BLI_assert_unreachable();
+ break;
+ }
+#else
+ default: {
+ break;
+ }
+#endif
}
+
+ CLOG_WARN(WM_LOG_EVENTS, "unknown event type %d from ghost", (int)key);
+ return EVENT_NONE;
}
static void wm_eventemulation(wmEvent *event, bool test_only)