From 13642a6cddd8657ec84a2bfa94c6ac7d34545dba Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Wed, 14 Nov 2012 16:55:35 +0300 Subject: Add support for on screen joystick for moving. --- src/touchmanager.h | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) (limited to 'src/touchmanager.h') 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 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 mNameToRect; + bool mActions[actionsSize]; }; extern TouchManager touchManager; -- cgit v1.2.3-60-g2f50