From aa7cd714989d460f0709d1a1f8bebe918e9dae92 Mon Sep 17 00:00:00 2001 From: Riteo Date: Wed, 25 Jan 2023 19:27:31 +0100 Subject: Put KeyMappingX11 stuff inside its own scope This avoids collisions with other "concurrent" key mappers. --- platform/linuxbsd/x11/key_mapping_x11.cpp | 14 -------------- platform/linuxbsd/x11/key_mapping_x11.h | 13 +++++++++++++ 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/platform/linuxbsd/x11/key_mapping_x11.cpp b/platform/linuxbsd/x11/key_mapping_x11.cpp index 506372292d..e5eba6ccad 100644 --- a/platform/linuxbsd/x11/key_mapping_x11.cpp +++ b/platform/linuxbsd/x11/key_mapping_x11.cpp @@ -30,20 +30,6 @@ #include "key_mapping_x11.h" -#include "core/templates/hash_map.h" - -struct HashMapHasherKeys { - static _FORCE_INLINE_ uint32_t hash(const Key p_key) { return hash_fmix32(static_cast(p_key)); } - static _FORCE_INLINE_ uint32_t hash(const char32_t p_uchar) { return hash_fmix32(p_uchar); } - static _FORCE_INLINE_ uint32_t hash(const unsigned p_key) { return hash_fmix32(p_key); } - static _FORCE_INLINE_ uint32_t hash(const KeySym p_key) { return hash_fmix32(p_key); } -}; - -HashMap xkeysym_map; -HashMap scancode_map; -HashMap scancode_map_inv; -HashMap xkeysym_unicode_map; - void KeyMappingX11::initialize() { // X11 Keysym to Godot Key map. diff --git a/platform/linuxbsd/x11/key_mapping_x11.h b/platform/linuxbsd/x11/key_mapping_x11.h index d4278a563c..48beefff4c 100644 --- a/platform/linuxbsd/x11/key_mapping_x11.h +++ b/platform/linuxbsd/x11/key_mapping_x11.h @@ -39,8 +39,21 @@ #include #include "core/os/keyboard.h" +#include "core/templates/hash_map.h" class KeyMappingX11 { + struct HashMapHasherKeys { + static _FORCE_INLINE_ uint32_t hash(const Key p_key) { return hash_fmix32(static_cast(p_key)); } + static _FORCE_INLINE_ uint32_t hash(const char32_t p_uchar) { return hash_fmix32(p_uchar); } + static _FORCE_INLINE_ uint32_t hash(const unsigned p_key) { return hash_fmix32(p_key); } + static _FORCE_INLINE_ uint32_t hash(const KeySym p_key) { return hash_fmix32(p_key); } + }; + + static inline HashMap xkeysym_map; + static inline HashMap scancode_map; + static inline HashMap scancode_map_inv; + static inline HashMap xkeysym_unicode_map; + KeyMappingX11() {} public: -- cgit v1.2.3