From c91d4edbef06f337ae1aff1ada66dc7ca5f8a74a Mon Sep 17 00:00:00 2001 From: y5nw <37980625+y5nw@users.noreply.github.com> Date: Fri, 13 Dec 2024 17:50:58 +0100 Subject: [PATCH] minor: KeyCode -> Keycode --- irr/include/IrrlichtDevice.h | 8 ++++---- irr/include/Keycodes.h | 6 +++--- irr/src/CIrrDeviceSDL.cpp | 8 ++++---- irr/src/CIrrDeviceSDL.h | 4 ++-- src/client/keycode.cpp | 4 ++-- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/irr/include/IrrlichtDevice.h b/irr/include/IrrlichtDevice.h index 28e11bef7..095738ba3 100644 --- a/irr/include/IrrlichtDevice.h +++ b/irr/include/IrrlichtDevice.h @@ -347,19 +347,19 @@ public: // not implement this. //! Get the scancode of the corresponding keycode. - virtual u32 getScancodeFromKey(const KeyCode &key) const + virtual u32 getScancodeFromKey(const Keycode &key) const { if (const auto *keycode = std::get_if(&key)) // treat KEY_UNKNOWN and KEY_KEY_CODES_COUNT as the same and return 0. - return KeyCode::isValid(*keycode) ? *keycode : 0; + return Keycode::isValid(*keycode) ? *keycode : 0; const auto keychar = std::get(key); return keychar == 0 ? 0 : KEY_KEY_CODES_COUNT + keychar; } //! Get the keycode of the corresponding scancode. - virtual KeyCode getKeyFromScancode(const u32 scancode) const + virtual Keycode getKeyFromScancode(const u32 scancode) const { - KeyCode key; + Keycode key; if (scancode < KEY_KEY_CODES_COUNT) key.emplace((EKEY_CODE)scancode); else diff --git a/irr/include/Keycodes.h b/irr/include/Keycodes.h index 832547cf3..8edbfebc9 100644 --- a/irr/include/Keycodes.h +++ b/irr/include/Keycodes.h @@ -183,12 +183,12 @@ enum EKEY_CODE KEY_KEY_CODES_COUNT = 0x100 // this is not a key, but the amount of keycodes there are. }; -class KeyCode : public std::variant { +class Keycode : public std::variant { using super = std::variant; public: - KeyCode() : KeyCode(KEY_KEY_CODES_COUNT, L'\0') {} + Keycode() : Keycode(KEY_KEY_CODES_COUNT, L'\0') {} - KeyCode(EKEY_CODE code, wchar_t ch) + Keycode(EKEY_CODE code, wchar_t ch) { emplace(code, ch); } diff --git a/irr/src/CIrrDeviceSDL.cpp b/irr/src/CIrrDeviceSDL.cpp index 5b7b4a93e..ff5c5b965 100644 --- a/irr/src/CIrrDeviceSDL.cpp +++ b/irr/src/CIrrDeviceSDL.cpp @@ -220,7 +220,7 @@ int CIrrDeviceSDL::findCharToPassToIrrlicht(uint32_t sdlKey, EKEY_CODE irrlichtK } } -u32 CIrrDeviceSDL::getScancodeFromKey(const KeyCode &key) const +u32 CIrrDeviceSDL::getScancodeFromKey(const Keycode &key) const { u32 keynum = 0; if (const auto *keycode = std::get_if(&key)) { @@ -236,13 +236,13 @@ u32 CIrrDeviceSDL::getScancodeFromKey(const KeyCode &key) const return SDL_GetScancodeFromKey(keynum); } -KeyCode CIrrDeviceSDL::getKeyFromScancode(const u32 scancode) const +Keycode CIrrDeviceSDL::getKeyFromScancode(const u32 scancode) const { auto keycode = SDL_GetKeyFromScancode((SDL_Scancode)scancode); const auto &keyentry = KeyMap.find(keycode); auto irrcode = keyentry != KeyMap.end() ? keyentry->second : KEY_UNKNOWN; auto keychar = findCharToPassToIrrlicht(keycode, irrcode, false); - return KeyCode(irrcode, keychar); + return Keycode(irrcode, keychar); } void CIrrDeviceSDL::resetReceiveTextInputEvents() @@ -858,7 +858,7 @@ bool CIrrDeviceSDL::run() const auto &entry = KeyMap.find(keysym); auto key = entry == KeyMap.end() ? KEY_UNKNOWN : entry->second; - if (!KeyCode::isValid(key)) + if (!Keycode::isValid(key)) os::Printer::log("keycode not mapped", core::stringc(keysym), ELL_DEBUG); // Make sure to only input special characters if something is in focus, as SDL_TEXTINPUT handles normal unicode already diff --git a/irr/src/CIrrDeviceSDL.h b/irr/src/CIrrDeviceSDL.h index 0b5c5afa8..4a74693d1 100644 --- a/irr/src/CIrrDeviceSDL.h +++ b/irr/src/CIrrDeviceSDL.h @@ -288,8 +288,8 @@ private: // Return the Char that should be sent to Irrlicht for the given key (either the one passed in or 0). static int findCharToPassToIrrlicht(uint32_t sdlKey, EKEY_CODE irrlichtKey, bool numlock); - virtual u32 getScancodeFromKey(const KeyCode &key) const override; - virtual KeyCode getKeyFromScancode(const u32 scancode) const override; + virtual u32 getScancodeFromKey(const Keycode &key) const override; + virtual Keycode getKeyFromScancode(const u32 scancode) const override; // Check if a text box is in focus. Enable or disable SDL_TEXTINPUT events only if in focus. void resetReceiveTextInputEvents(); diff --git a/src/client/keycode.cpp b/src/client/keycode.cpp index 19f556973..c6f278933 100644 --- a/src/client/keycode.cpp +++ b/src/client/keycode.cpp @@ -261,7 +261,7 @@ static const table_key &lookup_keyname(std::string_view name) static const table_key &lookup_keykey(irr::EKEY_CODE key) { - if (!KeyCode::isValid(key)) + if (!Keycode::isValid(key)) return invalid_key; for (const auto &table_key : table) { @@ -285,7 +285,7 @@ KeyPress::KeyPress(std::string_view name) if (loadFromScancode(name)) return; const auto &key = lookup_keyname(name); - KeyCode keycode(key.Key, key.Char); + Keycode keycode(key.Key, key.Char); scancode = RenderingEngine::get_raw_device()->getScancodeFromKey(keycode); }