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