OIS  1.5
Object-oriented Input System
OISPrereqs.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_Prereqs_H
24 #define OIS_Prereqs_H
25 //----------------------------------------------------------------------------//
26 // This Header File contains: forward declared classes
27 // * Forward Declarations of all public API classes
28 // * Several typedef's used around the library
29 // * Base class component types
30 // * Preprocessor definitons
31 //----------------------------------------------------------------------------//
32 
33 //-------------- Common STL Containers ---------------------------------------//
34 #include <vector>
35 #include <string>
36 #include <map>
37 #include "OISConfig.h"
38 
39 // Default is blank for most OS's
40 #define _OISExport
41 
42 //-------------- Determine Compiler ---------------------------------
43 #if defined( _MSC_VER )
44 # define OIS_MSVC_COMPILER
45 #elif defined( __GNUC__ )
46 # if defined( __WIN32__ ) || defined( _WIN32 )
47 # define OIS_MINGW_COMPILER
48 # else
49 # define OIS_GCC_COMPILER
50 # endif
51 #elif defined( __BORLANDC__ )
52 # define OIS_BORLAND_COMPILER
53 #else
54 # error No Recognized Compiler!
55 #endif
56 
57 // --------------- Determine Operating System Platform ---------------
58 #if defined( __WIN32__ ) || defined( _WIN32 ) // Windows 2000, XP, ETC
59 # if defined ( _XBOX )
60 # define OIS_XBOX_PLATFORM
61 # else
62 # define OIS_WIN32_PLATFORM
63 # if defined( OIS_DYNAMIC_LIB )
64 # undef _OISExport
65  //Ignorable Dll interface warning...
66 # if !defined(OIS_MINGW_COMPILER)
67 # pragma warning (disable : 4251)
68 # endif
69 # if defined( OIS_NONCLIENT_BUILD )
70 # define _OISExport __declspec( dllexport )
71 # else
72 # if defined(OIS_MINGW_COMPILER)
73 # define _OISExport
74 # else
75 # define _OISExport __declspec( dllimport )
76 # endif
77 # endif
78 # endif
79 # endif
80 #elif defined( __APPLE_CC__ ) // Apple OS X
81  // Device Simulator
82 # if __IPHONE_OS_VERSION_MIN_REQUIRED >= 20201 || __IPHONE_OS_VERSION_MIN_REQUIRED >= 20000
83 //# if __IPHONE_OS_VERSION_MIN_REQUIRED >= 30000 || __IPHONE_OS_VERSION_MIN_REQUIRED >= 30000
84 # define OIS_IPHONE_PLATFORM
85 # else
86 # define OIS_APPLE_PLATFORM
87 # endif
88 # undef _OISExport
89 # define _OISExport __attribute__((visibility("default")))
90 #else //Probably Linux
91 # define OIS_LINUX_PLATFORM
92 # include <unistd.h>
93 #endif
94 
95 //Is Processor 32 or 64 bits...
96 #if defined(__x86_64__)
97 # define OIS_ARCH_64
98 #else
99 # define OIS_ARCH_32
100 #endif
101 
102 //-------------- Various helper preprocessor definitions ---------------------//
103 
104 #ifdef OIS_MSVC_COMPILER
105 # define OIS_INLINE_PRAGMA(x) __pragma(x) // x is intentionally not wrapped; __pragma rejects expressions beginning with '('.
106 #else
107 # define OIS_INLINE_PRAGMA(x)
108 #endif
109 
110 #define OIS_MACRO_BEGIN do {
111 
112 #define OIS_MACRO_END \
113  } OIS_INLINE_PRAGMA(warning(push)) OIS_INLINE_PRAGMA(warning(disable:4127)) while (0) OIS_INLINE_PRAGMA(warning(pop))
114 
115 // This creative trickery taken from this StackOverflow answer:
116 // http://stackoverflow.com/questions/4030959/will-a-variablename-c-statement-be-a-no-op-at-all-times/4030983#4030983
117 #define OIS_UNUSED(x)\
118  OIS_MACRO_BEGIN\
119  ((void)(true ? 0 : ((x), void(), 0)));\
120  OIS_MACRO_END
121 
122 //-------------- Common Classes, Enums, and Typdef's -------------------------//
123 #define OIS_VERSION_MAJOR 1
124 #define OIS_VERSION_MINOR 5
125 #define OIS_VERSION_PATCH 0
126 #define OIS_VERSION_NAME "1.5.0"
127 
128 #define OIS_VERSION ((OIS_VERSION_MAJOR << 16) | (OIS_VERSION_MINOR << 8) | OIS_VERSION_PATCH)
129 
130 namespace OIS
131 {
132  //Forward Declarations
133  class InputManager;
134  class FactoryCreator;
135  class Object;
136  class Keyboard;
137  class Mouse;
138  class JoyStick;
139  class MultiTouch;
140  class KeyListener;
141  class MouseListener;
142  class MultiTouchListener;
143  class JoyStickListener;
144  class Interface;
145  class ForceFeedback;
146  class Effect;
147  class Exception;
148 
150  typedef std::multimap<std::string, std::string> ParamList;
151 
153  typedef std::vector<FactoryCreator*> FactoryList;
154 
156  typedef std::map<Object*, FactoryCreator*> FactoryCreatedObject;
157 
159  enum Type
160  {
163  OISMouse = 2,
167  };
168 
170  typedef std::multimap<Type, std::string> DeviceList;
171 
172  //-------- Shared common components ------------------------//
173 
176  {
178  OIS_Button = 1, //ie. Key, mouse button, joy button, etc
179  OIS_Axis = 2, //ie. A joystick or mouse axis
180  OIS_Slider = 3, //
181  OIS_POV = 4, //ie. Arrow direction keys
182  OIS_Vector3 = 5 //ie. WiiMote orientation
183  };
184 
187  {
188  public:
189  Component() : cType(OIS_Unknown) {};
190  explicit Component(ComponentType type) : cType(type) {};
192  ComponentType cType;
193  };
194 
196  class _OISExport Button : public Component
197  {
198  public:
199  Button() : Component(OIS_Button), pushed(false) {}
200  explicit Button(bool bPushed) : Component(OIS_Button), pushed(bPushed) {}
202  bool pushed;
203  };
204 
206  class _OISExport Axis : public Component
207  {
208  public:
209  Axis() : Component(OIS_Axis), abs(0), rel(0), absOnly(false) {};
210 
212  int abs, rel;
213 
215  bool absOnly;
216 
218  void clear()
219  {
220  abs = rel = 0;
221  }
222  };
223 
225  class _OISExport Vector3 : public Component
226  {
227  public:
228  Vector3() {}
229  Vector3(float _x, float _y, float _z) : Component(OIS_Vector3), x(_x), y(_y), z(_z) {};
230 
232  float x;
233 
235  float y;
236 
238  float z;
239 
240  void clear()
241  {
242  x = y = z = 0.0f;
243  }
244  };
245 }
246 
247 #endif //end if prereq header defined
Definition: OISPrereqs.h:181
Button()
Definition: OISPrereqs.h:199
#define _OISExport
Definition: OISPrereqs.h:40
A 3D Vector component (perhaps an orientation, as in the WiiMote)
Definition: OISPrereqs.h:225
Definition: OISPrereqs.h:163
ComponentType
Base type for all device components (button, axis, etc)
Definition: OISPrereqs.h:175
Definition: OISPrereqs.h:178
Definition: OISPrereqs.h:165
Definition: OISPrereqs.h:177
Definition: OISPrereqs.h:166
void clear()
Definition: OISPrereqs.h:240
Definition: OISException.h:55
Definition: OISPrereqs.h:180
Button(bool bPushed)
Definition: OISPrereqs.h:200
Base of all device components (button, axis, etc)
Definition: OISPrereqs.h:186
bool absOnly
Indicates if this Axis only supports Absoulte (ie JoyStick)
Definition: OISPrereqs.h:215
std::map< Object *, FactoryCreator * > FactoryCreatedObject
Map of FactoryCreator created Objects.
Definition: OISPrereqs.h:156
bool pushed
true if pushed, false otherwise
Definition: OISPrereqs.h:202
Definition: OISPrereqs.h:182
std::vector< FactoryCreator * > FactoryList
List of FactoryCreator&#39;s.
Definition: OISPrereqs.h:153
float z
Z component of vector.
Definition: OISPrereqs.h:238
Type
Each Input class has a General Type variable, a form of RTTI.
Definition: OISPrereqs.h:159
Definition: OISPrereqs.h:162
Definition: OISPrereqs.h:164
Definition: OISPrereqs.h:161
Axis component.
Definition: OISPrereqs.h:206
std::multimap< Type, std::string > DeviceList
Map of device objects connected and their respective vendors.
Definition: OISPrereqs.h:170
Definition: OISEffect.h:28
Definition: OISPrereqs.h:179
Vector3()
Definition: OISPrereqs.h:228
float y
Y component of vector.
Definition: OISPrereqs.h:235
void clear()
Used internally by OIS.
Definition: OISPrereqs.h:218
Component()
Definition: OISPrereqs.h:189
std::multimap< std::string, std::string > ParamList
Way to send OS nuetral parameters.. ie OS Window handles, modes, flags.
Definition: OISPrereqs.h:147
Button can be a keyboard key, mouse button, etc.
Definition: OISPrereqs.h:196