aboutsummaryrefslogtreecommitdiff
path: root/backends/keymapper/hardware-input.cpp
diff options
context:
space:
mode:
authorTarek Soliman2012-02-24 13:55:48 -0600
committerTarek Soliman2012-03-02 20:48:50 -0600
commit4ee1a3aceae7d68c89513f7d122606acbceb1e7c (patch)
tree0f9d3153b7f2f721f0d23e7bfce9e5fe8e287421 /backends/keymapper/hardware-input.cpp
parent101ec2b885aade21216c1bba8488711b30d192eb (diff)
downloadscummvm-rg350-4ee1a3aceae7d68c89513f7d122606acbceb1e7c.tar.gz
scummvm-rg350-4ee1a3aceae7d68c89513f7d122606acbceb1e7c.tar.bz2
scummvm-rg350-4ee1a3aceae7d68c89513f7d122606acbceb1e7c.zip
KEYMAPPER: Add non-key inputs to HardwareInput
Diffstat (limited to 'backends/keymapper/hardware-input.cpp')
-rw-r--r--backends/keymapper/hardware-input.cpp36
1 files changed, 29 insertions, 7 deletions
diff --git a/backends/keymapper/hardware-input.cpp b/backends/keymapper/hardware-input.cpp
index a09f0b54fc..d1f8822ac0 100644
--- a/backends/keymapper/hardware-input.cpp
+++ b/backends/keymapper/hardware-input.cpp
@@ -209,16 +209,33 @@ const HardwareInput *HardwareInputSet::findHardwareInput(String id) const {
return 0;
}
+const HardwareInput *HardwareInputSet::findHardwareInput(const HardwareInputCode code) const {
+ List<const HardwareInput *>::const_iterator it;
+
+ for (it = _inputs.begin(); it != _inputs.end(); ++it) {
+ const HardwareInput *entry = *it;
+ if (entry->type == kHardwareInputTypeGeneric && entry->inputCode == code)
+ return entry;
+ }
+ return 0;
+}
+
const HardwareInput *HardwareInputSet::findHardwareInput(const KeyState& keystate) const {
List<const HardwareInput *>::const_iterator it;
for (it = _inputs.begin(); it != _inputs.end(); ++it) {
- if ((*it)->key == keystate)
- return (*it);
+ const HardwareInput *entry = *it;
+ if (entry->type == kHardwareInputTypeKeyboard && entry->key == keystate)
+ return entry;
}
return 0;
}
+void HardwareInputSet::addHardwareInputs(const HardwareInputTableEntry inputs[]) {
+ for (const HardwareInputTableEntry *entry = inputs; entry->hwId; ++entry)
+ addHardwareInput(new HardwareInput(entry->hwId, entry->code, entry->desc));
+}
+
void HardwareInputSet::addHardwareInputs(const KeyTableEntry keys[], const ModifierTableEntry modifiers[]) {
const KeyTableEntry *key;
const ModifierTableEntry *mod;
@@ -247,10 +264,6 @@ void HardwareInputSet::addHardwareInputs(const KeyTableEntry keys[], const Modif
}
}
-void HardwareInputSet::addHardwareInputs(const KeyTableEntry keys[]) {
- addHardwareInputs(keys, defaultModifiers);
-}
-
void HardwareInputSet::removeHardwareInput(const HardwareInput *input) {
if (!input)
return;
@@ -259,7 +272,16 @@ void HardwareInputSet::removeHardwareInput(const HardwareInput *input) {
for (it = _inputs.begin(); it != _inputs.end(); ++it) {
const HardwareInput *entry = (*it);
- if (entry->id == input->id || entry->key == input->key) {
+ bool match = false;
+ if (entry->id == input->id)
+ match = true;
+ else if (input->type == entry->type) {
+ if (input->type == kHardwareInputTypeGeneric && input->inputCode == entry->inputCode)
+ match = true;
+ else if (input->type == kHardwareInputTypeKeyboard && input->key == entry->key)
+ match = true;
+ }
+ if (match) {
debug(7, "Removing hardware input [%s] (%s) because it matches [%s] (%s)", entry->id.c_str(), entry->description.c_str(), input->id.c_str(), input->description.c_str());
delete entry;
_inputs.erase(it);