diff options
author | Max Horn | 2009-01-21 02:02:55 +0000 |
---|---|---|
committer | Max Horn | 2009-01-21 02:02:55 +0000 |
commit | 250acd4c8d345301c1b7e831c3c0f485c77d8ac7 (patch) | |
tree | d1b7a9f4221a4b59bd7e75d464eb410c0ba23ac2 /backends/keymapper/hardware-key.h | |
parent | 9abce1b894b9b3b551fbae91395d0449f9aafa08 (diff) | |
download | scummvm-rg350-250acd4c8d345301c1b7e831c3c0f485c77d8ac7.tar.gz scummvm-rg350-250acd4c8d345301c1b7e831c3c0f485c77d8ac7.tar.bz2 scummvm-rg350-250acd4c8d345301c1b7e831c3c0f485c77d8ac7.zip |
more cleanup
svn-id: r35971
Diffstat (limited to 'backends/keymapper/hardware-key.h')
-rw-r--r-- | backends/keymapper/hardware-key.h | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/backends/keymapper/hardware-key.h b/backends/keymapper/hardware-key.h index 55cdf3089c..c89c395d33 100644 --- a/backends/keymapper/hardware-key.h +++ b/backends/keymapper/hardware-key.h @@ -36,14 +36,17 @@ namespace Common { #define HWKEY_ID_SIZE (4) + /** * Describes an available hardware key */ struct HardwareKey { /** unique id used for saving/loading to config */ - char id[HWKEY_ID_SIZE]; + char hwKeyId[HWKEY_ID_SIZE]; + /** Human readable description */ String description; + /** * The KeyState that is generated by the back-end * when this hardware key is pressed. @@ -57,20 +60,19 @@ struct HardwareKey { KeyType typ = kGenericKeyType, ActionType prefAct = kGenericActionType) : key(ky), description(desc), type(typ), preferredAction(prefAct) { assert(i); - strncpy(id, i, HWKEY_ID_SIZE); + strncpy(hwKeyId, i, HWKEY_ID_SIZE); } }; /** * Simple class to encapsulate a device's set of HardwareKeys. - * Each device should extend this and call addHardwareKey a number of times + * Each device should instantiate this and call addHardwareKey a number of times * in its constructor to define the device's available keys. */ class HardwareKeySet { public: - HardwareKeySet() : _count(0) {} virtual ~HardwareKeySet() { List<const HardwareKey*>::iterator it; for (it = _keys.begin(); it != _keys.end(); it++) @@ -80,13 +82,12 @@ public: void addHardwareKey(HardwareKey *key) { checkForKey(key); _keys.push_back(key); - ++_count; } const HardwareKey *findHardwareKey(const char *id) const { List<const HardwareKey*>::iterator it; for (it = _keys.begin(); it != _keys.end(); it++) { - if (strncmp((*it)->id, id, HWKEY_ID_SIZE) == 0) + if (strncmp((*it)->hwKeyId, id, HWKEY_ID_SIZE) == 0) return (*it); } return 0; @@ -101,12 +102,12 @@ public: return 0; } - List<const HardwareKey*> getHardwareKeys() const { + const List<const HardwareKey*> &getHardwareKeys() const { return _keys; } - uint count() const { - return _count; + uint size() const { + return _keys.size(); } @@ -115,15 +116,14 @@ private: void checkForKey(HardwareKey *key) { List<const HardwareKey*>::iterator it; for (it = _keys.begin(); it != _keys.end(); it++) { - if (strncmp((*it)->id, key->id, HWKEY_ID_SIZE) == 0) - error("Error adding HardwareKey '%s' - id of %s already in use!", key->description.c_str(), key->id); + if (strncmp((*it)->hwKeyId, key->hwKeyId, HWKEY_ID_SIZE) == 0) + error("Error adding HardwareKey '%s' - id of %s already in use!", key->description.c_str(), key->hwKeyId); else if ((*it)->key == key->key) error("Error adding HardwareKey '%s' - key already in use!", key->description.c_str()); } } List<const HardwareKey*> _keys; - uint _count; }; |