aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJody Northup2009-08-07 01:17:57 +0000
committerJody Northup2009-08-07 01:17:57 +0000
commite0e09e43b84cf9637fb289bd466235116674c1f2 (patch)
treef3d4dd0d3914a3f8a0ae8d0e39ee7453a2d5a4c5
parent8062d37283bcf8390d8fb66cce99c2bfd65668d8 (diff)
downloadscummvm-rg350-e0e09e43b84cf9637fb289bd466235116674c1f2.tar.gz
scummvm-rg350-e0e09e43b84cf9637fb289bd466235116674c1f2.tar.bz2
scummvm-rg350-e0e09e43b84cf9637fb289bd466235116674c1f2.zip
key remap dialog correctly reads keystrokes again, and can tell modified keys from unmodified keys (but does not yet print modifier prefixes, and actions mapped to modified keys still do not trigger)
svn-id: r43091
-rw-r--r--backends/keymapper/hardware-key.h22
-rw-r--r--backends/keymapper/keymapper.cpp4
-rw-r--r--backends/keymapper/keymapper.h5
-rw-r--r--backends/keymapper/remap-dialog.cpp6
-rw-r--r--backends/platform/sdl/hardwarekeys.cpp52
5 files changed, 61 insertions, 28 deletions
diff --git a/backends/keymapper/hardware-key.h b/backends/keymapper/hardware-key.h
index c8c1d3c145..34631a9484 100644
--- a/backends/keymapper/hardware-key.h
+++ b/backends/keymapper/hardware-key.h
@@ -127,7 +127,27 @@ public:
List<const HardwareKey*>::const_iterator it;
for (it = _keys.begin(); it != _keys.end(); it++) {
- if ((*it)->key == keystate)
+ if ((*it)->key.keycode == keystate.keycode)
+ return (*it);
+ }
+ return 0;
+ }
+
+ const HardwareMod *findHardwareMod(const char *id) const {
+ List<const HardwareMod*>::const_iterator it;
+
+ for (it = _mods.begin(); it != _mods.end(); it++) {
+ if (strncmp((*it)->hwModId, id, HWKEY_ID_SIZE) == 0)
+ return (*it);
+ }
+ return 0;
+ }
+
+ const HardwareMod *findHardwareMod(const KeyState& keystate) const {
+ List<const HardwareMod*>::const_iterator it;
+
+ for (it = _mods.begin(); it != _mods.end(); it++) {
+ if ((*it)->modFlags == keystate.flags)
return (*it);
}
return 0;
diff --git a/backends/keymapper/keymapper.cpp b/backends/keymapper/keymapper.cpp
index c0c454168c..a121ebafee 100644
--- a/backends/keymapper/keymapper.cpp
+++ b/backends/keymapper/keymapper.cpp
@@ -272,6 +272,10 @@ const HardwareKey *Keymapper::findHardwareKey(const KeyState& key) {
return (_hardwareKeys) ? _hardwareKeys->findHardwareKey(key) : 0;
}
+const HardwareMod *Keymapper::findHardwareMod(const KeyState& key) {
+ return (_hardwareKeys) ? _hardwareKeys->findHardwareMod(key) : 0;
+}
+
} // end of namespace Common
#endif // #ifdef ENABLE_KEYMAPPER
diff --git a/backends/keymapper/keymapper.h b/backends/keymapper/keymapper.h
index f492882ca2..af3314f8f5 100644
--- a/backends/keymapper/keymapper.h
+++ b/backends/keymapper/keymapper.h
@@ -170,6 +170,11 @@ public:
*/
const HardwareKey *findHardwareKey(const KeyState& key);
+ /**
+ * Return a HardwareMod pointer for the given key state
+ */
+ const HardwareMod *findHardwareMod(const KeyState& key);
+
Domain& getGlobalDomain() { return _globalDomain; }
Domain& getGameDomain() { return _gameDomain; }
const Stack<MapRecord>& getActiveStack() const { return _activeMaps; }
diff --git a/backends/keymapper/remap-dialog.cpp b/backends/keymapper/remap-dialog.cpp
index 0440acdd0a..9341c82747 100644
--- a/backends/keymapper/remap-dialog.cpp
+++ b/backends/keymapper/remap-dialog.cpp
@@ -239,11 +239,15 @@ void RemapDialog::handleKeyDown(Common::KeyState state) {
void RemapDialog::handleKeyUp(Common::KeyState state) {
if (_activeRemapAction) {
const HardwareKey *hwkey = _keymapper->findHardwareKey(state);
+ const HardwareMod *hwmod = _keymapper->findHardwareMod(state);
debug(0, "Key: %d, %d (%c), %x", state.keycode, state.ascii, (state.ascii ? state.ascii : ' '), state.flags);
if (hwkey) {
- _activeRemapAction->mapKey(hwkey);
+ HardwareKey *temphwkey = new HardwareKey(*hwkey);
+ temphwkey->description = hwkey->description;
+ temphwkey->key.flags = hwmod->modFlags;
+ _activeRemapAction->mapKey(temphwkey);
_activeRemapAction->getParent()->saveMappings();
_changes = true;
stopRemapping();
diff --git a/backends/platform/sdl/hardwarekeys.cpp b/backends/platform/sdl/hardwarekeys.cpp
index bba48286f0..c063ea5bff 100644
--- a/backends/platform/sdl/hardwarekeys.cpp
+++ b/backends/platform/sdl/hardwarekeys.cpp
@@ -86,32 +86,32 @@ static const Key keys[] = {
{"CARET", KEYCODE_CARET, '^', "^", kActionKeyType, ~0},
{"UNDERSCORE", KEYCODE_UNDERSCORE, '_', "_", kActionKeyType, ~0},
{"BACKQUOTE", KEYCODE_BACKQUOTE, '`', "`", kActionKeyType, ~0},
- {"a", KEYCODE_a, 'A', "A", kActionKeyType, ~0},
- {"b", KEYCODE_b, 'B', "B", kActionKeyType, ~0},
- {"c", KEYCODE_c, 'C', "C", kActionKeyType, ~0},
- {"d", KEYCODE_d, 'D', "D", kActionKeyType, ~0},
- {"e", KEYCODE_e, 'E', "E", kActionKeyType, ~0},
- {"f", KEYCODE_f, 'F', "F", kActionKeyType, ~0},
- {"g", KEYCODE_g, 'G', "G", kActionKeyType, ~0},
- {"h", KEYCODE_h, 'H', "H", kActionKeyType, ~0},
- {"i", KEYCODE_i, 'I', "I", kActionKeyType, ~0},
- {"j", KEYCODE_j, 'J', "J", kActionKeyType, ~0},
- {"k", KEYCODE_k, 'K', "K", kActionKeyType, ~0},
- {"l", KEYCODE_l, 'L', "L", kActionKeyType, ~0},
- {"m", KEYCODE_m, 'M', "M", kActionKeyType, ~0},
- {"n", KEYCODE_n, 'N', "N", kActionKeyType, ~0},
- {"o", KEYCODE_o, 'O', "O", kActionKeyType, ~0},
- {"p", KEYCODE_p, 'P', "P", kActionKeyType, ~0},
- {"q", KEYCODE_q, 'Q', "Q", kActionKeyType, ~0},
- {"r", KEYCODE_r, 'R', "R", kActionKeyType, ~0},
- {"s", KEYCODE_s, 'S', "S", kActionKeyType, ~0},
- {"t", KEYCODE_t, 'T', "T", kActionKeyType, ~0},
- {"u", KEYCODE_u, 'U', "U", kActionKeyType, ~0},
- {"v", KEYCODE_v, 'V', "V", kActionKeyType, ~0},
- {"w", KEYCODE_w, 'W', "W", kActionKeyType, ~0},
- {"x", KEYCODE_x, 'X', "X", kActionKeyType, ~0},
- {"y", KEYCODE_y, 'Y', "Y", kActionKeyType, ~0},
- {"z", KEYCODE_z, 'Z', "Z", kActionKeyType, ~0},
+ {"a", KEYCODE_a, 'a', "A", kActionKeyType, ~0},
+ {"b", KEYCODE_b, 'b', "B", kActionKeyType, ~0},
+ {"c", KEYCODE_c, 'c', "C", kActionKeyType, ~0},
+ {"d", KEYCODE_d, 'd', "D", kActionKeyType, ~0},
+ {"e", KEYCODE_e, 'e', "E", kActionKeyType, ~0},
+ {"f", KEYCODE_f, 'f', "F", kActionKeyType, ~0},
+ {"g", KEYCODE_g, 'g', "G", kActionKeyType, ~0},
+ {"h", KEYCODE_h, 'h', "H", kActionKeyType, ~0},
+ {"i", KEYCODE_i, 'i', "I", kActionKeyType, ~0},
+ {"j", KEYCODE_j, 'j', "J", kActionKeyType, ~0},
+ {"k", KEYCODE_k, 'k', "K", kActionKeyType, ~0},
+ {"l", KEYCODE_l, 'l', "L", kActionKeyType, ~0},
+ {"m", KEYCODE_m, 'm', "M", kActionKeyType, ~0},
+ {"n", KEYCODE_n, 'n', "N", kActionKeyType, ~0},
+ {"o", KEYCODE_o, 'o', "O", kActionKeyType, ~0},
+ {"p", KEYCODE_p, 'p', "P", kActionKeyType, ~0},
+ {"q", KEYCODE_q, 'q', "Q", kActionKeyType, ~0},
+ {"r", KEYCODE_r, 'r', "R", kActionKeyType, ~0},
+ {"s", KEYCODE_s, 's', "S", kActionKeyType, ~0},
+ {"t", KEYCODE_t, 't', "T", kActionKeyType, ~0},
+ {"u", KEYCODE_u, 'u', "U", kActionKeyType, ~0},
+ {"v", KEYCODE_v, 'v', "V", kActionKeyType, ~0},
+ {"w", KEYCODE_w, 'w', "W", kActionKeyType, ~0},
+ {"x", KEYCODE_x, 'x', "X", kActionKeyType, ~0},
+ {"y", KEYCODE_y, 'y', "Y", kActionKeyType, ~0},
+ {"z", KEYCODE_z, 'z', "Z", kActionKeyType, ~0},
{"DELETE", KEYCODE_DELETE, 0, "Del", kActionKeyType, ~0},
// Numeric keypad