summaryrefslogtreecommitdiff
path: root/src/inputmanager.h
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-04-08 19:41:19 +0300
committerAndrei Karas <akaras@inbox.ru>2012-04-08 19:41:19 +0300
commit30ef016b0a14f36dc480284e2d775295b5501dd4 (patch)
treea269c0983efb8dc9160bfe10b1dba26a302aff0c /src/inputmanager.h
parent25a6eae7f4fb561bbf930be28ee09510b40ebc80 (diff)
downloadmanaplus-30ef016b0a14f36dc480284e2d775295b5501dd4.tar.gz
manaplus-30ef016b0a14f36dc480284e2d775295b5501dd4.tar.bz2
manaplus-30ef016b0a14f36dc480284e2d775295b5501dd4.tar.xz
manaplus-30ef016b0a14f36dc480284e2d775295b5501dd4.zip
Move most input code from keyboardconfig to inputmanager.
Diffstat (limited to 'src/inputmanager.h')
-rw-r--r--src/inputmanager.h84
1 files changed, 83 insertions, 1 deletions
diff --git a/src/inputmanager.h b/src/inputmanager.h
index 635e27a33..b04f15726 100644
--- a/src/inputmanager.h
+++ b/src/inputmanager.h
@@ -21,13 +21,44 @@
#ifndef INPUTMANAGER_H
#define INPUTMANAGER_H
+#include "keydata.h"
+
#include "gui/sdlinput.h"
#include <string>
#include <map>
+#define KeyFunctionSize 3
+
struct KeyData;
-//struct KeyFunction;
+
+class Setup_Keyboard;
+
+enum KeyTypes
+{
+ INPUT_UNKNOWN = 0,
+ INPUT_KEYBOARD = 1,
+ INPUT_MOUSE = 2,
+ INPUT_JOYSTICK = 3
+};
+
+struct KeyItem
+{
+ KeyItem() : type(-1), value(-1)
+ { }
+
+ KeyItem(int type0, int value0) : type(type0), value(value0)
+ { }
+
+ int type;
+
+ int value;
+};
+
+struct KeyFunction
+{
+ KeyItem values[KeyFunctionSize];
+};
enum KeyCondition
{
@@ -51,6 +82,8 @@ class InputManager
public:
InputManager();
+ void init();
+
bool handleEvent(const SDL_Event &event);
bool handleKeyEvent(const SDL_Event &event);
@@ -58,6 +91,55 @@ class InputManager
int getInputConditionMask();
bool checkKey(const KeyData *key, int mask);
+
+ void retrieve();
+
+ void store();
+
+ void makeDefault();
+
+ bool hasConflicts(int &key1, int &key2);
+
+ void callbackNewKey();
+
+ KeyFunction &getKey(int index);
+
+ std::string getKeyValueString(int index) const;
+
+ std::string getKeyStringLong(int index) const;
+
+ void addActionKey(int action, int type, int val);
+
+ void setNewKey(const SDL_Event &event);
+
+ void unassignKey();
+
+ bool isActionActive(int index) const;
+
+ /**
+ * Set the index of the new key to be assigned.
+ */
+ void setNewKeyIndex(int value)
+ { mNewKeyIndex = value; }
+
+ /**
+ * Set a reference to the key setup window.
+ */
+ void setSetupKeyboard(Setup_Keyboard *setupKey)
+ { mSetupKey = setupKey; }
+
+ /**
+ * Get the index of the new key to be assigned.
+ */
+ int getNewKeyIndex() const
+ { return mNewKeyIndex; }
+
+ protected:
+ Setup_Keyboard *mSetupKey; /**< Reference to setup window */
+
+ int mNewKeyIndex; /**< Index of new key to be assigned */
+
+ KeyFunction mKey[Input::KEY_TOTAL]; /**< Pointer to all the key data */
};
extern InputManager inputManager;