[Scummvm-git-logs] scummvm master -> 31399a675b8baa359831c84a2d9a24de6df9bbc1
djsrv
dservilla at gmail.com
Wed Jun 17 02:44:33 UTC 2020
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
31399a675b DIRECTOR: Add Mac key code mappings
Commit: 31399a675b8baa359831c84a2d9a24de6df9bbc1
https://github.com/scummvm/scummvm/commit/31399a675b8baa359831c84a2d9a24de6df9bbc1
Author: djsrv (dservilla at gmail.com)
Date: 2020-06-16T22:43:12-04:00
Commit Message:
DIRECTOR: Add Mac key code mappings
Changed paths:
engines/director/director.cpp
engines/director/director.h
engines/director/events.cpp
engines/director/util.cpp
diff --git a/engines/director/director.cpp b/engines/director/director.cpp
index 134fd563ea..7a5848c994 100644
--- a/engines/director/director.cpp
+++ b/engines/director/director.cpp
@@ -73,6 +73,9 @@ DirectorEngine::DirectorEngine(OSystem *syst, const DirectorGameDescription *gam
// Load Patterns
loadPatterns();
+ // Load key codes
+ loadKeyCodes();
+
_currentScore = nullptr;
_soundManager = nullptr;
_currentPalette = nullptr;
diff --git a/engines/director/director.h b/engines/director/director.h
index 81dfb631e5..651ab2d8b1 100644
--- a/engines/director/director.h
+++ b/engines/director/director.h
@@ -125,6 +125,7 @@ public:
uint32 transformColor(uint32 color);
Graphics::MacPatterns &getPatterns();
void setCursor(int type); // graphics.cpp
+ void loadKeyCodes();
void loadInitialMovie(const Common::String movie);
Archive *openMainArchive(const Common::String movie);
@@ -147,6 +148,7 @@ public:
int _colorDepth;
unsigned char _key;
int _keyCode;
+ Common::HashMap<int, int> _macKeyCodes;
int _machineType;
bool _playbackPaused;
bool _skipFrameAdvance;
diff --git a/engines/director/events.cpp b/engines/director/events.cpp
index 4222ab2a5a..128c86e66c 100644
--- a/engines/director/events.cpp
+++ b/engines/director/events.cpp
@@ -141,25 +141,10 @@ void DirectorEngine::processEvents(bool bufferLingoEvents) {
break;
case Common::EVENT_KEYDOWN:
- _keyCode = event.kbd.keycode;
+ _keyCode = _macKeyCodes.contains(event.kbd.keycode) ? _macKeyCodes[event.kbd.keycode] : 0;
_key = (unsigned char)(event.kbd.ascii & 0xff);
- switch (_keyCode) {
- case Common::KEYCODE_LEFT:
- _keyCode = 123;
- break;
- case Common::KEYCODE_RIGHT:
- _keyCode = 124;
- break;
- case Common::KEYCODE_DOWN:
- _keyCode = 125;
- break;
- case Common::KEYCODE_UP:
- _keyCode = 126;
- break;
- default:
- debugC(1, kDebugEvents, "processEvents(): keycode: %d", _keyCode);
- }
+ debugC(1, kDebugEvents, "processEvents(): keycode: %d", _keyCode);
sc->_lastEventTime = g_director->getMacTicks();
sc->_lastKeyTime = sc->_lastEventTime;
diff --git a/engines/director/util.cpp b/engines/director/util.cpp
index ae624da4fc..619a17fcbb 100644
--- a/engines/director/util.cpp
+++ b/engines/director/util.cpp
@@ -21,6 +21,7 @@
*/
#include "common/file.h"
+#include "common/keyboard.h"
#include "common/str.h"
#include "common/textconsole.h"
@@ -29,6 +30,140 @@
namespace Director {
+static struct KeyCodeMapping {
+ Common::KeyCode scummvm;
+ int mac;
+} keyCodeMappings[] = {
+ { Common::KEYCODE_ESCAPE, 53 },
+ { Common::KEYCODE_F1, 122 },
+ { Common::KEYCODE_F2, 120 },
+ { Common::KEYCODE_F3, 99 },
+ { Common::KEYCODE_F4, 118 },
+ { Common::KEYCODE_F5, 96 },
+ { Common::KEYCODE_F6, 97 },
+ { Common::KEYCODE_F7, 98 },
+ { Common::KEYCODE_F8, 100 },
+ { Common::KEYCODE_F9, 101 },
+ { Common::KEYCODE_F10, 109 },
+ { Common::KEYCODE_F11, 103 },
+ { Common::KEYCODE_F12, 111 },
+ { Common::KEYCODE_F13, 105 }, // mirrored by print
+ { Common::KEYCODE_F14, 107 }, // mirrored by scroll lock
+ { Common::KEYCODE_F15, 113 }, // mirrored by pause
+
+ { Common::KEYCODE_BACKQUOTE, 10 },
+ { Common::KEYCODE_1, 18 },
+ { Common::KEYCODE_2, 19 },
+ { Common::KEYCODE_3, 20 },
+ { Common::KEYCODE_4, 21 },
+ { Common::KEYCODE_5, 23 },
+ { Common::KEYCODE_6, 22 },
+ { Common::KEYCODE_7, 26 },
+ { Common::KEYCODE_8, 28 },
+ { Common::KEYCODE_9, 25 },
+ { Common::KEYCODE_0, 29 },
+ { Common::KEYCODE_MINUS, 27 },
+ { Common::KEYCODE_EQUALS, 24 },
+ { Common::KEYCODE_BACKSPACE, 51 },
+
+ { Common::KEYCODE_TAB, 48 },
+ { Common::KEYCODE_q, 12 },
+ { Common::KEYCODE_w, 13 },
+ { Common::KEYCODE_e, 14 },
+ { Common::KEYCODE_r, 15 },
+ { Common::KEYCODE_t, 17 },
+ { Common::KEYCODE_y, 16 },
+ { Common::KEYCODE_u, 32 },
+ { Common::KEYCODE_i, 34 },
+ { Common::KEYCODE_o, 31 },
+ { Common::KEYCODE_p, 35 },
+ { Common::KEYCODE_LEFTBRACKET, 33 },
+ { Common::KEYCODE_RIGHTBRACKET, 30 },
+ { Common::KEYCODE_BACKSLASH, 42 },
+
+ { Common::KEYCODE_CAPSLOCK, 57 },
+ { Common::KEYCODE_a, 0 },
+ { Common::KEYCODE_s, 1 },
+ { Common::KEYCODE_d, 2 },
+ { Common::KEYCODE_f, 3 },
+ { Common::KEYCODE_g, 5 },
+ { Common::KEYCODE_h, 4 },
+ { Common::KEYCODE_j, 38 },
+ { Common::KEYCODE_k, 40 },
+ { Common::KEYCODE_l, 37 },
+ { Common::KEYCODE_SEMICOLON, 41 },
+ { Common::KEYCODE_QUOTE, 39 },
+ { Common::KEYCODE_RETURN, 36 },
+
+ { Common::KEYCODE_LSHIFT, 56 },
+ { Common::KEYCODE_z, 6 },
+ { Common::KEYCODE_x, 7 },
+ { Common::KEYCODE_c, 8 },
+ { Common::KEYCODE_v, 9 },
+ { Common::KEYCODE_b, 11 },
+ { Common::KEYCODE_n, 45 },
+ { Common::KEYCODE_m, 46 },
+ { Common::KEYCODE_COMMA, 43 },
+ { Common::KEYCODE_PERIOD, 47 },
+ { Common::KEYCODE_SLASH, 44 },
+ { Common::KEYCODE_RSHIFT, 56 },
+
+ { Common::KEYCODE_LCTRL, 54 }, // control
+ { Common::KEYCODE_LALT, 58 }, // option
+ { Common::KEYCODE_LSUPER, 55 }, // command
+ { Common::KEYCODE_SPACE, 49 },
+ { Common::KEYCODE_RSUPER, 55 }, // command
+ { Common::KEYCODE_RALT, 58 }, // option
+ { Common::KEYCODE_RCTRL, 54 }, // control
+
+ { Common::KEYCODE_LEFT, 123 },
+ { Common::KEYCODE_RIGHT, 124 },
+ { Common::KEYCODE_DOWN, 125 },
+ { Common::KEYCODE_UP, 126 },
+
+ { Common::KEYCODE_NUMLOCK, 71 },
+ { Common::KEYCODE_KP_EQUALS, 81 },
+ { Common::KEYCODE_KP_DIVIDE, 75 },
+ { Common::KEYCODE_KP_MULTIPLY, 67 },
+
+ { Common::KEYCODE_KP7, 89 },
+ { Common::KEYCODE_KP8, 91 },
+ { Common::KEYCODE_KP9, 92 },
+ { Common::KEYCODE_KP_MINUS, 78 },
+
+ { Common::KEYCODE_KP4, 86 },
+ { Common::KEYCODE_KP5, 87 },
+ { Common::KEYCODE_KP6, 88 },
+ { Common::KEYCODE_KP_PLUS, 69 },
+
+ { Common::KEYCODE_KP1, 83 },
+ { Common::KEYCODE_KP2, 84 },
+ { Common::KEYCODE_KP3, 85 },
+
+ { Common::KEYCODE_KP0, 82 },
+ { Common::KEYCODE_KP_PERIOD, 65 },
+ { Common::KEYCODE_KP_ENTER, 76 },
+
+ { Common::KEYCODE_MENU, 50 }, // international
+ { Common::KEYCODE_PRINT, 105 }, // mirrored by F13
+ { Common::KEYCODE_SCROLLOCK, 107 }, // mirrored by F14
+ { Common::KEYCODE_PAUSE, 113 }, // mirrored by F15
+ { Common::KEYCODE_INSERT, 114 },
+ { Common::KEYCODE_HOME, 115 },
+ { Common::KEYCODE_PAGEUP, 116 },
+ { Common::KEYCODE_DELETE, 117 },
+ { Common::KEYCODE_END, 119 },
+ { Common::KEYCODE_PAGEDOWN, 121 },
+
+ { Common::KEYCODE_INVALID, 0 }
+};
+
+void DirectorEngine::loadKeyCodes() {
+ for (KeyCodeMapping *k = keyCodeMappings; k->scummvm != Common::KEYCODE_INVALID; k++) {
+ _macKeyCodes[k->scummvm] = k->mac;
+ }
+}
+
int castNumToNum(const char *str) {
if (strlen(str) != 3)
return -1;
More information about the Scummvm-git-logs
mailing list