summaryrefslogtreecommitdiff
path: root/src/input
diff options
context:
space:
mode:
Diffstat (limited to 'src/input')
-rw-r--r--src/input/keyboardconfig.cpp24
-rw-r--r--src/input/keyboardconfig.h30
2 files changed, 26 insertions, 28 deletions
diff --git a/src/input/keyboardconfig.cpp b/src/input/keyboardconfig.cpp
index ecd563656..3405ad5c4 100644
--- a/src/input/keyboardconfig.cpp
+++ b/src/input/keyboardconfig.cpp
@@ -59,20 +59,6 @@ void KeyboardConfig::deinit()
mActiveKeys2 = nullptr;
}
-int KeyboardConfig::getKeyValueFromEvent(const SDL_Event &event)
-{
-#ifdef USE_SDL2
- return event.key.keysym.scancode;
-#else // USE_SDL2
-
- if (event.key.keysym.sym)
- return CAST_S32(event.key.keysym.sym);
- else if (event.key.keysym.scancode > 1)
- return -event.key.keysym.scancode;
- return 0;
-#endif // USE_SDL2
-}
-
InputActionT KeyboardConfig::getKeyIndex(const SDL_Event &event, const int grp)
{
const int keyValue = getKeyValueFromEvent(event);
@@ -149,16 +135,6 @@ std::string KeyboardConfig::getKeyShortString(const std::string &key)
return key;
}
-SDLKey KeyboardConfig::getKeyFromEvent(const SDL_Event &event)
-{
-#ifdef USE_SDL2
- return event.key.keysym.scancode;
-#else // USE_SDL2
-
- return event.key.keysym.sym;
-#endif // USE_SDL2
-}
-
KeysVector *KeyboardConfig::getActionVector(const SDL_Event &event)
{
const int i = getKeyValueFromEvent(event);
diff --git a/src/input/keyboardconfig.h b/src/input/keyboardconfig.h
index ad5e89ad8..a14afd200 100644
--- a/src/input/keyboardconfig.h
+++ b/src/input/keyboardconfig.h
@@ -32,14 +32,13 @@ _SDL_stdinc_h
#ifdef USE_SDL2
#pragma GCC diagnostic pop
#endif // USE_SDL2
+#include <SDL_events.h>
#include <SDL_keyboard.h>
#include "sdlshared.h"
#include "events/inputevent.h"
-union SDL_Event;
-
class KeyboardConfig final
{
public:
@@ -80,9 +79,32 @@ class KeyboardConfig final
static std::string getKeyShortString(const std::string &key)
A_WARN_UNUSED;
- static SDLKey getKeyFromEvent(const SDL_Event &event) A_WARN_UNUSED;
+ constexpr static SDLKey getKeyFromEvent(const SDL_Event &event)
+ A_WARN_UNUSED
+ {
+#ifdef USE_SDL2
+ return event.key.keysym.scancode;
+#else // USE_SDL2
+
+ return event.key.keysym.sym;
+#endif // USE_SDL2
+ }
+
+ constexpr static int getKeyValueFromEvent(const SDL_Event &event)
+ A_WARN_UNUSED
+ {
+#ifdef USE_SDL2
+ return event.key.keysym.scancode;
+#else // USE_SDL2
+
+ if (event.key.keysym.sym)
+ return CAST_S32(event.key.keysym.sym);
+ else if (event.key.keysym.scancode > 1)
+ return -event.key.keysym.scancode;
+ return 0;
+#endif // USE_SDL2
+ }
- static int getKeyValueFromEvent(const SDL_Event &event) A_WARN_UNUSED;
KeysVector *getActionVector(const SDL_Event &event) A_WARN_UNUSED;