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  EnumSetting<Keys::KeyCode>::Map allowedKeys = {
24  { "RALT", Keys::K_RALT },
25  { "MENU", Keys::K_MENU },
26  { "RCTRL", Keys::K_RCTRL },
27  { "HENKAN_MODE", Keys::K_HENKAN_MODE },
28  { "RSHIFT", Keys::K_RSHIFT },
29  { "RMETA", Keys::K_RMETA },
30  { "LMETA", Keys::K_LMETA },
31  { "LSUPER", Keys::K_LSUPER },
32  { "RSUPER", Keys::K_RSUPER },
33  { "HELP", Keys::K_HELP },
34  { "UNDO", Keys::K_UNDO },
35  { "END", Keys::K_END },
36  { "PAGEUP", Keys::K_PAGEUP },
37  { "PAGEDOWN", Keys::K_PAGEDOWN } };
38  codeKanaHostKey = make_unique<EnumSetting<Keys::KeyCode>>(
39  commandController, "kbd_code_kana_host_key",
40  "Host key that maps to the MSX CODE/KANA key. Please note that the HENKAN_MODE key only exists on Japanese host keyboards)",
41  Keys::K_RALT, allowedKeys);
42 
43  deadkeyHostKey[0] = make_unique<EnumSetting<Keys::KeyCode>>(
44  commandController, "kbd_deadkey1_host_key",
45  "Host key that maps to deadkey 1. Not applicable to Japanese and Korean MSX models",
46  Keys::K_RCTRL, allowedKeys);
47 
48  deadkeyHostKey[1] = make_unique<EnumSetting<Keys::KeyCode>>(
49  commandController, "kbd_deadkey2_host_key",
50  "Host key that maps to deadkey 2. Only applicable to Brazilian MSX models (Sharp Hotbit and Gradiente)",
51  Keys::K_PAGEUP, allowedKeys);
52 
53  deadkeyHostKey[2] = make_unique<EnumSetting<Keys::KeyCode>>(
54  commandController, "kbd_deadkey3_host_key",
55  "Host key that maps to deadkey 3. Only applicable to Brazilian Sharp Hotbit MSX models",
56  Keys::K_PAGEDOWN, allowedKeys);
57 
58  EnumSetting<KpEnterMode>::Map kpEnterModeMap = {
59  { "KEYPAD_COMMA", MSX_KP_COMMA },
60  { "ENTER", MSX_ENTER } };
61  kpEnterMode = make_unique<EnumSetting<KpEnterMode>>(
62  commandController, "kbd_numkeypad_enter_key",
63  "MSX key that the enter key on the host numeric keypad must map to",
64  MSX_KP_COMMA, kpEnterModeMap);
65 
66  EnumSetting<MappingMode>::Map mappingModeMap = {
67  { "KEY", KEY_MAPPING },
68  { "CHARACTER", CHARACTER_MAPPING } };
69  mappingMode = make_unique<EnumSetting<MappingMode>>(
70  commandController, "kbd_mapping_mode",
71  "Keyboard mapping mode",
72  CHARACTER_MAPPING, mappingModeMap);
73 }
74 
76 {
77 }
78 
80 {
81  assert(n < 3);
82  return deadkeyHostKey[n]->getEnum();
83 }
84 
85 } // 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