OIS  1.5
Object-oriented Input System
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  MB_Left = 0,
40  };
41 
47  {
48  public:
50  width(50), height(50), buttons(0){};
51 
55  mutable int width, height;
56 
59 
62 
65 
67  int buttons;
68 
70  inline bool buttonDown(MouseButtonID button) const
71  {
72  return ((buttons & (1L << button)) == 0) ? false : true;
73  }
74 
76  void clear()
77  {
78  X.clear();
79  Y.clear();
80  Z.clear();
81  buttons = 0;
82  }
83  };
84 
87  {
88  public:
89  MouseEvent(Object* obj, const MouseState& ms) :
90  EventArg(obj), state(ms) {}
91  virtual ~MouseEvent() {}
92 
94  const MouseState& state;
95 
96  private:
97  // Prevent copying.
98  MouseEvent(const MouseEvent&);
99  MouseEvent& operator=(MouseEvent);
100  };
101 
107  {
108  public:
109  virtual ~MouseListener() {}
110  virtual bool mouseMoved(const MouseEvent& arg) = 0;
111  virtual bool mousePressed(const MouseEvent& arg, MouseButtonID id) = 0;
112  virtual bool mouseReleased(const MouseEvent& arg, MouseButtonID id) = 0;
113  };
114 
119  class _OISExport Mouse : public Object
120  {
121  public:
122  virtual ~Mouse() {}
123 
131  virtual void setEventCallback(MouseListener* mouseListener) { mListener = mouseListener; }
132 
134  MouseListener* getEventCallback() const { return mListener; }
135 
137  const MouseState& getMouseState() const { return mState; }
138 
139  protected:
140  Mouse(const std::string& vendor, bool buffered, int devID, InputManager* creator) :
141  Object(vendor, OISMouse, buffered, devID, creator), mListener(0) {}
142 
145 
148  };
149 }
150 #endif
Axis X
X Axis component.
Definition: OISMouse.h:58
Definition: OISEvents.h:32
#define _OISExport
Definition: OISPrereqs.h:40
MouseState()
Definition: OISMouse.h:49
Definition: OISPrereqs.h:163
Mouse(const std::string &vendor, bool buffered, int devID, InputManager *creator)
Definition: OISMouse.h:140
bool buttonDown(MouseButtonID button) const
Button down test.
Definition: OISMouse.h:70
Definition: OISMouse.h:35
Definition: OISMouse.h:106
Definition: OISMouse.h:46
Definition: OISMouse.h:37
Definition: OISMouse.h:34
MouseButtonID
Button ID for mouse devices.
Definition: OISMouse.h:31
virtual ~MouseListener()
Definition: OISMouse.h:109
MouseEvent(Object *obj, const MouseState &ms)
Definition: OISMouse.h:89
Definition: OISMouse.h:119
virtual void setEventCallback(MouseListener *mouseListener)
Definition: OISMouse.h:131
Definition: OISMouse.h:36
MouseListener * getEventCallback() const
Definition: OISMouse.h:134
virtual ~Mouse()
Definition: OISMouse.h:122
Definition: OISMouse.h:32
Definition: OISObject.h:32
const MouseState & state
The state of the mouse - including buttons and axes.
Definition: OISMouse.h:94
virtual ~MouseEvent()
Definition: OISMouse.h:91
Axis Z
Z Axis Component.
Definition: OISMouse.h:64
Definition: OISMouse.h:39
void clear()
Clear all the values.
Definition: OISMouse.h:76
MouseListener * mListener
Used for buffered/actionmapping callback.
Definition: OISMouse.h:147
Definition: OISMouse.h:38
const MouseState & getMouseState() const
Definition: OISMouse.h:137
Definition: OISInputManager.h:38
Axis component.
Definition: OISPrereqs.h:206
Definition: OISMouse.h:33
Definition: OISMouse.h:86
Definition: OISEffect.h:28
void clear()
Used internally by OIS.
Definition: OISPrereqs.h:218
Axis Y
Y Axis Component.
Definition: OISMouse.h:61
MouseState mState
The state of the mouse.
Definition: OISMouse.h:144
int buttons
represents all buttons - bit position indicates button down
Definition: OISMouse.h:67