| [1505] | 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 | 
|---|
| [7163] | 63 | #               if !defined( OIS_STATIC_LIB ) | 
|---|
| [1505] | 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 | 
|---|
| [8284] | 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"))) | 
|---|
| [1505] | 90 | #else //Probably Linux | 
|---|
 | 91 | #       define OIS_LINUX_PLATFORM | 
|---|
 | 92 | #endif | 
|---|
 | 93 |  | 
|---|
 | 94 | //Is Processor 32 or 64 bits... | 
|---|
 | 95 | #if defined(__x86_64__) | 
|---|
 | 96 | #       define OIS_ARCH_64 | 
|---|
 | 97 | #else | 
|---|
 | 98 | #       define OIS_ARCH_32 | 
|---|
 | 99 | #endif | 
|---|
 | 100 |  | 
|---|
 | 101 | //-------------- Common Classes, Enums, and Typdef's -------------------------// | 
|---|
 | 102 | #define OIS_VERSION_MAJOR 1 | 
|---|
| [8284] | 103 | #define OIS_VERSION_MINOR 3 | 
|---|
| [1505] | 104 | #define OIS_VERSION_PATCH 0 | 
|---|
| [8284] | 105 | #define OIS_VERSION_NAME "1.3.0" | 
|---|
| [1505] | 106 |  | 
|---|
 | 107 | #define OIS_VERSION ((OIS_VERSION_MAJOR << 16) | (OIS_VERSION_MINOR << 8) | OIS_VERSION_PATCH) | 
|---|
 | 108 |  | 
|---|
 | 109 | namespace OIS | 
