28 lines
845 B
C++
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
|