diff options
author | Willem Jan Palenstijn | 2013-04-18 23:37:54 +0200 |
---|---|---|
committer | Willem Jan Palenstijn | 2013-05-08 20:46:44 +0200 |
commit | 02c5cc75a7cb8885d2a0fa141fbc0e763c5b31a0 (patch) | |
tree | 72b64a67ebeca41e9b83593da80850e848a99e2e /backends/keymapper/hardware-input.cpp | |
parent | 1539023834a2ad7cf8942711d60983891a10a82a (diff) | |
parent | 1e200620d673af4acdd2d128ed6e390df001aacf (diff) | |
download | scummvm-rg350-02c5cc75a7cb8885d2a0fa141fbc0e763c5b31a0.tar.gz scummvm-rg350-02c5cc75a7cb8885d2a0fa141fbc0e763c5b31a0.tar.bz2 scummvm-rg350-02c5cc75a7cb8885d2a0fa141fbc0e763c5b31a0.zip |
Merge branch 'master'
Conflicts:
configure
base/plugins.cpp
Diffstat (limited to 'backends/keymapper/hardware-input.cpp')
-rw-r--r-- | backends/keymapper/hardware-input.cpp | 36 |
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); |