Files
aee/source/core/input/key_remap.cpp
2026-04-05 00:41:04 +02:00

28 lines
845 B
C++

#include "core/input/key_remap.hpp"
#include <SDL3/SDL.h>
#include "core/jail/jinput.hpp"
#include "game/options.hpp"
namespace KeyRemap {
static void mirror(SDL_Scancode custom, SDL_Scancode standard, const bool* ks) {
if (custom == standard || custom == SDL_SCANCODE_UNKNOWN) {
JI_SetVirtualKey(standard, JI_VSRC_REMAP, false);
return;
}
JI_SetVirtualKey(standard, JI_VSRC_REMAP, ks[custom]);
}
void update() {
const bool* ks = SDL_GetKeyboardState(nullptr);
if (!ks) return;
mirror(Options::keys_game.up, SDL_SCANCODE_UP, ks);
mirror(Options::keys_game.down, SDL_SCANCODE_DOWN, ks);
mirror(Options::keys_game.left, SDL_SCANCODE_LEFT, ks);
mirror(Options::keys_game.right, SDL_SCANCODE_RIGHT, ks);
}
} // namespace KeyRemap