From 73dbe861a6deb49710101fdbb99ca0dede36ebdc Mon Sep 17 00:00:00 2001 From: stephena Date: Sat, 14 Jan 2012 22:00:54 +0000 Subject: [PATCH] Refactored the keycode handling through the GUI classes, making it more generic than SDL, but less generic than simply using int's for everything. This will help once we start porting to SDL2, which has an updated keycode handling system. The plan is that the internal core keyboard stuff is now insulated from any further changes in SDL. This also allows eventually adding support for CompuMate controller, which needs access to keycode names in a generic way. git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@2356 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba --- src/common/StellaKeys.hxx | 313 ++++++++++++ src/debugger/gui/DataGridWidget.cxx | 124 ++--- src/debugger/gui/DataGridWidget.hxx | 12 +- src/debugger/gui/DebuggerDialog.cxx | 8 +- src/debugger/gui/DebuggerDialog.hxx | 2 +- src/debugger/gui/PromptWidget.cxx | 47 +- src/debugger/gui/PromptWidget.hxx | 2 +- src/debugger/gui/RomListWidget.cxx | 22 +- src/debugger/gui/RomListWidget.hxx | 6 +- src/debugger/gui/TiaOutputWidget.hxx | 4 +- src/debugger/gui/ToggleWidget.cxx | 139 +++--- src/debugger/gui/ToggleWidget.hxx | 2 +- src/emucore/EventHandler.cxx | 715 +++++++++++++-------------- src/emucore/EventHandler.hxx | 19 +- src/gui/ContextMenu.cxx | 4 +- src/gui/ContextMenu.hxx | 2 +- src/gui/Dialog.cxx | 20 +- src/gui/Dialog.hxx | 5 +- src/gui/DialogContainer.cxx | 19 +- src/gui/DialogContainer.hxx | 10 +- src/gui/EditableWidget.cxx | 61 ++- src/gui/EditableWidget.hxx | 4 +- src/gui/EventMappingWidget.cxx | 4 +- src/gui/EventMappingWidget.hxx | 2 +- src/gui/InputDialog.cxx | 8 +- src/gui/InputDialog.hxx | 2 +- src/gui/LauncherDialog.cxx | 6 +- src/gui/LauncherDialog.hxx | 2 +- src/gui/ListWidget.cxx | 26 +- src/gui/ListWidget.hxx | 6 +- src/gui/Widget.hxx | 5 +- 31 files changed, 957 insertions(+), 644 deletions(-) create mode 100644 src/common/StellaKeys.hxx diff --git a/src/common/StellaKeys.hxx b/src/common/StellaKeys.hxx new file mode 100644 index 000000000..46bf4d3e3 --- /dev/null +++ b/src/common/StellaKeys.hxx @@ -0,0 +1,313 @@ +//============================================================================ +// +// SSSS tt lll lll +// SS SS tt ll ll +// SS tttttt eeee ll ll aaaa +// SSSS tt ee ee ll ll aa +// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" +// SS SS tt ee ll ll aa aa +// SSSS ttt eeeee llll llll aaaaa +// +// Copyright (c) 1995-2012 by Bradford W. Mott, Stephen Anthony +// and the Stella Team +// +// See the file "License.txt" for information on usage and redistribution of +// this file, and for a DISCLAIMER OF ALL WARRANTIES. +// +// $Id$ +//============================================================================ + +#ifndef STELLA_KEYS_HXX +#define STELLA_KEYS_HXX + +/** + This class implements a thin wrapper around the SDL keysym enumerations, + such that SDL-specific code doesn't have to go into the internal parts of + the codebase. The keycodes are exactly the same, but from the POV of the + rest of the code, they are *KBD* (keyboard) keys, not *SDL* keys. + + Once the codebase is ported to SDL2, the intent is to simply change this + file without having to modify all other classes that use StellaKey. + + @author Stephen Anthony +*/ + +// This comes directly from SDL_keysym.h +typedef enum { + /** @name ASCII mapped keysyms + * The keyboard syms have been cleverly chosen to map to ASCII + */ + /*@{*/ + KBDK_UNKNOWN = 0, + KBDK_FIRST = 0, + KBDK_BACKSPACE = 8, + KBDK_TAB = 9, + KBDK_CLEAR = 12, + KBDK_RETURN = 13, + KBDK_PAUSE = 19, + KBDK_ESCAPE = 27, + KBDK_SPACE = 32, + KBDK_EXCLAIM = 33, + KBDK_QUOTEDBL = 34, + KBDK_HASH = 35, + KBDK_DOLLAR = 36, + KBDK_AMPERSAND = 38, + KBDK_QUOTE = 39, + KBDK_LEFTPAREN = 40, + KBDK_RIGHTPAREN = 41, + KBDK_ASTERISK = 42, + KBDK_PLUS = 43, + KBDK_COMMA = 44, + KBDK_MINUS = 45, + KBDK_PERIOD = 46, + KBDK_SLASH = 47, + KBDK_0 = 48, + KBDK_1 = 49, + KBDK_2 = 50, + KBDK_3 = 51, + KBDK_4 = 52, + KBDK_5 = 53, + KBDK_6 = 54, + KBDK_7 = 55, + KBDK_8 = 56, + KBDK_9 = 57, + KBDK_COLON = 58, + KBDK_SEMICOLON = 59, + KBDK_LESS = 60, + KBDK_EQUALS = 61, + KBDK_GREATER = 62, + KBDK_QUESTION = 63, + KBDK_AT = 64, + /* + Skip uppercase letters + */ + KBDK_LEFTBRACKET = 91, + KBDK_BACKSLASH = 92, + KBDK_RIGHTBRACKET = 93, + KBDK_CARET = 94, + KBDK_UNDERSCORE = 95, + KBDK_BACKQUOTE = 96, + KBDK_a = 97, + KBDK_b = 98, + KBDK_c = 99, + KBDK_d = 100, + KBDK_e = 101, + KBDK_f = 102, + KBDK_g = 103, + KBDK_h = 104, + KBDK_i = 105, + KBDK_j = 106, + KBDK_k = 107, + KBDK_l = 108, + KBDK_m = 109, + KBDK_n = 110, + KBDK_o = 111, + KBDK_p = 112, + KBDK_q = 113, + KBDK_r = 114, + KBDK_s = 115, + KBDK_t = 116, + KBDK_u = 117, + KBDK_v = 118, + KBDK_w = 119, + KBDK_x = 120, + KBDK_y = 121, + KBDK_z = 122, + KBDK_DELETE = 127, + /* End of ASCII mapped keysyms */ + /*@}*/ + + /** @name International keyboard syms */ + /*@{*/ + KBDK_WORLD_0 = 160, /* 0xA0 */ + KBDK_WORLD_1 = 161, + KBDK_WORLD_2 = 162, + KBDK_WORLD_3 = 163, + KBDK_WORLD_4 = 164, + KBDK_WORLD_5 = 165, + KBDK_WORLD_6 = 166, + KBDK_WORLD_7 = 167, + KBDK_WORLD_8 = 168, + KBDK_WORLD_9 = 169, + KBDK_WORLD_10 = 170, + KBDK_WORLD_11 = 171, + KBDK_WORLD_12 = 172, + KBDK_WORLD_13 = 173, + KBDK_WORLD_14 = 174, + KBDK_WORLD_15 = 175, + KBDK_WORLD_16 = 176, + KBDK_WORLD_17 = 177, + KBDK_WORLD_18 = 178, + KBDK_WORLD_19 = 179, + KBDK_WORLD_20 = 180, + KBDK_WORLD_21 = 181, + KBDK_WORLD_22 = 182, + KBDK_WORLD_23 = 183, + KBDK_WORLD_24 = 184, + KBDK_WORLD_25 = 185, + KBDK_WORLD_26 = 186, + KBDK_WORLD_27 = 187, + KBDK_WORLD_28 = 188, + KBDK_WORLD_29 = 189, + KBDK_WORLD_30 = 190, + KBDK_WORLD_31 = 191, + KBDK_WORLD_32 = 192, + KBDK_WORLD_33 = 193, + KBDK_WORLD_34 = 194, + KBDK_WORLD_35 = 195, + KBDK_WORLD_36 = 196, + KBDK_WORLD_37 = 197, + KBDK_WORLD_38 = 198, + KBDK_WORLD_39 = 199, + KBDK_WORLD_40 = 200, + KBDK_WORLD_41 = 201, + KBDK_WORLD_42 = 202, + KBDK_WORLD_43 = 203, + KBDK_WORLD_44 = 204, + KBDK_WORLD_45 = 205, + KBDK_WORLD_46 = 206, + KBDK_WORLD_47 = 207, + KBDK_WORLD_48 = 208, + KBDK_WORLD_49 = 209, + KBDK_WORLD_50 = 210, + KBDK_WORLD_51 = 211, + KBDK_WORLD_52 = 212, + KBDK_WORLD_53 = 213, + KBDK_WORLD_54 = 214, + KBDK_WORLD_55 = 215, + KBDK_WORLD_56 = 216, + KBDK_WORLD_57 = 217, + KBDK_WORLD_58 = 218, + KBDK_WORLD_59 = 219, + KBDK_WORLD_60 = 220, + KBDK_WORLD_61 = 221, + KBDK_WORLD_62 = 222, + KBDK_WORLD_63 = 223, + KBDK_WORLD_64 = 224, + KBDK_WORLD_65 = 225, + KBDK_WORLD_66 = 226, + KBDK_WORLD_67 = 227, + KBDK_WORLD_68 = 228, + KBDK_WORLD_69 = 229, + KBDK_WORLD_70 = 230, + KBDK_WORLD_71 = 231, + KBDK_WORLD_72 = 232, + KBDK_WORLD_73 = 233, + KBDK_WORLD_74 = 234, + KBDK_WORLD_75 = 235, + KBDK_WORLD_76 = 236, + KBDK_WORLD_77 = 237, + KBDK_WORLD_78 = 238, + KBDK_WORLD_79 = 239, + KBDK_WORLD_80 = 240, + KBDK_WORLD_81 = 241, + KBDK_WORLD_82 = 242, + KBDK_WORLD_83 = 243, + KBDK_WORLD_84 = 244, + KBDK_WORLD_85 = 245, + KBDK_WORLD_86 = 246, + KBDK_WORLD_87 = 247, + KBDK_WORLD_88 = 248, + KBDK_WORLD_89 = 249, + KBDK_WORLD_90 = 250, + KBDK_WORLD_91 = 251, + KBDK_WORLD_92 = 252, + KBDK_WORLD_93 = 253, + KBDK_WORLD_94 = 254, + KBDK_WORLD_95 = 255, /* 0xFF */ + /*@}*/ + + /** @name Numeric keypad */ + /*@{*/ + KBDK_KP0 = 256, + KBDK_KP1 = 257, + KBDK_KP2 = 258, + KBDK_KP3 = 259, + KBDK_KP4 = 260, + KBDK_KP5 = 261, + KBDK_KP6 = 262, + KBDK_KP7 = 263, + KBDK_KP8 = 264, + KBDK_KP9 = 265, + KBDK_KP_PERIOD = 266, + KBDK_KP_DIVIDE = 267, + KBDK_KP_MULTIPLY = 268, + KBDK_KP_MINUS = 269, + KBDK_KP_PLUS = 270, + KBDK_KP_ENTER = 271, + KBDK_KP_EQUALS = 272, + /*@}*/ + + /** @name Arrows + Home/End pad */ + /*@{*/ + KBDK_UP = 273, + KBDK_DOWN = 274, + KBDK_RIGHT = 275, + KBDK_LEFT = 276, + KBDK_INSERT = 277, + KBDK_HOME = 278, + KBDK_END = 279, + KBDK_PAGEUP = 280, + KBDK_PAGEDOWN = 281, + /*@}*/ + + /** @name Function keys */ + /*@{*/ + KBDK_F1 = 282, + KBDK_F2 = 283, + KBDK_F3 = 284, + KBDK_F4 = 285, + KBDK_F5 = 286, + KBDK_F6 = 287, + KBDK_F7 = 288, + KBDK_F8 = 289, + KBDK_F9 = 290, + KBDK_F10 = 291, + KBDK_F11 = 292, + KBDK_F12 = 293, + KBDK_F13 = 294, + KBDK_F14 = 295, + KBDK_F15 = 296, + /*@}*/ + + /** @name Key state modifier keys */ + /*@{*/ + KBDK_NUMLOCK = 300, + KBDK_CAPSLOCK = 301, + KBDK_SCROLLOCK = 302, + KBDK_RSHIFT = 303, + KBDK_LSHIFT = 304, + KBDK_RCTRL = 305, + KBDK_LCTRL = 306, + KBDK_RALT = 307, + KBDK_LALT = 308, + KBDK_RMETA = 309, + KBDK_LMETA = 310, + KBDK_LSUPER = 311, /**< Left "Windows" key */ + KBDK_RSUPER = 312, /**< Right "Windows" key */ + KBDK_MODE = 313, /**< "Alt Gr" key */ + KBDK_COMPOSE = 314, /**< Multi-key compose key */ + /*@}*/ + + /** @name Miscellaneous function keys */ + /*@{*/ + KBDK_HELP = 315, + KBDK_PRINT = 316, + KBDK_SYSREQ = 317, + KBDK_BREAK = 318, + KBDK_MENU = 319, + KBDK_POWER = 320, /**< Power Macintosh power key */ + KBDK_EURO = 321, /**< Some european keyboards */ + KBDK_UNDO = 322, /**< Atari keyboard has Undo */ + /*@}*/ + + /* Add any other keys here */ + + KBDK_LAST +} StellaKey; + +// Just pass SDLMod directly as int (placeholder for now) +// The underlying code doesn't need to know how it's implemented +typedef int StellaMod; + +#endif /* StellaKeys */ diff --git a/src/debugger/gui/DataGridWidget.cxx b/src/debugger/gui/DataGridWidget.cxx index 4e4ac9c62..6b6876c86 100644 --- a/src/debugger/gui/DataGridWidget.cxx +++ b/src/debugger/gui/DataGridWidget.cxx @@ -47,6 +47,7 @@ DataGridWidget::DataGridWidget(GuiObject* boss, const GUI::Font& font, _bits(bits), _base(base), _selectedItem(0), + _currentKeyDown(KBDK_UNKNOWN), _opsWidget(NULL), _scrollBar(NULL) { @@ -55,8 +56,6 @@ DataGridWidget::DataGridWidget(GuiObject* boss, const GUI::Font& font, _type = kDataGridWidget; _editMode = false; - _currentKeyDown = 0; - // The item is selected, thus _bgcolor is used to draw the caret and // _textcolorhi to erase it _caretInverse = true; @@ -282,11 +281,11 @@ int DataGridWidget::findItem(int x, int y) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool DataGridWidget::handleKeyDown(int ascii, int keycode, int modifiers) +bool DataGridWidget::handleKeyDown(StellaKey key, StellaMod mod, char ascii) { // Ignore all mod keys - if(instance().eventHandler().kbdControl(modifiers) || - instance().eventHandler().kbdAlt(modifiers)) + if(instance().eventHandler().kbdControl(mod) || + instance().eventHandler().kbdAlt(mod)) return true; bool handled = true; @@ -295,17 +294,16 @@ bool DataGridWidget::handleKeyDown(int ascii, int keycode, int modifiers) if (_editMode) { // Class EditableWidget handles all text editing related key presses for us - handled = EditableWidget::handleKeyDown(ascii, keycode, modifiers); + handled = EditableWidget::handleKeyDown(key, mod, ascii); if(handled) setDirty(); draw(); } else { // not editmode - switch(ascii) + switch(key) { - case '\n': // enter/return - case '\r': + case KBDK_RETURN: if (_currentRow >= 0 && _currentCol >= 0) { dirty = true; @@ -314,7 +312,7 @@ bool DataGridWidget::handleKeyDown(int ascii, int keycode, int modifiers) } break; - case 256+17: // up arrow + case KBDK_UP: if (_currentRow > 0) { _currentRow--; @@ -328,7 +326,7 @@ bool DataGridWidget::handleKeyDown(int ascii, int keycode, int modifiers) } break; - case 256+18: // down arrow + case KBDK_DOWN: if (_currentRow < (int) _rows - 1) { _currentRow++; @@ -342,7 +340,7 @@ bool DataGridWidget::handleKeyDown(int ascii, int keycode, int modifiers) } break; - case 256+20: // left arrow + case KBDK_LEFT: if (_currentCol > 0) { _currentCol--; @@ -356,7 +354,7 @@ bool DataGridWidget::handleKeyDown(int ascii, int keycode, int modifiers) } break; - case 256+19: // right arrow + case KBDK_RIGHT: if (_currentCol < (int) _cols - 1) { _currentCol++; @@ -370,8 +368,8 @@ bool DataGridWidget::handleKeyDown(int ascii, int keycode, int modifiers) } break; - case 256+24: // pageup - if(instance().eventHandler().kbdShift(modifiers) && _scrollBar) + case KBDK_PAGEUP: + if(instance().eventHandler().kbdShift(mod) && _scrollBar) handleMouseWheel(0, 0, -1); else if (_currentRow > 0) { @@ -380,8 +378,8 @@ bool DataGridWidget::handleKeyDown(int ascii, int keycode, int modifiers) } break; - case 256+25: // pagedown - if(instance().eventHandler().kbdShift(modifiers) && _scrollBar) + case KBDK_PAGEDOWN: + if(instance().eventHandler().kbdShift(mod) && _scrollBar) handleMouseWheel(0, 0, +1); else if (_currentRow < (int) _rows - 1) { @@ -390,7 +388,7 @@ bool DataGridWidget::handleKeyDown(int ascii, int keycode, int modifiers) } break; - case 256+22: // home + case KBDK_HOME: if (_currentCol > 0) { _currentCol = 0; @@ -398,7 +396,7 @@ bool DataGridWidget::handleKeyDown(int ascii, int keycode, int modifiers) } break; - case 256+23: // end + case KBDK_END: if (_currentCol < (int) _cols - 1) { _currentCol = _cols - 1; @@ -406,48 +404,58 @@ bool DataGridWidget::handleKeyDown(int ascii, int keycode, int modifiers) } break; - case 'n': // negate + case KBDK_n: // negate if(_editable) negateCell(); break; - case 'i': // invert - case '!': - if(_editable) - invertCell(); - break; - - case '-': // decrement - if(_editable) - decrementCell(); - break; - - case '+': // increment - case '=': - if(_editable) - incrementCell(); - break; - - case '<': // shift left - case ',': - if(_editable) - lshiftCell(); - break; - - case '>': // shift right - case '.': - if(_editable) - rshiftCell(); - break; - - case 'z': // zero - if(_editable) - zeroCell(); - break; - default: handled = false; } + if(!handled) + { + handled = true; + + switch(ascii) + { + case 'i': // invert + case '!': + if(_editable) + invertCell(); + break; + + case '-': // decrement + if(_editable) + decrementCell(); + break; + + case '+': // increment + case '=': + if(_editable) + incrementCell(); + break; + + case '<': // shift left + case ',': + if(_editable) + lshiftCell(); + break; + + case '>': // shift right + case '.': + if(_editable) + rshiftCell(); + break; + + case 'z': // zero + if(_editable) + zeroCell(); + break; + + default: + handled = false; + } + } } if (dirty) @@ -461,15 +469,15 @@ bool DataGridWidget::handleKeyDown(int ascii, int keycode, int modifiers) setDirty(); draw(); } - _currentKeyDown = keycode; + _currentKeyDown = key; return handled; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool DataGridWidget::handleKeyUp(int ascii, int keycode, int modifiers) +bool DataGridWidget::handleKeyUp(StellaKey key, StellaMod mod, char ascii) { - if (keycode == _currentKeyDown) - _currentKeyDown = 0; + if (key == _currentKeyDown) + _currentKeyDown = KBDK_UNKNOWN; return true; } diff --git a/src/debugger/gui/DataGridWidget.hxx b/src/debugger/gui/DataGridWidget.hxx index 37ebc6dd2..072dcd6f3 100644 --- a/src/debugger/gui/DataGridWidget.hxx +++ b/src/debugger/gui/DataGridWidget.hxx @@ -75,8 +75,8 @@ class DataGridWidget : public EditableWidget virtual void handleMouseDown(int x, int y, int button, int clickCount); virtual void handleMouseUp(int x, int y, int button, int clickCount); virtual void handleMouseWheel(int x, int y, int direction); - virtual bool handleKeyDown(int ascii, int keycode, int modifiers); - virtual bool handleKeyUp(int ascii, int keycode, int modifiers); + virtual bool handleKeyDown(StellaKey key, StellaMod mod, char ascii); + virtual bool handleKeyUp(StellaKey key, StellaMod mod, char ascii); virtual void handleCommand(CommandSender* sender, int cmd, int data, int id); virtual bool wantsFocus() { return true; } @@ -125,10 +125,10 @@ class DataGridWidget : public EditableWidget BoolArray _changedList; BoolArray _hiliteList; - bool _editMode; - int _selectedItem; - int _currentKeyDown; - string _backupString; + bool _editMode; + int _selectedItem; + StellaKey _currentKeyDown; + string _backupString; DataGridOpsWidget* _opsWidget; ScrollBarWidget* _scrollBar; diff --git a/src/debugger/gui/DebuggerDialog.cxx b/src/debugger/gui/DebuggerDialog.cxx index e2d5efc98..ac9d71b36 100644 --- a/src/debugger/gui/DebuggerDialog.cxx +++ b/src/debugger/gui/DebuggerDialog.cxx @@ -78,12 +78,12 @@ void DebuggerDialog::loadConfig() } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void DebuggerDialog::handleKeyDown(int ascii, int keycode, int modifiers) +void DebuggerDialog::handleKeyDown(StellaKey key, StellaMod mod, char ascii) { - bool handled = instance().eventHandler().kbdAlt(modifiers); + bool handled = instance().eventHandler().kbdAlt(mod); if(handled) { - switch(keycode) + switch(ascii) { case 's': doStep(); @@ -106,7 +106,7 @@ void DebuggerDialog::handleKeyDown(int ascii, int keycode, int modifiers) } } if(!handled) - Dialog::handleKeyDown(ascii, keycode, modifiers); + Dialog::handleKeyDown(key, mod, ascii); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/debugger/gui/DebuggerDialog.hxx b/src/debugger/gui/DebuggerDialog.hxx index 6a7b6f801..10751fce7 100644 --- a/src/debugger/gui/DebuggerDialog.hxx +++ b/src/debugger/gui/DebuggerDialog.hxx @@ -56,7 +56,7 @@ class DebuggerDialog : public Dialog ButtonWidget& rewindButton() { return *myRewindButton; } void loadConfig(); - void handleKeyDown(int ascii, int keycode, int modifiers); + void handleKeyDown(StellaKey key, StellaMod mod, char ascii); void handleCommand(CommandSender* sender, int cmd, int data, int id); void showFatalMessage(const string& msg); diff --git a/src/debugger/gui/PromptWidget.cxx b/src/debugger/gui/PromptWidget.cxx index 450b8cc33..c23c78f8a 100644 --- a/src/debugger/gui/PromptWidget.cxx +++ b/src/debugger/gui/PromptWidget.cxx @@ -141,16 +141,15 @@ void PromptWidget::printPrompt() } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool PromptWidget::handleKeyDown(int ascii, int keycode, int modifiers) +bool PromptWidget::handleKeyDown(StellaKey key, StellaMod mod, char ascii) { int i; bool handled = true; bool dirty = false; - switch(ascii) + switch(key) { - case '\n': // enter/return - case '\r': + case KBDK_RETURN: { nextLine(); @@ -188,7 +187,7 @@ bool PromptWidget::handleKeyDown(int ascii, int keycode, int modifiers) break; } - case '\t': // tab + case KBDK_TAB: { // Tab completion: we complete either commands or labels, but not // both at once. @@ -289,7 +288,7 @@ bool PromptWidget::handleKeyDown(int ascii, int keycode, int modifiers) break; } - case 8: // backspace + case KBDK_BACKSPACE: if (_currentPos > _promptStartPos) killChar(-1); @@ -297,13 +296,13 @@ bool PromptWidget::handleKeyDown(int ascii, int keycode, int modifiers) dirty = true; break; - case 127: + case KBDK_DELETE: killChar(+1); dirty = true; break; - case 256 + 24: // pageup - if (instance().eventHandler().kbdShift(modifiers)) + case KBDK_PAGEUP: + if (instance().eventHandler().kbdShift(mod)) { // Don't scroll up when at top of buffer if(_scrollLine < _linesPerPage) @@ -318,8 +317,8 @@ bool PromptWidget::handleKeyDown(int ascii, int keycode, int modifiers) } break; - case 256 + 25: // pagedown - if (instance().eventHandler().kbdShift(modifiers)) + case KBDK_PAGEDOWN: + if (instance().eventHandler().kbdShift(mod)) { // Don't scroll down when at bottom of buffer if(_scrollLine >= _promptEndPos / _lineWidth) @@ -334,8 +333,8 @@ bool PromptWidget::handleKeyDown(int ascii, int keycode, int modifiers) } break; - case 256 + 22: // home - if (instance().eventHandler().kbdShift(modifiers)) + case KBDK_HOME: + if (instance().eventHandler().kbdShift(mod)) { _scrollLine = _firstLineInBuffer + _linesPerPage - 1; updateScrollBuffer(); @@ -346,8 +345,8 @@ bool PromptWidget::handleKeyDown(int ascii, int keycode, int modifiers) dirty = true; break; - case 256 + 23: // end - if (instance().eventHandler().kbdShift(modifiers)) + case KBDK_END: + if (instance().eventHandler().kbdShift(mod)) { _scrollLine = _promptEndPos / _lineWidth; if (_scrollLine < _linesPerPage - 1) @@ -360,8 +359,8 @@ bool PromptWidget::handleKeyDown(int ascii, int keycode, int modifiers) dirty = true; break; - case 273: // cursor up - if (instance().eventHandler().kbdShift(modifiers)) + case KBDK_UP: + if (instance().eventHandler().kbdShift(mod)) { if(_scrollLine <= _firstLineInBuffer + _linesPerPage - 1) break; @@ -375,8 +374,8 @@ bool PromptWidget::handleKeyDown(int ascii, int keycode, int modifiers) historyScroll(+1); break; - case 274: // cursor down - if (instance().eventHandler().kbdShift(modifiers)) + case KBDK_DOWN: + if (instance().eventHandler().kbdShift(mod)) { // Don't scroll down when at bottom of buffer if(_scrollLine >= _promptEndPos / _lineWidth) @@ -391,14 +390,14 @@ bool PromptWidget::handleKeyDown(int ascii, int keycode, int modifiers) historyScroll(-1); break; - case 275: // cursor right + case KBDK_RIGHT: if (_currentPos < _promptEndPos) _currentPos++; dirty = true; break; - case 276: // cursor left + case KBDK_LEFT: if (_currentPos > _promptStartPos) _currentPos--; @@ -406,11 +405,11 @@ bool PromptWidget::handleKeyDown(int ascii, int keycode, int modifiers) break; default: - if (instance().eventHandler().kbdControl(modifiers)) + if (instance().eventHandler().kbdControl(mod)) { - specialKeys(keycode); + specialKeys(key); } - else if (instance().eventHandler().kbdAlt(modifiers)) + else if (instance().eventHandler().kbdAlt(mod)) { } else if (isprint(ascii)) diff --git a/src/debugger/gui/PromptWidget.hxx b/src/debugger/gui/PromptWidget.hxx index ccf036972..b03e87dab 100644 --- a/src/debugger/gui/PromptWidget.hxx +++ b/src/debugger/gui/PromptWidget.hxx @@ -73,7 +73,7 @@ class PromptWidget : public Widget, public CommandSender void handleMouseDown(int x, int y, int button, int clickCount); void handleMouseWheel(int x, int y, int direction); - bool handleKeyDown(int ascii, int keycode, int modifiers); + bool handleKeyDown(StellaKey key, StellaMod mod, char ascii); void handleCommand(CommandSender* sender, int cmd, int data, int id); // Account for the extra width of embedded scrollbar diff --git a/src/debugger/gui/RomListWidget.cxx b/src/debugger/gui/RomListWidget.cxx index 3d847ac4d..0eef06c65 100644 --- a/src/debugger/gui/RomListWidget.cxx +++ b/src/debugger/gui/RomListWidget.cxx @@ -38,8 +38,8 @@ RomListWidget::RomListWidget(GuiObject* boss, const GUI::Font& font, _currentPos(0), _selectedItem(-1), _highlightedItem(-1), - _currentKeyDown(0), - _editMode(false) + _editMode(false), + _currentKeyDown(KBDK_UNKNOWN) { _flags = WIDGET_ENABLED | WIDGET_CLEARBG | WIDGET_RETAIN_FOCUS; _type = kRomListWidget; @@ -284,10 +284,10 @@ void RomListWidget::handleMouseWheel(int x, int y, int direction) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool RomListWidget::handleKeyDown(int ascii, int keycode, int modifiers) +bool RomListWidget::handleKeyDown(StellaKey key, StellaMod mod, char ascii) { // Ignore all Alt-mod keys - if(instance().eventHandler().kbdAlt(modifiers)) + if(instance().eventHandler().kbdAlt(mod)) return true; bool handled = true; @@ -296,14 +296,14 @@ bool RomListWidget::handleKeyDown(int ascii, int keycode, int modifiers) if (_editMode) { // Class EditableWidget handles all text editing related key presses for us - handled = EditableWidget::handleKeyDown(ascii, keycode, modifiers); + handled = EditableWidget::handleKeyDown(key, mod, ascii); } else { // not editmode - switch (keycode) + switch (key) { - case ' ': // space + case KBDK_SPACE: // Snap list back to currently highlighted line if(_highlightedItem >= 0) { @@ -323,15 +323,15 @@ bool RomListWidget::handleKeyDown(int ascii, int keycode, int modifiers) scrollToSelected(); } - _currentKeyDown = keycode; + _currentKeyDown = key; return handled; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool RomListWidget::handleKeyUp(int ascii, int keycode, int modifiers) +bool RomListWidget::handleKeyUp(StellaKey key, StellaMod mod, char ascii) { - if (keycode == _currentKeyDown) - _currentKeyDown = 0; + if (key == _currentKeyDown) + _currentKeyDown = KBDK_UNKNOWN; return true; } diff --git a/src/debugger/gui/RomListWidget.hxx b/src/debugger/gui/RomListWidget.hxx index 026a8cede..e603a7860 100644 --- a/src/debugger/gui/RomListWidget.hxx +++ b/src/debugger/gui/RomListWidget.hxx @@ -63,8 +63,8 @@ class RomListWidget : public EditableWidget void handleMouseDown(int x, int y, int button, int clickCount); void handleMouseUp(int x, int y, int button, int clickCount); void handleMouseWheel(int x, int y, int direction); - bool handleKeyDown(int ascii, int keycode, int modifiers); - bool handleKeyUp(int ascii, int keycode, int modifiers); + bool handleKeyDown(StellaKey key, StellaMod mod, char ascii); + bool handleKeyUp(StellaKey key, StellaMod mod, char ascii); bool handleEvent(Event::Type e); void handleCommand(CommandSender* sender, int cmd, int data, int id); @@ -96,8 +96,8 @@ class RomListWidget : public EditableWidget int _currentPos; int _selectedItem; int _highlightedItem; - int _currentKeyDown; bool _editMode; + StellaKey _currentKeyDown; const CartDebug::Disassembly* myDisasm; const PackedBitArray* myBPState; diff --git a/src/debugger/gui/TiaOutputWidget.hxx b/src/debugger/gui/TiaOutputWidget.hxx index 1e6eb1dbe..bd8626f3c 100644 --- a/src/debugger/gui/TiaOutputWidget.hxx +++ b/src/debugger/gui/TiaOutputWidget.hxx @@ -47,8 +47,8 @@ class TiaOutputWidget : public Widget, public CommandSender /* virtual void handleMouseUp(int x, int y, int button, int clickCount); virtual void handleMouseWheel(int x, int y, int direction); - virtual bool handleKeyDown(int ascii, int keycode, int modifiers); - virtual bool handleKeyUp(int ascii, int keycode, int modifiers); + virtual bool handleKeyDown(StellaKey key, StellaMod mod, char ascii); + virtual bool handleKeyUp(StellaKey key, StellaMod mod, char ascii); */ protected: diff --git a/src/debugger/gui/ToggleWidget.cxx b/src/debugger/gui/ToggleWidget.cxx index d11d79d67..12948963f 100644 --- a/src/debugger/gui/ToggleWidget.cxx +++ b/src/debugger/gui/ToggleWidget.cxx @@ -97,93 +97,92 @@ int ToggleWidget::findItem(int x, int y) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool ToggleWidget::handleKeyDown(int ascii, int keycode, int modifiers) +bool ToggleWidget::handleKeyDown(StellaKey key, StellaMod mod, char ascii) { // Ignore all mod keys - if(instance().eventHandler().kbdControl(modifiers) || - instance().eventHandler().kbdAlt(modifiers)) + if(instance().eventHandler().kbdControl(mod) || + instance().eventHandler().kbdAlt(mod)) return true; bool handled = true; bool dirty = false, toggle = false; - switch(ascii) + switch(key) { - case '\n': // enter/return - case '\r': - if (_currentRow >= 0 && _currentCol >= 0) - { - dirty = true; + case KBDK_RETURN: + if (_currentRow >= 0 && _currentCol >= 0) + { + dirty = true; toggle = true; - } - break; + } + break; - case 256+17: // up arrow - if (_currentRow > 0) - { - _currentRow--; - dirty = true; - } - break; + case KBDK_UP: + if (_currentRow > 0) + { + _currentRow--; + dirty = true; + } + break; - case 256+18: // down arrow - if (_currentRow < (int) _rows - 1) - { - _currentRow++; - dirty = true; - } - break; + case KBDK_DOWN: + if (_currentRow < (int) _rows - 1) + { + _currentRow++; + dirty = true; + } + break; - case 256+20: // left arrow - if (_currentCol > 0) - { - _currentCol--; - dirty = true; - } - break; + case KBDK_LEFT: + if (_currentCol > 0) + { + _currentCol--; + dirty = true; + } + break; - case 256+19: // right arrow - if (_currentCol < (int) _cols - 1) - { - _currentCol++; - dirty = true; - } - break; + case KBDK_RIGHT: + if (_currentCol < (int) _cols - 1) + { + _currentCol++; + dirty = true; + } + break; - case 256+24: // pageup - if (_currentRow > 0) - { - _currentRow = 0; - dirty = true; - } - break; + case KBDK_PAGEUP: + if (_currentRow > 0) + { + _currentRow = 0; + dirty = true; + } + break; - case 256+25: // pagedown - if (_currentRow < (int) _rows - 1) - { - _currentRow = _rows - 1; - dirty = true; - } - break; + case KBDK_PAGEDOWN: + if (_currentRow < (int) _rows - 1) + { + _currentRow = _rows - 1; + dirty = true; + } + break; - case 256+22: // home - if (_currentCol > 0) - { - _currentCol = 0; - dirty = true; - } - break; + case KBDK_HOME: + if (_currentCol > 0) + { + _currentCol = 0; + dirty = true; + } + break; - case 256+23: // end - if (_currentCol < (int) _cols - 1) - { - _currentCol = _cols - 1; - dirty = true; - } - break; + case KBDK_END: + if (_currentCol < (int) _cols - 1) + { + _currentCol = _cols - 1; + dirty = true; + } + break; - default: - handled = false; + default: + handled = false; } if (dirty) @@ -205,7 +204,7 @@ bool ToggleWidget::handleKeyDown(int ascii, int keycode, int modifiers) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void ToggleWidget::handleCommand(CommandSender* sender, int cmd, - int data, int id) + int data, int id) { switch (cmd) { diff --git a/src/debugger/gui/ToggleWidget.hxx b/src/debugger/gui/ToggleWidget.hxx index 0c9cd9e19..0068aa628 100644 --- a/src/debugger/gui/ToggleWidget.hxx +++ b/src/debugger/gui/ToggleWidget.hxx @@ -46,7 +46,7 @@ class ToggleWidget : public Widget, public CommandSender virtual void handleMouseDown(int x, int y, int button, int clickCount); virtual void handleMouseUp(int x, int y, int button, int clickCount); - virtual bool handleKeyDown(int ascii, int keycode, int modifiers); + virtual bool handleKeyDown(StellaKey key, StellaMod mod, char ascii); virtual void handleCommand(CommandSender* sender, int cmd, int data, int id); virtual bool wantsFocus() { return true; } diff --git a/src/emucore/EventHandler.cxx b/src/emucore/EventHandler.cxx index 1a39bae37..423b20d14 100644 --- a/src/emucore/EventHandler.cxx +++ b/src/emucore/EventHandler.cxx @@ -66,9 +66,9 @@ EventHandler::EventHandler(OSystem* osystem) myNumJoysticks(0) { // Erase the key mapping array - for(int i = 0; i < SDLK_LAST; ++i) + for(int i = 0; i < KBDK_LAST; ++i) { - ourSDLMapping[i] = ""; + ourKBDKMapping[i] = ""; for(int m = 0; m < kNumModes; ++m) myKeyTable[i][m] = Event::NoType; } @@ -310,10 +310,9 @@ void EventHandler::poll(uInt64 time) case SDL_KEYUP: case SDL_KEYDOWN: { - int ascii = event.key.keysym.unicode; - SDLKey key = event.key.keysym.sym; - SDLMod mod = event.key.keysym.mod; - uInt8 state = event.key.type == SDL_KEYDOWN ? 1 : 0; + StellaKey key = (StellaKey)event.key.keysym.sym; + StellaMod mod = event.key.keysym.mod; + bool state = event.key.type == SDL_KEYDOWN; bool handled = true; // An attempt to speed up event processing @@ -323,13 +322,13 @@ void EventHandler::poll(uInt64 time) { #ifdef MAC_OSX // These keys work in all states - if(key == SDLK_q) + if(key == KBDK_q) { handleEvent(Event::Quit, 1); } else #endif - if(key == SDLK_RETURN) + if(key == KBDK_RETURN) { myOSystem->frameBuffer().toggleFullscreen(); } @@ -338,103 +337,103 @@ void EventHandler::poll(uInt64 time) { switch(int(key)) { - case SDLK_EQUALS: + case KBDK_EQUALS: myOSystem->frameBuffer().changeVidMode(+1); break; - case SDLK_MINUS: + case KBDK_MINUS: myOSystem->frameBuffer().changeVidMode(-1); break; - case SDLK_LEFTBRACKET: + case KBDK_LEFTBRACKET: myOSystem->sound().adjustVolume(-1); break; - case SDLK_RIGHTBRACKET: + case KBDK_RIGHTBRACKET: myOSystem->sound().adjustVolume(+1); break; - case SDLK_PAGEUP: // Alt-PageUp increases YStart + case KBDK_PAGEUP: // Alt-PageUp increases YStart myOSystem->console().changeYStart(+1); break; - case SDLK_PAGEDOWN: // Alt-PageDown decreases YStart + case KBDK_PAGEDOWN: // Alt-PageDown decreases YStart myOSystem->console().changeYStart(-1); break; - case SDLK_z: + case KBDK_z: if(mod & KMOD_SHIFT) myOSystem->console().toggleP0Collision(); else myOSystem->console().toggleP0Bit(); break; - case SDLK_x: + case KBDK_x: if(mod & KMOD_SHIFT) myOSystem->console().toggleP1Collision(); else myOSystem->console().toggleP1Bit(); break; - case SDLK_c: + case KBDK_c: if(mod & KMOD_SHIFT) myOSystem->console().toggleM0Collision(); else myOSystem->console().toggleM0Bit(); break; - case SDLK_v: + case KBDK_v: if(mod & KMOD_SHIFT) myOSystem->console().toggleM1Collision(); else myOSystem->console().toggleM1Bit(); break; - case SDLK_b: + case KBDK_b: if(mod & KMOD_SHIFT) myOSystem->console().toggleBLCollision(); else myOSystem->console().toggleBLBit(); break; - case SDLK_n: + case KBDK_n: if(mod & KMOD_SHIFT) myOSystem->console().togglePFCollision(); else myOSystem->console().togglePFBit(); break; - case SDLK_m: + case KBDK_m: myOSystem->console().toggleHMOVE(); break; - case SDLK_COMMA: + case KBDK_COMMA: myOSystem->console().toggleFixedColors(); break; - case SDLK_PERIOD: + case KBDK_PERIOD: if(mod & KMOD_SHIFT) myOSystem->console().enableCollisions(false); else myOSystem->console().enableBits(false); break; - case SDLK_SLASH: + case KBDK_SLASH: if(mod & KMOD_SHIFT) myOSystem->console().enableCollisions(true); else myOSystem->console().enableBits(true); break; - case SDLK_p: // Alt-p toggles phosphor effect + case KBDK_p: // Alt-p toggles phosphor effect myOSystem->console().togglePhosphor(); break; - case SDLK_l: + case KBDK_l: myOSystem->frameBuffer().toggleFrameStats(); break; - case SDLK_s: // TODO - make this remappable + case KBDK_s: // TODO - make this remappable if(myContSnapshotInterval == 0) { ostringstream buf; @@ -455,21 +454,21 @@ void EventHandler::poll(uInt64 time) break; #if 0 // these will be removed when a UI is added for event recording - case SDLK_e: // Alt-e starts/stops event recording + case KBDK_e: // Alt-e starts/stops event recording if(myOSystem->state().toggleRecordMode()) myOSystem->frameBuffer().showMessage("Recording started"); else myOSystem->frameBuffer().showMessage("Recording stopped"); break; - case SDLK_r: // Alt-r starts/stops rewind mode + case KBDK_r: // Alt-r starts/stops rewind mode if(myOSystem->state().toggleRewindMode()) myOSystem->frameBuffer().showMessage("Rewind mode started"); else myOSystem->frameBuffer().showMessage("Rewind mode stopped"); break; /* - case SDLK_l: // Alt-l loads a recording + case KBDK_l: // Alt-l loads a recording if(myEventStreamer->loadRecording()) myOSystem->frameBuffer().showMessage("Playing recording"); else @@ -490,7 +489,7 @@ void EventHandler::poll(uInt64 time) else if(kbdControl(mod) && state && myUseCtrlKeyFlag) { // These keys work in all states - if(key == SDLK_q) + if(key == KBDK_q) { handleEvent(Event::Quit, 1); } @@ -499,53 +498,53 @@ void EventHandler::poll(uInt64 time) { switch(int(key)) { - case SDLK_0: // Ctrl-0 sets the mouse to paddle 0 + case KBDK_0: // Ctrl-0 sets the mouse to paddle 0 setMouseAsPaddle(0, "Mouse is paddle 0"); break; - case SDLK_1: // Ctrl-1 sets the mouse to paddle 1 + case KBDK_1: // Ctrl-1 sets the mouse to paddle 1 setMouseAsPaddle(1, "Mouse is paddle 1"); break; - case SDLK_2: // Ctrl-2 sets the mouse to paddle 2 + case KBDK_2: // Ctrl-2 sets the mouse to paddle 2 setMouseAsPaddle(2, "Mouse is paddle 2"); break; - case SDLK_3: // Ctrl-3 sets the mouse to paddle 3 + case KBDK_3: // Ctrl-3 sets the mouse to paddle 3 setMouseAsPaddle(3, "Mouse is paddle 3"); break; - case SDLK_f: // Ctrl-f toggles NTSC/PAL mode + case KBDK_f: // Ctrl-f toggles NTSC/PAL mode myOSystem->console().toggleFormat(); break; - case SDLK_g: // Ctrl-g (un)grabs mouse + case KBDK_g: // Ctrl-g (un)grabs mouse if(!myOSystem->frameBuffer().fullScreen()) myOSystem->frameBuffer().toggleGrabMouse(); break; - case SDLK_l: // Ctrl-l toggles PAL color-loss effect + case KBDK_l: // Ctrl-l toggles PAL color-loss effect myOSystem->console().toggleColorLoss(); break; - case SDLK_p: // Ctrl-p toggles different palettes + case KBDK_p: // Ctrl-p toggles different palettes myOSystem->console().togglePalette(); break; - case SDLK_r: // Ctrl-r reloads the currently loaded ROM + case KBDK_r: // Ctrl-r reloads the currently loaded ROM myOSystem->deleteConsole(); myOSystem->createConsole(); break; - case SDLK_PAGEUP: // Ctrl-PageUp increases Height + case KBDK_PAGEUP: // Ctrl-PageUp increases Height myOSystem->console().changeHeight(+1); break; - case SDLK_PAGEDOWN: // Ctrl-PageDown decreases Height + case KBDK_PAGEDOWN: // Ctrl-PageDown decreases Height myOSystem->console().changeHeight(-1); break; - case SDLK_s: // Ctrl-s saves properties to a file + case KBDK_s: // Ctrl-s saves properties to a file { string filename = myOSystem->baseDir() + myOSystem->console().properties().get(Cartridge_Name) + ".pro"; @@ -585,15 +584,7 @@ void EventHandler::poll(uInt64 time) if(myState == S_EMULATE) handleEvent(myKeyTable[key][kEmulationMode], state); else if(myOverlay != NULL) - { - // Assign ascii field if it doesn't exist - // Make sure 'state change' keys (Shift, Ctrl, etc) are excluded - if(!ascii || ascii >= SDLK_LAST || - key == SDLK_BACKSPACE || key == SDLK_DELETE) ascii = key; - if(key > SDLK_F15 && key < SDLK_HELP) ascii = 0; - - myOverlay->handleKeyEvent(ascii, key, mod, state); - } + myOverlay->handleKeyEvent(key, mod, event.key.keysym.unicode & 0x7f, state); break; // SDL_KEYUP, SDL_KEYDOWN } @@ -1137,14 +1128,14 @@ void EventHandler::setActionMappings(EventMode mode) free(list[i].key); list[i].key = NULL; list[i].key = strdup("None"); string key = ""; - for(int j = 0; j < SDLK_LAST; ++j) // key mapping + for(int j = 0; j < KBDK_LAST; ++j) // key mapping { if(myKeyTable[j][mode] == event) { if(key == "") - key = key + ourSDLMapping[j]; + key = key + ourKBDKMapping[j]; else - key = key + ", " + ourSDLMapping[j]; + key = key + ", " + ourKBDKMapping[j]; } } @@ -1268,12 +1259,12 @@ void EventHandler::setKeymap() map.push_back(value); // Only fill the key mapping array if the data is valid - if(event == Event::LastType && map.size() == SDLK_LAST * kNumModes) + if(event == Event::LastType && map.size() == KBDK_LAST * kNumModes) { // Fill the keymap table with events IntArray::const_iterator event = map.begin(); for(int mode = 0; mode < kNumModes; ++mode) - for(int i = 0; i < SDLK_LAST; ++i) + for(int i = 0; i < KBDK_LAST; ++i) myKeyTable[i][mode] = (Event::Type) *event++; } else @@ -1369,10 +1360,10 @@ void EventHandler::setComboMap() } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool EventHandler::addKeyMapping(Event::Type event, EventMode mode, int key) +bool EventHandler::addKeyMapping(Event::Type event, EventMode mode, StellaKey key) { // These keys cannot be remapped - if(key == SDLK_TAB || eventIsAnalog(event)) + if(key == KBDK_TAB || eventIsAnalog(event)) return false; else { @@ -1473,8 +1464,8 @@ bool EventHandler::addJoyHatMapping(Event::Type event, EventMode mode, void EventHandler::eraseMapping(Event::Type event, EventMode mode) { // Erase the KeyEvent arrays - for(int i = 0; i < SDLK_LAST; ++i) - if(myKeyTable[i][mode] == event && i != SDLK_TAB) + for(int i = 0; i < KBDK_LAST; ++i) + if(myKeyTable[i][mode] == event && i != KBDK_TAB) myKeyTable[i][mode] = Event::NoType; #ifdef JOYSTICK_SUPPORT @@ -1506,92 +1497,92 @@ void EventHandler::setDefaultKeymap(Event::Type event, EventMode mode) if(eraseAll) { // Erase all mappings - for(int i = 0; i < SDLK_LAST; ++i) + for(int i = 0; i < KBDK_LAST; ++i) myKeyTable[i][mode] = Event::NoType; } switch(mode) { case kEmulationMode: - SET_DEFAULT_KEY(SDLK_1, mode, Event::KeyboardZero1, event); - SET_DEFAULT_KEY(SDLK_2, mode, Event::KeyboardZero2, event); - SET_DEFAULT_KEY(SDLK_3, mode, Event::KeyboardZero3, event); - SET_DEFAULT_KEY(SDLK_q, mode, Event::KeyboardZero4, event); - SET_DEFAULT_KEY(SDLK_w, mode, Event::KeyboardZero5, event); - SET_DEFAULT_KEY(SDLK_e, mode, Event::KeyboardZero6, event); - SET_DEFAULT_KEY(SDLK_a, mode, Event::KeyboardZero7, event); - SET_DEFAULT_KEY(SDLK_s, mode, Event::KeyboardZero8, event); - SET_DEFAULT_KEY(SDLK_d, mode, Event::KeyboardZero9, event); - SET_DEFAULT_KEY(SDLK_z, mode, Event::KeyboardZeroStar, event); - SET_DEFAULT_KEY(SDLK_x, mode, Event::KeyboardZero0, event); - SET_DEFAULT_KEY(SDLK_c, mode, Event::KeyboardZeroPound, event); + SET_DEFAULT_KEY(KBDK_1, mode, Event::KeyboardZero1, event); + SET_DEFAULT_KEY(KBDK_2, mode, Event::KeyboardZero2, event); + SET_DEFAULT_KEY(KBDK_3, mode, Event::KeyboardZero3, event); + SET_DEFAULT_KEY(KBDK_q, mode, Event::KeyboardZero4, event); + SET_DEFAULT_KEY(KBDK_w, mode, Event::KeyboardZero5, event); + SET_DEFAULT_KEY(KBDK_e, mode, Event::KeyboardZero6, event); + SET_DEFAULT_KEY(KBDK_a, mode, Event::KeyboardZero7, event); + SET_DEFAULT_KEY(KBDK_s, mode, Event::KeyboardZero8, event); + SET_DEFAULT_KEY(KBDK_d, mode, Event::KeyboardZero9, event); + SET_DEFAULT_KEY(KBDK_z, mode, Event::KeyboardZeroStar, event); + SET_DEFAULT_KEY(KBDK_x, mode, Event::KeyboardZero0, event); + SET_DEFAULT_KEY(KBDK_c, mode, Event::KeyboardZeroPound, event); - SET_DEFAULT_KEY(SDLK_8, mode, Event::KeyboardOne1, event); - SET_DEFAULT_KEY(SDLK_9, mode, Event::KeyboardOne2, event); - SET_DEFAULT_KEY(SDLK_0, mode, Event::KeyboardOne3, event); - SET_DEFAULT_KEY(SDLK_i, mode, Event::KeyboardOne4, event); - SET_DEFAULT_KEY(SDLK_o, mode, Event::KeyboardOne5, event); - SET_DEFAULT_KEY(SDLK_p, mode, Event::KeyboardOne6, event); - SET_DEFAULT_KEY(SDLK_k, mode, Event::KeyboardOne7, event); - SET_DEFAULT_KEY(SDLK_l, mode, Event::KeyboardOne8, event); - SET_DEFAULT_KEY(SDLK_SEMICOLON, mode, Event::KeyboardOne9, event); - SET_DEFAULT_KEY(SDLK_COMMA, mode, Event::KeyboardOneStar, event); - SET_DEFAULT_KEY(SDLK_PERIOD, mode, Event::KeyboardOne0, event); - SET_DEFAULT_KEY(SDLK_SLASH, mode, Event::KeyboardOnePound, event); + SET_DEFAULT_KEY(KBDK_8, mode, Event::KeyboardOne1, event); + SET_DEFAULT_KEY(KBDK_9, mode, Event::KeyboardOne2, event); + SET_DEFAULT_KEY(KBDK_0, mode, Event::KeyboardOne3, event); + SET_DEFAULT_KEY(KBDK_i, mode, Event::KeyboardOne4, event); + SET_DEFAULT_KEY(KBDK_o, mode, Event::KeyboardOne5, event); + SET_DEFAULT_KEY(KBDK_p, mode, Event::KeyboardOne6, event); + SET_DEFAULT_KEY(KBDK_k, mode, Event::KeyboardOne7, event); + SET_DEFAULT_KEY(KBDK_l, mode, Event::KeyboardOne8, event); + SET_DEFAULT_KEY(KBDK_SEMICOLON, mode, Event::KeyboardOne9, event); + SET_DEFAULT_KEY(KBDK_COMMA, mode, Event::KeyboardOneStar, event); + SET_DEFAULT_KEY(KBDK_PERIOD, mode, Event::KeyboardOne0, event); + SET_DEFAULT_KEY(KBDK_SLASH, mode, Event::KeyboardOnePound, event); - SET_DEFAULT_KEY(SDLK_UP, mode, Event::JoystickZeroUp, event); - SET_DEFAULT_KEY(SDLK_DOWN, mode, Event::JoystickZeroDown, event); - SET_DEFAULT_KEY(SDLK_LEFT, mode, Event::JoystickZeroLeft, event); - SET_DEFAULT_KEY(SDLK_RIGHT, mode, Event::JoystickZeroRight, event); - SET_DEFAULT_KEY(SDLK_SPACE, mode, Event::JoystickZeroFire1, event); - SET_DEFAULT_KEY(SDLK_LCTRL, mode, Event::JoystickZeroFire1, event); - SET_DEFAULT_KEY(SDLK_4, mode, Event::JoystickZeroFire2, event); - SET_DEFAULT_KEY(SDLK_5, mode, Event::JoystickZeroFire3, event); + SET_DEFAULT_KEY(KBDK_UP, mode, Event::JoystickZeroUp, event); + SET_DEFAULT_KEY(KBDK_DOWN, mode, Event::JoystickZeroDown, event); + SET_DEFAULT_KEY(KBDK_LEFT, mode, Event::JoystickZeroLeft, event); + SET_DEFAULT_KEY(KBDK_RIGHT, mode, Event::JoystickZeroRight, event); + SET_DEFAULT_KEY(KBDK_SPACE, mode, Event::JoystickZeroFire1, event); + SET_DEFAULT_KEY(KBDK_LCTRL, mode, Event::JoystickZeroFire1, event); + SET_DEFAULT_KEY(KBDK_4, mode, Event::JoystickZeroFire2, event); + SET_DEFAULT_KEY(KBDK_5, mode, Event::JoystickZeroFire3, event); - SET_DEFAULT_KEY(SDLK_y, mode, Event::JoystickOneUp, event); - SET_DEFAULT_KEY(SDLK_h, mode, Event::JoystickOneDown, event); - SET_DEFAULT_KEY(SDLK_g, mode, Event::JoystickOneLeft, event); - SET_DEFAULT_KEY(SDLK_j, mode, Event::JoystickOneRight, event); - SET_DEFAULT_KEY(SDLK_f, mode, Event::JoystickOneFire1, event); - SET_DEFAULT_KEY(SDLK_6, mode, Event::JoystickOneFire2, event); - SET_DEFAULT_KEY(SDLK_7, mode, Event::JoystickOneFire3, event); + SET_DEFAULT_KEY(KBDK_y, mode, Event::JoystickOneUp, event); + SET_DEFAULT_KEY(KBDK_h, mode, Event::JoystickOneDown, event); + SET_DEFAULT_KEY(KBDK_g, mode, Event::JoystickOneLeft, event); + SET_DEFAULT_KEY(KBDK_j, mode, Event::JoystickOneRight, event); + SET_DEFAULT_KEY(KBDK_f, mode, Event::JoystickOneFire1, event); + SET_DEFAULT_KEY(KBDK_6, mode, Event::JoystickOneFire2, event); + SET_DEFAULT_KEY(KBDK_7, mode, Event::JoystickOneFire3, event); - SET_DEFAULT_KEY(SDLK_F1, mode, Event::ConsoleSelect, event); - SET_DEFAULT_KEY(SDLK_F2, mode, Event::ConsoleReset, event); - SET_DEFAULT_KEY(SDLK_F3, mode, Event::ConsoleColor, event); - SET_DEFAULT_KEY(SDLK_F4, mode, Event::ConsoleBlackWhite, event); - SET_DEFAULT_KEY(SDLK_F5, mode, Event::ConsoleLeftDiffA, event); - SET_DEFAULT_KEY(SDLK_F6, mode, Event::ConsoleLeftDiffB, event); - SET_DEFAULT_KEY(SDLK_F7, mode, Event::ConsoleRightDiffA, event); - SET_DEFAULT_KEY(SDLK_F8, mode, Event::ConsoleRightDiffB, event); - SET_DEFAULT_KEY(SDLK_F9, mode, Event::SaveState, event); - SET_DEFAULT_KEY(SDLK_F10, mode, Event::ChangeState, event); - SET_DEFAULT_KEY(SDLK_F11, mode, Event::LoadState, event); - SET_DEFAULT_KEY(SDLK_F12, mode, Event::TakeSnapshot, event); - SET_DEFAULT_KEY(SDLK_BACKSPACE, mode, Event::Fry, event); - SET_DEFAULT_KEY(SDLK_PAUSE, mode, Event::PauseMode, event); - SET_DEFAULT_KEY(SDLK_TAB, mode, Event::MenuMode, event); - SET_DEFAULT_KEY(SDLK_BACKSLASH, mode, Event::CmdMenuMode, event); - SET_DEFAULT_KEY(SDLK_BACKQUOTE, mode, Event::DebuggerMode, event); - SET_DEFAULT_KEY(SDLK_ESCAPE, mode, Event::LauncherMode, event); + SET_DEFAULT_KEY(KBDK_F1, mode, Event::ConsoleSelect, event); + SET_DEFAULT_KEY(KBDK_F2, mode, Event::ConsoleReset, event); + SET_DEFAULT_KEY(KBDK_F3, mode, Event::ConsoleColor, event); + SET_DEFAULT_KEY(KBDK_F4, mode, Event::ConsoleBlackWhite, event); + SET_DEFAULT_KEY(KBDK_F5, mode, Event::ConsoleLeftDiffA, event); + SET_DEFAULT_KEY(KBDK_F6, mode, Event::ConsoleLeftDiffB, event); + SET_DEFAULT_KEY(KBDK_F7, mode, Event::ConsoleRightDiffA, event); + SET_DEFAULT_KEY(KBDK_F8, mode, Event::ConsoleRightDiffB, event); + SET_DEFAULT_KEY(KBDK_F9, mode, Event::SaveState, event); + SET_DEFAULT_KEY(KBDK_F10, mode, Event::ChangeState, event); + SET_DEFAULT_KEY(KBDK_F11, mode, Event::LoadState, event); + SET_DEFAULT_KEY(KBDK_F12, mode, Event::TakeSnapshot, event); + SET_DEFAULT_KEY(KBDK_BACKSPACE, mode, Event::Fry, event); + SET_DEFAULT_KEY(KBDK_PAUSE, mode, Event::PauseMode, event); + SET_DEFAULT_KEY(KBDK_TAB, mode, Event::MenuMode, event); + SET_DEFAULT_KEY(KBDK_BACKSLASH, mode, Event::CmdMenuMode, event); + SET_DEFAULT_KEY(KBDK_BACKQUOTE, mode, Event::DebuggerMode, event); + SET_DEFAULT_KEY(KBDK_ESCAPE, mode, Event::LauncherMode, event); break; case kMenuMode: - SET_DEFAULT_KEY(SDLK_UP, mode, Event::UIUp, event); - SET_DEFAULT_KEY(SDLK_DOWN, mode, Event::UIDown, event); - SET_DEFAULT_KEY(SDLK_LEFT, mode, Event::UILeft, event); - SET_DEFAULT_KEY(SDLK_RIGHT, mode, Event::UIRight, event); + SET_DEFAULT_KEY(KBDK_UP, mode, Event::UIUp, event); + SET_DEFAULT_KEY(KBDK_DOWN, mode, Event::UIDown, event); + SET_DEFAULT_KEY(KBDK_LEFT, mode, Event::UILeft, event); + SET_DEFAULT_KEY(KBDK_RIGHT, mode, Event::UIRight, event); - SET_DEFAULT_KEY(SDLK_HOME, mode, Event::UIHome, event); - SET_DEFAULT_KEY(SDLK_END, mode, Event::UIEnd, event); - SET_DEFAULT_KEY(SDLK_PAGEUP, mode, Event::UIPgUp, event); - SET_DEFAULT_KEY(SDLK_PAGEDOWN, mode, Event::UIPgDown, event); + SET_DEFAULT_KEY(KBDK_HOME, mode, Event::UIHome, event); + SET_DEFAULT_KEY(KBDK_END, mode, Event::UIEnd, event); + SET_DEFAULT_KEY(KBDK_PAGEUP, mode, Event::UIPgUp, event); + SET_DEFAULT_KEY(KBDK_PAGEDOWN, mode, Event::UIPgDown, event); - SET_DEFAULT_KEY(SDLK_RETURN, mode, Event::UISelect, event); - SET_DEFAULT_KEY(SDLK_ESCAPE, mode, Event::UICancel, event); + SET_DEFAULT_KEY(KBDK_RETURN, mode, Event::UISelect, event); + SET_DEFAULT_KEY(KBDK_ESCAPE, mode, Event::UICancel, event); - SET_DEFAULT_KEY(SDLK_BACKSPACE, mode, Event::UIPrevDir, event); + SET_DEFAULT_KEY(KBDK_BACKSPACE, mode, Event::UIPrevDir, event); break; default: @@ -1627,7 +1618,7 @@ void EventHandler::saveKeyMapping() ostringstream keybuf; keybuf << Event::LastType; for(int mode = 0; mode < kNumModes; ++mode) - for(int i = 0; i < SDLK_LAST; ++i) + for(int i = 0; i < KBDK_LAST; ++i) keybuf << ":" << myKeyTable[i][mode]; myOSystem->settings().setString("keymap", keybuf.str()); @@ -2094,237 +2085,237 @@ void EventHandler::setEventState(State state) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void EventHandler::setSDLMappings() { - ourSDLMapping[ SDLK_BACKSPACE ] = "BACKSPACE"; - ourSDLMapping[ SDLK_TAB ] = "TAB"; - ourSDLMapping[ SDLK_CLEAR ] = "CLEAR"; - ourSDLMapping[ SDLK_RETURN ] = "RETURN"; - ourSDLMapping[ SDLK_PAUSE ] = "PAUSE"; - ourSDLMapping[ SDLK_ESCAPE ] = "ESCAPE"; - ourSDLMapping[ SDLK_SPACE ] = "SPACE"; - ourSDLMapping[ SDLK_EXCLAIM ] = "!"; - ourSDLMapping[ SDLK_QUOTEDBL ] = "\""; - ourSDLMapping[ SDLK_HASH ] = "#"; - ourSDLMapping[ SDLK_DOLLAR ] = "$"; - ourSDLMapping[ SDLK_AMPERSAND ] = "&"; - ourSDLMapping[ SDLK_QUOTE ] = "\'"; - ourSDLMapping[ SDLK_LEFTPAREN ] = "("; - ourSDLMapping[ SDLK_RIGHTPAREN ] = ")"; - ourSDLMapping[ SDLK_ASTERISK ] = "*"; - ourSDLMapping[ SDLK_PLUS ] = "+"; - ourSDLMapping[ SDLK_COMMA ] = "COMMA"; - ourSDLMapping[ SDLK_MINUS ] = "-"; - ourSDLMapping[ SDLK_PERIOD ] = "."; - ourSDLMapping[ SDLK_SLASH ] = "/"; - ourSDLMapping[ SDLK_0 ] = "0"; - ourSDLMapping[ SDLK_1 ] = "1"; - ourSDLMapping[ SDLK_2 ] = "2"; - ourSDLMapping[ SDLK_3 ] = "3"; - ourSDLMapping[ SDLK_4 ] = "4"; - ourSDLMapping[ SDLK_5 ] = "5"; - ourSDLMapping[ SDLK_6 ] = "6"; - ourSDLMapping[ SDLK_7 ] = "7"; - ourSDLMapping[ SDLK_8 ] = "8"; - ourSDLMapping[ SDLK_9 ] = "9"; - ourSDLMapping[ SDLK_COLON ] = ":"; - ourSDLMapping[ SDLK_SEMICOLON ] = ";"; - ourSDLMapping[ SDLK_LESS ] = "<"; - ourSDLMapping[ SDLK_EQUALS ] = "="; - ourSDLMapping[ SDLK_GREATER ] = ">"; - ourSDLMapping[ SDLK_QUESTION ] = "?"; - ourSDLMapping[ SDLK_AT ] = "@"; - ourSDLMapping[ SDLK_LEFTBRACKET ] = "["; - ourSDLMapping[ SDLK_BACKSLASH ] = "\\"; - ourSDLMapping[ SDLK_RIGHTBRACKET ] = "]"; - ourSDLMapping[ SDLK_CARET ] = "^"; - ourSDLMapping[ SDLK_UNDERSCORE ] = "_"; - ourSDLMapping[ SDLK_BACKQUOTE ] = "`"; - ourSDLMapping[ SDLK_a ] = "A"; - ourSDLMapping[ SDLK_b ] = "B"; - ourSDLMapping[ SDLK_c ] = "C"; - ourSDLMapping[ SDLK_d ] = "D"; - ourSDLMapping[ SDLK_e ] = "E"; - ourSDLMapping[ SDLK_f ] = "F"; - ourSDLMapping[ SDLK_g ] = "G"; - ourSDLMapping[ SDLK_h ] = "H"; - ourSDLMapping[ SDLK_i ] = "I"; - ourSDLMapping[ SDLK_j ] = "J"; - ourSDLMapping[ SDLK_k ] = "K"; - ourSDLMapping[ SDLK_l ] = "L"; - ourSDLMapping[ SDLK_m ] = "M"; - ourSDLMapping[ SDLK_n ] = "N"; - ourSDLMapping[ SDLK_o ] = "O"; - ourSDLMapping[ SDLK_p ] = "P"; - ourSDLMapping[ SDLK_q ] = "Q"; - ourSDLMapping[ SDLK_r ] = "R"; - ourSDLMapping[ SDLK_s ] = "S"; - ourSDLMapping[ SDLK_t ] = "T"; - ourSDLMapping[ SDLK_u ] = "U"; - ourSDLMapping[ SDLK_v ] = "V"; - ourSDLMapping[ SDLK_w ] = "W"; - ourSDLMapping[ SDLK_x ] = "X"; - ourSDLMapping[ SDLK_y ] = "Y"; - ourSDLMapping[ SDLK_z ] = "Z"; - ourSDLMapping[ SDLK_DELETE ] = "DELETE"; - ourSDLMapping[ SDLK_WORLD_0 ] = "WORLD_0"; - ourSDLMapping[ SDLK_WORLD_1 ] = "WORLD_1"; - ourSDLMapping[ SDLK_WORLD_2 ] = "WORLD_2"; - ourSDLMapping[ SDLK_WORLD_3 ] = "WORLD_3"; - ourSDLMapping[ SDLK_WORLD_4 ] = "WORLD_4"; - ourSDLMapping[ SDLK_WORLD_5 ] = "WORLD_5"; - ourSDLMapping[ SDLK_WORLD_6 ] = "WORLD_6"; - ourSDLMapping[ SDLK_WORLD_7 ] = "WORLD_7"; - ourSDLMapping[ SDLK_WORLD_8 ] = "WORLD_8"; - ourSDLMapping[ SDLK_WORLD_9 ] = "WORLD_9"; - ourSDLMapping[ SDLK_WORLD_10 ] = "WORLD_10"; - ourSDLMapping[ SDLK_WORLD_11 ] = "WORLD_11"; - ourSDLMapping[ SDLK_WORLD_12 ] = "WORLD_12"; - ourSDLMapping[ SDLK_WORLD_13 ] = "WORLD_13"; - ourSDLMapping[ SDLK_WORLD_14 ] = "WORLD_14"; - ourSDLMapping[ SDLK_WORLD_15 ] = "WORLD_15"; - ourSDLMapping[ SDLK_WORLD_16 ] = "WORLD_16"; - ourSDLMapping[ SDLK_WORLD_17 ] = "WORLD_17"; - ourSDLMapping[ SDLK_WORLD_18 ] = "WORLD_18"; - ourSDLMapping[ SDLK_WORLD_19 ] = "WORLD_19"; - ourSDLMapping[ SDLK_WORLD_20 ] = "WORLD_20"; - ourSDLMapping[ SDLK_WORLD_21 ] = "WORLD_21"; - ourSDLMapping[ SDLK_WORLD_22 ] = "WORLD_22"; - ourSDLMapping[ SDLK_WORLD_23 ] = "WORLD_23"; - ourSDLMapping[ SDLK_WORLD_24 ] = "WORLD_24"; - ourSDLMapping[ SDLK_WORLD_25 ] = "WORLD_25"; - ourSDLMapping[ SDLK_WORLD_26 ] = "WORLD_26"; - ourSDLMapping[ SDLK_WORLD_27 ] = "WORLD_27"; - ourSDLMapping[ SDLK_WORLD_28 ] = "WORLD_28"; - ourSDLMapping[ SDLK_WORLD_29 ] = "WORLD_29"; - ourSDLMapping[ SDLK_WORLD_30 ] = "WORLD_30"; - ourSDLMapping[ SDLK_WORLD_31 ] = "WORLD_31"; - ourSDLMapping[ SDLK_WORLD_32 ] = "WORLD_32"; - ourSDLMapping[ SDLK_WORLD_33 ] = "WORLD_33"; - ourSDLMapping[ SDLK_WORLD_34 ] = "WORLD_34"; - ourSDLMapping[ SDLK_WORLD_35 ] = "WORLD_35"; - ourSDLMapping[ SDLK_WORLD_36 ] = "WORLD_36"; - ourSDLMapping[ SDLK_WORLD_37 ] = "WORLD_37"; - ourSDLMapping[ SDLK_WORLD_38 ] = "WORLD_38"; - ourSDLMapping[ SDLK_WORLD_39 ] = "WORLD_39"; - ourSDLMapping[ SDLK_WORLD_40 ] = "WORLD_40"; - ourSDLMapping[ SDLK_WORLD_41 ] = "WORLD_41"; - ourSDLMapping[ SDLK_WORLD_42 ] = "WORLD_42"; - ourSDLMapping[ SDLK_WORLD_43 ] = "WORLD_43"; - ourSDLMapping[ SDLK_WORLD_44 ] = "WORLD_44"; - ourSDLMapping[ SDLK_WORLD_45 ] = "WORLD_45"; - ourSDLMapping[ SDLK_WORLD_46 ] = "WORLD_46"; - ourSDLMapping[ SDLK_WORLD_47 ] = "WORLD_47"; - ourSDLMapping[ SDLK_WORLD_48 ] = "WORLD_48"; - ourSDLMapping[ SDLK_WORLD_49 ] = "WORLD_49"; - ourSDLMapping[ SDLK_WORLD_50 ] = "WORLD_50"; - ourSDLMapping[ SDLK_WORLD_51 ] = "WORLD_51"; - ourSDLMapping[ SDLK_WORLD_52 ] = "WORLD_52"; - ourSDLMapping[ SDLK_WORLD_53 ] = "WORLD_53"; - ourSDLMapping[ SDLK_WORLD_54 ] = "WORLD_54"; - ourSDLMapping[ SDLK_WORLD_55 ] = "WORLD_55"; - ourSDLMapping[ SDLK_WORLD_56 ] = "WORLD_56"; - ourSDLMapping[ SDLK_WORLD_57 ] = "WORLD_57"; - ourSDLMapping[ SDLK_WORLD_58 ] = "WORLD_58"; - ourSDLMapping[ SDLK_WORLD_59 ] = "WORLD_59"; - ourSDLMapping[ SDLK_WORLD_60 ] = "WORLD_60"; - ourSDLMapping[ SDLK_WORLD_61 ] = "WORLD_61"; - ourSDLMapping[ SDLK_WORLD_62 ] = "WORLD_62"; - ourSDLMapping[ SDLK_WORLD_63 ] = "WORLD_63"; - ourSDLMapping[ SDLK_WORLD_64 ] = "WORLD_64"; - ourSDLMapping[ SDLK_WORLD_65 ] = "WORLD_65"; - ourSDLMapping[ SDLK_WORLD_66 ] = "WORLD_66"; - ourSDLMapping[ SDLK_WORLD_67 ] = "WORLD_67"; - ourSDLMapping[ SDLK_WORLD_68 ] = "WORLD_68"; - ourSDLMapping[ SDLK_WORLD_69 ] = "WORLD_69"; - ourSDLMapping[ SDLK_WORLD_70 ] = "WORLD_70"; - ourSDLMapping[ SDLK_WORLD_71 ] = "WORLD_71"; - ourSDLMapping[ SDLK_WORLD_72 ] = "WORLD_72"; - ourSDLMapping[ SDLK_WORLD_73 ] = "WORLD_73"; - ourSDLMapping[ SDLK_WORLD_74 ] = "WORLD_74"; - ourSDLMapping[ SDLK_WORLD_75 ] = "WORLD_75"; - ourSDLMapping[ SDLK_WORLD_76 ] = "WORLD_76"; - ourSDLMapping[ SDLK_WORLD_77 ] = "WORLD_77"; - ourSDLMapping[ SDLK_WORLD_78 ] = "WORLD_78"; - ourSDLMapping[ SDLK_WORLD_79 ] = "WORLD_79"; - ourSDLMapping[ SDLK_WORLD_80 ] = "WORLD_80"; - ourSDLMapping[ SDLK_WORLD_81 ] = "WORLD_81"; - ourSDLMapping[ SDLK_WORLD_82 ] = "WORLD_82"; - ourSDLMapping[ SDLK_WORLD_83 ] = "WORLD_83"; - ourSDLMapping[ SDLK_WORLD_84 ] = "WORLD_84"; - ourSDLMapping[ SDLK_WORLD_85 ] = "WORLD_85"; - ourSDLMapping[ SDLK_WORLD_86 ] = "WORLD_86"; - ourSDLMapping[ SDLK_WORLD_87 ] = "WORLD_87"; - ourSDLMapping[ SDLK_WORLD_88 ] = "WORLD_88"; - ourSDLMapping[ SDLK_WORLD_89 ] = "WORLD_89"; - ourSDLMapping[ SDLK_WORLD_90 ] = "WORLD_90"; - ourSDLMapping[ SDLK_WORLD_91 ] = "WORLD_91"; - ourSDLMapping[ SDLK_WORLD_92 ] = "WORLD_92"; - ourSDLMapping[ SDLK_WORLD_93 ] = "WORLD_93"; - ourSDLMapping[ SDLK_WORLD_94 ] = "WORLD_94"; - ourSDLMapping[ SDLK_WORLD_95 ] = "WORLD_95"; - ourSDLMapping[ SDLK_KP0 ] = "KP0"; - ourSDLMapping[ SDLK_KP1 ] = "KP1"; - ourSDLMapping[ SDLK_KP2 ] = "KP2"; - ourSDLMapping[ SDLK_KP3 ] = "KP3"; - ourSDLMapping[ SDLK_KP4 ] = "KP4"; - ourSDLMapping[ SDLK_KP5 ] = "KP5"; - ourSDLMapping[ SDLK_KP6 ] = "KP6"; - ourSDLMapping[ SDLK_KP7 ] = "KP7"; - ourSDLMapping[ SDLK_KP8 ] = "KP8"; - ourSDLMapping[ SDLK_KP9 ] = "KP9"; - ourSDLMapping[ SDLK_KP_PERIOD ] = "KP ."; - ourSDLMapping[ SDLK_KP_DIVIDE ] = "KP /"; - ourSDLMapping[ SDLK_KP_MULTIPLY ] = "KP *"; - ourSDLMapping[ SDLK_KP_MINUS ] = "KP -"; - ourSDLMapping[ SDLK_KP_PLUS ] = "KP +"; - ourSDLMapping[ SDLK_KP_ENTER ] = "KP ENTER"; - ourSDLMapping[ SDLK_KP_EQUALS ] = "KP ="; - ourSDLMapping[ SDLK_UP ] = "UP"; - ourSDLMapping[ SDLK_DOWN ] = "DOWN"; - ourSDLMapping[ SDLK_RIGHT ] = "RIGHT"; - ourSDLMapping[ SDLK_LEFT ] = "LEFT"; - ourSDLMapping[ SDLK_INSERT ] = "INS"; - ourSDLMapping[ SDLK_HOME ] = "HOME"; - ourSDLMapping[ SDLK_END ] = "END"; - ourSDLMapping[ SDLK_PAGEUP ] = "PGUP"; - ourSDLMapping[ SDLK_PAGEDOWN ] = "PGDN"; - ourSDLMapping[ SDLK_F1 ] = "F1"; - ourSDLMapping[ SDLK_F2 ] = "F2"; - ourSDLMapping[ SDLK_F3 ] = "F3"; - ourSDLMapping[ SDLK_F4 ] = "F4"; - ourSDLMapping[ SDLK_F5 ] = "F5"; - ourSDLMapping[ SDLK_F6 ] = "F6"; - ourSDLMapping[ SDLK_F7 ] = "F7"; - ourSDLMapping[ SDLK_F8 ] = "F8"; - ourSDLMapping[ SDLK_F9 ] = "F9"; - ourSDLMapping[ SDLK_F10 ] = "F10"; - ourSDLMapping[ SDLK_F11 ] = "F11"; - ourSDLMapping[ SDLK_F12 ] = "F12"; - ourSDLMapping[ SDLK_F13 ] = "F13"; - ourSDLMapping[ SDLK_F14 ] = "F14"; - ourSDLMapping[ SDLK_F15 ] = "F15"; - ourSDLMapping[ SDLK_NUMLOCK ] = "NUMLOCK"; - ourSDLMapping[ SDLK_CAPSLOCK ] = "CAPSLOCK"; - ourSDLMapping[ SDLK_SCROLLOCK ] = "SCROLLOCK"; - ourSDLMapping[ SDLK_RSHIFT ] = "RSHIFT"; - ourSDLMapping[ SDLK_LSHIFT ] = "LSHIFT"; - ourSDLMapping[ SDLK_RCTRL ] = "RCTRL"; - ourSDLMapping[ SDLK_LCTRL ] = "LCTRL"; - ourSDLMapping[ SDLK_RALT ] = "RALT"; - ourSDLMapping[ SDLK_LALT ] = "LALT"; - ourSDLMapping[ SDLK_RMETA ] = "RMETA"; - ourSDLMapping[ SDLK_LMETA ] = "LMETA"; - ourSDLMapping[ SDLK_LSUPER ] = "LSUPER"; - ourSDLMapping[ SDLK_RSUPER ] = "RSUPER"; - ourSDLMapping[ SDLK_MODE ] = "MODE"; - ourSDLMapping[ SDLK_COMPOSE ] = "COMPOSE"; - ourSDLMapping[ SDLK_HELP ] = "HELP"; - ourSDLMapping[ SDLK_PRINT ] = "PRINT"; - ourSDLMapping[ SDLK_SYSREQ ] = "SYSREQ"; - ourSDLMapping[ SDLK_BREAK ] = "BREAK"; - ourSDLMapping[ SDLK_MENU ] = "MENU"; - ourSDLMapping[ SDLK_POWER ] = "POWER"; - ourSDLMapping[ SDLK_EURO ] = "EURO"; - ourSDLMapping[ SDLK_UNDO ] = "UNDO"; + ourKBDKMapping[ KBDK_BACKSPACE ] = "BACKSPACE"; + ourKBDKMapping[ KBDK_TAB ] = "TAB"; + ourKBDKMapping[ KBDK_CLEAR ] = "CLEAR"; + ourKBDKMapping[ KBDK_RETURN ] = "RETURN"; + ourKBDKMapping[ KBDK_PAUSE ] = "PAUSE"; + ourKBDKMapping[ KBDK_ESCAPE ] = "ESCAPE"; + ourKBDKMapping[ KBDK_SPACE ] = "SPACE"; + ourKBDKMapping[ KBDK_EXCLAIM ] = "!"; + ourKBDKMapping[ KBDK_QUOTEDBL ] = "\""; + ourKBDKMapping[ KBDK_HASH ] = "#"; + ourKBDKMapping[ KBDK_DOLLAR ] = "$"; + ourKBDKMapping[ KBDK_AMPERSAND ] = "&"; + ourKBDKMapping[ KBDK_QUOTE ] = "\'"; + ourKBDKMapping[ KBDK_LEFTPAREN ] = "("; + ourKBDKMapping[ KBDK_RIGHTPAREN ] = ")"; + ourKBDKMapping[ KBDK_ASTERISK ] = "*"; + ourKBDKMapping[ KBDK_PLUS ] = "+"; + ourKBDKMapping[ KBDK_COMMA ] = "COMMA"; + ourKBDKMapping[ KBDK_MINUS ] = "-"; + ourKBDKMapping[ KBDK_PERIOD ] = "."; + ourKBDKMapping[ KBDK_SLASH ] = "/"; + ourKBDKMapping[ KBDK_0 ] = "0"; + ourKBDKMapping[ KBDK_1 ] = "1"; + ourKBDKMapping[ KBDK_2 ] = "2"; + ourKBDKMapping[ KBDK_3 ] = "3"; + ourKBDKMapping[ KBDK_4 ] = "4"; + ourKBDKMapping[ KBDK_5 ] = "5"; + ourKBDKMapping[ KBDK_6 ] = "6"; + ourKBDKMapping[ KBDK_7 ] = "7"; + ourKBDKMapping[ KBDK_8 ] = "8"; + ourKBDKMapping[ KBDK_9 ] = "9"; + ourKBDKMapping[ KBDK_COLON ] = ":"; + ourKBDKMapping[ KBDK_SEMICOLON ] = ";"; + ourKBDKMapping[ KBDK_LESS ] = "<"; + ourKBDKMapping[ KBDK_EQUALS ] = "="; + ourKBDKMapping[ KBDK_GREATER ] = ">"; + ourKBDKMapping[ KBDK_QUESTION ] = "?"; + ourKBDKMapping[ KBDK_AT ] = "@"; + ourKBDKMapping[ KBDK_LEFTBRACKET ] = "["; + ourKBDKMapping[ KBDK_BACKSLASH ] = "\\"; + ourKBDKMapping[ KBDK_RIGHTBRACKET ] = "]"; + ourKBDKMapping[ KBDK_CARET ] = "^"; + ourKBDKMapping[ KBDK_UNDERSCORE ] = "_"; + ourKBDKMapping[ KBDK_BACKQUOTE ] = "`"; + ourKBDKMapping[ KBDK_a ] = "A"; + ourKBDKMapping[ KBDK_b ] = "B"; + ourKBDKMapping[ KBDK_c ] = "C"; + ourKBDKMapping[ KBDK_d ] = "D"; + ourKBDKMapping[ KBDK_e ] = "E"; + ourKBDKMapping[ KBDK_f ] = "F"; + ourKBDKMapping[ KBDK_g ] = "G"; + ourKBDKMapping[ KBDK_h ] = "H"; + ourKBDKMapping[ KBDK_i ] = "I"; + ourKBDKMapping[ KBDK_j ] = "J"; + ourKBDKMapping[ KBDK_k ] = "K"; + ourKBDKMapping[ KBDK_l ] = "L"; + ourKBDKMapping[ KBDK_m ] = "M"; + ourKBDKMapping[ KBDK_n ] = "N"; + ourKBDKMapping[ KBDK_o ] = "O"; + ourKBDKMapping[ KBDK_p ] = "P"; + ourKBDKMapping[ KBDK_q ] = "Q"; + ourKBDKMapping[ KBDK_r ] = "R"; + ourKBDKMapping[ KBDK_s ] = "S"; + ourKBDKMapping[ KBDK_t ] = "T"; + ourKBDKMapping[ KBDK_u ] = "U"; + ourKBDKMapping[ KBDK_v ] = "V"; + ourKBDKMapping[ KBDK_w ] = "W"; + ourKBDKMapping[ KBDK_x ] = "X"; + ourKBDKMapping[ KBDK_y ] = "Y"; + ourKBDKMapping[ KBDK_z ] = "Z"; + ourKBDKMapping[ KBDK_DELETE ] = "DELETE"; + ourKBDKMapping[ KBDK_WORLD_0 ] = "WORLD_0"; + ourKBDKMapping[ KBDK_WORLD_1 ] = "WORLD_1"; + ourKBDKMapping[ KBDK_WORLD_2 ] = "WORLD_2"; + ourKBDKMapping[ KBDK_WORLD_3 ] = "WORLD_3"; + ourKBDKMapping[ KBDK_WORLD_4 ] = "WORLD_4"; + ourKBDKMapping[ KBDK_WORLD_5 ] = "WORLD_5"; + ourKBDKMapping[ KBDK_WORLD_6 ] = "WORLD_6"; + ourKBDKMapping[ KBDK_WORLD_7 ] = "WORLD_7"; + ourKBDKMapping[ KBDK_WORLD_8 ] = "WORLD_8"; + ourKBDKMapping[ KBDK_WORLD_9 ] = "WORLD_9"; + ourKBDKMapping[ KBDK_WORLD_10 ] = "WORLD_10"; + ourKBDKMapping[ KBDK_WORLD_11 ] = "WORLD_11"; + ourKBDKMapping[ KBDK_WORLD_12 ] = "WORLD_12"; + ourKBDKMapping[ KBDK_WORLD_13 ] = "WORLD_13"; + ourKBDKMapping[ KBDK_WORLD_14 ] = "WORLD_14"; + ourKBDKMapping[ KBDK_WORLD_15 ] = "WORLD_15"; + ourKBDKMapping[ KBDK_WORLD_16 ] = "WORLD_16"; + ourKBDKMapping[ KBDK_WORLD_17 ] = "WORLD_17"; + ourKBDKMapping[ KBDK_WORLD_18 ] = "WORLD_18"; + ourKBDKMapping[ KBDK_WORLD_19 ] = "WORLD_19"; + ourKBDKMapping[ KBDK_WORLD_20 ] = "WORLD_20"; + ourKBDKMapping[ KBDK_WORLD_21 ] = "WORLD_21"; + ourKBDKMapping[ KBDK_WORLD_22 ] = "WORLD_22"; + ourKBDKMapping[ KBDK_WORLD_23 ] = "WORLD_23"; + ourKBDKMapping[ KBDK_WORLD_24 ] = "WORLD_24"; + ourKBDKMapping[ KBDK_WORLD_25 ] = "WORLD_25"; + ourKBDKMapping[ KBDK_WORLD_26 ] = "WORLD_26"; + ourKBDKMapping[ KBDK_WORLD_27 ] = "WORLD_27"; + ourKBDKMapping[ KBDK_WORLD_28 ] = "WORLD_28"; + ourKBDKMapping[ KBDK_WORLD_29 ] = "WORLD_29"; + ourKBDKMapping[ KBDK_WORLD_30 ] = "WORLD_30"; + ourKBDKMapping[ KBDK_WORLD_31 ] = "WORLD_31"; + ourKBDKMapping[ KBDK_WORLD_32 ] = "WORLD_32"; + ourKBDKMapping[ KBDK_WORLD_33 ] = "WORLD_33"; + ourKBDKMapping[ KBDK_WORLD_34 ] = "WORLD_34"; + ourKBDKMapping[ KBDK_WORLD_35 ] = "WORLD_35"; + ourKBDKMapping[ KBDK_WORLD_36 ] = "WORLD_36"; + ourKBDKMapping[ KBDK_WORLD_37 ] = "WORLD_37"; + ourKBDKMapping[ KBDK_WORLD_38 ] = "WORLD_38"; + ourKBDKMapping[ KBDK_WORLD_39 ] = "WORLD_39"; + ourKBDKMapping[ KBDK_WORLD_40 ] = "WORLD_40"; + ourKBDKMapping[ KBDK_WORLD_41 ] = "WORLD_41"; + ourKBDKMapping[ KBDK_WORLD_42 ] = "WORLD_42"; + ourKBDKMapping[ KBDK_WORLD_43 ] = "WORLD_43"; + ourKBDKMapping[ KBDK_WORLD_44 ] = "WORLD_44"; + ourKBDKMapping[ KBDK_WORLD_45 ] = "WORLD_45"; + ourKBDKMapping[ KBDK_WORLD_46 ] = "WORLD_46"; + ourKBDKMapping[ KBDK_WORLD_47 ] = "WORLD_47"; + ourKBDKMapping[ KBDK_WORLD_48 ] = "WORLD_48"; + ourKBDKMapping[ KBDK_WORLD_49 ] = "WORLD_49"; + ourKBDKMapping[ KBDK_WORLD_50 ] = "WORLD_50"; + ourKBDKMapping[ KBDK_WORLD_51 ] = "WORLD_51"; + ourKBDKMapping[ KBDK_WORLD_52 ] = "WORLD_52"; + ourKBDKMapping[ KBDK_WORLD_53 ] = "WORLD_53"; + ourKBDKMapping[ KBDK_WORLD_54 ] = "WORLD_54"; + ourKBDKMapping[ KBDK_WORLD_55 ] = "WORLD_55"; + ourKBDKMapping[ KBDK_WORLD_56 ] = "WORLD_56"; + ourKBDKMapping[ KBDK_WORLD_57 ] = "WORLD_57"; + ourKBDKMapping[ KBDK_WORLD_58 ] = "WORLD_58"; + ourKBDKMapping[ KBDK_WORLD_59 ] = "WORLD_59"; + ourKBDKMapping[ KBDK_WORLD_60 ] = "WORLD_60"; + ourKBDKMapping[ KBDK_WORLD_61 ] = "WORLD_61"; + ourKBDKMapping[ KBDK_WORLD_62 ] = "WORLD_62"; + ourKBDKMapping[ KBDK_WORLD_63 ] = "WORLD_63"; + ourKBDKMapping[ KBDK_WORLD_64 ] = "WORLD_64"; + ourKBDKMapping[ KBDK_WORLD_65 ] = "WORLD_65"; + ourKBDKMapping[ KBDK_WORLD_66 ] = "WORLD_66"; + ourKBDKMapping[ KBDK_WORLD_67 ] = "WORLD_67"; + ourKBDKMapping[ KBDK_WORLD_68 ] = "WORLD_68"; + ourKBDKMapping[ KBDK_WORLD_69 ] = "WORLD_69"; + ourKBDKMapping[ KBDK_WORLD_70 ] = "WORLD_70"; + ourKBDKMapping[ KBDK_WORLD_71 ] = "WORLD_71"; + ourKBDKMapping[ KBDK_WORLD_72 ] = "WORLD_72"; + ourKBDKMapping[ KBDK_WORLD_73 ] = "WORLD_73"; + ourKBDKMapping[ KBDK_WORLD_74 ] = "WORLD_74"; + ourKBDKMapping[ KBDK_WORLD_75 ] = "WORLD_75"; + ourKBDKMapping[ KBDK_WORLD_76 ] = "WORLD_76"; + ourKBDKMapping[ KBDK_WORLD_77 ] = "WORLD_77"; + ourKBDKMapping[ KBDK_WORLD_78 ] = "WORLD_78"; + ourKBDKMapping[ KBDK_WORLD_79 ] = "WORLD_79"; + ourKBDKMapping[ KBDK_WORLD_80 ] = "WORLD_80"; + ourKBDKMapping[ KBDK_WORLD_81 ] = "WORLD_81"; + ourKBDKMapping[ KBDK_WORLD_82 ] = "WORLD_82"; + ourKBDKMapping[ KBDK_WORLD_83 ] = "WORLD_83"; + ourKBDKMapping[ KBDK_WORLD_84 ] = "WORLD_84"; + ourKBDKMapping[ KBDK_WORLD_85 ] = "WORLD_85"; + ourKBDKMapping[ KBDK_WORLD_86 ] = "WORLD_86"; + ourKBDKMapping[ KBDK_WORLD_87 ] = "WORLD_87"; + ourKBDKMapping[ KBDK_WORLD_88 ] = "WORLD_88"; + ourKBDKMapping[ KBDK_WORLD_89 ] = "WORLD_89"; + ourKBDKMapping[ KBDK_WORLD_90 ] = "WORLD_90"; + ourKBDKMapping[ KBDK_WORLD_91 ] = "WORLD_91"; + ourKBDKMapping[ KBDK_WORLD_92 ] = "WORLD_92"; + ourKBDKMapping[ KBDK_WORLD_93 ] = "WORLD_93"; + ourKBDKMapping[ KBDK_WORLD_94 ] = "WORLD_94"; + ourKBDKMapping[ KBDK_WORLD_95 ] = "WORLD_95"; + ourKBDKMapping[ KBDK_KP0 ] = "KP0"; + ourKBDKMapping[ KBDK_KP1 ] = "KP1"; + ourKBDKMapping[ KBDK_KP2 ] = "KP2"; + ourKBDKMapping[ KBDK_KP3 ] = "KP3"; + ourKBDKMapping[ KBDK_KP4 ] = "KP4"; + ourKBDKMapping[ KBDK_KP5 ] = "KP5"; + ourKBDKMapping[ KBDK_KP6 ] = "KP6"; + ourKBDKMapping[ KBDK_KP7 ] = "KP7"; + ourKBDKMapping[ KBDK_KP8 ] = "KP8"; + ourKBDKMapping[ KBDK_KP9 ] = "KP9"; + ourKBDKMapping[ KBDK_KP_PERIOD ] = "KP ."; + ourKBDKMapping[ KBDK_KP_DIVIDE ] = "KP /"; + ourKBDKMapping[ KBDK_KP_MULTIPLY ] = "KP *"; + ourKBDKMapping[ KBDK_KP_MINUS ] = "KP -"; + ourKBDKMapping[ KBDK_KP_PLUS ] = "KP +"; + ourKBDKMapping[ KBDK_KP_ENTER ] = "KP ENTER"; + ourKBDKMapping[ KBDK_KP_EQUALS ] = "KP ="; + ourKBDKMapping[ KBDK_UP ] = "UP"; + ourKBDKMapping[ KBDK_DOWN ] = "DOWN"; + ourKBDKMapping[ KBDK_RIGHT ] = "RIGHT"; + ourKBDKMapping[ KBDK_LEFT ] = "LEFT"; + ourKBDKMapping[ KBDK_INSERT ] = "INS"; + ourKBDKMapping[ KBDK_HOME ] = "HOME"; + ourKBDKMapping[ KBDK_END ] = "END"; + ourKBDKMapping[ KBDK_PAGEUP ] = "PGUP"; + ourKBDKMapping[ KBDK_PAGEDOWN ] = "PGDN"; + ourKBDKMapping[ KBDK_F1 ] = "F1"; + ourKBDKMapping[ KBDK_F2 ] = "F2"; + ourKBDKMapping[ KBDK_F3 ] = "F3"; + ourKBDKMapping[ KBDK_F4 ] = "F4"; + ourKBDKMapping[ KBDK_F5 ] = "F5"; + ourKBDKMapping[ KBDK_F6 ] = "F6"; + ourKBDKMapping[ KBDK_F7 ] = "F7"; + ourKBDKMapping[ KBDK_F8 ] = "F8"; + ourKBDKMapping[ KBDK_F9 ] = "F9"; + ourKBDKMapping[ KBDK_F10 ] = "F10"; + ourKBDKMapping[ KBDK_F11 ] = "F11"; + ourKBDKMapping[ KBDK_F12 ] = "F12"; + ourKBDKMapping[ KBDK_F13 ] = "F13"; + ourKBDKMapping[ KBDK_F14 ] = "F14"; + ourKBDKMapping[ KBDK_F15 ] = "F15"; + ourKBDKMapping[ KBDK_NUMLOCK ] = "NUMLOCK"; + ourKBDKMapping[ KBDK_CAPSLOCK ] = "CAPSLOCK"; + ourKBDKMapping[ KBDK_SCROLLOCK ] = "SCROLLOCK"; + ourKBDKMapping[ KBDK_RSHIFT ] = "RSHIFT"; + ourKBDKMapping[ KBDK_LSHIFT ] = "LSHIFT"; + ourKBDKMapping[ KBDK_RCTRL ] = "RCTRL"; + ourKBDKMapping[ KBDK_LCTRL ] = "LCTRL"; + ourKBDKMapping[ KBDK_RALT ] = "RALT"; + ourKBDKMapping[ KBDK_LALT ] = "LALT"; + ourKBDKMapping[ KBDK_RMETA ] = "RMETA"; + ourKBDKMapping[ KBDK_LMETA ] = "LMETA"; + ourKBDKMapping[ KBDK_LSUPER ] = "LSUPER"; + ourKBDKMapping[ KBDK_RSUPER ] = "RSUPER"; + ourKBDKMapping[ KBDK_MODE ] = "MODE"; + ourKBDKMapping[ KBDK_COMPOSE ] = "COMPOSE"; + ourKBDKMapping[ KBDK_HELP ] = "HELP"; + ourKBDKMapping[ KBDK_PRINT ] = "PRINT"; + ourKBDKMapping[ KBDK_SYSREQ ] = "SYSREQ"; + ourKBDKMapping[ KBDK_BREAK ] = "BREAK"; + ourKBDKMapping[ KBDK_MENU ] = "MENU"; + ourKBDKMapping[ KBDK_POWER ] = "POWER"; + ourKBDKMapping[ KBDK_EURO ] = "EURO"; + ourKBDKMapping[ KBDK_UNDO ] = "UNDO"; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/emucore/EventHandler.hxx b/src/emucore/EventHandler.hxx index 4a3ae1726..54796bdf2 100644 --- a/src/emucore/EventHandler.hxx +++ b/src/emucore/EventHandler.hxx @@ -32,6 +32,7 @@ class StringList; #include "Array.hxx" #include "Event.hxx" +#include "StellaKeys.hxx" #include "bspf.hxx" enum MouseButton { @@ -168,7 +169,7 @@ class EventHandler */ void setContinuousSnapshots(uInt32 interval); - bool kbdAlt(int mod) const + inline bool kbdAlt(int mod) const { #ifndef MAC_OSX return (mod & KMOD_ALT); @@ -177,12 +178,12 @@ class EventHandler #endif } - bool kbdControl(int mod) const + inline bool kbdControl(int mod) const { return (mod & KMOD_CTRL) > 0; } - bool kbdShift(int mod) const + inline bool kbdShift(int mod) const { return (mod & KMOD_SHIFT); } @@ -211,7 +212,7 @@ class EventHandler void getComboListForEvent(Event::Type event, StringList& list) const; void setComboListForEvent(Event::Type event, const StringList& events); - Event::Type eventForKey(int key, EventMode mode) const + Event::Type eventForKey(StellaKey key, EventMode mode) const { return myKeyTable[key][mode]; } Event::Type eventForJoyAxis(int stick, int axis, int value, EventMode mode) const { return myJoysticks[stick].axisTable[axis][(value > 0)][mode]; } @@ -231,7 +232,7 @@ class EventHandler @param mode The mode where this event is active @param key The key to bind to this event */ - bool addKeyMapping(Event::Type event, EventMode mode, int key); + bool addKeyMapping(Event::Type event, EventMode mode, StellaKey key); /** Bind a joystick axis direction to an event/action and regenerate @@ -374,8 +375,8 @@ class EventHandler // Indicates current overlay object DialogContainer* myOverlay; - // Array of key events, indexed by SDLKey - Event::Type myKeyTable[SDLK_LAST][kNumModes]; + // Array of key events, indexed by StellaKey + Event::Type myKeyTable[KBDK_LAST][kNumModes]; // The event(s) assigned to each combination event Event::Type myComboTable[kComboSize][kEventsPerCombo]; @@ -383,8 +384,8 @@ class EventHandler // Array of messages for each Event string ourMessageTable[Event::LastType]; - // Array of strings which correspond to the given SDL key - string ourSDLMapping[SDLK_LAST]; + // Array of strings which correspond to the given StellaKey + string ourKBDKMapping[KBDK_LAST]; // Indicates the current state of the system (ie, which mode is current) State myState; diff --git a/src/gui/ContextMenu.cxx b/src/gui/ContextMenu.cxx index a719843ca..e94ec3b21 100644 --- a/src/gui/ContextMenu.cxx +++ b/src/gui/ContextMenu.cxx @@ -246,9 +246,9 @@ void ContextMenu::handleMouseWheel(int x, int y, int direction) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void ContextMenu::handleKeyDown(int ascii, int keycode, int modifiers) +void ContextMenu::handleKeyDown(StellaKey key, StellaMod mod, char ascii) { - handleEvent(instance().eventHandler().eventForKey(keycode, kMenuMode)); + handleEvent(instance().eventHandler().eventForKey(key, kMenuMode)); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/gui/ContextMenu.hxx b/src/gui/ContextMenu.hxx index 1b62eb85d..76536fd34 100644 --- a/src/gui/ContextMenu.hxx +++ b/src/gui/ContextMenu.hxx @@ -76,7 +76,7 @@ class ContextMenu : public Dialog, public CommandSender void handleMouseMoved(int x, int y, int button); bool handleMouseClicks(int x, int y, int button); void handleMouseWheel(int x, int y, int direction); - void handleKeyDown(int ascii, int keycode, int modifiers); // Scroll through entries with arrow keys etc + void handleKeyDown(StellaKey key, StellaMod mod, char ascii); void handleJoyDown(int stick, int button); void handleJoyAxis(int stick, int axis, int value); bool handleJoyHat(int stick, int hat, int value); diff --git a/src/gui/Dialog.cxx b/src/gui/Dialog.cxx index 5fab97551..f036a9a35 100644 --- a/src/gui/Dialog.cxx +++ b/src/gui/Dialog.cxx @@ -282,7 +282,7 @@ void Dialog::drawDialog() } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void Dialog::handleKeyDown(int ascii, int keycode, int modifiers) +void Dialog::handleKeyDown(StellaKey key, StellaMod mod, char ascii) { // Test for TAB character // Shift-left/shift-right cursor selects next tab @@ -293,46 +293,46 @@ void Dialog::handleKeyDown(int ascii, int keycode, int modifiers) // Detect selection of previous and next tab headers and objects // For some strange reason, 'tab' needs to be interpreted as keycode, // not ascii?? - if(instance().eventHandler().kbdShift(modifiers)) + if(instance().eventHandler().kbdShift(mod)) { - if(ascii == 256+20 && _ourTab) // left arrow + if(key == KBDK_LEFT && _ourTab) // left arrow { _ourTab->cycleTab(-1); return; } - else if(ascii == 256+19 && _ourTab) // right arrow + else if(key == KBDK_RIGHT && _ourTab) // right arrow { _ourTab->cycleTab(+1); return; } - else if(keycode == 9) // tab + else if(key == KBDK_TAB) // tab e = Event::UINavPrev; } - else if(keycode == 9) // tab + else if(key == KBDK_TAB) // tab e = Event::UINavNext; // Check the keytable now, since we might get one of the above events, // which must always be processed before any widget sees it. if(e == Event::NoType) - e = instance().eventHandler().eventForKey(keycode, kMenuMode); + e = instance().eventHandler().eventForKey(key, kMenuMode); // Unless a widget has claimed all responsibility for data, we assume // that if an event exists for the given data, it should have priority. if(!handleNavEvent(e) && _focusedWidget) { if(_focusedWidget->wantsRaw() || e == Event::NoType) - _focusedWidget->handleKeyDown(ascii, keycode, modifiers); + _focusedWidget->handleKeyDown(key, mod, ascii); else _focusedWidget->handleEvent(e); } } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void Dialog::handleKeyUp(int ascii, int keycode, int modifiers) +void Dialog::handleKeyUp(StellaKey key, StellaMod mod, char ascii) { // Focused widget receives keyup events if(_focusedWidget) - _focusedWidget->handleKeyUp(ascii, keycode, modifiers); + _focusedWidget->handleKeyUp(key, mod, ascii); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/gui/Dialog.hxx b/src/gui/Dialog.hxx index 4022bbe4c..d63a428e9 100644 --- a/src/gui/Dialog.hxx +++ b/src/gui/Dialog.hxx @@ -31,6 +31,7 @@ class TabWidget; #include "Command.hxx" #include "Widget.hxx" #include "GuiObject.hxx" +#include "StellaKeys.hxx" #include "bspf.hxx" @@ -82,8 +83,8 @@ class Dialog : public GuiObject virtual void draw(); void releaseFocus(); - virtual void handleKeyDown(int ascii, int keycode, int modifiers); - virtual void handleKeyUp(int ascii, int keycode, int modifiers); + virtual void handleKeyDown(StellaKey key, StellaMod modifiers, char ascii); + virtual void handleKeyUp(StellaKey key, StellaMod modifiers, char ascii); virtual void handleMouseDown(int x, int y, int button, int clickCount); virtual void handleMouseUp(int x, int y, int button, int clickCount); virtual void handleMouseWheel(int x, int y, int direction); diff --git a/src/gui/DialogContainer.cxx b/src/gui/DialogContainer.cxx index 8674a81d4..5af5d88bc 100644 --- a/src/gui/DialogContainer.cxx +++ b/src/gui/DialogContainer.cxx @@ -56,8 +56,8 @@ void DialogContainer::updateTime(uInt64 time) // Key still pressed if(myCurrentKeyDown.keycode != 0 && myKeyRepeatTime < myTime) { - activeDialog->handleKeyDown(myCurrentKeyDown.ascii, myCurrentKeyDown.keycode, - myCurrentKeyDown.flags); + activeDialog->handleKeyDown(myCurrentKeyDown.keycode, myCurrentKeyDown.flags, + myCurrentKeyDown.ascii); myKeyRepeatTime = myTime + kRepeatSustainDelay; } @@ -151,29 +151,30 @@ void DialogContainer::reStack() } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void DialogContainer::handleKeyEvent(int ascii, int key, int mod, uInt8 state) +void DialogContainer::handleKeyEvent(StellaKey key, StellaMod mod, + char ascii, bool state) { if(myDialogStack.empty()) return; // Send the event to the dialog box on the top of the stack Dialog* activeDialog = myDialogStack.top(); - if(state == 1) + if(state) { - myCurrentKeyDown.ascii = ascii; myCurrentKeyDown.keycode = key; myCurrentKeyDown.flags = mod; + myCurrentKeyDown.ascii = ascii; myKeyRepeatTime = myTime + kRepeatInitialDelay; - activeDialog->handleKeyDown(ascii, key, mod); + activeDialog->handleKeyDown(key, mod, ascii); } else { - activeDialog->handleKeyUp(ascii, key, mod); + activeDialog->handleKeyUp(key, mod, ascii); // Only stop firing events if it's the current key if (key == myCurrentKeyDown.keycode) - myCurrentKeyDown.keycode = 0; + myCurrentKeyDown.keycode = KBDK_UNKNOWN; } } @@ -338,7 +339,7 @@ void DialogContainer::handleJoyHatEvent(int stick, int hat, JoyHat value) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void DialogContainer::reset() { - myCurrentKeyDown.keycode = 0; + myCurrentKeyDown.keycode = KBDK_UNKNOWN; myCurrentMouseDown.button = -1; myLastClick.x = myLastClick.y = 0; myLastClick.time = 0; diff --git a/src/gui/DialogContainer.hxx b/src/gui/DialogContainer.hxx index 62e33a24b..5ec241d9d 100644 --- a/src/gui/DialogContainer.hxx +++ b/src/gui/DialogContainer.hxx @@ -66,12 +66,12 @@ class DialogContainer /** Handle a keyboard event. - @param ascii ASCII translation @param key Actual key symbol @param mod Modifiers - @param state Pressed or released + @param ascii ASCII translation + @param state Pressed (true) or released (false) */ - void handleKeyEvent(int ascii, int key, int mod, uInt8 state); + void handleKeyEvent(StellaKey key, StellaMod mod, char ascii, bool state); /** Handle a mouse motion event. @@ -164,8 +164,8 @@ class DialogContainer // For continuous 'key down' events struct { - int ascii; - int keycode; + StellaKey keycode; + char ascii; int flags; } myCurrentKeyDown; uInt64 myKeyRepeatTime; diff --git a/src/gui/EditableWidget.cxx b/src/gui/EditableWidget.cxx index e06d3a826..bca059981 100644 --- a/src/gui/EditableWidget.cxx +++ b/src/gui/EditableWidget.cxx @@ -90,72 +90,71 @@ bool EditableWidget::tryInsertChar(char c, int pos) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool EditableWidget::handleKeyDown(int ascii, int keycode, int modifiers) +bool EditableWidget::handleKeyDown(StellaKey key, StellaMod mod, char ascii) { if(!_editable) return true; // Ignore all alt-mod keys - if(instance().eventHandler().kbdAlt(modifiers)) + if(instance().eventHandler().kbdAlt(mod)) return true; bool handled = true; bool dirty = false; - switch (ascii) + switch(key) { - case '\n': // enter/return - case '\r': + case KBDK_RETURN: // confirm edit and exit editmode endEditMode(); sendCommand(kEditAcceptCmd, 0, _id); dirty = true; break; - case 27: // escape + case KBDK_ESCAPE: abortEditMode(); sendCommand(kEditCancelCmd, 0, _id); dirty = true; break; - case 8: // backspace + case KBDK_BACKSPACE: dirty = killChar(-1); if(dirty) sendCommand(kEditChangedCmd, ascii, _id); break; - case 127: // delete + case KBDK_DELETE: dirty = killChar(+1); if(dirty) sendCommand(kEditChangedCmd, ascii, _id); break; - case 256 + 20: // left arrow - if(instance().eventHandler().kbdControl(modifiers)) - dirty = specialKeys(ascii, keycode); + case KBDK_LEFT: + if(instance().eventHandler().kbdControl(mod)) + dirty = specialKeys(key, ascii); else if(_caretPos > 0) dirty = setCaretPos(_caretPos - 1); break; - case 256 + 19: // right arrow - if(instance().eventHandler().kbdControl(modifiers)) - dirty = specialKeys(ascii, keycode); + case KBDK_RIGHT: + if(instance().eventHandler().kbdControl(mod)) + dirty = specialKeys(key, ascii); else if(_caretPos < (int)_editString.size()) dirty = setCaretPos(_caretPos + 1); break; - case 256 + 22: // home + case KBDK_HOME: dirty = setCaretPos(0); break; - case 256 + 23: // end + case KBDK_END: dirty = setCaretPos(_editString.size()); break; default: - if (instance().eventHandler().kbdControl(modifiers)) + if (instance().eventHandler().kbdControl(mod)) { - dirty = specialKeys(ascii, keycode); + dirty = specialKeys(key, ascii); } - else if (tryInsertChar((char)ascii, _caretPos)) + else if (tryInsertChar(ascii, _caretPos)) { _caretPos++; sendCommand(kEditChangedCmd, ascii, _id); @@ -253,55 +252,55 @@ bool EditableWidget::adjustOffset() } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool EditableWidget::specialKeys(int ascii, int keycode) +bool EditableWidget::specialKeys(StellaKey key, char ascii) { bool handled = true; - switch (keycode) + switch (key) { - case 'a': + case KBDK_a: setCaretPos(0); break; - case 'c': + case KBDK_c: copySelectedText(); if(handled) sendCommand(kEditChangedCmd, ascii, _id); break; - case 'e': + case KBDK_e: setCaretPos(_editString.size()); break; - case 'd': + case KBDK_d: handled = killChar(+1); if(handled) sendCommand(kEditChangedCmd, ascii, _id); break; - case 'k': + case KBDK_k: handled = killLine(+1); if(handled) sendCommand(kEditChangedCmd, ascii, _id); break; - case 'u': + case KBDK_u: handled = killLine(-1); if(handled) sendCommand(kEditChangedCmd, ascii, _id); break; - case 'v': + case KBDK_v: pasteSelectedText(); if(handled) sendCommand(kEditChangedCmd, ascii, _id); break; - case 'w': + case KBDK_w: handled = killLastWord(); if(handled) sendCommand(kEditChangedCmd, ascii, _id); break; - case 256 + 20: // left arrow + case KBDK_LEFT: handled = moveWord(-1); break; - case 256 + 19: // right arrow + case KBDK_RIGHT: handled = moveWord(+1); break; diff --git a/src/gui/EditableWidget.hxx b/src/gui/EditableWidget.hxx index 9b119bd21..bbb6bf470 100644 --- a/src/gui/EditableWidget.hxx +++ b/src/gui/EditableWidget.hxx @@ -49,7 +49,7 @@ class EditableWidget : public Widget, public CommandSender bool isEditable() const { return _editable; } void setEditable(bool editable); - virtual bool handleKeyDown(int ascii, int keycode, int modifiers); + virtual bool handleKeyDown(StellaKey key, StellaMod mod, char ascii); // We only want to focus this widget when we can edit its contents virtual bool wantsFocus() { return _editable; } @@ -69,7 +69,7 @@ class EditableWidget : public Widget, public CommandSender private: // Line editing - bool specialKeys(int ascii, int keycode); + bool specialKeys(StellaKey key, char ascii); bool killChar(int direction); bool killLine(int direction); bool killLastWord(); diff --git a/src/gui/EventMappingWidget.cxx b/src/gui/EventMappingWidget.cxx index 3c743c21c..be506ff78 100644 --- a/src/gui/EventMappingWidget.cxx +++ b/src/gui/EventMappingWidget.cxx @@ -251,14 +251,14 @@ void EventMappingWidget::enableButtons(bool state) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool EventMappingWidget::handleKeyDown(int ascii, int keycode, int modifiers) +bool EventMappingWidget::handleKeyDown(StellaKey key, StellaMod mod, char ascii) { // Remap keys in remap mode if(myRemapStatus && myActionSelected >= 0) { Event::Type event = instance().eventHandler().eventAtIndex(myActionSelected, myEventMode); - if(instance().eventHandler().addKeyMapping(event, myEventMode, keycode)) + if(instance().eventHandler().addKeyMapping(event, myEventMode, key)) stopRemapping(); } return true; diff --git a/src/gui/EventMappingWidget.hxx b/src/gui/EventMappingWidget.hxx index a7699c4bc..4714dae7a 100644 --- a/src/gui/EventMappingWidget.hxx +++ b/src/gui/EventMappingWidget.hxx @@ -49,7 +49,7 @@ class EventMappingWidget : public Widget, public CommandSender const StringList& actions, EventMode mode); ~EventMappingWidget(); - bool handleKeyDown(int ascii, int keycode, int modifiers); + bool handleKeyDown(StellaKey key, StellaMod mod, char ascii); void handleJoyDown(int stick, int button); void handleJoyAxis(int stick, int axis, int value); bool handleJoyHat(int stick, int hat, int value); diff --git a/src/gui/InputDialog.cxx b/src/gui/InputDialog.cxx index 46bb24812..91912cb1c 100644 --- a/src/gui/InputDialog.cxx +++ b/src/gui/InputDialog.cxx @@ -371,15 +371,15 @@ void InputDialog::setDefaults() } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void InputDialog::handleKeyDown(int ascii, int keycode, int modifiers) +void InputDialog::handleKeyDown(StellaKey key, StellaMod mod, char ascii) { // Remap key events in remap mode, otherwise pass to parent dialog if(myEmulEventMapper->remapMode()) - myEmulEventMapper->handleKeyDown(ascii, keycode, modifiers); + myEmulEventMapper->handleKeyDown(key, mod, ascii); else if(myMenuEventMapper->remapMode()) - myMenuEventMapper->handleKeyDown(ascii, keycode, modifiers); + myMenuEventMapper->handleKeyDown(key, mod, ascii); else - Dialog::handleKeyDown(ascii, keycode, modifiers); + Dialog::handleKeyDown(key, mod, ascii); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/gui/InputDialog.hxx b/src/gui/InputDialog.hxx index d74d18f3f..21e1976aa 100644 --- a/src/gui/InputDialog.hxx +++ b/src/gui/InputDialog.hxx @@ -41,7 +41,7 @@ class InputDialog : public Dialog ~InputDialog(); protected: - virtual void handleKeyDown(int ascii, int keycode, int modifiers); + virtual void handleKeyDown(StellaKey key, StellaMod mod, char ascii); virtual void handleJoyDown(int stick, int button); virtual void handleJoyAxis(int stick, int axis, int value); virtual bool handleJoyHat(int stick, int hat, int value); diff --git a/src/gui/LauncherDialog.cxx b/src/gui/LauncherDialog.cxx index 109a88cee..f217083dc 100644 --- a/src/gui/LauncherDialog.cxx +++ b/src/gui/LauncherDialog.cxx @@ -478,14 +478,14 @@ bool LauncherDialog::matchPattern(const string& s, const string& pattern) const } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void LauncherDialog::handleKeyDown(int ascii, int keycode, int modifiers) +void LauncherDialog::handleKeyDown(StellaKey key, StellaMod mod, char ascii) { // Grab the key before passing it to the actual dialog and check for // Control-R (reload ROM listing) - if(instance().eventHandler().kbdControl(modifiers) && keycode == 'r') + if(instance().eventHandler().kbdControl(mod) && key == KBDK_r) updateListing(); else - Dialog::handleKeyDown(ascii, keycode, modifiers); + Dialog::handleKeyDown(key, mod, ascii); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/gui/LauncherDialog.hxx b/src/gui/LauncherDialog.hxx index d300513d8..e1e6fdad0 100644 --- a/src/gui/LauncherDialog.hxx +++ b/src/gui/LauncherDialog.hxx @@ -82,7 +82,7 @@ class LauncherDialog : public Dialog void reload() { updateListing(); } protected: - virtual void handleKeyDown(int ascii, int keycode, int modifiers); + virtual void handleKeyDown(StellaKey key, StellaMod mod, char ascii); virtual void handleMouseDown(int x, int y, int button, int clickCount); virtual void handleCommand(CommandSender* sender, int cmd, int data, int id); diff --git a/src/gui/ListWidget.cxx b/src/gui/ListWidget.cxx index f676b9cc0..fffc65c6d 100644 --- a/src/gui/ListWidget.cxx +++ b/src/gui/ListWidget.cxx @@ -40,8 +40,8 @@ ListWidget::ListWidget(GuiObject* boss, const GUI::Font& font, _currentPos(0), _selectedItem(-1), _highlightedItem(-1), - _currentKeyDown(0), _editMode(false), + _currentKeyDown(KBDK_UNKNOWN), _quickSelect(quickSelect), _quickSelectTime(0) { @@ -210,17 +210,17 @@ int ListWidget::findItem(int x, int y) const } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool ListWidget::handleKeyDown(int ascii, int keycode, int modifiers) +bool ListWidget::handleKeyDown(StellaKey key, StellaMod mod, char ascii) { // Ignore all Alt-mod keys - if(instance().eventHandler().kbdAlt(modifiers)) + if(instance().eventHandler().kbdAlt(mod)) return true; bool handled = true; int oldSelectedItem = _selectedItem; if (!_editMode && _quickSelect && - ((isalnum((char)ascii)) || isspace((char)ascii))) + ((isalnum(ascii)) || isspace(ascii))) { // Quick selection mode: Go to first list item starting with this key // (or a substring accumulated from the last couple key presses). @@ -229,9 +229,9 @@ bool ListWidget::handleKeyDown(int ascii, int keycode, int modifiers) // method "enableQuickSelect()" or so ? uInt64 time = instance().getTicks() / 1000; if (_quickSelectTime < time) - _quickSelectStr = (char)ascii; + _quickSelectStr = ascii; else - _quickSelectStr += (char)ascii; + _quickSelectStr += ascii; _quickSelectTime = time + _QUICK_SELECT_DELAY; // FIXME: This is bad slow code (it scans the list linearly each time a @@ -253,14 +253,14 @@ bool ListWidget::handleKeyDown(int ascii, int keycode, int modifiers) else if (_editMode) { // Class EditableWidget handles all text editing related key presses for us - handled = EditableWidget::handleKeyDown(ascii, keycode, modifiers); + handled = EditableWidget::handleKeyDown(key, mod, ascii); } else { // not editmode - switch (keycode) + switch(key) { - case ' ': // space + case KBDK_SPACE: // Snap list back to currently highlighted line if(_highlightedItem >= 0) { @@ -282,15 +282,15 @@ bool ListWidget::handleKeyDown(int ascii, int keycode, int modifiers) sendCommand(kListSelectionChangedCmd, _selectedItem, _id); } - _currentKeyDown = keycode; + _currentKeyDown = key; return handled; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool ListWidget::handleKeyUp(int ascii, int keycode, int modifiers) +bool ListWidget::handleKeyUp(StellaKey key, StellaMod mod, char ascii) { - if (keycode == _currentKeyDown) - _currentKeyDown = 0; + if (key == _currentKeyDown) + _currentKeyDown = KBDK_UNKNOWN; return true; } diff --git a/src/gui/ListWidget.hxx b/src/gui/ListWidget.hxx index 58c8fa11f..fb375d370 100644 --- a/src/gui/ListWidget.hxx +++ b/src/gui/ListWidget.hxx @@ -69,8 +69,8 @@ class ListWidget : public EditableWidget virtual void handleMouseDown(int x, int y, int button, int clickCount); virtual void handleMouseUp(int x, int y, int button, int clickCount); virtual void handleMouseWheel(int x, int y, int direction); - virtual bool handleKeyDown(int ascii, int keycode, int modifiers); - virtual bool handleKeyUp(int ascii, int keycode, int modifiers); + virtual bool handleKeyDown(StellaKey key, StellaMod mod, char ascii); + virtual bool handleKeyUp(StellaKey key, StellaMod mod, char ascii); virtual bool handleEvent(Event::Type e); virtual void handleCommand(CommandSender* sender, int cmd, int data, int id); @@ -105,8 +105,8 @@ class ListWidget : public EditableWidget int _currentPos; int _selectedItem; int _highlightedItem; - int _currentKeyDown; bool _editMode; + StellaKey _currentKeyDown; ScrollBarWidget* _scrollBar; diff --git a/src/gui/Widget.hxx b/src/gui/Widget.hxx index 93d299475..a2d593f4a 100644 --- a/src/gui/Widget.hxx +++ b/src/gui/Widget.hxx @@ -36,6 +36,7 @@ #include "GuiObject.hxx" #include "OSystem.hxx" #include "Rect.hxx" +#include "StellaKeys.hxx" enum { WIDGET_ENABLED = 1 << 0, @@ -98,8 +99,8 @@ class Widget : public GuiObject virtual int getAbsX() const { return _x + _boss->getChildX(); } virtual int getAbsY() const { return _y + _boss->getChildY(); } - virtual bool handleKeyDown(int ascii, int keycode, int modifiers) { return false; } - virtual bool handleKeyUp(int ascii, int keycode, int modifiers) { return false; } + virtual bool handleKeyDown(StellaKey key, StellaMod mod, char ascii) { return false; } + virtual bool handleKeyUp(StellaKey key, StellaMod mod, char ascii) { return false; } virtual void handleMouseDown(int x, int y, int button, int clickCount) {} virtual void handleMouseUp(int x, int y, int button, int clickCount) {} virtual void handleMouseEntered(int button) {}