From 250acd4c8d345301c1b7e831c3c0f485c77d8ac7 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Wed, 21 Jan 2009 02:02:55 +0000 Subject: more cleanup svn-id: r35971 --- backends/keymapper/hardware-key.h | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'backends/keymapper/hardware-key.h') 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::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::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 getHardwareKeys() const { + const List &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::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 _keys; - uint _count; }; -- cgit v1.2.3