aboutsummaryrefslogtreecommitdiff
path: root/backends/common/keymap.h
diff options
context:
space:
mode:
authorStephen Kennedy2008-07-24 10:00:56 +0000
committerStephen Kennedy2008-07-24 10:00:56 +0000
commitdfcdbb0d335128c99d13ba017a4e36f2338f7736 (patch)
tree727f48a0e5e589229788b0c42b0a73cafd31b39e /backends/common/keymap.h
parent2f064da1021344f28c9106285475c72930638390 (diff)
downloadscummvm-rg350-dfcdbb0d335128c99d13ba017a4e36f2338f7736.tar.gz
scummvm-rg350-dfcdbb0d335128c99d13ba017a4e36f2338f7736.tar.bz2
scummvm-rg350-dfcdbb0d335128c99d13ba017a4e36f2338f7736.zip
KeymapManager - implemented loading/saving of keymaps
- Refactoring of code to map a key to a UserAction - now we call a method on UserAction to do it (and it then tells the Keymap class) - General cleanup of code svn-id: r33262
Diffstat (limited to 'backends/common/keymap.h')
-rw-r--r--backends/common/keymap.h42
1 files changed, 21 insertions, 21 deletions
diff --git a/backends/common/keymap.h b/backends/common/keymap.h
index 5197e86b48..d9bc8f08df 100644
--- a/backends/common/keymap.h
+++ b/backends/common/keymap.h
@@ -1,15 +1,16 @@
#ifndef COMMON_KEYMAP
#define COMMON_KEYMAP
-#include "backends/common/hardware-key.h"
-#include "backends/common/user-action.h"
#include "common/array.h"
#include "common/keyboard.h"
#include "common/func.h"
#include "common/hashmap.h"
+#include "backends/common/user-action.h"
namespace Common {
+struct HardwareKey;
+
/**
* Hash function for KeyState
*/
@@ -34,30 +35,14 @@ public:
* adding it at the back of the internal array
* @param action the UserAction to add
*/
- void addAction(const UserAction& action);
-
- /**
- * Maps a HardwareKey to the given UserAction
- * @param action must point to a UserAction in this Keymap
- * @param key pointer to HardwareKey to map
- * @note if action does not point to a UserAction in this Keymap a
- * fatal error will occur
- */
- void mapKeyToAction(UserAction *action, HardwareKey *key);
-
- /**
- * 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(int32 id, HardwareKey *key);
+ void addAction(UserAction& action);
/**
* 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;
+ UserAction *getUserAction(int32 id);
/**
* Get a read-only array of all the UserActions contained in this Keymap
@@ -72,7 +57,22 @@ public:
UserAction *getMappedAction(const KeyState& ks) const;
private:
-
+ friend struct UserAction;
+ /**
+ * Registers a HardwareKey to the given UserAction
+ * @param action UserAction in this Keymap
+ * @param key pointer to HardwareKey to map
+ * @see UserAction::mapKey
+ */
+ void registerMapping(UserAction *action, const HardwareKey *key);
+
+ /**
+ * Unregisters a HardwareKey from the given UserAction (if one is mapped)
+ * @param action UserAction in this Keymap
+ * @see UserAction::mapKey
+ */
+ void unregisterMapping(UserAction *action);
+
UserAction *findUserAction(int32 id);
const UserAction *findUserAction(int32 id) const;