1//============================================================================
2//
3// SSSS tt lll lll
4// SS SS tt ll ll
5// SS tttttt eeee ll ll aaaa
6// SSSS tt ee ee ll ll aa
7// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator"
8// SS SS tt ee ll ll aa aa
9// SSSS ttt eeeee llll llll aaaaa
10//
11// Copyright (c) 1995-2019 by Bradford W. Mott, Stephen Anthony
12// and the Stella Team
13//
14// See the file "License.txt" for information on usage and redistribution of
15// this file, and for a DISCLAIMER OF ALL WARRANTIES.
16//============================================================================
17
18#include "OSystem.hxx"
19#include "Console.hxx"
20#include "Settings.hxx"
21#include "EventHandler.hxx"
22#include "Sound.hxx"
23#include "StateManager.hxx"
24#include "StellaKeys.hxx"
25#include "TIASurface.hxx"
26#include "PNGLibrary.hxx"
27#include "PKeyboardHandler.hxx"
28
29#ifdef DEBUGGER_SUPPORT
30 #include "Debugger.hxx"
31#endif
32#ifdef GUI_SUPPORT
33 #include "DialogContainer.hxx"
34#endif
35
36#if defined(BSPF_MACOS) || defined(MACOS_KEYS)
37static constexpr int MOD3 = KBDM_GUI;
38#else
39static constexpr int MOD3 = KBDM_ALT;
40#endif
41
42// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
43PhysicalKeyboardHandler::PhysicalKeyboardHandler(OSystem& system, EventHandler& handler)
44 : myOSystem(system),
45 myHandler(handler)
46#ifdef BSPF_UNIX
47 , myAltKeyCounter(0)
48#endif
49{
50 Int32 version = myOSystem.settings().getInt("event_ver");
51
52 // Compare if event list version has changed so that key maps became invalid
53 if (version == Event::VERSION)
54 {
55 string list = myOSystem.settings().getString("keymap_emu");
56 myKeyMap.loadMapping(list, EventMode::kCommonMode);
57 list = myOSystem.settings().getString("keymap_joy");
58 myKeyMap.loadMapping(list, EventMode::kJoystickMode);
59 list = myOSystem.settings().getString("keymap_pad");
60 myKeyMap.loadMapping(list, EventMode::kPaddlesMode);
61 list = myOSystem.settings().getString("keymap_key");
62 myKeyMap.loadMapping(list, EventMode::kKeypadMode);
63 list = myOSystem.settings().getString("keymap_ui");
64 myKeyMap.loadMapping(list, EventMode::kMenuMode);
65 }
66 myKeyMap.enableMod() = myOSystem.settings().getBool("modcombo");
67
68 setDefaultMapping(Event::NoType, EventMode::kEmulationMode, true);
69 setDefaultMapping(Event::NoType, EventMode::kMenuMode, true);
70}
71
72// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
73// Depending on parameters, this method does the following:
74// 1. update all events with default (event == Event::NoType, updateDefault == true)
75// 2. reset all events to default (event == Event::NoType, updateDefault == false)
76// 3. reset one event to default (event != Event::NoType)
77void PhysicalKeyboardHandler::setDefaultKey(EventMapping map, Event::Type event,
78 EventMode mode, bool updateDefaults)
79{
80 // If event is 'NoType', erase and reset all mappings
81 // Otherwise, only reset the given event
82 bool eraseAll = !updateDefaults && (event == Event::NoType);
83
84 if (updateDefaults)
85 {
86 // if there is no existing mapping for the event or
87 // the default mapping for the event is unused, set default key for event
88 if (myKeyMap.getEventMapping(map.event, mode).size() == 0 ||
89 !myKeyMap.check(mode, map.key, map.mod))
90 {
91 myKeyMap.add(map.event, mode, map.key, map.mod);
92 }
93 }
94 else if (eraseAll || map.event == event)
95 {
96 //myKeyMap.eraseEvent(map.event, mode);
97 myKeyMap.add(map.event, mode, map.key, map.mod);
98 }
99}
100
101// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
102// Depending on parameters, this method does the following:
103// 1. update all events with default (event == Event::NoType, updateDefault == true)
104// 2. reset all events to default (event == Event::NoType, updateDefault == false)
105// 3. reset one event to default (event != Event::NoType)
106void PhysicalKeyboardHandler::setDefaultMapping(Event::Type event, EventMode mode,
107 bool updateDefaults)
108{
109 if (!updateDefaults)
110 {
111 myKeyMap.eraseEvent(event, mode);
112 myKeyMap.eraseEvent(event, getEventMode(event, mode));
113 }
114
115 switch(mode)
116 {
117 case EventMode::kEmulationMode:
118 for (const auto& item: DefaultCommonMapping)
119 setDefaultKey(item, event, EventMode::kCommonMode, updateDefaults);
120 // put all controller events into their own mode's mappings
121 for (const auto& item: DefaultJoystickMapping)
122 setDefaultKey(item, event, EventMode::kJoystickMode, updateDefaults);
123 for (const auto& item: DefaultPaddleMapping)
124 setDefaultKey(item, event, EventMode::kPaddlesMode, updateDefaults);
125 for (const auto& item: DefaultKeypadMapping)
126 setDefaultKey(item, event, EventMode::kKeypadMode, updateDefaults);
127 for (const auto& item : CompuMateMapping)
128 setDefaultKey(item, event, EventMode::kCompuMateMode, updateDefaults);
129 break;
130
131 case EventMode::kMenuMode:
132 for (const auto& item: DefaultMenuMapping)
133 setDefaultKey(item, event, EventMode::kMenuMode, updateDefaults);
134 break;
135
136 default:
137 break;
138 }
139}
140
141// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
142void PhysicalKeyboardHandler::defineControllerMappings(const Controller::Type type, Controller::Jack port)
143{
144 // determine controller events to use
145 switch(type)
146 {
147 case Controller::Type::Keyboard:
148 case Controller::Type::KidVid:
149 if(port == Controller::Jack::Left)
150 myLeftMode = EventMode::kKeypadMode;
151 else
152 myRightMode = EventMode::kKeypadMode;
153 break;
154
155 case Controller::Type::Paddles:
156 case Controller::Type::PaddlesIAxDr:
157 case Controller::Type::PaddlesIAxis:
158 if(port == Controller::Jack::Left)
159 myLeftMode = EventMode::kPaddlesMode;
160 else
161 myRightMode = EventMode::kPaddlesMode;
162 break;
163
164 case Controller::Type::CompuMate:
165 myLeftMode = myRightMode = EventMode::kCompuMateMode;
166 break;
167
168 default:
169 // let's use joystick then
170 if(port == Controller::Jack::Left)
171 myLeftMode = EventMode::kJoystickMode;
172 else
173 myRightMode = EventMode::kJoystickMode;
174 }
175}
176
177// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
178void PhysicalKeyboardHandler::enableEmulationMappings()
179{
180 // start from scratch and enable common mappings
181 myKeyMap.eraseMode(EventMode::kEmulationMode);
182 enableCommonMappings();
183
184 // enable right mode first, so that in case of mapping clashes the left controller has preference
185 switch (myRightMode)
186 {
187 case EventMode::kPaddlesMode:
188 enableMappings(RightPaddlesEvents, EventMode::kPaddlesMode);
189 break;
190
191 case EventMode::kKeypadMode:
192 enableMappings(RightKeypadEvents, EventMode::kKeypadMode);
193 break;
194
195 case EventMode::kCompuMateMode:
196 // see below
197 break;
198
199 default:
200 enableMappings(RightJoystickEvents, EventMode::kJoystickMode);
201 break;
202 }
203
204 switch (myLeftMode)
205 {
206 case EventMode::kPaddlesMode:
207 enableMappings(LeftPaddlesEvents, EventMode::kPaddlesMode);
208 break;
209
210 case EventMode::kKeypadMode:
211 enableMappings(LeftKeypadEvents, EventMode::kKeypadMode);
212 break;
213
214 case EventMode::kCompuMateMode:
215 for (const auto& item : CompuMateMapping)
216 enableMapping(item.event, EventMode::kCompuMateMode);
217 break;
218
219 default:
220 enableMappings(LeftJoystickEvents, EventMode::kJoystickMode);
221 break;
222 }
223}
224
225// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
226void PhysicalKeyboardHandler::enableCommonMappings()
227{
228 for (int i = Event::NoType + 1; i < Event::LastType; i++)
229 {
230 Event::Type event = static_cast<Event::Type>(i);
231
232 if (isCommonEvent(event))
233 enableMapping(event, EventMode::kCommonMode);
234 }
235}
236
237// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
238void PhysicalKeyboardHandler::enableMappings(const Event::EventSet events, EventMode mode)
239{
240 for (const auto& event : events)
241 enableMapping(event, mode);
242}
243
244// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
245void PhysicalKeyboardHandler::enableMapping(const Event::Type event, EventMode mode)
246{
247 // copy from controller mode into emulation mode
248 KeyMap::MappingArray mappings = myKeyMap.getEventMapping(event, mode);
249
250 for (const auto& mapping : mappings)
251 myKeyMap.add(event, EventMode::kEmulationMode, mapping.key, mapping.mod);
252}
253
254// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
255EventMode PhysicalKeyboardHandler::getEventMode(const Event::Type event, const EventMode mode) const
256{
257 if (mode == EventMode::kEmulationMode)
258 {
259 if (isJoystickEvent(event))
260 return EventMode::kJoystickMode;
261
262 if (isPaddleEvent(event))
263 return EventMode::kPaddlesMode;
264
265 if (isKeypadEvent(event))
266 return EventMode::kKeypadMode;
267
268 if (isCommonEvent(event))
269 return EventMode::kCommonMode;
270 }
271
272 return mode;
273}
274
275// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
276bool PhysicalKeyboardHandler::isJoystickEvent(const Event::Type event) const
277{
278 return LeftJoystickEvents.find(event) != LeftJoystickEvents.end()
279 || RightJoystickEvents.find(event) != RightJoystickEvents.end();
280}
281
282// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
283bool PhysicalKeyboardHandler::isPaddleEvent(const Event::Type event) const
284{
285 return LeftPaddlesEvents.find(event) != LeftPaddlesEvents.end()
286 || RightPaddlesEvents.find(event) != RightPaddlesEvents.end();
287}
288
289// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
290bool PhysicalKeyboardHandler::isKeypadEvent(const Event::Type event) const
291{
292 return LeftKeypadEvents.find(event) != LeftKeypadEvents.end()
293 || RightKeypadEvents.find(event) != RightKeypadEvents.end();
294}
295
296// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
297bool PhysicalKeyboardHandler::isCommonEvent(const Event::Type event) const
298{
299 return !(isJoystickEvent(event) || isPaddleEvent(event) || isKeypadEvent(event));
300}
301
302// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
303void PhysicalKeyboardHandler::eraseMapping(Event::Type event, EventMode mode)
304{
305 myKeyMap.eraseEvent(event, mode);
306 myKeyMap.eraseEvent(event, getEventMode(event, mode));
307}
308
309// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
310void PhysicalKeyboardHandler::saveMapping()
311{
312 myOSystem.settings().setValue("event_ver", Event::VERSION);
313 myOSystem.settings().setValue("keymap_emu", myKeyMap.saveMapping(EventMode::kCommonMode));
314 myOSystem.settings().setValue("keymap_joy", myKeyMap.saveMapping(EventMode::kJoystickMode));
315 myOSystem.settings().setValue("keymap_pad", myKeyMap.saveMapping(EventMode::kPaddlesMode));
316 myOSystem.settings().setValue("keymap_key", myKeyMap.saveMapping(EventMode::kKeypadMode));
317 myOSystem.settings().setValue("keymap_ui", myKeyMap.saveMapping(EventMode::kMenuMode));
318 enableEmulationMappings();
319}
320
321// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
322bool PhysicalKeyboardHandler::addMapping(Event::Type event, EventMode mode,
323 StellaKey key, StellaMod mod)
324{
325 // These events cannot be remapped to keys
326 if(Event::isAnalog(event))
327 return false;
328 else
329 {
330 EventMode evMode = getEventMode(event, mode);
331
332 myKeyMap.add(event, evMode, key, mod);
333 if (evMode == myLeftMode || evMode == myRightMode)
334 myKeyMap.add(event, mode, key, mod);
335 }
336
337 return true;
338}
339
340// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
341void PhysicalKeyboardHandler::handleEvent(StellaKey key, StellaMod mod, bool pressed, bool repeated)
342{
343#ifdef BSPF_UNIX
344 // Swallow KBDK_TAB under certain conditions
345 // See commments on 'myAltKeyCounter' for more information
346 if(myAltKeyCounter > 1 && key == KBDK_TAB)
347 {
348 myAltKeyCounter = 0;
349 return;
350 }
351 if (key == KBDK_TAB && pressed && StellaModTest::isAlt(mod))
352 {
353 // Swallow Alt-Tab, but remember that it happened
354 myAltKeyCounter = 1;
355 return;
356 }
357#endif
358
359 EventHandlerState estate = myHandler.state();
360
361 // special handling for CompuMate in emulation modes
362 if ((estate == EventHandlerState::EMULATION || estate == EventHandlerState::PAUSE) &&
363 myOSystem.console().leftController().type() == Controller::Type::CompuMate)
364 {
365 Event::Type event = myKeyMap.get(EventMode::kCompuMateMode, key, mod);
366
367 // (potential) CompuMate events are handled directly.
368 if (myKeyMap.get(EventMode::kEmulationMode, key, mod) != Event::ExitMode &&
369 !StellaModTest::isAlt(mod) && event != Event::NoType)
370 {
371 myHandler.handleEvent(event, pressed, repeated);
372 return;
373 }
374 }
375
376 // Arrange the logic to take advantage of short-circuit evaluation
377 // Handle keys which switch eventhandler state
378 if (!pressed && myHandler.changeStateByEvent(myKeyMap.get(EventMode::kEmulationMode, key, mod)))
379 return;
380
381 // Otherwise, let the event handler deal with it
382 switch(estate)
383 {
384 case EventHandlerState::EMULATION:
385 case EventHandlerState::PAUSE:
386 myHandler.handleEvent(myKeyMap.get(EventMode::kEmulationMode, key, mod), pressed, repeated);
387 break;
388
389 default:
390 #ifdef GUI_SUPPORT
391 if (myHandler.hasOverlay())
392 myHandler.overlay().handleKeyEvent(key, mod, pressed, repeated);
393 #endif
394 myHandler.handleEvent(myKeyMap.get(EventMode::kMenuMode, key, mod), pressed, repeated);
395 break;
396 }
397}
398
399// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
400PhysicalKeyboardHandler::EventMappingArray PhysicalKeyboardHandler::DefaultCommonMapping = {
401 {Event::ConsoleSelect, KBDK_F1},
402 {Event::ConsoleReset, KBDK_F2},
403 {Event::ConsoleColor, KBDK_F3},
404 {Event::ConsoleBlackWhite, KBDK_F4},
405 {Event::ConsoleLeftDiffA, KBDK_F5},
406 {Event::ConsoleLeftDiffB, KBDK_F6},
407 {Event::ConsoleRightDiffA, KBDK_F7},
408 {Event::ConsoleRightDiffB, KBDK_F8},
409 {Event::SaveState, KBDK_F9},
410 {Event::SaveAllStates, KBDK_F9, MOD3},
411 {Event::ChangeState, KBDK_F10},
412 {Event::ToggleAutoSlot, KBDK_F10, MOD3},
413 {Event::LoadState, KBDK_F11},
414 {Event::LoadAllStates, KBDK_F11, MOD3},
415 {Event::TakeSnapshot, KBDK_F12},
416 {Event::Fry, KBDK_BACKSPACE},
417 {Event::TogglePauseMode, KBDK_PAUSE},
418 {Event::OptionsMenuMode, KBDK_TAB},
419 {Event::CmdMenuMode, KBDK_BACKSLASH},
420 {Event::TimeMachineMode, KBDK_T},
421 {Event::DebuggerMode, KBDK_GRAVE},
422 {Event::ExitMode, KBDK_ESCAPE},
423#ifdef BSPF_MACOS
424 {Event::Quit, KBDK_Q, MOD3},
425#else
426 {Event::Quit, KBDK_Q, KBDM_CTRL},
427#endif
428 {Event::ReloadConsole, KBDK_R, KBDM_CTRL},
429
430 {Event::VidmodeDecrease, KBDK_MINUS, MOD3},
431 {Event::VidmodeIncrease, KBDK_EQUALS, MOD3},
432 {Event::VolumeDecrease, KBDK_LEFTBRACKET, MOD3},
433 {Event::VolumeIncrease, KBDK_RIGHTBRACKET, MOD3},
434 {Event::SoundToggle, KBDK_RIGHTBRACKET, KBDM_CTRL},
435
436 {Event::ToggleFullScreen, KBDK_RETURN, MOD3},
437 {Event::DecreaseOverscan, KBDK_PAGEDOWN, MOD3},
438 {Event::IncreaseOverScan, KBDK_PAGEUP, MOD3},
439 {Event::VidmodeStd, KBDK_1, MOD3},
440 {Event::VidmodeRGB, KBDK_2, MOD3},
441 {Event::VidmodeSVideo, KBDK_3, MOD3},
442 {Event::VidModeComposite, KBDK_4, MOD3},
443 {Event::VidModeBad, KBDK_5, MOD3},
444 {Event::VidModeCustom, KBDK_6, MOD3},
445 {Event::PreviousAttribute, KBDK_7, KBDM_SHIFT | MOD3},
446 {Event::NextAttribute, KBDK_7, MOD3},
447 {Event::DecreaseAttribute, KBDK_8, KBDM_SHIFT | MOD3},
448 {Event::IncreaseAttribute, KBDK_8, MOD3},
449 {Event::DecreasePhosphor, KBDK_9, KBDM_SHIFT | MOD3},
450 {Event::IncreasePhosphor, KBDK_9, MOD3},
451 {Event::TogglePhosphor, KBDK_P, MOD3},
452 {Event::ScanlinesDecrease, KBDK_0, KBDM_SHIFT | MOD3},
453 {Event::ScanlinesIncrease, KBDK_0, MOD3},
454 {Event::ToggleColorLoss, KBDK_L, KBDM_CTRL},
455 {Event::TogglePalette, KBDK_P, KBDM_CTRL},
456 {Event::ToggleJitter, KBDK_J, MOD3},
457 {Event::ToggleFrameStats, KBDK_L, MOD3},
458 {Event::ToggleTimeMachine, KBDK_T, MOD3},
459#ifdef PNG_SUPPORT
460 {Event::ToggleContSnapshots, KBDK_S, MOD3},
461 {Event::ToggleContSnapshotsFrame, KBDK_S, KBDM_SHIFT | MOD3},
462#endif
463 {Event::HandleMouseControl, KBDK_0, KBDM_CTRL},
464 {Event::ToggleGrabMouse, KBDK_G, KBDM_CTRL},
465 {Event::ToggleSAPortOrder, KBDK_1, KBDM_CTRL},
466 {Event::DecreaseFormat, KBDK_F, KBDM_SHIFT | KBDM_CTRL},
467 {Event::IncreaseFormat, KBDK_F, KBDM_CTRL},
468
469 {Event::ToggleP0Collision, KBDK_Z, KBDM_SHIFT | MOD3},
470 {Event::ToggleP0Bit, KBDK_Z, MOD3},
471 {Event::ToggleP1Collision, KBDK_X, KBDM_SHIFT | MOD3},
472 {Event::ToggleP1Bit, KBDK_X, MOD3},
473 {Event::ToggleM0Collision, KBDK_C, KBDM_SHIFT | MOD3},
474 {Event::ToggleM0Bit, KBDK_C, MOD3},
475 {Event::ToggleM1Collision, KBDK_V, KBDM_SHIFT | MOD3},
476 {Event::ToggleM1Bit, KBDK_V, MOD3},
477 {Event::ToggleBLCollision, KBDK_B, KBDM_SHIFT | MOD3},
478 {Event::ToggleBLBit, KBDK_B, MOD3},
479 {Event::TogglePFCollision, KBDK_N, KBDM_SHIFT | MOD3},
480 {Event::TogglePFBit, KBDK_N, MOD3},
481 {Event::ToggleCollisions, KBDK_COMMA, KBDM_SHIFT | MOD3},
482 {Event::ToggleBits, KBDK_COMMA, MOD3},
483 {Event::ToggleFixedColors, KBDK_PERIOD, MOD3},
484
485 {Event::RewindPause, KBDK_LEFT, KBDM_SHIFT},
486 {Event::Rewind1Menu, KBDK_LEFT, MOD3},
487 {Event::Rewind10Menu, KBDK_LEFT, KBDM_SHIFT | MOD3},
488 {Event::RewindAllMenu, KBDK_DOWN, MOD3},
489 {Event::UnwindPause, KBDK_LEFT, KBDM_SHIFT},
490 {Event::Unwind1Menu, KBDK_RIGHT, MOD3},
491 {Event::Unwind10Menu, KBDK_RIGHT, KBDM_SHIFT | MOD3},
492 {Event::UnwindAllMenu, KBDK_UP, MOD3},
493
494#if defined(RETRON77)
495 {Event::ConsoleColorToggle, KBDK_F4}, // back ("COLOR","B/W")
496 {Event::ConsoleLeftDiffToggle, KBDK_F6}, // front ("SKILL P1")
497 {Event::ConsoleRightDiffToggle, KBDK_F8}, // front ("SKILL P2")
498 {Event::CmdMenuMode, KBDK_F13}, // back ("4:3","16:9")
499 {Event::ExitMode, KBDK_BACKSPACE}, // back ("FRY")
500#endif
501};
502
503// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
504PhysicalKeyboardHandler::EventMappingArray PhysicalKeyboardHandler::DefaultMenuMapping = {
505 {Event::UIUp, KBDK_UP},
506 {Event::UIDown, KBDK_DOWN},
507 {Event::UILeft, KBDK_LEFT},
508 {Event::UIRight, KBDK_RIGHT},
509 {Event::UISelect, KBDK_RETURN},
510
511 {Event::UIHome, KBDK_HOME},
512 {Event::UIEnd, KBDK_END},
513 {Event::UIPgUp, KBDK_PAGEUP},
514 {Event::UIPgDown, KBDK_PAGEDOWN},
515 // same with keypad
516 {Event::UIUp, KBDK_KP_8},
517 {Event::UIDown, KBDK_KP_2},
518 {Event::UILeft, KBDK_KP_4},
519 {Event::UIRight, KBDK_KP_6},
520 {Event::UISelect, KBDK_KP_ENTER},
521
522 {Event::UIHome, KBDK_KP_7},
523 {Event::UIEnd, KBDK_KP_1},
524 {Event::UIPgUp, KBDK_KP_9},
525 {Event::UIPgDown, KBDK_KP_3},
526
527 {Event::UICancel, KBDK_ESCAPE},
528
529 {Event::UINavPrev, KBDK_TAB, KBDM_SHIFT},
530 {Event::UINavNext, KBDK_TAB},
531 {Event::UITabPrev, KBDK_TAB, KBDM_SHIFT | KBDM_CTRL},
532 {Event::UITabNext, KBDK_TAB, KBDM_CTRL},
533
534 {Event::UIPrevDir, KBDK_BACKSPACE},
535 {Event::ToggleFullScreen, KBDK_RETURN, MOD3},
536
537#ifdef BSPF_MACOS
538 {Event::Quit, KBDK_Q, MOD3},
539#else
540 {Event::Quit, KBDK_Q, KBDM_CTRL},
541#endif
542
543#if defined(RETRON77)
544 {Event::UIUp, KBDK_F9}, // front ("SAVE")
545 {Event::UIDown, KBDK_F2}, // front ("RESET")
546 {Event::UINavPrev, KBDK_F11}, // front ("LOAD")
547 {Event::UINavNext, KBDK_F1}, // front ("MODE")
548 {Event::UISelect, KBDK_F6}, // front ("SKILL P1")
549 {Event::UICancel, KBDK_F8}, // front ("SKILL P2")
550 //{Event::NoType, KBDK_F4}, // back ("COLOR","B/W")
551 {Event::UITabPrev, KBDK_F13}, // back ("4:3","16:9")
552 {Event::UITabNext, KBDK_BACKSPACE}, // back (FRY)
553#endif
554};
555
556// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
557PhysicalKeyboardHandler::EventMappingArray PhysicalKeyboardHandler::DefaultJoystickMapping = {
558 {Event::JoystickZeroUp, KBDK_UP},
559 {Event::JoystickZeroDown, KBDK_DOWN},
560 {Event::JoystickZeroLeft, KBDK_LEFT},
561 {Event::JoystickZeroRight, KBDK_RIGHT},
562 {Event::JoystickZeroUp, KBDK_KP_8},
563 {Event::JoystickZeroDown, KBDK_KP_2},
564 {Event::JoystickZeroLeft, KBDK_KP_4},
565 {Event::JoystickZeroRight, KBDK_KP_6},
566 {Event::JoystickZeroFire, KBDK_SPACE},
567 {Event::JoystickZeroFire, KBDK_LCTRL},
568 {Event::JoystickZeroFire, KBDK_KP_5},
569 {Event::JoystickZeroFire5, KBDK_4},
570 {Event::JoystickZeroFire5, KBDK_RSHIFT},
571 {Event::JoystickZeroFire5, KBDK_KP_9},
572 {Event::JoystickZeroFire9, KBDK_5},
573 {Event::JoystickZeroFire9, KBDK_RCTRL},
574 {Event::JoystickZeroFire9, KBDK_KP_3},
575 {Event::JoystickOneUp, KBDK_Y},
576 {Event::JoystickOneDown, KBDK_H},
577 {Event::JoystickOneLeft, KBDK_G},
578 {Event::JoystickOneRight, KBDK_J},
579 {Event::JoystickOneFire, KBDK_F},
580 {Event::JoystickOneFire5, KBDK_6},
581 {Event::JoystickOneFire9, KBDK_7},
582};
583
584// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
585PhysicalKeyboardHandler::EventMappingArray PhysicalKeyboardHandler::DefaultPaddleMapping = {
586 {Event::PaddleZeroDecrease, KBDK_RIGHT},
587 {Event::PaddleZeroIncrease, KBDK_LEFT},
588 {Event::PaddleZeroFire, KBDK_SPACE},
589 {Event::PaddleZeroFire, KBDK_LCTRL},
590 {Event::PaddleZeroFire, KBDK_KP_5},
591
592 {Event::PaddleOneDecrease, KBDK_DOWN},
593 {Event::PaddleOneIncrease, KBDK_UP},
594 {Event::PaddleOneFire, KBDK_4},
595 {Event::PaddleOneFire, KBDK_RCTRL},
596
597 {Event::PaddleTwoDecrease, KBDK_J},
598 {Event::PaddleTwoIncrease, KBDK_G},
599 {Event::PaddleTwoFire, KBDK_F},
600
601 {Event::PaddleThreeDecrease, KBDK_H},
602 {Event::PaddleThreeIncrease, KBDK_Y},
603 {Event::PaddleThreeFire, KBDK_6},
604};
605
606// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
607PhysicalKeyboardHandler::EventMappingArray PhysicalKeyboardHandler::DefaultKeypadMapping = {
608 {Event::KeyboardZero1, KBDK_1},
609 {Event::KeyboardZero2, KBDK_2},
610 {Event::KeyboardZero3, KBDK_3},
611 {Event::KeyboardZero4, KBDK_Q},
612 {Event::KeyboardZero5, KBDK_W},
613 {Event::KeyboardZero6, KBDK_E},
614 {Event::KeyboardZero7, KBDK_A},
615 {Event::KeyboardZero8, KBDK_S},
616 {Event::KeyboardZero9, KBDK_D},
617 {Event::KeyboardZeroStar, KBDK_Z},
618 {Event::KeyboardZero0, KBDK_X},
619 {Event::KeyboardZeroPound, KBDK_C},
620
621 {Event::KeyboardOne1, KBDK_8},
622 {Event::KeyboardOne2, KBDK_9},
623 {Event::KeyboardOne3, KBDK_0},
624 {Event::KeyboardOne4, KBDK_I},
625 {Event::KeyboardOne5, KBDK_O},
626 {Event::KeyboardOne6, KBDK_P},
627 {Event::KeyboardOne7, KBDK_K},
628 {Event::KeyboardOne8, KBDK_L},
629 {Event::KeyboardOne9, KBDK_SEMICOLON},
630 {Event::KeyboardOneStar, KBDK_COMMA},
631 {Event::KeyboardOne0, KBDK_PERIOD},
632 {Event::KeyboardOnePound, KBDK_SLASH},
633};
634
635// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
636PhysicalKeyboardHandler::EventMappingArray PhysicalKeyboardHandler::CompuMateMapping = {
637 {Event::CompuMateShift, KBDK_LSHIFT},
638 {Event::CompuMateShift, KBDK_RSHIFT},
639 {Event::CompuMateFunc, KBDK_LCTRL},
640 {Event::CompuMateFunc, KBDK_RCTRL},
641 {Event::CompuMate0, KBDK_0},
642 {Event::CompuMate1, KBDK_1},
643 {Event::CompuMate2, KBDK_2},
644 {Event::CompuMate3, KBDK_3},
645 {Event::CompuMate4, KBDK_4},
646 {Event::CompuMate5, KBDK_5},
647 {Event::CompuMate6, KBDK_6},
648 {Event::CompuMate7, KBDK_7},
649 {Event::CompuMate8, KBDK_8},
650 {Event::CompuMate9, KBDK_9},
651 {Event::CompuMateA, KBDK_A},
652 {Event::CompuMateB, KBDK_B},
653 {Event::CompuMateC, KBDK_C},
654 {Event::CompuMateD, KBDK_D},
655 {Event::CompuMateE, KBDK_E},
656 {Event::CompuMateF, KBDK_F},
657 {Event::CompuMateG, KBDK_G},
658 {Event::CompuMateH, KBDK_H},
659 {Event::CompuMateI, KBDK_I},
660 {Event::CompuMateJ, KBDK_J},
661 {Event::CompuMateK, KBDK_K},
662 {Event::CompuMateL, KBDK_L},
663 {Event::CompuMateM, KBDK_M},
664 {Event::CompuMateN, KBDK_N},
665 {Event::CompuMateO, KBDK_O},
666 {Event::CompuMateP, KBDK_P},
667 {Event::CompuMateQ, KBDK_Q},
668 {Event::CompuMateR, KBDK_R},
669 {Event::CompuMateS, KBDK_S},
670 {Event::CompuMateT, KBDK_T},
671 {Event::CompuMateU, KBDK_U},
672 {Event::CompuMateV, KBDK_V},
673 {Event::CompuMateW, KBDK_W},
674 {Event::CompuMateX, KBDK_X},
675 {Event::CompuMateY, KBDK_Y},
676 {Event::CompuMateZ, KBDK_Z},
677 {Event::CompuMateComma, KBDK_COMMA},
678 {Event::CompuMatePeriod, KBDK_PERIOD},
679 {Event::CompuMateEnter, KBDK_RETURN},
680 {Event::CompuMateEnter, KBDK_KP_ENTER},
681 {Event::CompuMateSpace, KBDK_SPACE},
682 // extra emulated keys
683 {Event::CompuMateQuestion, KBDK_SLASH, KBDM_SHIFT},
684 {Event::CompuMateLeftBracket, KBDK_LEFTBRACKET},
685 {Event::CompuMateRightBracket, KBDK_RIGHTBRACKET},
686 {Event::CompuMateMinus, KBDK_MINUS},
687 {Event::CompuMateQuote, KBDK_APOSTROPHE, KBDM_SHIFT},
688 {Event::CompuMateBackspace, KBDK_BACKSPACE},
689 {Event::CompuMateEquals, KBDK_EQUALS},
690 {Event::CompuMatePlus, KBDK_EQUALS, KBDM_SHIFT},
691 {Event::CompuMateSlash, KBDK_SLASH}
692};
693