2019-02-12 10:30:24 +00:00
|
|
|
#pragma once
|
|
|
|
#include "input/keyboard_device.h"
|
|
|
|
#include "sdl.h"
|
|
|
|
|
2021-03-02 17:45:18 +00:00
|
|
|
class SDLKeyboardDevice : public KeyboardDeviceTemplate<SDL_Scancode>
|
2019-02-12 10:30:24 +00:00
|
|
|
{
|
|
|
|
public:
|
2021-04-29 16:58:04 +00:00
|
|
|
SDLKeyboardDevice(int maple_port) : KeyboardDeviceTemplate(maple_port, "SDL") {
|
|
|
|
_unique_id = "sdl_keyboard";
|
|
|
|
if (!find_mapping())
|
|
|
|
input_mapper = std::make_shared<KeyboardInputMapping>();
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual const char *get_button_name(u32 code) override
|
|
|
|
{
|
|
|
|
const char *name = SDL_GetKeyName(SDL_GetKeyFromScancode((SDL_Scancode)code));
|
|
|
|
if (name[0] == 0)
|
|
|
|
return nullptr;
|
|
|
|
return name;
|
|
|
|
}
|
2019-02-12 10:30:24 +00:00
|
|
|
|
|
|
|
protected:
|
2021-03-02 17:45:18 +00:00
|
|
|
virtual u8 convert_keycode(SDL_Scancode scancode) override
|
2019-02-12 10:30:24 +00:00
|
|
|
{
|
2021-03-02 17:45:18 +00:00
|
|
|
if (settings.input.keyboardLangId != KeyboardLayout::US && scancode == SDL_SCANCODE_BACKSLASH)
|
|
|
|
return (u8)SDL_SCANCODE_NONUSHASH;
|
|
|
|
else
|
|
|
|
return (u8)scancode;
|
2019-02-12 10:30:24 +00:00
|
|
|
}
|
|
|
|
};
|