Update of /cvsroot/simspark/simspark/spark/utility/ois In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv13856 Added Files: Tag: projectx Makefile.am OIS.h OIS.pc.in OISConfig.h OISEffect.cpp OISEffect.h OISEvents.h OISException.h OISForceFeedback.cpp OISForceFeedback.h OISInputManager.cpp OISInputManager.h OISInterface.h OISJoyStick.cpp OISJoyStick.h OISKeyboard.cpp OISKeyboard.h OISMouse.h OISObject.cpp OISObject.h OISPrereqs.h README Log Message: added OIS Library sources --- NEW FILE: OISJoyStick.cpp --- /* The zlib/libpng License Copyright (c) 2006 Phillip Castaneda (pjcast -- www.wreckedgames.com) This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #include "OISJoyStick.h" //VC7.1 had a problem with these not getting included.. //Perhaps a case of a crazy extreme optimizer :/ (moved to header) // The minimal axis value //const int OIS::JoyStick::MIN_AXIS = -32767; // The maximum axis value //const int OIS::JoyStick::MAX_AXIS = 32768; --- NEW FILE: OIS.h --- /* The zlib/libpng License Copyright (c) 2006 Phillip Castaneda (pjcast -- www.wreckedgames.com) This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #ifndef OIS_OISALL_H #define OIS_OISALL_H #include "OISPrereqs.h" #include "OISObject.h" #include "OISMouse.h" #include "OISKeyboard.h" #include "OISJoyStick.h" #include "OISInterface.h" #include "OISInputManager.h" #include "OISForceFeedback.h" #include "OISException.h" #include "OISEvents.h" #include "OISEffect.h" #endif --- NEW FILE: OISConfig.h --- /* The zlib/libpng License Copyright (c) 2006 Phillip Castaneda (pjcast -- www.wreckedgames.com) This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #ifndef OIS_CONFIG_HEADER #define OIS_CONFIG_HEADER //----------------------------------------------------------------------------// //* This file contains defines for building certain parts of this Lib //* This file is not meant for External inclusion. However, you can edit this //* file before a build to effect what features are used internally //----------------------------------------------------------------------------// /** @remarks These lines have no bearing on internal build of OIS. This is here for external build settings. Meaning, changing this does not require a rebuild of OIS. This just affects VC dll import settings, as the DLL build already defines this during its build for setting dll exports. The undefine here is here just incase you decide to only use DLL, and want to set it permently and recompile OIS too.. Avoid redefinition from DLL build of OIS. So, if wanting to link against DLL version, just uncomment these lines. */ //#ifdef OIS_DYNAMIC_LIB //# undef OIS_DYNAMIC_LIB //#endif //#define OIS_DYNAMIC_LIB #endif --- NEW FILE: OISObject.cpp --- /* The zlib/libpng License Copyright (c) 2006 Phillip Castaneda (pjcast -- www.wreckedgames.com) This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ //#include "OISObject.h" --- NEW FILE: Makefile.am --- lib_LTLIBRARIES=libOIS.la if BUNDLE_SUPPORT sources = \ mac/MacHelpers.cpp mac/MacHelpers.h \ mac/MacInputManager.cpp mac/MacInputManager.h \ mac/MacKeyboard.cpp mac/MacKeyboard.h \ mac/MacMouse.cpp mac/MacMouse.h \ mac/MacPrereqs.h else sources = \ linux/EventHelpers.cpp linux/EventHelpers.h\ linux/LinuxInputManager.cpp linux/LinuxInputManager.h \ linux/LinuxJoyStickEvents.cpp linux/LinuxJoyStickEvents.h linux/LinuxJoyStick.h \ linux/LinuxForceFeedback.cpp linux/LinuxForceFeedback.h \ linux/LinuxKeyboard.cpp linux/LinuxKeyboard.h \ linux/LinuxMouse.cpp linux/LinuxMouse.h \ linux/LinuxPrereqs.h endif libOIS_la_SOURCES = OISInputManager.cpp \ OISObject.cpp \ OISEffect.cpp \ OISJoyStick.cpp \ OISKeyboard.cpp \ OISForceFeedback.cpp \ OIS.h \ OISConfig.h \ OISEffect.h \ OISEvents.h \ OISException.h \ OISForceFeedback.h \ OISInputManager.h \ OISInterface.h \ OISJoystick.h \ OISKeyboard.h \ OISMouse.h \ OISObject.h \ OISPrereqs.h \ $(sources) libOIS_la_LDFLAGS = -release 1.0.0 libOIS_la_LIBADD = -L/usr/X11R6/lib -lX11 -lXaw --- NEW FILE: OISException.h --- /* The zlib/libpng License Copyright (c) 2006 Phillip Castaneda (pjcast -- www.wreckedgames.com) This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #ifndef _OIS_EXCEPTION_HEADER_ #define _OIS_EXCEPTION_HEADER_ namespace OIS { //! Simple enum's for dealing with exceptions enum _OISExport OIS_ERROR { E_InputDisconnected, E_InputDeviceNonExistant, E_InputDeviceNotSupported, E_DeviceFull, E_NotSupported, E_NotImplemented, E_Duplicate, E_InvalidParam, E_General }; /** @remarks Class for handling OIS exceptions. Much cleaner than checking every method for reurn value. */ class _OISExport Exception { //! Hidden default Exception() : eType(E_General), eLine(0), eFile(0) {} public: //! Creates exception object Exception( OIS_ERROR err, const char* str, int line, const char *file ) : eType(err), eLine(line), eFile(file) ,eText(str) {} //! The type of exception raised const OIS_ERROR eType; //! The line number it occurred on const int eLine; //! The source file const char* eFile; //! A message passed along when the exception was raised const char* eText; }; } //! Use this macro to handle exceptions easily #define OIS_EXCEPT( err, str ) throw( OIS::Exception(err, str, __LINE__, __FILE__) ) #endif //_OIS_EXCEPTION_HEADER_ --- NEW FILE: README --- ====================================================================================== ================ LICENSE ============================================================= ====================================================================================== The zlib/libpng License Copyright (c) 2006 Phillip Castaneda (pjcast -- www.wreckedgames.com) This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. ====================================================================================== ================ LICENSE EXPLAINED =================================================== ====================================================================================== In case the license was not clear enough... Basically, you can link with this lib which puts no restrictions on what you have to license your code as. You can modify this lib, and not have release your changes. Though, as explained above, <bold> Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software </bold> This is to allow users the greatest flexibility in what you can use this lib for. ====================================================================================== ================ INFO ================================================================ ====================================================================================== Cross Platform Object Oriented Input Lib System. Meant to be very robust and compatiable with many systems and operating systems Win32/ Contains Visual Studio .Net Solution Files Contains CodeBlocks + MinGW + StlPort project files for OIS ---- Dependencies ------------------------------------------------------ DirectInput 8 Ogre & CEGUI 0.4.0 If building CEGUIOgre OIS Demo SDL/ A test bed for an OIS InputManager with SDL as the backend. Not recommended; however, useful for platforms with non-native OIS ports for temporary use. Linux/ ---- Dependencies ------------------------------------------------------ X11 Ogre (GLX Platform) & CEGUI 0.4.0 If building CEGUIOgre OIS Demo Newer Linux Kernel (2.6+ ?) for Event API - else, use --disable-joyevents Steps to build on Linux: ./bootstrap ./configure ./make && make install ---- Configure build options -------------------------------------------- ./configure --help --- List all configure options ./configure --disable-ogre --- Disables CEGUIOgre ActionMapping Demo ./configure --disable-joyevents --- Uses /dev/input/jsX instead of /dev/input/eventX LinuxCB/ Contains CodeBlock files for building OIS and Demos with codeblocks This project file looks for Ogre and other dependencies in /usr/local/lib and /usr/local/include. If installed elsewhere, modify the project settings. It also installs libOIS to ~/libs Mac/ XCode-1.5/ Non-complete native OIS port. XCode-2.2/ Working, complete, OIS port to OSX using SDL as a backend. --- NEW FILE: OISInputManager.h --- /* The zlib/libpng License Copyright (c) 2006 Phillip Castaneda (pjcast -- www.wreckedgames.com) This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #ifndef OIS_InputManager_H #define OIS_InputManager_H #include "OISPrereqs.h" namespace OIS { /** Base Manager class. No longer a Singleton; so feel free to create as many InputManager's as you have windows. */ class _OISExport InputManager { public: /** @remarks Returns version number (useful in DLL/SO libs) @returns Bits: 1-8 Patch number, 9-16 Minor version, 17-32 Major version */ static unsigned int getVersionNumber(); /** @remarks Returns version string (useful in DLL/SO libs) @returns Version name */ static const char* getVersionName(); /** @remarks Creates appropriate input system dependent on platform. @param winHandle Contains OS specific window handle (such as HWND or X11 Window) @returns A pointer to the created manager, or raises Exception */ static InputManager* createInputSystem( std::size_t winHandle ); /** @remarks Creates appropriate input system dependent on platform. @param paramList ParamList contains OS specific info (such as HWND and HINSTANCE for window apps), and access mode. @returns A pointer to the created manager, or raises Exception */ static InputManager* createInputSystem( ParamList ¶mList ); /** @remarks Gets the name of the current input system.. eg. "Win32", "Linux", "XBox", etc */ virtual const std::string& inputSystemName() = 0; /** @remarks Destroys the InputManager @param manager Manager to destroy */ static void destroyInputSystem(InputManager* manager); /** @remarks Returns the number of joysticks found */ virtual int numJoysticks() = 0; /** @remarks Returns the number of mice found */ virtual int numMice() = 0; /** @remarks Returns the number of keyboards found */ virtual int numKeyBoards() = 0; /** @remarks Returns the type of input requested or raises Exception */ virtual Object* createInputObject( Type iType, bool bufferMode ) = 0; /** @remarks Destroys Input Object */ virtual void destroyInputObject( Object* obj ) = 0; protected: //! Internal... Called from createInputSystem virtual void _initialize(ParamList ¶mList) = 0; //These are hidden to prevent app from directly instantiating/deleting an InputManager class InputManager() {} virtual ~InputManager() {} }; } #endif --- NEW FILE: OISInterface.h --- /* The zlib/libpng License Copyright (c) 2006 Phillip Castaneda (pjcast -- www.wreckedgames.com) This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #ifndef OIS_Interface_H #define OIS_Interface_H #include "OISPrereqs.h" namespace OIS { /** An Object's interface is a way to gain write access to devices which support it. For example, force feedack. */ class _OISExport Interface { public: virtual ~Interface() {}; //! Type of Interface enum IType { ForceFeedback, Reserved }; }; } #endif //OIS_Interface_H --- NEW FILE: OISJoyStick.h --- /* The zlib/libpng License Copyright (c) 2006 Phillip Castaneda (pjcast -- www.wreckedgames.com) This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #ifndef OIS_Joystick_H #define OIS_Joystick_H #include "OISObject.h" #include "OISEvents.h" namespace OIS { //! POV / HAT Joystick component struct _OISExport Pov : Component { Pov() : Component(OIS_POV), direction(0) {} static const int Centered = 0x00000000; static const int North = 0x00000001; static const int South = 0x00000010; static const int East = 0x00000100; static const int West = 0x00001000; static const int NorthEast = 0x00000101; static const int SouthEast = 0x00000110; static const int NorthWest = 0x00001001; static const int SouthWest = 0x00001010; int direction; }; //! A sliding axis - only used in Win32 Right Now struct _OISExport Slider : Component { Slider() : Component(OIS_Slider), abX(0), abY(0) {}; //! true if pushed, false otherwise int abX, abY; }; /** Represents the state of the joystick All members are valid for both buffered and non buffered mode Sticks with zero values are not present on the device */ struct _OISExport JoyStickState { JoyStickState() : buttons(0) { clear(); } //! Represents all the single axes on the device std::vector<Axis> mAxes; //! Represents the value of a POV. Maximum of 4 Pov mPOV[4]; //! Represent the max sliders Slider mSliders[4]; //! Represents All Buttons By Bit (max buttons = 32) int buttons; //! Button Bit Test - returns true if down inline int buttonDown( int button ) const { return ((buttons & ( 1L << button )) == 0) ? false : true; } //! internal method void clear() { buttons = 0; for( std::vector<Axis>::iterator i = mAxes.begin(), e = mAxes.end(); i != e; ++i ) { (*i).absOnly = true; //Currently, joysticks only report Abs (*i).clear(); } } }; /** Specialised for joystick events */ class _OISExport JoyStickEvent : public EventArg { public: JoyStickEvent( Object* obj, const JoyStickState &st ) : EventArg(obj), state(st) {} virtual ~JoyStickEvent() {} const JoyStickState &state; }; /** To recieve buffered joystick input, derive a class from this, and implement the methods here. Then set the call back to your JoyStick instance with JoyStick::setEventCallback Each JoyStick instance can use the same callback class, as a devID number will be provided to differentiate between connected joysticks. Of course, each can have a seperate callback instead. */ class _OISExport JoyStickListener { public: virtual ~JoyStickListener() {} virtual bool buttonPressed( const JoyStickEvent &arg, int button ) = 0; virtual bool buttonReleased( const JoyStickEvent &arg, int button ) = 0; virtual bool axisMoved( const JoyStickEvent &arg, int axis ) = 0; //Joystick Event, amd sliderID virtual bool sliderMoved( const JoyStickEvent &, int ) {return true;} //Joystick Event, amd povID virtual bool povMoved( const JoyStickEvent &, int ) {return true;} }; /** Joystick base class. To be implemented by specific system (ie. DirectX joystick) This class is useful as you remain OS independent using this common interface. */ class _OISExport JoyStick : public Object { public: virtual ~JoyStick() {} /** @remarks Returns the number of buttons */ short buttons() {return numButtons;} /** @remarks Returns the number of axes */ short axes() {return numAxes;} /** @remarks Returns the number of hats */ short hats() {return numHats;} /** @remarks Register/unregister a JoyStick Listener - Only one allowed for simplicity. If broadcasting is neccessary, just broadcast from the callback you registered. @param joyListener Send a pointer to a class derived from JoyStickListener or 0 to clear the callback */ virtual void setEventCallback( JoyStickListener *joyListener ) {listener = joyListener;} /** @remarks Returns currently set callback.. or null */ JoyStickListener* getEventCallback() {return listener;} /** @remarks Returns the state of the joystick - is valid for both buffered and non buffered mode */ const JoyStickState& getJoyStickState() const { return mState; } //! The minimal axis value static const int MIN_AXIS = -32768; //! The maximum axis value static const int MAX_AXIS = 32767; protected: JoyStick() : numButtons(0), numAxes(0), numHats(0), listener(0) {} short numButtons; short numAxes; short numHats; JoyStickState mState; JoyStickListener *listener; }; } #endif --- NEW FILE: OISEffect.cpp --- /* The zlib/libpng License Copyright (c) 2006 Phillip Castaneda (pjcast -- www.wreckedgames.com) This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #include "OISEffect.h" #include "OISException.h" using namespace OIS; //VC7.1 had a problem with these not getting included.. //Perhaps a case of a crazy extreme optimizer :/ (moved to header) //const unsigned int Effect::OIS_INFINITE = 0xFFFFFFFF; //------------------------------------------------------------------------------// Effect::Effect() : force(UnknownForce), type(Unknown), effect(0), axes(1) { } //------------------------------------------------------------------------------// Effect::Effect(EForce ef, EType et) : force(ef), type(et), direction(North), trigger_button(-1), trigger_interval(0), replay_length(Effect::OIS_INFINITE), replay_delay(0), _handle(-1), axes(1) { effect = 0; switch( ef ) { case ConstantForce: effect = new ConstantEffect(); break; case RampForce: effect = new RampEffect(); break; case PeriodicForce: effect = new PeriodicEffect(); break; case ConditionalForce: effect = new ConditionalEffect(); break; default: break; } } //------------------------------------------------------------------------------// Effect::~Effect() { delete effect; } //------------------------------------------------------------------------------// ForceEffect* Effect::getForceEffect() const { //If no effect was created in constructor, then we raise an error here if( effect == 0 ) OIS_EXCEPT( E_NotSupported, "Requested ForceEffect is null!" ); return effect; } //------------------------------------------------------------------------------// void Effect::setNumAxes(short nAxes) { //Can only be set before a handle was assigned (effect created) if( _handle != -1 ) axes = nAxes; } //------------------------------------------------------------------------------// short Effect::getNumAxes() const { return axes; } --- NEW FILE: OISKeyboard.cpp --- /* The zlib/libpng License Copyright (c) 2006 Phillip Castaneda (pjcast -- www.wreckedgames.com) This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #include "OISKeyboard.h" #include "OISException.h" using namespace OIS; //----------------------------------------------------------------------// Keyboard::Keyboard() : mModifiers(0), listener(0), mTextMode(Unicode) { } //----------------------------------------------------------------------// void Keyboard::setTextTranslation( TextTranslationMode mode ) { mTextMode = mode; } //----------------------------------------------------------------------// bool Keyboard::isModifierDown( Modifier mod ) { #if defined(OIS_MSVC_COMPILER) #pragma warning (push) #pragma warning (disable : 4800) #endif return (mModifiers & mod); #if defined(OIS_MSVC_COMPILER) #pragma warning (pop) #endif } --- NEW FILE: OISKeyboard.h --- /* The zlib/libpng License Copyright (c) 2006 Phillip Castaneda (pjcast -- www.wreckedgames.com) This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #ifndef OIS_Keyboard_H #define OIS_Keyboard_H #include "OISObject.h" #include "OISEvents.h" namespace OIS { //! Keyboard scan codes enum KeyCode { KC_UNASSIGNED = 0x00, KC_ESCAPE = 0x01, KC_1 = 0x02, KC_2 = 0x03, KC_3 = 0x04, KC_4 = 0x05, KC_5 = 0x06, KC_6 = 0x07, KC_7 = 0x08, KC_8 = 0x09, KC_9 = 0x0A, KC_0 = 0x0B, KC_MINUS = 0x0C, // - on main keyboard KC_EQUALS = 0x0D, KC_BACK = 0x0E, // backspace KC_TAB = 0x0F, KC_Q = 0x10, KC_W = 0x11, KC_E = 0x12, KC_R = 0x13, KC_T = 0x14, KC_Y = 0x15, KC_U = 0x16, KC_I = 0x17, KC_O = 0x18, KC_P = 0x19, KC_LBRACKET = 0x1A, KC_RBRACKET = 0x1B, KC_RETURN = 0x1C, // Enter on main keyboard KC_LCONTROL = 0x1D, KC_A = 0x1E, KC_S = 0x1F, KC_D = 0x20, KC_F = 0x21, KC_G = 0x22, KC_H = 0x23, KC_J = 0x24, KC_K = 0x25, KC_L = 0x26, KC_SEMICOLON = 0x27, KC_APOSTROPHE = 0x28, KC_GRAVE = 0x29, // accent KC_LSHIFT = 0x2A, KC_BACKSLASH = 0x2B, KC_Z = 0x2C, KC_X = 0x2D, KC_C = 0x2E, KC_V = 0x2F, KC_B = 0x30, KC_N = 0x31, KC_M = 0x32, KC_COMMA = 0x33, KC_PERIOD = 0x34, // . on main keyboard KC_SLASH = 0x35, // / on main keyboard KC_RSHIFT = 0x36, KC_MULTIPLY = 0x37, // * on numeric keypad KC_LMENU = 0x38, // left Alt KC_SPACE = 0x39, KC_CAPITAL = 0x3A, KC_F1 = 0x3B, KC_F2 = 0x3C, KC_F3 = 0x3D, KC_F4 = 0x3E, KC_F5 = 0x3F, KC_F6 = 0x40, KC_F7 = 0x41, KC_F8 = 0x42, KC_F9 = 0x43, KC_F10 = 0x44, KC_NUMLOCK = 0x45, KC_SCROLL = 0x46, // Scroll Lock KC_NUMPAD7 = 0x47, KC_NUMPAD8 = 0x48, KC_NUMPAD9 = 0x49, KC_SUBTRACT = 0x4A, // - on numeric keypad KC_NUMPAD4 = 0x4B, KC_NUMPAD5 = 0x4C, KC_NUMPAD6 = 0x4D, KC_ADD = 0x4E, // + on numeric keypad KC_NUMPAD1 = 0x4F, KC_NUMPAD2 = 0x50, KC_NUMPAD3 = 0x51, KC_NUMPAD0 = 0x52, KC_DECIMAL = 0x53, // . on numeric keypad KC_OEM_102 = 0x56, // < > | on UK/Germany keyboards KC_F11 = 0x57, KC_F12 = 0x58, KC_F13 = 0x64, // (NEC PC98) KC_F14 = 0x65, // (NEC PC98) KC_F15 = 0x66, // (NEC PC98) KC_KANA = 0x70, // (Japanese keyboard) KC_ABNT_C1 = 0x73, // / ? on Portugese (Brazilian) keyboards KC_CONVERT = 0x79, // (Japanese keyboard) KC_NOCONVERT = 0x7B, // (Japanese keyboard) KC_YEN = 0x7D, // (Japanese keyboard) KC_ABNT_C2 = 0x7E, // Numpad . on Portugese (Brazilian) keyboards KC_NUMPADEQUALS= 0x8D, // = on numeric keypad (NEC PC98) KC_PREVTRACK = 0x90, // Previous Track (KC_CIRCUMFLEX on Japanese keyboard) KC_AT = 0x91, // (NEC PC98) KC_COLON = 0x92, // (NEC PC98) KC_UNDERLINE = 0x93, // (NEC PC98) KC_KANJI = 0x94, // (Japanese keyboard) KC_STOP = 0x95, // (NEC PC98) KC_AX = 0x96, // (Japan AX) KC_UNLABELED = 0x97, // (J3100) KC_NEXTTRACK = 0x99, // Next Track KC_NUMPADENTER = 0x9C, // Enter on numeric keypad KC_RCONTROL = 0x9D, KC_MUTE = 0xA0, // Mute KC_CALCULATOR = 0xA1, // Calculator KC_PLAYPAUSE = 0xA2, // Play / Pause KC_MEDIASTOP = 0xA4, // Media Stop KC_VOLUMEDOWN = 0xAE, // Volume - KC_VOLUMEUP = 0xB0, // Volume + KC_WEBHOME = 0xB2, // Web home KC_NUMPADCOMMA = 0xB3, // , on numeric keypad (NEC PC98) KC_DIVIDE = 0xB5, // / on numeric keypad KC_SYSRQ = 0xB7, KC_RMENU = 0xB8, // right Alt KC_PAUSE = 0xC5, // Pause KC_HOME = 0xC7, // Home on arrow keypad KC_UP = 0xC8, // UpArrow on arrow keypad KC_PGUP = 0xC9, // PgUp on arrow keypad KC_LEFT = 0xCB, // LeftArrow on arrow keypad KC_RIGHT = 0xCD, // RightArrow on arrow keypad KC_END = 0xCF, // End on arrow keypad KC_DOWN = 0xD0, // DownArrow on arrow keypad KC_PGDOWN = 0xD1, // PgDn on arrow keypad KC_INSERT = 0xD2, // Insert on arrow keypad KC_DELETE = 0xD3, // Delete on arrow keypad KC_LWIN = 0xDB, // Left Windows key KC_RWIN = 0xDC, // Right Windows key KC_APPS = 0xDD, // AppMenu key KC_POWER = 0xDE, // System Power KC_SLEEP = 0xDF, // System Sleep KC_WAKE = 0xE3, // System Wake KC_WEBSEARCH = 0xE5, // Web Search KC_WEBFAVORITES= 0xE6, // Web Favorites KC_WEBREFRESH = 0xE7, // Web Refresh KC_WEBSTOP = 0xE8, // Web Stop KC_WEBFORWARD = 0xE9, // Web Forward KC_WEBBACK = 0xEA, // Web Back KC_MYCOMPUTER = 0xEB, // My Computer KC_MAIL = 0xEC, // Mail KC_MEDIASELECT = 0xED // Media Select }; /** Specialised for key events */ class _OISExport KeyEvent : public EventArg { public: KeyEvent( Object* obj, KeyCode kc, unsigned int txt ) : EventArg(obj), key(kc), text(txt) {} virtual ~KeyEvent() {} //! KeyCode of event const KeyCode key; //! Text character, depends on current TextTranslationMode unsigned int text; }; /** To recieve buffered keyboard input, derive a class from this, and implement the methods here. Then set the call back to your Keyboard instance with Keyboard::setEventCallback */ class _OISExport KeyListener { public: virtual ~KeyListener() {} virtual bool keyPressed( const KeyEvent &arg ) = 0; virtual bool keyReleased( const KeyEvent &arg ) = 0; }; /** Keyboard base class. To be implemented by specific system (ie. DirectX Keyboard) This class is useful as you remain OS independent using this common interface. */ class _OISExport Keyboard : public Object { public: virtual ~Keyboard() {}; /** @remarks Returns true if key is donwn @param key A KeyCode to check */ virtual bool isKeyDown( KeyCode key ) = 0; /** @remarks Register/unregister a Keyboard Listener - Only one allowed for simplicity. If broadcasting is neccessary, just broadcast from the callback you registered. @param keyListener Send a pointer to a class derived from KeyListener or 0 to clear the callback */ virtual void setEventCallback( KeyListener *keyListener ) {listener=keyListener;} /** @remarks Returns currently set callback.. or 0 */ KeyListener* getEventCallback() {return listener;} //! TextTranslation Mode enum TextTranslationMode { Off, Unicode, Ascii }; /** @remarks Enable extra processing to translate KC_*** to an actual text character based off of locale. Different managers may implement none or all. Check the translation mode after setting to be sure @param mode Off, Unicode, Ascii */ virtual void setTextTranslation( TextTranslationMode mode ); /** @remarks Returns current translation mode */ TextTranslationMode getTextTranslation(){return mTextMode;} /** @remarks Translates KeyCode to string representation. For example, KC_ENTER will be "Enter" - Locale specific of course. @param kc KeyCode to convert @returns The string as determined from the current locale */ virtual const std::string& getAsString( KeyCode kc ) = 0; //! Enum of bit position of modifer enum Modifier { Shift = 0x0000001, Ctrl = 0x0000010, Alt = 0x0000100 }; /** @remarks Check modifier status */ bool isModifierDown( Modifier mod ); /** @remarks Copies the state of the keys into the sent buffer (in the form of 1 is down and 0 is up) */ virtual void copyKeyStates( char keys[256] ) = 0; protected: Keyboard(); //! Bit field that holds status of Alt, Ctrl, Shift unsigned int mModifiers; //! Used for buffered/actionmapping callback KeyListener *listener; //! The current translation mode TextTranslationMode mTextMode; }; } #endif --- NEW FILE: OISEvents.h --- /* The zlib/libpng License Copyright (c) 2006 Phillip Castaneda (pjcast -- www.wreckedgames.com) This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #ifndef _OIS_EVENTHEADERS_ #define _OIS_EVENTHEADERS_ #include "OISPrereqs.h" namespace OIS { /** Base class of all events */ class _OISExport EventArg { public: EventArg( Object* obj ) : device(obj) {} virtual ~EventArg() {} //! Pointer to the Input Device const Object* device; }; } #endif //_OIS_EVENTHEADERS_ --- NEW FILE: OIS.pc.in --- prefix=@prefix@ exec_prefix=@exec_prefix@ libdir=@libdir@ includedir=@includedir@ Name: OIS Description: Crossplatform C++ Input Framework Version: @VERSION@ Libs: -L${libdir} -lOIS Cflags: -I${includedir}/@PACKAGE@ -I${includedir} --- NEW FILE: OISPrereqs.h --- /* The zlib/libpng License Copyright (c) 2006 Phillip Castaneda (pjcast -- www.wreckedgames.com) This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #ifndef OIS_Prereqs_H #define OIS_Prereqs_H //----------------------------------------------------------------------------// //* This Header File contains forward declared classes *// //* Also, common properties for the keyboard and mouse *// //* There is also preprocessor defines to determine type of OS *// //----------------------------------------------------------------------------// //-------------- Common STL Containers ---------------------------------------// #include <vector> #include <string> #include <map> #include "OISConfig.h" // Default is blank for most OS's #define _OISExport //-------------- Determine Compiler --------------------------------- #if defined( _MSC_VER ) # define OIS_MSVC_COMPILER #elif defined( __GNUC__ ) # if defined( __WIN32__ ) || defined( _WIN32 ) # define OIS_MINGW_COMPILER # else # define OIS_GCC_COMPILER # endif #elif defined( __BORLANDC__ ) # define OIS_BORLAND_COMPILER #else # error No Recognized Compiler! #endif // --------------- Determine Operating System Platform --------------- #if defined( __WIN32__ ) || defined( _WIN32 ) // Windows 2000, XP, ETC # if defined ( _XBOX ) # define OIS_XBOX_PLATFORM # else # define OIS_WIN32_PLATFORM # if defined( OIS_DYNAMIC_LIB ) && !defined(OIS_MINGW_COMPILER) # undef _OISExport //Ignorable Dll interface warning... # pragma warning (disable : 4251) # if defined( OIS_NONCLIENT_BUILD ) # define _OISExport __declspec( dllexport ) # else # define _OISExport __declspec( dllimport ) # endif # endif # endif #elif defined( __APPLE_CC__ ) // Apple OS X # define OIS_APPLE_PLATFORM #else //Probably Linux # define OIS_LINUX_PLATFORM #endif //Is Processor 32 or 64 bits... #if defined(__x86_64__) # define OIS_ARCH_64 #else # define OIS_ARCH_32 #endif //-------------- Common Classes, Enums, and Typdef's -------------------------// #define OIS_VERSION_MAJOR 1 #define OIS_VERSION_MINOR 0 #define OIS_VERSION_PATCH 0 #define OIS_VERSION_NAME "Nitro" #define OIS_VERSION ((OIS_VERSION_MAJOR << 16) | (OIS_VERSION_MINOR << 8) | OIS_VERSION_PATCH) namespace OIS { //Device Types class InputManager; class Object; class Keyboard; class Mouse; class JoyStick; class KeyListener; class MouseListener; class JoyStickListener; class Interface; class ForceFeedback; class Effect; //! Way to send OS nuetral parameters.. ie OS Window handles, modes, flags typedef _OISExport std::multimap<std::string, std::string> ParamList; //! Each Input class has a General Type variable, a form of RTTI enum _OISExport Type { OISUnknown = 0, OISKeyboard = 1, OISMouse = 2, OISJoyStick = 3, OISTablet = 4 }; //-------- Shared common components ------------------------// //! Base type for all device components (button, axis, etc) enum _OISExport ComponentType { OIS_Unknown = 0, OIS_Button = 1, //Key, mouse button, joy button, etc OIS_Axis = 2, OIS_Slider = 3, OIS_POV = 4 }; //! Base of all device components (button, axis, etc) struct _OISExport Component { Component() : cType(OIS_Unknown) {}; Component(ComponentType type) : cType(type) {}; //! Indicates what type of coponent this is ComponentType cType; }; //! Button can be a keyboard key, mouse button, etc struct _OISExport Button : Component { Button() {} Button(bool bPushed) : Component(OIS_Button), pushed(bPushed) {}; //! true if pushed, false otherwise bool pushed; }; //! Axis component struct _OISExport Axis : Component { Axis() : Component(OIS_Axis), abs(0), rel(0), absOnly(false) {}; //! Absoulte and Relative value components int abs, rel; //! Indicates if this Axis only supports Absoulte (ie JoyStick) bool absOnly; //! Used internally by OIS void clear() { abs = rel = 0; } }; } #endif //end if prereq header defined --- NEW FILE: OISMouse.h --- /* The zlib/libpng License Copyright (c) 2006 Phillip Castaneda (pjcast -- www.wreckedgames.com) This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #ifndef OIS_Mouse_H #define OIS_Mouse_H #include "OISObject.h" #include "OISEvents.h" namespace OIS { //! Button ID for mouse devices enum MouseButtonID { MB_Left = 0, MB_Right, MB_Middle, MB_Button3, MB_Button4, MB_Button5, MB_Button6, MB_Button7 }; /** Represents the state of the mouse All members are valid for both buffered and non buffered mode */ struct _OISExport MouseState { MouseState() : width(50), height(50), buttons(0) {}; /** Represents the height/width of your display area.. used if mouse clipping or mouse grabbed in case of X11 - defaults to 50.. Make sure to set this and change when your size changes.. */ mutable int width, height; //! X Axis component Axis X; //! Y Axis Component Axis Y; //! Z Axis Component Axis Z; //! represents all buttons - bit position indicates button down int buttons; //! Button down test inline bool buttonDown( MouseButtonID button ) const { return ((buttons & ( 1L << button )) == 0) ? false : true; } //! Clear all the values void clear() { X.clear(); Y.clear(); Z.clear(); buttons = 0; } }; /** Specialised for mouse events */ class _OISExport MouseEvent : public EventArg { public: MouseEvent( Object *obj, const MouseState &ms ) : EventArg(obj), state(ms) {} virtual ~MouseEvent() {} //! The state of the mouse - including buttons and axes const MouseState &state; }; /** To recieve buffered mouse input, derive a class from this, and implement the methods here. Then set the call back to your Mouse instance with Mouse::setEventCallback */ class _OISExport MouseListener { public: virtual ~MouseListener() {} virtual bool mouseMoved( const MouseEvent &arg ) = 0; virtual bool mousePressed( const MouseEvent &arg, MouseButtonID id ) = 0; virtual bool mouseReleased( const MouseEvent &arg, MouseButtonID id ) = 0; }; /** Mouse base class. To be implemented by specific system (ie. DirectX Mouse) This class is useful as you remain OS independent using this common interface. */ class _OISExport Mouse : public Object { public: virtual ~Mouse() {} /** @remarks Register/unregister a Mouse Listener - Only one allowed for simplicity. If broadcasting is neccessary, just broadcast from the callback you registered. @param mouseListener Send a pointer to a class derived from MouseListener or 0 to clear the callback */ virtual void setEventCallback( MouseListener *mouseListener ) {listener = mouseListener;} /** @remarks Returns currently set callback.. or 0 */ MouseListener* getEventCallback() {return listener;} /** @remarks Returns the state of the mouse - is valid for both buffered and non buffered mode */ const MouseState& getMouseState() const { return mState; } protected: Mouse() : listener(0) {} //! The state of the mouse MouseState mState; //! Used for buffered/actionmapping callback MouseListener *listener; }; } #endif --- NEW FILE: OISObject.h --- /* The zlib/libpng License Copyright (c) 2006 Phillip Castaneda (pjcast -- www.wreckedgames.com) This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #ifndef OIS_Object_H #define OIS_Object_H #include "OISPrereqs.h" #include "OISInterface.h" namespace OIS { /** The base class of all input types. */ class _OISExport Object { public: virtual ~Object() {} /** @remarks Get the type of device */ Type type() const { return mType; } /** @remarks Get the vender string name */ const std::string& vendor() const { return mVendor; } /** @remarks Get buffered mode - true is buffered, false otherwise */ virtual bool buffered() const { return mBuffered; } /** @remarks Returns this input object's creator */ InputManager* getCreator() { return mCreator; } /** @remarks Sets buffered mode */ virtual void setBuffered(bool buffered) = 0; /** @remarks Used for updating call once per frame before checking state or to update events */ virtual void capture() = 0; /** @remarks Not fully implemented yet */ virtual int getID() const {return mDevID;} /** @remarks If available, get an interface to write to some devices. Examples include, turning on and off LEDs, ForceFeedback, etc @param type The type of interface you are looking for */ virtual Interface* queryInterface(Interface::IType type) = 0; /** @remarks Internal... Do not call this directly. */ virtual void _initialize() = 0; protected: Object() : mType(OISUnknown), mBuffered(false), mDevID(-1), mCreator(0) {} //! Vendor name if applicable/known std::string mVendor; //! Type of controller object Type mType; //! Buffered flag bool mBuffered; //! Not fully implemented yet int mDevID; //! The creator who created this object InputManager* mCreator; }; } #endif --- NEW FILE: OISInputManager.cpp --- /* The zlib/libpng License Copyright (c) 2006 Phillip Castaneda (pjcast -- www.wreckedgames.com) This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #include "OISInputManager.h" #include "OISException.h" #include <sstream> //Bring in correct Header / InputManager for current build platform #if defined OIS_SDL_PLATFORM # include "SDL/SDLInputManager.h" #elif defined OIS_WIN32_PLATFORM # include "win32/Win32InputManager.h" #elif defined OIS_LINUX_PLATFORM # include "linux/LinuxInputManager.h" #elif defined OIS_APPLE_PLATFORM # include "mac/MacInputManager.h" #elif defined OIS_XBOX_PLATFORM # include "xbox/XBoxInputManager.h" #endif using namespace OIS; const char* gVersionName = OIS_VERSION_NAME; //----------------------------------------------------------------------------// unsigned int InputManager::getVersionNumber() { return OIS_VERSION; } //----------------------------------------------------------------------------// const char* InputManager::getVersionName() { return gVersionName; } //----------------------------------------------------------------------------// InputManager* InputManager::createInputSystem( std::size_t windowhandle ) { ParamList pl; std::ostringstream wnd; wnd << windowhandle; pl.insert(std::make_pair( std::string("WINDOW"), wnd.str() )); return createInputSystem( pl ); } //----------------------------------------------------------------------------// InputManager* InputManager::createInputSystem( ParamList ¶mList ) { InputManager* im = 0; #if defined OIS_SDL_PLATFORM im = new SDLInputManager(); #elif defined OIS_WIN32_PLATFORM im = new Win32InputManager(); #elif defined OIS_XBOX_PLATFORM im = new XBoxInputManager(); #elif defined OIS_LINUX_PLATFORM im = new LinuxInputManager(); #elif defined OIS_APPLE_PLATFORM im = new MacInputManager(); #else OIS_EXCEPT(E_General, "No platform library.. check build platform defines!"); #endif try { im->_initialize(paramList); } catch(...) { delete im; throw; //rethrow } return im; } //----------------------------------------------------------------------------// void InputManager::destroyInputSystem(InputManager* manager) { delete manager; } --- NEW FILE: OISForceFeedback.cpp --- /* The zlib/libpng License Copyright (c) 2006 Phillip Castaneda (pjcast -- www.wreckedgames.com) This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #include "OISForceFeedback.h" #include "OISException.h" using namespace OIS; //-------------------------------------------------------------// void ForceFeedback::_addEffectTypes( Effect::EForce force, Effect::EType type ) { if( force == Effect::UnknownForce || type == Effect::Unknown ) OIS_EXCEPT( E_General, "Unknown Force||Type was added too effect list..." ); mSupportedEffects[force] = type; } //-------------------------------------------------------------// const ForceFeedback::SupportedEffectList& ForceFeedback::getSupportedEffects() const { return mSupportedEffects; } --- NEW FILE: OISForceFeedback.h --- /* The zlib/libpng License Copyright (c) 2006 Phillip Castaneda (pjcast -- www.wreckedgames.com) This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #ifndef OIS_ForceFeedBack_H #define OIS_ForceFeedBack_H #include "OISPrereqs.h" #include "OISInterface.h" #include "OISEffect.h" namespace OIS { /** Interface class for dealing with Force Feedback devices */ class _OISExport ForceFeedback : public Interface { public: ForceFeedback() {} virtual ~ForceFeedback() {} /** @remarks This is like setting the master volume of an audio device. Individual effects have gain levels; however, this affects all effects at once. @param level A value between 0.0 and 1.0 represent the percentage of gain. 1.0 being the highest possible force level (means no scaling). */ virtual void setMasterGain( float level ) = 0; /** @remarks If using Force Feedback effects, this should be turned off before uploading any effects. Auto centering is the motor moving the joystick back to center. DirectInput only has an on/off setting, whereas linux has levels.. Though, we go with DI's on/off mode only @param auto_on true to turn auto centering on, false to turn off. */ virtual void setAutoCenterMode( bool auto_on ) = 0; /** @remarks Creates and Plays the effect immediately. If the device is full of effects, it will fail to be uploaded. You will know this by an invalid Effect Handle */ virtual void upload( const Effect* effect ) = 0; /** @remarks Modifies an effect that is currently playing */ virtual void modify( const Effect* effect ) = 0; /** @remarks Remove the effect from the device */ virtual void remove( const Effect* effect ) = 0; /** @remarks Get the number of supported Axes for FF usage */ virtual short getFFAxesNumber() = 0; typedef std::map<Effect::EForce, Effect::EType> SupportedEffectList; /** @remarks Get a list of all supported effects */ const SupportedEffectList& getSupportedEffects() const; void _addEffectTypes( Effect::EForce force, Effect::EType type ); protected: SupportedEffectList mSupportedEffects; }; } #endif //OIS_ForceFeedBack_H --- NEW FILE: OISEffect.h --- /* The zlib/libpng License Copyright (c) 2006 Phillip Castaneda (pjcast -- www.wreckedgames.com) This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #ifndef OIS_Effect_H #define OIS_Effect_H #include "OISPrereqs.h" namespace OIS { //Predeclare some Effect Property structs struct ForceEffect; struct ConstantEffect; struct RampEffect; struct PeriodicEffect; struct ConditionalEffect; /** Force Feedback is a relatively complex set of properties to upload to a device. The best place for information on the different properties, effects, etc is in the DX Documentation and MSDN - there are even pretty graphs ther =) As this class is modeled on the the DX interface you can apply that same knowledge to creating effects via this class on any OS supported by OIS. In anycase, this is the main class you will be using. There is *absolutely* no need to instance any of the supporting ForceEffect classes yourself. */ class _OISExport Effect { /** hidden so this class cannot be instanced with default constructor */ Effect(); public: //! Type of force enum EForce { UnknownForce = 0, ConstantForce, RampForce, PeriodicForce, ConditionalForce, CustomForce }; //! Type of effect enum EType { //Type ----- Pairs with force: Unknown = 0, //UnknownForce Constant, //ConstantForce Ramp, //RampForce Square, //PeriodicForce Triangle, //PeriodicForce Sine, //PeriodicForce SawToothUp, //PeriodicForce SawToothDown,//PeriodicForce Friction, //ConditionalForce Damper, //ConditionalForce Inertia, //ConditionalForce Spring, //ConditionalForce Custom //CustomForce }; //! Direction of the Force enum EDirection { NorthWest, North, NorthEast, East, SouthEast, South, SouthWest, West }; /** This constructor allows you to set the force type and effect. */ Effect(EForce ef, EType et); virtual ~Effect(); co... [truncated message content] |