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 {
24  allowedKeys["RALT"] = Keys::K_RALT;
25  allowedKeys["MENU"] = Keys::K_MENU;
26  allowedKeys["RCTRL"] = Keys::K_RCTRL;
27  allowedKeys["HENKAN_MODE"] = Keys::K_HENKAN_MODE;
28  allowedKeys["RSHIFT"] = Keys::K_RSHIFT;
29  allowedKeys["RMETA"] = Keys::K_RMETA;
30  allowedKeys["LMETA"] = Keys::K_LMETA;
31  allowedKeys["LSUPER"] = Keys::K_LSUPER;
32  allowedKeys["RSUPER"] = Keys::K_RSUPER;
33  allowedKeys["HELP"] = Keys::K_HELP;
34  allowedKeys["UNDO"] = Keys::K_UNDO;
35  allowedKeys["END"] = Keys::K_END;
36  allowedKeys["PAGEUP"] = Keys::K_PAGEUP;
37  allowedKeys["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  kpEnterModeMap["KEYPAD_COMMA"] = MSX_KP_COMMA;
60  kpEnterModeMap["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  mappingModeMap["KEY"] = KEY_MAPPING;
68  mappingModeMap["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  return *codeKanaHostKey;
82 }
83 
85 {
86  assert(n < 3);
87  return deadkeyHostKey[n]->getValue();
88 }
89 
91 {
92  return *kpEnterMode;
93 }
94 
96 {
97  return *mappingMode;
98 }
99 
101 {
102  return *alwaysEnableKeypad;
103 }
104 
106 {
107  return *traceKeyPresses;
108 }
109 
111 {
112  return *autoToggleCodeKanaLock;
113 }
114 
115 } // namespace openmsx