| 1 |
#include "KeyboardSettings.hh" |
| 2 |
|
| 3 |
#include "stl.hh" |
| 4 |
#include "strCat.hh" |
| 5 |
|
| 6 |
#include <array> |
| 7 |
|
| 8 |
namespace openmsx { |
| 9 |
|
| 10 |
[[nodiscard]] static EnumSetting<SDL_Keycode>::Map getAllowedKeysMap() |
| 11 |
{ |
| 12 |
return { |
| 13 |
{"RALT", SDLK_RALT}, |
| 14 |
{"MENU", SDLK_MENU}, |
| 15 |
{"RCTRL", SDLK_RCTRL}, |
| 16 |
|
| 17 |
{"RSHIFT", SDLK_RSHIFT}, |
| 18 |
{"RGUI", SDLK_RGUI}, |
| 19 |
{"LGUI", SDLK_LGUI}, |
| 20 |
{"RMETA", SDLK_RGUI}, |
| 21 |
{"LMETA", SDLK_LGUI}, |
| 22 |
{"LSUPER", SDLK_LGUI}, |
| 23 |
{"RSUPER", SDLK_RGUI}, |
| 24 |
{"HELP", SDLK_HELP}, |
| 25 |
{"UNDO", SDLK_UNDO}, |
| 26 |
{"END", SDLK_END}, |
| 27 |
{"PAGEUP", SDLK_PAGEUP}, |
| 28 |
{"PAGEDOWN", SDLK_PAGEDOWN} |
| 29 |
}; |
| 30 |
} |
| 31 |
|
| 32 |
KeyboardSettings::KeyboardSettings(CommandController& commandController) |
| 33 |
: deadKeyHostKey(generate_array<3>([&](auto i) { |
| 34 |
static constexpr std::array<static_string_view, 3> description = { |
| 35 |
"Host key that maps to deadkey 1. Not applicable to Japanese and Korean MSX models", |
| 36 |
"Host key that maps to deadkey 2. Only applicable to Brazilian MSX models (Sharp Hotbit and Gradiente)", |
| 37 |
"Host key that maps to deadkey 3. Only applicable to Brazilian Sharp Hotbit MSX models", |
| 38 |
}; |
| 39 |
static constexpr std::array<SDL_Keycode, 3> defaultKey = { |
| 40 |
SDLK_RCTRL, SDLK_PAGEUP, SDLK_PAGEDOWN, |
| 41 |
}; |
| 42 |
return EnumSetting<SDL_Keycode>( |
| 43 |
commandController, tmpStrCat("kbd_deadkey", i + 1, "_host_key"), |
| 44 |
description[i], defaultKey[i], getAllowedKeysMap()); |
| 45 |
})) |
| 46 |
, codeKanaHostKey(commandController, |
| 47 |
"kbd_code_kana_host_key", |
| 48 |
"Host key that maps to the MSX CODE/KANA key. Please note that the HENKAN_MODE key only exists on Japanese host keyboards)", |
| 49 |
SDLK_RALT, getAllowedKeysMap()) |
| 50 |
, kpEnterMode(commandController, |
| 51 |
"kbd_numkeypad_enter_key", |
| 52 |
"MSX key that the enter key on the host numeric keypad must map to", |
| 53 |
KpEnterMode::MSX_KP_COMMA, EnumSetting<KpEnterMode>::Map{ |
| 54 |
{"KEYPAD_COMMA", KpEnterMode::MSX_KP_COMMA}, |
| 55 |
{"ENTER", KpEnterMode::MSX_ENTER}}) |
| 56 |
, mappingMode(commandController, |
| 57 |
"kbd_mapping_mode", |
| 58 |
"Keyboard mapping mode", |
| 59 |
MappingMode::CHARACTER, EnumSetting<MappingMode>::Map{ |
| 60 |
{"KEY", MappingMode::KEY}, |
| 61 |
{"CHARACTER", MappingMode::CHARACTER}, |
| 62 |
{"POSITIONAL", MappingMode::POSITIONAL}}) |
| 63 |
, alwaysEnableKeypad(commandController, |
| 64 |
"kbd_numkeypad_always_enabled", |
| 65 |
"Numeric keypad is always enabled, even on an MSX that does not have one", |
| 66 |
false) |
| 67 |
, traceKeyPresses(commandController, |
| 68 |
"kbd_trace_key_presses", |
| 69 |
"Trace key presses (show SDL key code, SDL modifiers and Unicode code-point value)", |
| 70 |
false, Setting::Save::NO) |
| 71 |
, autoToggleCodeKanaLock(commandController, |
| 72 |
"kbd_auto_toggle_code_kana_lock", |
| 73 |
"Automatically toggle the CODE/KANA lock, based on the characters entered on the host keyboard", |
| 74 |
true) |
| 75 |
#if defined(_WIN32) |
| 76 |
, disableIME(commandController, |
| 77 |
"kbd_disable_IME", |
| 78 |
"disable IME, avoid keyboard input problems in Kanji mode", |
| 79 |
true) |
| 80 |
#endif |
| 81 |
{ |
| 82 |
} |
| 83 |
|
| 84 |
} |