diff options
author | Erik Kundiman <erik@megapahit.org> | 2024-07-05 20:24:10 +0800 |
---|---|---|
committer | Erik Kundiman <erik@megapahit.org> | 2024-07-05 20:24:10 +0800 |
commit | 6369047dcb74323b248de59bc8187db0d315548a (patch) | |
tree | acd9fc3ef76b0ea563e2099f6d87f14e8f91849c /indra/llwindow | |
parent | 1ed01f5134fa2e62fa447e9eb8c1745143b3779f (diff) |
Temporary Cocoa U16 vs. SDL2 U32 key types
Even when maint-b is merged to main, webrtc-voice will very likely
still have to wait until it's merged with main to get maint-b's
changes. I'll worry about the conflicts later, just so any branch
would build on SDL2 or not without any patches.
Diffstat (limited to 'indra/llwindow')
-rw-r--r-- | indra/llwindow/llkeyboard.cpp | 12 | ||||
-rw-r--r-- | indra/llwindow/llkeyboard.h | 15 | ||||
-rw-r--r-- | indra/llwindow/llkeyboardheadless.cpp | 8 | ||||
-rw-r--r-- | indra/llwindow/llkeyboardheadless.h | 5 |
4 files changed, 40 insertions, 0 deletions
diff --git a/indra/llwindow/llkeyboard.cpp b/indra/llwindow/llkeyboard.cpp index b3dcac6222..e93ad28fdf 100644 --- a/indra/llwindow/llkeyboard.cpp +++ b/indra/llwindow/llkeyboard.cpp @@ -195,9 +195,15 @@ void LLKeyboard::resetKeys() } +#if LL_SDL +BOOL LLKeyboard::translateKey(const U32 os_key, KEY *out_key) +{ + std::map<U32, KEY>::iterator iter; +#else BOOL LLKeyboard::translateKey(const U16 os_key, KEY *out_key) { std::map<U16, KEY>::iterator iter; +#endif // Only translate keys in the map, ignore all other keys for now iter = mTranslateKeyMap.find(os_key); @@ -215,9 +221,15 @@ BOOL LLKeyboard::translateKey(const U16 os_key, KEY *out_key) } +#if LL_SDL +U32 LLKeyboard::inverseTranslateKey(const KEY translated_key) +{ + std::map<KEY, U32>::iterator iter; +#else U16 LLKeyboard::inverseTranslateKey(const KEY translated_key) { std::map<KEY, U16>::iterator iter; +#endif iter = mInvTranslateKeyMap.find(translated_key); if (iter == mInvTranslateKeyMap.end()) { diff --git a/indra/llwindow/llkeyboard.h b/indra/llwindow/llkeyboard.h index e406de347c..89fa840e42 100644 --- a/indra/llwindow/llkeyboard.h +++ b/indra/llwindow/llkeyboard.h @@ -67,14 +67,24 @@ public: BOOL getKeyDown(const KEY key) { return mKeyLevel[key]; } BOOL getKeyRepeated(const KEY key) { return mKeyRepeated[key]; } +#if LL_SDL + BOOL translateKey(const U32 os_key, KEY *translated_key); + U32 inverseTranslateKey(const KEY translated_key); +#else BOOL translateKey(const U16 os_key, KEY *translated_key); U16 inverseTranslateKey(const KEY translated_key); +#endif BOOL handleTranslatedKeyUp(KEY translated_key, U32 translated_mask); // Translated into "Linden" keycodes BOOL handleTranslatedKeyDown(KEY translated_key, U32 translated_mask); // Translated into "Linden" keycodes +#if LL_SDL + virtual BOOL handleKeyUp(const U32 key, MASK mask) = 0; + virtual BOOL handleKeyDown(const U32 key, MASK mask) = 0; +#else virtual BOOL handleKeyUp(const U16 key, MASK mask) = 0; virtual BOOL handleKeyDown(const U16 key, MASK mask) = 0; +#endif #if defined(LL_DARWIN) && !defined(LL_SDL) // We only actually use this for OS X. @@ -111,8 +121,13 @@ protected: void addKeyName(KEY key, const std::string& name); protected: +#if LL_SDL + std::map<U32, KEY> mTranslateKeyMap; // Map of translations from OS keys to Linden KEYs + std::map<KEY, U32> mInvTranslateKeyMap; // Map of translations from Linden KEYs to OS keys +#else std::map<U16, KEY> mTranslateKeyMap; // Map of translations from OS keys to Linden KEYs std::map<KEY, U16> mInvTranslateKeyMap; // Map of translations from Linden KEYs to OS keys +#endif LLWindowCallbacks *mCallbacks; LLTimer mKeyLevelTimer[KEY_COUNT]; // Time since level was set diff --git a/indra/llwindow/llkeyboardheadless.cpp b/indra/llwindow/llkeyboardheadless.cpp index 01ac26261b..a3c86fde2b 100644 --- a/indra/llwindow/llkeyboardheadless.cpp +++ b/indra/llwindow/llkeyboardheadless.cpp @@ -35,11 +35,19 @@ void LLKeyboardHeadless::resetMaskKeys() { } +#if LL_SDL +BOOL LLKeyboardHeadless::handleKeyDown(const U32 key, const U32 mask) +#else BOOL LLKeyboardHeadless::handleKeyDown(const U16 key, const U32 mask) +#endif { return FALSE; } +#if LL_SDL +BOOL LLKeyboardHeadless::handleKeyUp(const U32 key, const U32 mask) +#else BOOL LLKeyboardHeadless::handleKeyUp(const U16 key, const U32 mask) +#endif { return FALSE; } MASK LLKeyboardHeadless::currentMask(BOOL for_mouse_event) diff --git a/indra/llwindow/llkeyboardheadless.h b/indra/llwindow/llkeyboardheadless.h index 8e067e6108..2bb670a53d 100644 --- a/indra/llwindow/llkeyboardheadless.h +++ b/indra/llwindow/llkeyboardheadless.h @@ -35,8 +35,13 @@ public: LLKeyboardHeadless(); /*virtual*/ ~LLKeyboardHeadless() {}; +#if LL_SDL + /*virtual*/ BOOL handleKeyUp(const U32 key, MASK mask); + /*virtual*/ BOOL handleKeyDown(const U32 key, MASK mask); +#else /*virtual*/ BOOL handleKeyUp(const U16 key, MASK mask); /*virtual*/ BOOL handleKeyDown(const U16 key, MASK mask); +#endif /*virtual*/ void resetMaskKeys(); /*virtual*/ MASK currentMask(BOOL for_mouse_event); /*virtual*/ void scanKeyboard(); |