Orxonox  0.0.5 Codename: Arcturus
OISMouse.h
Go to the documentation of this file.
1 /*
2 The zlib/libpng License
3 
4 Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
5 
6 This software is provided 'as-is', without any express or implied warranty. In no event will
7 the authors be held liable for any damages arising from the use of this software.
8 
9 Permission is granted to anyone to use this software for any purpose, including commercial
10 applications, and to alter it and redistribute it freely, subject to the following
11 restrictions:
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_Mouse_H
24 #define OIS_Mouse_H
25 #include "OISObject.h"
26 #include "OISEvents.h"
27 
28 namespace OIS
29 {
32  {
35  };
36 
42  {
43  public:
44  MouseState() : width(50), height(50), buttons(0) {};
45 
49  mutable int width, height;
50 
53 
56 
59 
61  int buttons;
62 
64  inline bool buttonDown( MouseButtonID button ) const
65  {
66  return ((buttons & ( 1L << button )) == 0) ? false : true;
67  }
68 
70  void clear()
71  {
72  X.clear();
73  Y.clear();
74  Z.clear();
75  buttons = 0;
76  }
77  };
78 
81  {
82  public:
83  MouseEvent( Object *obj, const MouseState &ms ) : EventArg(obj), state(ms) {}
84  virtual ~MouseEvent() {}
85 
87  const MouseState &state;
88  };
89 
95  {
96  public:
97  virtual ~MouseListener() {}
98  virtual bool mouseMoved( const MouseEvent &arg ) = 0;
99  virtual bool mousePressed( const MouseEvent &arg, MouseButtonID id ) = 0;
100  virtual bool mouseReleased( const MouseEvent &arg, MouseButtonID id ) = 0;
101  };
102 
107  class _OISExport Mouse : public Object
108  {
109  public:
110  virtual ~Mouse() {}
111 
119  virtual void setEventCallback( MouseListener *mouseListener ) {mListener = mouseListener;}
120 
122  MouseListener* getEventCallback() const {return mListener;}
123 
125  const MouseState& getMouseState() const { return mState; }
126 
127  protected:
128  Mouse(const std::string &vendor, bool buffered, int devID, InputManager* creator)
129  : Object(vendor, OISMouse, buffered, devID, creator), mListener(0) {}
130 
133 
136  };
137 }
138 #endif
Axis X
X Axis component.
Definition: OISMouse.h:52
Base class of all events.
Definition: OISEvents.h:32
#define _OISExport
Definition: OISPrereqs.h:40
MouseListener * getEventCallback() const
Definition: OISMouse.h:122
Definition: OISPrereqs.h:142
Mouse(const std::string &vendor, bool buffered, int devID, InputManager *creator)
Definition: OISMouse.h:128
::std::string string
Definition: gtest-port.h:756
Definition: OISMouse.h:34
To recieve buffered mouse input, derive a class from this, and implement the methods here...
Definition: OISMouse.h:94
Represents the state of the mouse All members are valid for both buffered and non buffered mode...
Definition: OISMouse.h:41
Definition: OISMouse.h:34
Definition: OISMouse.h:33
MouseButtonID
Button ID for mouse devices.
Definition: OISMouse.h:31
virtual ~MouseListener()
Definition: OISMouse.h:97
MouseEvent(Object *obj, const MouseState &ms)
Definition: OISMouse.h:83
Mouse base class.
Definition: OISMouse.h:107
virtual void setEventCallback(MouseListener *mouseListener)
Definition: OISMouse.h:119
Definition: OISMouse.h:34
Definition: InputPrereqs.h:96
virtual ~Mouse()
Definition: OISMouse.h:110
int width
Represents the height/width of your display area.
Definition: OISMouse.h:44
Definition: OISMouse.h:33
The base class of all input types.
Definition: OISObject.h:32
const MouseState & state
The state of the mouse - including buttons and axes.
Definition: OISMouse.h:87
virtual ~MouseEvent()
Definition: OISMouse.h:84
Axis Z
Z Axis Component.
Definition: OISMouse.h:58
bool buttonDown(MouseButtonID button) const
Button down test.
Definition: OISMouse.h:64
Definition: OISMouse.h:34
void clear()
Clear all the values.
Definition: OISMouse.h:70
MouseListener * mListener
Used for buffered/actionmapping callback.
Definition: OISMouse.h:135
Definition: OISMouse.h:34
Base Manager class.
Definition: OISInputManager.h:38
Axis component.
Definition: OISPrereqs.h:185
Definition: OISMouse.h:33
Specialised for mouse events.
Definition: OISMouse.h:80
Definition: EventHelpers.h:31
void clear()
Used internally by OIS.
Definition: OISPrereqs.h:197
const MouseState & getMouseState() const
Definition: OISMouse.h:125
Axis Y
Y Axis Component.
Definition: OISMouse.h:55
MouseState mState
The state of the mouse.
Definition: OISMouse.h:132
int buttons
represents all buttons - bit position indicates button down
Definition: OISMouse.h:61