aboutsummaryrefslogtreecommitdiff
path: root/backends/common/keymap.h
diff options
context:
space:
mode:
authorStephen Kennedy2008-07-19 19:12:49 +0000
committerStephen Kennedy2008-07-19 19:12:49 +0000
commit0b8203b0e500bb448233b618edf45ba9e28fe738 (patch)
tree47730de6f9709d2deb1f15064ef41112d58e1d74 /backends/common/keymap.h
parent19345b5a624570dd673bdcaf86188e93110f0e5c (diff)
downloadscummvm-rg350-0b8203b0e500bb448233b618edf45ba9e28fe738.tar.gz
scummvm-rg350-0b8203b0e500bb448233b618edf45ba9e28fe738.tar.bz2
scummvm-rg350-0b8203b0e500bb448233b618edf45ba9e28fe738.zip
More WIP development of Keymap class
svn-id: r33113
Diffstat (limited to 'backends/common/keymap.h')
-rw-r--r--backends/common/keymap.h55
1 files changed, 31 insertions, 24 deletions
diff --git a/backends/common/keymap.h b/backends/common/keymap.h
index 75350a992b..c03e2e03d5 100644
--- a/backends/common/keymap.h
+++ b/backends/common/keymap.h
@@ -9,7 +9,6 @@
namespace Common {
-
enum UserActionType {
kGenericUserActionType,
@@ -39,18 +38,19 @@ enum UserActionCategory {
* Describes an available hardware key
*/
struct HardwareKey {
+ /** unique id used for saving/loading to config */
+ int32 id;
+ /** Human readable description */
+ String description;
/**
* The KeyState that is generated by the back-end
* when this hardware key is pressed.
*/
KeyState key;
- /** Human readable description */
- String description;
-
UserActionCategory preferredCategory;
UserActionType preferredType;
- int group;
+ int16 group;
HardwareKey(KeyState ks = KeyState(), String des = "",
UserActionCategory cat = kGenericUserActionCategory,
@@ -64,16 +64,20 @@ struct HardwareKey {
};
struct UserAction {
- /** Events to be sent when mapped key is pressed */
- List<Event> events;
+ /** unique id used for saving/loading to config */
+ int32 id;
/** Human readable description */
String description;
+ /** Events to be sent when mapped key is pressed */
+ List<Event> events;
UserActionCategory category;
UserActionType type;
int priority;
int group;
int flags;
+ HardwareKey *hwKey;
+
UserAction( String des = "",
UserActionCategory cat = kGenericUserActionCategory,
UserActionType ty = kGenericUserActionType,
@@ -84,17 +88,8 @@ struct UserAction {
priority = pr;
group = gr;
flags = fl;
- _hwKey = 0;
+ hwKey = 0;
}
-
- friend class Keymap;
-
- HardwareKey *mappedKey() { return _hwKey; }
-private:
- /**
- * Key that is mapped to this UserAction, only KeyMap can set this
- */
- HardwareKey *_hwKey;
};
/**
@@ -123,10 +118,12 @@ template<> struct Hash<KeyState>
class Keymap {
public:
-
- Keymap() {}
+ Keymap() { init(); }
Keymap(const Keymap& km);
+private:
+ void init();
+public:
/**
* Adds a new UserAction to this Map,
* adding it at the back of the internal array
@@ -144,25 +141,35 @@ public:
void mapKeyToAction(UserAction *action, HardwareKey *key);
/**
- * Maps a HardwareKey to the UserAction at the given index
- * @param index Index of UserAction in the internal array
+ * Maps a HardwareKey to the UserAction of the given id
+ * @param id id of the UserAction to map to
* @param key pointer to HardwareKey to map
*/
- void mapKeyToAction(uint index, HardwareKey *key);
+ void mapKeyToAction(int32 id, HardwareKey *key);
+
+ /**
+ * Retrieves the UserAction with the given id
+ * @param id id of UserAction to retrieve
+ * @return Pointer to the UserAction or 0 if not found
+ */
+ const UserAction *getUserAction(int32 id) const;
/**
* Get a read-only array of all the UserActions contained in this Keymap
*/
- const Array<UserAction>& getUserActions() { return _actions; }
+ const Array<UserAction>& getUserActions() const { return _actions; }
/**
* Find the UserAction that a key is mapped to
* @param key the key that is mapped to the required UserAction
* @return a pointer to the UserAction or 0 if no
*/
- UserAction *getMappedAction(KeyState key);
+ UserAction *getMappedAction(KeyState key) const;
private:
+
+ UserAction *findUserAction(int32 id);
+ const UserAction *findUserAction(int32 id) const;
void internalMapKey(UserAction *action, HardwareKey *hwKey);