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";
|
2021-05-19 16:13:52 +00:00
|
|
|
loadMapping();
|
2021-04-29 16:58:04 +00:00
|
|
|
}
|
|
|
|
|
2021-06-07 18:53:31 +00:00
|
|
|
const char *get_button_name(u32 code) override
|
2021-04-29 16:58:04 +00:00
|
|
|
{
|
|
|
|
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-05-31 17:44:55 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
};
|