1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

SDL: Use scancodes for keybindings (#14964)

Co-authored-by: Lars Müller <34514239+appgurueu@users.noreply.github.com>
Co-authored-by: sfan5 <sfan5@live.de>
Co-authored-by: SmallJoker <SmallJoker@users.noreply.github.com>
This commit is contained in:
y5nw 2025-03-16 20:35:34 +01:00 committed by GitHub
parent e0378737b7
commit cc65c8bd70
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 509 additions and 369 deletions

View file

@ -24,6 +24,7 @@
#include <SDL_syswm.h>
#include <memory>
#include <unordered_map>
namespace irr
{
@ -286,6 +287,9 @@ 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);
std::variant<u32, EKEY_CODE> getScancodeFromKey(const Keycode &key) const override;
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();
@ -319,24 +323,9 @@ private:
core::rect<s32> lastElemPos;
struct SKeyMap
{
SKeyMap() {}
SKeyMap(s32 x11, s32 win32) :
SDLKey(x11), Win32Key(win32)
{
}
s32 SDLKey;
s32 Win32Key;
bool operator<(const SKeyMap &o) const
{
return SDLKey < o.SDLKey;
}
};
core::array<SKeyMap> KeyMap;
// TODO: This is only used for scancode/keycode conversion with EKEY_CODE (among other things, for Luanti
// to display keys to users). Drop this along with EKEY_CODE.
std::unordered_map<SDL_Keycode, EKEY_CODE> KeyMap;
s32 CurrentTouchCount;
bool IsInBackground;