diff options
author | Andrei Karas <akaras@inbox.ru> | 2012-11-14 16:55:35 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2012-11-14 18:37:50 +0300 |
commit | 13642a6cddd8657ec84a2bfa94c6ac7d34545dba (patch) | |
tree | cefec154fe5b6ec59990c4ef5cfe67eba4a484e6 /src/touchmanager.h | |
parent | eaaafe3312a361e332d495ee68451e424d90a19d (diff) | |
download | manaplus-13642a6cddd8657ec84a2bfa94c6ac7d34545dba.tar.gz manaplus-13642a6cddd8657ec84a2bfa94c6ac7d34545dba.tar.bz2 manaplus-13642a6cddd8657ec84a2bfa94c6ac7d34545dba.tar.xz manaplus-13642a6cddd8657ec84a2bfa94c6ac7d34545dba.zip |
Add support for on screen joystick for moving.
Diffstat (limited to 'src/touchmanager.h')
-rw-r--r-- | src/touchmanager.h | 28 |
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; |