Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/sagerjFS16/src/external/ois/OISMultiTouch.h @ 11851

Last change on this file since 11851 was 8351, checked in by rgrieder, 14 years ago

Merged kicklib2 branch back to trunk (includes former branches ois_update, mac_osx and kicklib).

Notes for updating

Linux:
You don't need an extra package for CEGUILua and Tolua, it's already shipped with CEGUI.
However you do need to make sure that the OgreRenderer is installed too with CEGUI 0.7 (may be a separate package).
Also, Orxonox now recognises if you install the CgProgramManager (a separate package available on newer Ubuntu on Debian systems).

Windows:
Download the new dependency packages versioned 6.0 and use these. If you have problems with that or if you don't like the in game console problem mentioned below, you can download the new 4.3 version of the packages (only available for Visual Studio 2005/2008).

Key new features:

  • *Support for Mac OS X*
  • Visual Studio 2010 support
  • Bullet library update to 2.77
  • OIS library update to 1.3
  • Support for CEGUI 0.7 —> Support for Arch Linux and even SuSE
  • Improved install target
  • Compiles now with GCC 4.6
  • Ogre Cg Shader plugin activated for Linux if available
  • And of course lots of bug fixes

There are also some regressions:

  • No support for CEGUI 0.5, Ogre 1.4 and boost 1.35 - 1.39 any more
  • In game console is not working in main menu for CEGUI 0.7
  • Tolua (just the C lib, not the application) and CEGUILua libraries are no longer in our repository. —> You will need to get these as well when compiling Orxonox
  • And of course lots of new bugs we don't yet know about
  • Property svn:eol-style set to native
File size: 5.6 KB
Line 
1/*
2The zlib/libpng License
3
4Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
5
6This software is provided 'as-is', without any express or implied warranty. In no event will
7the authors be held liable for any damages arising from the use of this software.
8
9Permission is granted to anyone to use this software for any purpose, including commercial
10applications, and to alter it and redistribute it freely, subject to the following
11restrictions:
12
13    1. The origin of this software must not be misrepresented; you must not claim that
14                you wrote the original software. If you use this software in a product,
15                an acknowledgment in the product documentation would be appreciated but is
16                not required.
17
18    2. Altered source versions must be plainly marked as such, and must not be
19                misrepresented as being the original software.
20
21    3. This notice may not be removed or altered from any source distribution.
22*/
23#ifndef OIS_MultiTouch_H
24#define OIS_MultiTouch_H
25#include "OISObject.h"
26#include "OISEvents.h"
27
28#include <set>
29#include <vector>
30
31#define OIS_MAX_NUM_TOUCHES 4   // 4 finger touches are probably the highest we'll ever get
32
33namespace OIS
34{
35        /**
36                Represents the state of the multi-touch device
37                All members are valid for both buffered and non buffered mode
38        */
39   
40        //! Touch Event type
41        enum MultiTypeEventTypeID
42        {
43                MT_None = 0, MT_Pressed, MT_Released, MT_Moved, MT_Cancelled
44        };
45
46        class _OISExport MultiTouchState
47        {
48        public:
49                MultiTouchState() : width(50), height(50), touchType(MT_None) {};
50
51                /** Represents the height/width of your display area.. used if touch clipping
52                or touch grabbed in case of X11 - defaults to 50.. Make sure to set this
53                and change when your size changes.. */
54                mutable int width, height;
55
56                //! X Axis component
57                Axis X;
58
59                //! Y Axis Component
60                Axis Y;
61
62                //! Z Axis Component
63                Axis Z;
64
65        int touchType;
66
67        inline bool touchIsType( MultiTypeEventTypeID touch ) const
68                {
69                        return ((touchType & ( 1L << touch )) == 0) ? false : true;
70                }
71       
72                //! Clear all the values
73                void clear()
74                {
75                        X.clear();
76                        Y.clear();
77                        Z.clear();
78            touchType = MT_None;
79                }
80        };
81
82        /** Specialised for multi-touch events */
83        class _OISExport MultiTouchEvent : public EventArg
84        {
85        public:
86                MultiTouchEvent( Object *obj, const MultiTouchState &ms ) : EventArg(obj), state(ms) {}
87                virtual ~MultiTouchEvent() {}
88
89                //! The state of the touch - including axes
90                const MultiTouchState &state;
91        };
92
93        /**
94                To receive buffered touch input, derive a class from this, and implement the
95                methods here. Then set the call back to your MultiTouch instance with MultiTouch::setEventCallback
96        */
97        class _OISExport MultiTouchListener
98        {
99        public:
100                virtual ~MultiTouchListener() {}
101                virtual bool touchMoved( const MultiTouchEvent &arg ) = 0;
102                virtual bool touchPressed( const MultiTouchEvent &arg ) = 0;
103                virtual bool touchReleased( const MultiTouchEvent &arg ) = 0;
104                virtual bool touchCancelled( const MultiTouchEvent &arg ) = 0;
105        };
106
107        /**
108                MultiTouch base class. To be implemented by specific system (ie. iPhone UITouch)
109                This class is useful as you remain OS independent using this common interface.
110        */
111        class _OISExport MultiTouch : public Object
112        {
113        public:
114                virtual ~MultiTouch() {}
115
116                /**
117                @remarks
118                        Register/unregister a MultiTouch Listener - Only one allowed for simplicity. If broadcasting
119                        is necessary, just broadcast from the callback you registered.
120                @param touchListener
121                        Send a pointer to a class derived from MultiTouchListener or 0 to clear the callback
122                */
123                virtual void setEventCallback( MultiTouchListener *touchListener ) {mListener = touchListener;}
124
125                /** @remarks Returns currently set callback.. or 0 */
126                MultiTouchListener* getEventCallback() {return mListener;}
127
128                /** @remarks Clear out the set of input states.  Should be called after input has been processed by the application */
129        void clearStates(void) { mStates.clear(); }
130
131                /** @remarks Returns the state of the touch - is valid for both buffered and non buffered mode */
132                std::vector<MultiTouchState> getMultiTouchStates() const { return mStates; }
133       
134        /** @remarks Returns the first n touch states.  Useful if you know your app only needs to
135                process n touches.  The return value is a vector to allow random access */
136        const std::vector<MultiTouchState> getFirstNTouchStates(int n) {
137            std::vector<MultiTouchState> states;
138            for( unsigned int i = 0; i < mStates.size(); i++ ) {
139                if(!(mStates[i].touchIsType(MT_None))) {
140                    states.push_back(mStates[i]);
141                }
142            }
143            return states;
144        }
145
146        /** @remarks Returns the first n touch states.  Useful if you know your app only needs to
147         process n touches.  The return value is a vector to allow random access */
148        const std::vector<MultiTouchState> getMultiTouchStatesOfType(MultiTypeEventTypeID type) {
149            std::vector<MultiTouchState> states;
150            for( unsigned int i = 0; i < mStates.size(); i++ ) {
151                if(mStates[i].touchIsType(type)) {
152                    states.push_back(mStates[i]);
153                }
154            }
155            return states;
156        }
157       
158        protected:
159                MultiTouch(const std::string &vendor, bool buffered, int devID, InputManager* creator)
160                        : Object(vendor, OISMultiTouch, buffered, devID, creator), mListener(0) {}
161
162                //! The state of the touch device, implemented in a vector to store the state from each finger touch
163        std::vector<MultiTouchState> mStates;
164
165                //! Used for buffered/actionmapping callback
166                MultiTouchListener *mListener;
167        };
168}
169#endif
Note: See TracBrowser for help on using the repository browser.