diff options
| author | Jody Northup | 2009-08-05 21:32:42 +0000 |
|---|---|---|
| committer | Jody Northup | 2009-08-05 21:32:42 +0000 |
| commit | 8062d37283bcf8390d8fb66cce99c2bfd65668d8 (patch) | |
| tree | 60ecdf7e1a6c10f95280a257d26fefc2d86b1cb1 /backends/keymapper/hardware-key.h | |
| parent | 19609e1bdeafe5d76f059ade3a80b64cc6f53200 (diff) | |
| download | scummvm-rg350-8062d37283bcf8390d8fb66cce99c2bfd65668d8.tar.gz scummvm-rg350-8062d37283bcf8390d8fb66cce99c2bfd65668d8.tar.bz2 scummvm-rg350-8062d37283bcf8390d8fb66cce99c2bfd65668d8.zip | |
Some groundwork for a better implementation of modifier keys. (incomplete, and breaks previous implementation)
svn-id: r43078
Diffstat (limited to 'backends/keymapper/hardware-key.h')
| -rw-r--r-- | backends/keymapper/hardware-key.h | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/backends/keymapper/hardware-key.h b/backends/keymapper/hardware-key.h index 8ddeada51e..c8c1d3c145 100644 --- a/backends/keymapper/hardware-key.h +++ b/backends/keymapper/hardware-key.h @@ -64,6 +64,29 @@ struct HardwareKey { } }; +/** +* Describes an available hardware modifier +*/ +struct HardwareMod { + /** unique id used for saving/loading to config */ + char hwModId[HWKEY_ID_SIZE]; + + /** Human readable description */ + String description; + + /** + * The modifier flags that are generated by the + * back-end when this modifier key is pressed. + */ + byte modFlags; + + HardwareMod(const char *i, byte mf, String desc = "") + : modFlags(mf), description(desc) { + assert(i); + strncpy(hwModId, i, HWKEY_ID_SIZE); + } +}; + /** * Simple class to encapsulate a device's set of HardwareKeys. @@ -80,6 +103,11 @@ public: delete *it; } + void addHardwareMod(HardwareMod *mod) { + checkForMod(mod); + _mods.push_back(mod); + } + void addHardwareKey(HardwareKey *key) { checkForKey(key); _keys.push_back(key); @@ -127,7 +155,19 @@ private: } } + void checkForMod(HardwareMod *mod) { + List<const HardwareMod*>::iterator it; + + for (it = _mods.begin(); it != _mods.end(); it++) { + if (strncmp((*it)->hwModId, mod->hwModId, HWKEY_ID_SIZE) == 0) + error("Error adding HardwareMod '%s' - id of %s already in use!", mod->description.c_str(), mod->hwModId); + else if ((*it)->modFlags == mod->modFlags) + error("Error adding HardwareMod '%s' - modFlags already in use!", mod->description.c_str()); + } + } + List<const HardwareKey*> _keys; + List<const HardwareMod*> _mods; }; |
