redefinir tecles

This commit is contained in:
2026-04-05 00:41:04 +02:00
parent a328681365
commit f8b60cb641
11 changed files with 167 additions and 24 deletions

View File

@@ -0,0 +1,27 @@
#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