[Scummvm-cvs-logs] SF.net SVN: scummvm:[43363] scummvm/branches/gsoc2009-16bit
upthorn at users.sourceforge.net
upthorn at users.sourceforge.net
Fri Aug 14 10:11:18 CEST 2009
Revision: 43363
http://scummvm.svn.sourceforge.net/scummvm/?rev=43363&view=rev
Author: upthorn
Date: 2009-08-14 08:11:18 +0000 (Fri, 14 Aug 2009)
Log Message:
-----------
Added proper saving/loading of mapped key modifiers. Fixed modifier recognition in a much less hackish manner, (but still using a minor hack as a stopgap until KeyState can be replaced as the primary lookup type for the keymapper).
Modified Paths:
--------------
scummvm/branches/gsoc2009-16bit/backends/keymapper/keymap.cpp
scummvm/branches/gsoc2009-16bit/backends/keymapper/keymapper.cpp
scummvm/branches/gsoc2009-16bit/backends/keymapper/remap-dialog.cpp
scummvm/branches/gsoc2009-16bit/common/keyboard.h
Modified: scummvm/branches/gsoc2009-16bit/backends/keymapper/keymap.cpp
===================================================================
--- scummvm/branches/gsoc2009-16bit/backends/keymapper/keymap.cpp 2009-08-14 06:42:57 UTC (rev 43362)
+++ scummvm/branches/gsoc2009-16bit/backends/keymapper/keymap.cpp 2009-08-14 08:11:18 UTC (rev 43363)
@@ -127,6 +127,10 @@
ConfigManager::Domain::iterator it;
String prefix = KEYMAP_KEY_PREFIX + _name + "_";
+ uint32 modId = 0;
+ char hwId[HWKEY_ID_SIZE+1];
+ memset(hwId,0,HWKEY_ID_SIZE+1);
+
for (it = _configDomain->begin(); it != _configDomain->end(); it++) {
const String& key = it->_key;
@@ -145,15 +149,17 @@
continue;
}
- const HardwareKey *hwKey = hwKeys->findHardwareKey(it->_value.c_str());
+ sscanf(it->_value.c_str(),"%d,%s",&modId,hwId);
+ const HardwareKey *hwKey = hwKeys->findHardwareKey(hwId);
if (!hwKey) {
warning("HardwareKey with ID %s not known", it->_value.c_str());
_configDomain->erase(key);
continue;
}
-
- ua->mapKey(hwKey);
+ HardwareKey *mappedKey = new HardwareKey(*hwKey);
+ mappedKey->key.flags = modId;
+ ua->mapKey(mappedKey);
}
}
@@ -171,13 +177,19 @@
String actId((*it)->id, (*it)->id + actIdLen);
char hwId[HWKEY_ID_SIZE+1];
-
memset(hwId, 0, HWKEY_ID_SIZE+1);
+ char modId[4];
+ memset(modId, 0, 4);
+
if ((*it)->getMappedKey()) {
memcpy(hwId, (*it)->getMappedKey()->hwKeyId, HWKEY_ID_SIZE);
+ sprintf(modId,"%d",(*it)->getMappedKey()->key.flags);
}
- _configDomain->setVal(prefix + actId, hwId);
+ String val = modId;
+ val += ',';
+ val += hwId;
+ _configDomain->setVal(prefix + actId, val);
}
}
Modified: scummvm/branches/gsoc2009-16bit/backends/keymapper/keymapper.cpp
===================================================================
--- scummvm/branches/gsoc2009-16bit/backends/keymapper/keymapper.cpp 2009-08-14 06:42:57 UTC (rev 43362)
+++ scummvm/branches/gsoc2009-16bit/backends/keymapper/keymapper.cpp 2009-08-14 08:11:18 UTC (rev 43363)
@@ -192,18 +192,28 @@
Action *action = 0;
if (keyDown) {
+ // HACK: Temporary fix for modifier recognition, get the hwkey's keystate
+ // to correct for keydown and keyup generating different ascii codes in SDL
+ // to be solved more permanently by using a structure other than KeyState
+ const HardwareKey *hwkey = findHardwareKey(key);
+ if (!hwkey)
+ return false;
+
+ KeyState k = hwkey->key;
+ k.flags = key.flags;
+
// Search for key in active keymap stack
for (int i = _activeMaps.size() - 1; i >= 0; --i) {
MapRecord mr = _activeMaps[i];
- action = mr.keymap->getMappedAction(key);
+ action = mr.keymap->getMappedAction(k);
if (action || mr.inherit == false)
break;
}
if (action)
- _keysDown[key] = action;
+ _keysDown[k] = action;
} else {
HashMap<KeyState, Action*>::iterator it = _keysDown.find(key);
Modified: scummvm/branches/gsoc2009-16bit/backends/keymapper/remap-dialog.cpp
===================================================================
--- scummvm/branches/gsoc2009-16bit/backends/keymapper/remap-dialog.cpp 2009-08-14 06:42:57 UTC (rev 43362)
+++ scummvm/branches/gsoc2009-16bit/backends/keymapper/remap-dialog.cpp 2009-08-14 08:11:18 UTC (rev 43363)
@@ -239,15 +239,14 @@
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);
+ debug( "Key: %d, %d (%c), %x", state.keycode, state.ascii, (state.ascii ? state.ascii : ' '), state.flags);
if (hwkey) {
- HardwareKey *temphwkey = new HardwareKey(*hwkey);
- temphwkey->description = hwkey->description;
- temphwkey->key.flags = hwmod->modFlags;
- _activeRemapAction->mapKey(temphwkey);
+ HardwareKey *mappedkey = new HardwareKey(*hwkey);
+ mappedkey->description = hwkey->description;
+ mappedkey->key.flags = (state.flags & hwkey->modMask);
+ _activeRemapAction->mapKey(mappedkey);
_activeRemapAction->getParent()->saveMappings();
_changes = true;
stopRemapping();
@@ -363,8 +362,21 @@
const HardwareKey *mappedKey = info.action->getMappedKey();
if (mappedKey)
- widg.keyButton->setLabel(mappedKey->description);
- else
+ {
+ Common::String description = "";
+ if (mappedKey->key.flags)
+ {
+ byte flags = mappedKey->key.flags;
+ if (flags & KBD_CTRL)
+ description += "Ctrl+";
+ if (flags & KBD_SHIFT)
+ description += "Shift+";
+ if (flags & KBD_ALT)
+ description += "Alt+";
+ }
+ description += mappedKey->description;
+ widg.keyButton->setLabel(description);
+ } else
widg.keyButton->setLabel("-");
widg.actionText->setVisible(true);
Modified: scummvm/branches/gsoc2009-16bit/common/keyboard.h
===================================================================
--- scummvm/branches/gsoc2009-16bit/common/keyboard.h 2009-08-14 06:42:57 UTC (rev 43362)
+++ scummvm/branches/gsoc2009-16bit/common/keyboard.h 2009-08-14 08:11:18 UTC (rev 43363)
@@ -267,7 +267,7 @@
}
bool operator ==(const KeyState &x) const {
- return keycode == x.keycode && /*ascii == x.ascii && */flags == x.flags;
+ return keycode == x.keycode && ascii == x.ascii && flags == x.flags;
}
};
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list