summaryrefslogtreecommitdiff
path: root/src/touchmanager.h
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-11-14 16:55:35 +0300
committerAndrei Karas <akaras@inbox.ru>2012-11-14 18:37:50 +0300
commit13642a6cddd8657ec84a2bfa94c6ac7d34545dba (patch)
treecefec154fe5b6ec59990c4ef5cfe67eba4a484e6 /src/touchmanager.h
parenteaaafe3312a361e332d495ee68451e424d90a19d (diff)
downloadplus-13642a6cddd8657ec84a2bfa94c6ac7d34545dba.tar.gz
plus-13642a6cddd8657ec84a2bfa94c6ac7d34545dba.tar.bz2
plus-13642a6cddd8657ec84a2bfa94c6ac7d34545dba.tar.xz
plus-13642a6cddd8657ec84a2bfa94c6ac7d34545dba.zip
Add support for on screen joystick for moving.
Diffstat (limited to 'src/touchmanager.h')
-rw-r--r--src/touchmanager.h28
1 files changed, 25 insertions, 3 deletions
diff --git a/src/touchmanager.h b/src/touchmanager.h
index 97d7d5625..ae25d9a8c 100644
--- a/src/touchmanager.h
+++ b/src/touchmanager.h
@@ -34,18 +34,21 @@
typedef void (*TouchFuncPtr) (const gcn::MouseInput &mouseInput);
+const int actionsSize = 10;
+
struct TouchItem final
{
TouchItem(const gcn::Rectangle rect0, Image *const img, int x0, int y0,
TouchFuncPtr ptrAll, TouchFuncPtr ptrPressed,
- TouchFuncPtr ptrReleased) :
+ TouchFuncPtr ptrReleased, TouchFuncPtr ptrOut) :
rect(rect0),
image(img),
x(x0),
y(y0),
funcAll(ptrAll),
funcPressed(ptrPressed),
- funcReleased(ptrReleased)
+ funcReleased(ptrReleased),
+ funcOut(ptrOut)
{
}
@@ -58,6 +61,7 @@ struct TouchItem final
TouchFuncPtr funcAll;
TouchFuncPtr funcPressed;
TouchFuncPtr funcReleased;
+ TouchFuncPtr funcOut;
};
typedef std::vector<TouchItem*> TouchItemVector;
@@ -74,15 +78,33 @@ class TouchManager final
void init();
+ void loadTouchItem(TouchItem **item, std::string name, bool type,
+ TouchFuncPtr fAll, TouchFuncPtr fPressed,
+ TouchFuncPtr fReleased, TouchFuncPtr fOut);
+
void clear();
+ void unloadTouchItem(TouchItem **item0);
+
void draw();
+ void drawTouchItem(const TouchItem *const item) const;
+
bool processEvent(const gcn::MouseInput &mouseInput);
+ bool isActionActive(const int index) const;
+
+ void setActionActive(const int index, const bool value)
+ {
+ if (index >= 0 && index < actionsSize)
+ mActions[index] = value;
+ }
+
private:
+ TouchItem *mKeyboard;
+ TouchItem *mPad;
TouchItemVector mObjects;
-// std::map <std::string, int> mNameToRect;
+ bool mActions[actionsSize];
};
extern TouchManager touchManager;