|---|
 | 110 | { | 
|---|
 | 111 |         //Forward Declarations | 
|---|
 | 112 |         class InputManager; | 
|---|
 | 113 |         class FactoryCreator; | 
|---|
 | 114 |         class Object; | 
|---|
 | 115 |         class Keyboard; | 
|---|
 | 116 |         class Mouse; | 
|---|
 | 117 |         class JoyStick; | 
|---|
| [8284] | 118 |     class MultiTouch; | 
|---|
| [1505] | 119 |         class KeyListener; | 
|---|
 | 120 |         class MouseListener; | 
|---|
| [8284] | 121 |     class MultiTouchListener; | 
|---|
| [1505] | 122 |         class JoyStickListener; | 
|---|
 | 123 |         class Interface; | 
|---|
 | 124 |         class ForceFeedback; | 
|---|
 | 125 |         class Effect; | 
|---|
 | 126 |         class Exception; | 
|---|
 | 127 |  | 
|---|
 | 128 |         //! Way to send OS nuetral parameters.. ie OS Window handles, modes, flags | 
|---|
 | 129 |         typedef std::multimap<std::string, std::string> ParamList; | 
|---|
 | 130 |  | 
|---|
 | 131 |         //! List of FactoryCreator's | 
|---|
 | 132 |         typedef std::vector<FactoryCreator*> FactoryList; | 
|---|
 | 133 |  | 
|---|
 | 134 |         //! Map of FactoryCreator created Objects | 
|---|
 | 135 |         typedef std::map<Object*, FactoryCreator*> FactoryCreatedObject; | 
|---|
 | 136 |  | 
|---|
 | 137 |         //! Each Input class has a General Type variable, a form of RTTI | 
|---|
 | 138 |     enum Type | 
|---|
 | 139 |         { | 
|---|
| [8284] | 140 |                 OISUnknown       = 0, | 
|---|
 | 141 |                 OISKeyboard      = 1, | 
|---|
 | 142 |                 OISMouse         = 2, | 
|---|
 | 143 |                 OISJoyStick      = 3, | 
|---|
 | 144 |                 OISTablet        = 4, | 
|---|
 | 145 |                 OISMultiTouch    = 5 | 
|---|
| [1505] | 146 |         }; | 
|---|
 | 147 |  | 
|---|
 | 148 |         //! Map of device objects connected and their respective vendors | 
|---|
 | 149 |         typedef std::multimap<Type, std::string> DeviceList; | 
|---|
 | 150 |  | 
|---|
 | 151 |         //--------     Shared common components    ------------------------// | 
|---|
 | 152 |  | 
|---|
 | 153 |         //! Base type for all device components (button, axis, etc) | 
|---|
 | 154 |     enum ComponentType | 
|---|
 | 155 |         { | 
|---|
 | 156 |                 OIS_Unknown = 0, | 
|---|
 | 157 |                 OIS_Button  = 1, //ie. Key, mouse button, joy button, etc | 
|---|
 | 158 |                 OIS_Axis    = 2, //ie. A joystick or mouse axis | 
|---|
 | 159 |                 OIS_Slider  = 3, // | 
|---|
 | 160 |                 OIS_POV     = 4, //ie. Arrow direction keys | 
|---|
 | 161 |                 OIS_Vector3 = 5  //ie. WiiMote orientation | 
|---|
 | 162 |         }; | 
|---|
 | 163 |  | 
|---|
 | 164 |         //! Base of all device components (button, axis, etc) | 
|---|
 | 165 |         class _OISExport Component | 
|---|
 | 166 |         { | 
|---|
 | 167 |         public: | 
|---|
 | 168 |                 Component() : cType(OIS_Unknown) {}; | 
|---|
 | 169 |                 Component(ComponentType type) : cType(type) {}; | 
|---|
 | 170 |                 //! Indicates what type of coponent this is | 
|---|
 | 171 |                 ComponentType cType; | 
|---|
 | 172 |         }; | 
|---|
 | 173 |  | 
|---|
 | 174 |         //! Button can be a keyboard key, mouse button, etc | 
|---|
 | 175 |         class _OISExport Button : public Component | 
|---|
 | 176 |         { | 
|---|
 | 177 |         public: | 
|---|
| [5695] | 178 |                 Button() : Component(OIS_Button), pushed(false) {} | 
|---|
 | 179 |                 Button(bool bPushed) : Component(OIS_Button), pushed(bPushed) {} | 
|---|
| [1505] | 180 |                 //! true if pushed, false otherwise | 
|---|
 | 181 |                 bool pushed; | 
|---|
 | 182 |         }; | 
|---|
 | 183 |  | 
|---|
 | 184 |         //! Axis component | 
|---|
 | 185 |         class _OISExport Axis : public Component | 
|---|
 | 186 |         { | 
|---|
 | 187 |         public: | 
|---|
 | 188 |                 Axis() : Component(OIS_Axis), abs(0), rel(0), absOnly(false) {}; | 
|---|
 | 189 |  | 
|---|
 | 190 |                 //! Absoulte and Relative value components | 
|---|
 | 191 |                 int abs, rel; | 
|---|
 | 192 |  | 
|---|
 | 193 |                 //! Indicates if this Axis only supports Absoulte (ie JoyStick) | 
|---|
 | 194 |                 bool absOnly; | 
|---|
 | 195 |  | 
|---|
 | 196 |                 //! Used internally by OIS | 
|---|
 | 197 |                 void clear() | 
|---|
 | 198 |                 { | 
|---|
 | 199 |                         abs = rel = 0; | 
|---|
 | 200 |                 } | 
|---|
 | 201 |         }; | 
|---|
 | 202 |  | 
|---|
 | 203 |         //! A 3D Vector component (perhaps an orientation, as in the WiiMote) | 
|---|
 | 204 |         class _OISExport Vector3 : public Component | 
|---|
 | 205 |         { | 
|---|
 | 206 |         public: | 
|---|
 | 207 |                 Vector3() {} | 
|---|
 | 208 |                 Vector3(float _x, float _y, float _z) : Component(OIS_Vector3), x(_x), y(_y), z(_z) {}; | 
|---|
 | 209 |                  | 
|---|
 | 210 |                 //! X component of vector | 
|---|
 | 211 |                 float x; | 
|---|
 | 212 |                  | 
|---|
 | 213 |                 //! Y component of vector | 
|---|
 | 214 |                 float y; | 
|---|
 | 215 |  | 
|---|
 | 216 |                 //! Z component of vector | 
|---|
 | 217 |                 float z; | 
|---|
 | 218 |  | 
|---|
 | 219 |                 void clear() | 
|---|
 | 220 |                 { | 
|---|
 | 221 |                         x = y = z = 0.0f; | 
|---|
 | 222 |                 } | 
|---|
 | 223 |         }; | 
|---|
 | 224 | } | 
|---|
 | 225 |  | 
|---|
 | 226 | #endif //end if prereq header defined | 
|---|