openMSX
KeyboardSettings.cc
Go to the documentation of this file.
1 #include "KeyboardSettings.hh"
2 #include "EnumSetting.hh"
3 #include "BooleanSetting.hh"
4 #include "memory.hh"
5 #include <cassert>
6 
7 namespace openmsx {
8 
10  : alwaysEnableKeypad(make_unique<BooleanSetting>(
11  commandController, "kbd_numkeypad_always_enabled",
12  "Numeric keypad is always enabled, even on an MSX that does not have one",
13  false))
14  , traceKeyPresses(make_unique<BooleanSetting>(
15  commandController, "kbd_trace_key_presses",
16  "Trace key presses (show SDL key code, SDL modifiers and Unicode code-point value)",
17  false, Setting::DONT_SAVE))
18  , autoToggleCodeKanaLock(make_unique<BooleanSetting>(commandController,
19  "kbd_auto_toggle_code_kana_lock",
20  "Automatically toggle the CODE/KANA lock, based on the characters entered on the host keyboard",
21  true))
22 {
23  typedef EnumSetting<Keys::KeyCode>::Map KeyMap;
24  KeyMap allowedKeys = {
25  {"RALT", Keys::K_RALT},
26  {"MENU", Keys::K_MENU},
27  {"RCTRL", Keys::K_RCTRL},
28  {"HENKAN_MODE", Keys::K_HENKAN_MODE},
29  {"RSHIFT", Keys::K_RSHIFT},
30  {"RMETA", Keys::K_RMETA},
31  {"LMETA", Keys::K_LMETA},
32  {"LSUPER", Keys::K_LSUPER},
33  {"RSUPER", Keys::K_RSUPER},
34  {"HELP", Keys::K_HELP},
35  {"UNDO", Keys::K_UNDO},
36  {"END", Keys::K_END},
37  {"PAGEUP", Keys::K_PAGEUP},
38  {"PAGEDOWN", Keys::K_PAGEDOWN}};
39  codeKanaHostKey = make_unique<EnumSetting<Keys::KeyCode>>(
40  commandController, "kbd_code_kana_host_key",
41  "Host key that maps to the MSX CODE/KANA key. Please note that the HENKAN_MODE key only exists on Japanese host keyboards)",
42  Keys::K_RALT, KeyMap(allowedKeys));
43 
44  deadkeyHostKey[0] = make_unique<EnumSetting<Keys::KeyCode>>(
45  commandController, "kbd_deadkey1_host_key",
46  "Host key that maps to deadkey 1. Not applicable to Japanese and Korean MSX models",
47  Keys::K_RCTRL, KeyMap(allowedKeys));
48 
49  deadkeyHostKey[1] = make_unique<EnumSetting<Keys::KeyCode>>(
50  commandController, "kbd_deadkey2_host_key",
51  "Host key that maps to deadkey 2. Only applicable to Brazilian MSX models (Sharp Hotbit and Gradiente)",
52  Keys::K_PAGEUP, KeyMap(allowedKeys));
53 
54  deadkeyHostKey[2] = make_unique<EnumSetting<Keys::KeyCode>>(
55  commandController, "kbd_deadkey3_host_key",
56  "Host key that maps to deadkey 3. Only applicable to Brazilian Sharp Hotbit MSX models",
57  Keys::K_PAGEDOWN, std::move(allowedKeys));
58 
59  kpEnterMode = make_unique<EnumSetting<KpEnterMode>>(
60  commandController, "kbd_numkeypad_enter_key",
61  "MSX key that the enter key on the host numeric keypad must map to",
63  {"KEYPAD_COMMA", MSX_KP_COMMA},
64  {"ENTER", MSX_ENTER}});
65 
66  mappingMode = make_unique<EnumSetting<MappingMode>>(
67  commandController, "kbd_mapping_mode",
68  "Keyboard mapping mode",
70  {"KEY", KEY_MAPPING},
71  {"CHARACTER", CHARACTER_MAPPING}});
72 }
73 
75 {
76 }
77 
79 {
80  assert(n < 3);
81  return deadkeyHostKey[n]->getEnum();
82 }
83 
84 } // namespace openmsx
KeyboardSettings(CommandController &commandController)
KeyCode
Constants that identify keys and key modifiers.
Definition: Keys.hh:26
Keys::KeyCode getDeadkeyHostKey(unsigned n) const
commandController(commandController_)
std::unique_ptr< T > make_unique()
Definition: memory.hh:27