Commit b408932f authored by Ben Hymers's avatar Ben Hymers
Browse files

Add .gitattributes to control line endings, and normalise all existing files

parent c50bad3f
/* /*
The zlib/libpng License The zlib/libpng License
Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com) Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
This software is provided 'as-is', without any express or implied warranty. In no event will 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. 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 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 applications, and to alter it and redistribute it freely, subject to the following
restrictions: restrictions:
1. The origin of this software must not be misrepresented; you must not claim that 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, you wrote the original software. If you use this software in a product,
an acknowledgment in the product documentation would be appreciated but is an acknowledgment in the product documentation would be appreciated but is
not required. not required.
2. Altered source versions must be plainly marked as such, and must not be 2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software. misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
*/ */
#ifndef _OIS_SDLKEYBOARD_H #ifndef _OIS_SDLKEYBOARD_H
#define _OIS_SDLKEYBOARD_H #define _OIS_SDLKEYBOARD_H
#include "OISKeyboard.h" #include "OISKeyboard.h"
#include "SDL/SDLPrereqs.h" #include "SDL/SDLPrereqs.h"
namespace OIS namespace OIS
{ {
class SDLKeyboard : public Keyboard class SDLKeyboard : public Keyboard
{ {
public: public:
/** /**
@remarks @remarks
Constructor Constructor
@param buffered @param buffered
True for buffered input mode True for buffered input mode
*/ */
SDLKeyboard( bool buffered ); SDLKeyboard( bool buffered );
virtual ~SDLKeyboard(); virtual ~SDLKeyboard();
/** @copydoc Keyboard::isKeyDown */ /** @copydoc Keyboard::isKeyDown */
virtual bool isKeyDown( KeyCode key ); virtual bool isKeyDown( KeyCode key );
/** @copydoc Keyboard::getAsString */ /** @copydoc Keyboard::getAsString */
virtual const std::string& getAsString( KeyCode kc ); virtual const std::string& getAsString( KeyCode kc );
/** @copydoc Keyboard::copyKeyStates */ /** @copydoc Keyboard::copyKeyStates */
virtual void copyKeyStates( char keys[256] ); virtual void copyKeyStates( char keys[256] );
/** @copydoc Object::setBuffered */ /** @copydoc Object::setBuffered */
virtual void setBuffered(bool buffered); virtual void setBuffered(bool buffered);
/** @copydoc Object::capture */ /** @copydoc Object::capture */
virtual void capture(); virtual void capture();
/** @copydoc Object::queryInterface */ /** @copydoc Object::queryInterface */
virtual Interface* queryInterface(Interface::IType type) {return 0;} virtual Interface* queryInterface(Interface::IType type) {return 0;}
/** @copydoc Object::_initialize */ /** @copydoc Object::_initialize */
virtual void _initialize(); virtual void _initialize();
/** @copydoc Object::setTextTranslation */ /** @copydoc Object::setTextTranslation */
virtual void setTextTranslation( TextTranslationMode mode ); virtual void setTextTranslation( TextTranslationMode mode );
protected: protected:
SDLKeyboard() {} SDLKeyboard() {}
typedef std::map<SDLKey, KeyCode> KeyMap; typedef std::map<SDLKey, KeyCode> KeyMap;
KeyMap mKeyMap; KeyMap mKeyMap;
unsigned char KeyBuffer[256]; unsigned char KeyBuffer[256];
Uint8* mSDLBuff; Uint8* mSDLBuff;
std::string mGetString; std::string mGetString;
}; };
} }
#endif #endif
/* /*
The zlib/libpng License The zlib/libpng License
Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com) Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
This software is provided 'as-is', without any express or implied warranty. In no event will 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. 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 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 applications, and to alter it and redistribute it freely, subject to the following
restrictions: restrictions:
1. The origin of this software must not be misrepresented; you must not claim that 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, you wrote the original software. If you use this software in a product,
an acknowledgment in the product documentation would be appreciated but is an acknowledgment in the product documentation would be appreciated but is
not required. not required.
2. Altered source versions must be plainly marked as such, and must not be 2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software. misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
*/ */
#ifndef _OIS_SDLMOUSE_H #ifndef _OIS_SDLMOUSE_H
#define _OIS_SDLMOUSE_H #define _OIS_SDLMOUSE_H
#include "OISMouse.h" #include "OISMouse.h"
#include "SDL/SDLPrereqs.h" #include "SDL/SDLPrereqs.h"
namespace OIS namespace OIS
{ {
class SDLMouse : public Mouse class SDLMouse : public Mouse
{ {
public: public:
SDLMouse( bool buffered ); SDLMouse( bool buffered );
virtual ~SDLMouse(); virtual ~SDLMouse();
/** @copydoc Object::setBuffered */ /** @copydoc Object::setBuffered */
virtual void setBuffered(bool buffered); virtual void setBuffered(bool buffered);
/** @copydoc Object::capture */ /** @copydoc Object::capture */
virtual void capture(); virtual void capture();
/** @copydoc Object::queryInterface */ /** @copydoc Object::queryInterface */
virtual Interface* queryInterface(Interface::IType type) {return 0;} virtual Interface* queryInterface(Interface::IType type) {return 0;}
/** @copydoc Object::_initialize */ /** @copydoc Object::_initialize */
virtual void _initialize(); virtual void _initialize();
void _setGrab(bool grabbed); void _setGrab(bool grabbed);
void _setVisible(bool visible); void _setVisible(bool visible);
protected: protected:
SDLMouse() {} SDLMouse() {}
bool mGrabbed; bool mGrabbed;
bool mRegainFocus; bool mRegainFocus;
}; };
} }
#endif #endif
/* /*
The zlib/libpng License The zlib/libpng License
Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com) Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
This software is provided 'as-is', without any express or implied warranty. In no event will 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. 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 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 applications, and to alter it and redistribute it freely, subject to the following
restrictions: restrictions:
1. The origin of this software must not be misrepresented; you must not claim that 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, you wrote the original software. If you use this software in a product,
an acknowledgment in the product documentation would be appreciated but is an acknowledgment in the product documentation would be appreciated but is
not required. not required.
2. Altered source versions must be plainly marked as such, and must not be 2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software. misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
*/ */
#ifndef OIS_SDLPrereqs_H #ifndef OIS_SDLPrereqs_H
#define OIS_SDLPrereqs_H #define OIS_SDLPrereqs_H
#include "OISPrereqs.h" #include "OISPrereqs.h"
#ifdef OIS_APPLE_PLATFORM #ifdef OIS_APPLE_PLATFORM
# include <SDL/SDL.h> # include <SDL/SDL.h>
#else #else
# include <SDL.h> # include <SDL.h>
#endif #endif
#define OIS_SDL_KEY_BUFF 16 #define OIS_SDL_KEY_BUFF 16
#define OIS_SDL_MOUSE_BUFF 50 #define OIS_SDL_MOUSE_BUFF 50
#define OIS_SDL_JOY_BUFF 80 #define OIS_SDL_JOY_BUFF 80
#endif #endif
#ifndef OIS_iPhoneAccelerometer_H #ifndef OIS_iPhoneAccelerometer_H
#define OIS_iPhoneAccelerometer_H #define OIS_iPhoneAccelerometer_H
#include "OISJoystick.h" #include "OISJoystick.h"
#include "iphone/iPhonePrereqs.h" #include "iphone/iPhonePrereqs.h"
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
@class iPhoneAccelerometerDelegate; @class iPhoneAccelerometerDelegate;
class JoyStickState; class JoyStickState;
namespace OIS namespace OIS
{ {
class iPhoneAccelerometer : public JoyStick class iPhoneAccelerometer : public JoyStick
{ {
public: public:
iPhoneAccelerometer(InputManager* creator, bool buffered); iPhoneAccelerometer(InputManager* creator, bool buffered);
virtual ~iPhoneAccelerometer(); virtual ~iPhoneAccelerometer();
/** @copydoc Object::setBuffered */ /** @copydoc Object::setBuffered */
virtual void setBuffered(bool buffered); virtual void setBuffered(bool buffered);
void setUpdateInterval(float interval) { void setUpdateInterval(float interval) {
mUpdateInterval = interval; mUpdateInterval = interval;
[[UIAccelerometer sharedAccelerometer] setUpdateInterval:(1.0f / mUpdateInterval)]; [[UIAccelerometer sharedAccelerometer] setUpdateInterval:(1.0f / mUpdateInterval)];
} }
Vector3 getAccelerometerVector3(void) { return mState.mVectors[0]; } Vector3 getAccelerometerVector3(void) { return mState.mVectors[0]; }
/** @copydoc Object::capture */ /** @copydoc Object::capture */
virtual void capture(); virtual void capture();
/** @copydoc Object::queryInterface */ /** @copydoc Object::queryInterface */
virtual Interface* queryInterface(Interface::IType type) {return 0;} virtual Interface* queryInterface(Interface::IType type) {return 0;}
/** @copydoc Object::_initialize */ /** @copydoc Object::_initialize */
virtual void _initialize(); virtual void _initialize();
void didAccelerate(UIAcceleration *acceleration); void didAccelerate(UIAcceleration *acceleration);
protected: protected:
iPhoneAccelerometerDelegate *accelerometerDelegate; iPhoneAccelerometerDelegate *accelerometerDelegate;
/** The update frequency of the accelerometer. Represented in times per second. */ /** The update frequency of the accelerometer. Represented in times per second. */
float mUpdateInterval; float mUpdateInterval;
Vector3 mTempState; Vector3 mTempState;
}; };
} }
#endif // OIS_iPhoneAccelerometer_H #endif // OIS_iPhoneAccelerometer_H
/* /*
The zlib/libpng License The zlib/libpng License
Copyright (c) 2006 Chris Snyder Copyright (c) 2006 Chris Snyder
This software is provided 'as-is', without any express or implied warranty. In no event will 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. 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 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 applications, and to alter it and redistribute it freely, subject to the following
restrictions: restrictions:
1. The origin of this software must not be misrepresented; you must not claim that 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, you wrote the original software. If you use this software in a product,
an acknowledgment in the product documentation would be appreciated but is an acknowledgment in the product documentation would be appreciated but is
not required. not required.
2. Altered source versions must be plainly marked as such, and must not be 2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software. misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
*/ */
#ifndef OIS_iPhoneHelpers_H #ifndef OIS_iPhoneHelpers_H
#define OIS_iPhoneHelpers_H #define OIS_iPhoneHelpers_H
#include "iphone/iPhonePrereqs.h" #include "iphone/iPhonePrereqs.h"
#include "OISMultiTouch.h" #include "OISMultiTouch.h"
// This is needed for keeping an event stack for keyboard and mouse // This is needed for keeping an event stack for keyboard and mouse
namespace OIS namespace OIS
{ {
// used in the eventStack to store the type // used in the eventStack to store the type
enum iPhone_EventType { iPhone_KEYUP = 0, enum iPhone_EventType { iPhone_KEYUP = 0,
iPhone_KEYDOWN = 1, iPhone_KEYDOWN = 1,
iPhone_KEYREPEAT, iPhone_KEYREPEAT,
iPhone_MOUSEDOWN, iPhone_MOUSEDOWN,
iPhone_MOUSEUP, iPhone_MOUSEUP,
iPhone_MOUSEMOVED, iPhone_MOUSEMOVED,
iPhone_MOUSESCROLL}; iPhone_MOUSESCROLL};
typedef enum iPhone_EventType iPhoneEventType; typedef enum iPhone_EventType iPhoneEventType;
// only used by iPhoneMultiTouch // only used by iPhoneMultiTouch
typedef class iPhoneMultiTouchStackEvent typedef class iPhoneMultiTouchStackEvent
{ {
friend class iPhoneMultiTouch; friend class iPhoneMultiTouch;
private: private:
iPhoneMultiTouchStackEvent( MultiTouchEvent event, iPhoneEventType type) : Event(event), Type(type) {} iPhoneMultiTouchStackEvent( MultiTouchEvent event, iPhoneEventType type) : Event(event), Type(type) {}
iPhoneEventType Type; iPhoneEventType Type;
MultiTouchEvent Event; MultiTouchEvent Event;
} iPhoneMultiTouchStackEvent; } iPhoneMultiTouchStackEvent;
} }
#endif #endif
/* /*
The zlib/libpng License The zlib/libpng License
Copyright (c) 2006 Chris Snyder Copyright (c) 2006 Chris Snyder
This software is provided 'as-is', without any express or implied warranty. In no event will 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. 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 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 applications, and to alter it and redistribute it freely, subject to the following
restrictions: restrictions:
1. The origin of this software must not be misrepresented; you must not claim that 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, you wrote the original software. If you use this software in a product,
an acknowledgment in the product documentation would be appreciated but is an acknowledgment in the product documentation would be appreciated but is
not required. not required.
2. Altered source versions must be plainly marked as such, and must not be 2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software. misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
*/ */
#ifndef OIS_iPhoneInputManager_H #ifndef OIS_iPhoneInputManager_H
#define OIS_iPhoneInputManager_H #define OIS_iPhoneInputManager_H
#include "OISInputManager.h" #include "OISInputManager.h"
#include "OISFactoryCreator.h" #include "OISFactoryCreator.h"
#include "iphone/iPhonePrereqs.h" #include "iphone/iPhonePrereqs.h"
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
namespace OIS { namespace OIS {
class iPhoneAccelerometer; class iPhoneAccelerometer;
class iPhoneMultiTouch; class iPhoneMultiTouch;
} }
@interface InputDelegate : UIView <UIAccelerometerDelegate> { @interface InputDelegate : UIView <UIAccelerometerDelegate> {
OIS::iPhoneAccelerometer *accelerometerObject; OIS::iPhoneAccelerometer *accelerometerObject;
OIS::iPhoneMultiTouch *touchObject; OIS::iPhoneMultiTouch *touchObject;
} }
@property (assign) OIS::iPhoneAccelerometer *accelerometerObject; @property (assign) OIS::iPhoneAccelerometer *accelerometerObject;
@property (assign) OIS::iPhoneMultiTouch *touchObject; @property (assign) OIS::iPhoneMultiTouch *touchObject;
@end @end
namespace OIS namespace OIS
{ {
class iPhoneInputManager : public InputManager, public FactoryCreator class iPhoneInputManager : public InputManager, public FactoryCreator
{ {
public: public:
iPhoneInputManager(); iPhoneInputManager();
virtual ~iPhoneInputManager(); virtual ~iPhoneInputManager();
//InputManager Overrides //InputManager Overrides
/** @copydoc InputManager::_initialize */ /** @copydoc InputManager::_initialize */
void _initialize( ParamList &paramList ); void _initialize( ParamList &paramList );
//FactoryCreator Overrides //FactoryCreator Overrides
/** @copydoc FactoryCreator::deviceList */ /** @copydoc FactoryCreator::deviceList */
DeviceList freeDeviceList(); DeviceList freeDeviceList();
/** @copydoc FactoryCreator::totalDevices */ /** @copydoc FactoryCreator::totalDevices */
int totalDevices(Type iType); int totalDevices(Type iType);
/** @copydoc FactoryCreator::freeDevices */ /** @copydoc FactoryCreator::freeDevices */
int freeDevices(Type iType); int freeDevices(Type iType);
/** @copydoc FactoryCreator::vendorExist */ /** @copydoc FactoryCreator::vendorExist */
bool vendorExist(Type iType, const std::string & vendor); bool vendorExist(Type iType, const std::string & vendor);
/** @copydoc FactoryCreator::createObject */ /** @copydoc FactoryCreator::createObject */
Object* createObject(InputManager* creator, Type iType, bool bufferMode, const std::string & vendor = ""); Object* createObject(InputManager* creator, Type iType, bool bufferMode, const std::string & vendor = "");
/** @copydoc FactoryCreator::destroyObject */ /** @copydoc FactoryCreator::destroyObject */
void destroyObject(Object* obj); void destroyObject(Object* obj);
//Internal Items //Internal Items
//! Internal method, used for flagging multi-touch as available/unavailable for creation //! Internal method, used for flagging multi-touch as available/unavailable for creation
void _setMultiTouchUsed(bool used) { bMultiTouchUsed = used; } void _setMultiTouchUsed(bool used) { bMultiTouchUsed = used; }
//! Internal method, used for flagging accelerometer as available/unavailable for creation //! Internal method, used for flagging accelerometer as available/unavailable for creation
void _setAccelerometerUsed(bool used) { bAccelerometerUsed = used; } void _setAccelerometerUsed(bool used) { bAccelerometerUsed = used; }
//! methodfor getting the delegate //! methodfor getting the delegate
InputDelegate * _getDelegate() { return mDelegate; } InputDelegate * _getDelegate() { return mDelegate; }
//! method for getting window //! method for getting window
UIWindow * _getWindow() { return mWindow; } UIWindow * _getWindow() { return mWindow; }
protected: protected:
void _parseConfigSettings( ParamList& paramList ); void _parseConfigSettings( ParamList& paramList );
// iPhone stuff // iPhone stuff
UIWindow *mWindow; UIWindow *mWindow;
InputDelegate *mDelegate; InputDelegate *mDelegate;
// settings // settings
bool mHideMouse; bool mHideMouse;
//! Used to know if we used up multi-touch device //! Used to know if we used up multi-touch device
bool bMultiTouchUsed; bool bMultiTouchUsed;
//! Used to know if we used up accelerometer //! Used to know if we used up accelerometer
bool bAccelerometerUsed; bool bAccelerometerUsed;
}; };
} }
#endif #endif
/* /*
The zlib/libpng License The zlib/libpng License
Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com) Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
This software is provided 'as-is', without any express or implied warranty. In no event will 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. 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 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 applications, and to alter it and redistribute it freely, subject to the following
restrictions: restrictions:
1. The origin of this software must not be misrepresented; you must not claim that 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, you wrote the original software. If you use this software in a product,
an acknowledgment in the product documentation would be appreciated but is an acknowledgment in the product documentation would be appreciated but is
not required. not required.
2. Altered source versions must be plainly marked as such, and must not be 2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software. misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
*/ */
#ifndef OIS_iPhoneMultiTouch_H #ifndef OIS_iPhoneMultiTouch_H
#define OIS_iPhoneMultiTouch_H #define OIS_iPhoneMultiTouch_H
#include "OISMultiTouch.h" #include "OISMultiTouch.h"
#include "iphone/iPhonePrereqs.h" #include "iphone/iPhonePrereqs.h"
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
struct CGPoint; struct CGPoint;
namespace OIS namespace OIS
{ {
class iPhoneMultiTouch : public MultiTouch class iPhoneMultiTouch : public MultiTouch
{ {
public: public:
iPhoneMultiTouch( InputManager* creator, bool buffered ); iPhoneMultiTouch( InputManager* creator, bool buffered );
virtual ~iPhoneMultiTouch(); virtual ~iPhoneMultiTouch();
/** @copydoc Object::setBuffered */ /** @copydoc Object::setBuffered */
virtual void setBuffered(bool buffered); virtual void setBuffered(bool buffered);
/** @copydoc Object::capture */ /** @copydoc Object::capture */
virtual void capture(); virtual void capture();
/** @copydoc Object::queryInterface */ /** @copydoc Object::queryInterface */
virtual Interface* queryInterface(Interface::IType type) {return 0;} virtual Interface* queryInterface(Interface::IType type) {return 0;}
/** @copydoc Object::_initialize */ /** @copydoc Object::_initialize */
virtual void _initialize(); virtual void _initialize();
void _touchBegan(UITouch *touch); void _touchBegan(UITouch *touch);
void _touchEnded(UITouch *touch); void _touchEnded(UITouch *touch);
void _touchMoved(UITouch *touch); void _touchMoved(UITouch *touch);
void _touchCancelled(UITouch *touch); void _touchCancelled(UITouch *touch);
protected: protected:
MultiTouchState mTempState; MultiTouchState mTempState;
}; };
} }
#endif // OIS_iPhoneTouch_H #endif // OIS_iPhoneTouch_H
/* /*
The zlib/libpng License The zlib/libpng License
Copyright (c) 2006 Chris Snyder Copyright (c) 2006 Chris Snyder
This software is provided 'as-is', without any express or implied warranty. In no event will 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. 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 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 applications, and to alter it and redistribute it freely, subject to the following
restrictions: restrictions:
1. The origin of this software must not be misrepresented; you must not claim that 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, you wrote the original software. If you use this software in a product,
an acknowledgment in the product documentation would be appreciated but is an acknowledgment in the product documentation would be appreciated but is
not required. not required.
2. Altered source versions must be plainly marked as such, and must not be 2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software. misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
*/ */
#ifndef OIS_iPhonePrereqs_H #ifndef OIS_iPhonePrereqs_H
#define OIS_iPhonePrereqs_H #define OIS_iPhonePrereqs_H
#include <string> #include <string>
#include <list> #include <list>
#include <CoreFoundation/CoreFoundation.h> #include <CoreFoundation/CoreFoundation.h>
namespace OIS namespace OIS
{ {
class iPhoneInputManager; class iPhoneInputManager;
class iPhoneAccelerometer; class iPhoneAccelerometer;
class iPhoneMouse; class iPhoneMouse;
/** /**
Simple wrapper class for CFString which will create a valid CFString and retain ownership until class instance is outof scope Simple wrapper class for CFString which will create a valid CFString and retain ownership until class instance is outof scope
To Access the CFStringRef instance, simply cast to void*, pass into a function expecting a void* CFStringRef object, or access via cf_str() method To Access the CFStringRef instance, simply cast to void*, pass into a function expecting a void* CFStringRef object, or access via cf_str() method
*/ */
class OIS_CFString class OIS_CFString
{ {
public: public:
OIS_CFString() { m_StringRef = CFStringCreateWithCString(NULL, "", kCFStringEncodingUTF8); } OIS_CFString() { m_StringRef = CFStringCreateWithCString(NULL, "", kCFStringEncodingUTF8); }
OIS_CFString(const char* c_str) { m_StringRef = CFStringCreateWithCString(NULL, c_str, kCFStringEncodingUTF8); } OIS_CFString(const char* c_str) { m_StringRef = CFStringCreateWithCString(NULL, c_str, kCFStringEncodingUTF8); }
OIS_CFString(const std::string &s_str) { m_StringRef = CFStringCreateWithCString(NULL, s_str.c_str(), kCFStringEncodingUTF8); } OIS_CFString(const std::string &s_str) { m_StringRef = CFStringCreateWithCString(NULL, s_str.c_str(), kCFStringEncodingUTF8); }
~OIS_CFString() { CFRelease(m_StringRef); } ~OIS_CFString() { CFRelease(m_StringRef); }
//Allow this class to be autoconverted to base class of StringRef (void*) //Allow this class to be autoconverted to base class of StringRef (void*)
operator void*() { return (void*)m_StringRef; } operator void*() { return (void*)m_StringRef; }
CFStringRef cf_str() { return m_StringRef; } CFStringRef cf_str() { return m_StringRef; }
private: private:
CFStringRef m_StringRef; CFStringRef m_StringRef;
}; };
} }
#endif #endif
/* /*
The zlib/libpng License The zlib/libpng License
Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com) Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
This software is provided 'as-is', without any express or implied warranty. In no event will 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. 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 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 applications, and to alter it and redistribute it freely, subject to the following
restrictions: restrictions:
1. The origin of this software must not be misrepresented; you must not claim that 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, you wrote the original software. If you use this software in a product,
an acknowledgment in the product documentation would be appreciated but is an acknowledgment in the product documentation would be appreciated but is
not required. not required.
2. Altered source versions must be plainly marked as such, and must not be 2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software. misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
*/ */
#ifndef _LINUX_OISEVENT_HEADER_ #ifndef _LINUX_OISEVENT_HEADER_
#define _LINUX_OISEVENT_HEADER_ #define _LINUX_OISEVENT_HEADER_
#include "linux/LinuxPrereqs.h" #include "linux/LinuxPrereqs.h"
#define OIS_MAX_DEVICES 32 #define OIS_MAX_DEVICES 32
#define OIS_DEVICE_NAME 128 #define OIS_DEVICE_NAME 128
namespace OIS namespace OIS
{ {
class EventUtils class EventUtils
{ {
public: public:
static bool isJoyStick( int deviceID, JoyStickInfo &js ); static bool isJoyStick( int deviceID, JoyStickInfo &js );
static bool isMouse( int ) {return false;} static bool isMouse( int ) {return false;}
static bool isKeyboard( int ) {return false;} static bool isKeyboard( int ) {return false;}
//Double pointer is so that we can set the value of the sent pointer //Double pointer is so that we can set the value of the sent pointer
static void enumerateForceFeedback( int deviceID, LinuxForceFeedback** ff ); static void enumerateForceFeedback( int deviceID, LinuxForceFeedback** ff );
static void removeForceFeedback( LinuxForceFeedback** ff ); static void removeForceFeedback( LinuxForceFeedback** ff );
static std::string getName( int deviceID ); static std::string getName( int deviceID );
static std::string getUniqueId( int deviceID ); static std::string getUniqueId( int deviceID );
static std::string getPhysicalLocation( int deviceID ); static std::string getPhysicalLocation( int deviceID );
}; };
} }
#endif #endif
/* /*
The zlib/libpng License The zlib/libpng License
Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com) Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
This software is provided 'as-is', without any express or implied warranty. In no event will 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. 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 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 applications, and to alter it and redistribute it freely, subject to the following
restrictions: restrictions:
1. The origin of this software must not be misrepresented; you must not claim that 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, you wrote the original software. If you use this software in a product,
an acknowledgment in the product documentation would be appreciated but is an acknowledgment in the product documentation would be appreciated but is
not required. not required.
2. Altered source versions must be plainly marked as such, and must not be 2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software. misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
*/ */
#ifndef OIS_LinuxForceFeedBack_H #ifndef OIS_LinuxForceFeedBack_H
#define OIS_LinuxForceFeedBack_H #define OIS_LinuxForceFeedBack_H
#include "linux/LinuxPrereqs.h" #include "linux/LinuxPrereqs.h"
#include "OISForceFeedback.h" #include "OISForceFeedback.h"
#include <linux/input.h> #include <linux/input.h>
namespace OIS namespace OIS
{ {
class LinuxForceFeedback : public ForceFeedback class LinuxForceFeedback : public ForceFeedback
{ {
public: public:
LinuxForceFeedback(int deviceID); LinuxForceFeedback(int deviceID);
~LinuxForceFeedback(); ~LinuxForceFeedback();
/** @copydoc ForceFeedback::setMasterGain */ /** @copydoc ForceFeedback::setMasterGain */
void setMasterGain(float); void setMasterGain(float);
/** @copydoc ForceFeedback::setAutoCenterMode */ /** @copydoc ForceFeedback::setAutoCenterMode */
void setAutoCenterMode(bool); void setAutoCenterMode(bool);
/** @copydoc ForceFeedback::upload */ /** @copydoc ForceFeedback::upload */
void upload( const Effect* effect ); void upload( const Effect* effect );
/** @copydoc ForceFeedback::modify */ /** @copydoc ForceFeedback::modify */
void modify( const Effect* effect ); void modify( const Effect* effect );
/** @copydoc ForceFeedback::remove */ /** @copydoc ForceFeedback::remove */
void remove( const Effect* effect ); void remove( const Effect* effect );
/** FF is not yet implemented fully on Linux.. just return -1 for now. todo, xxx */ /** FF is not yet implemented fully on Linux.. just return -1 for now. todo, xxx */
short int getFFAxesNumber() { return -1; } short int getFFAxesNumber() { return -1; }
/** @copydoc ForceFeedback::getFFMemoryLoad */ /** @copydoc ForceFeedback::getFFMemoryLoad */
unsigned short getFFMemoryLoad(); unsigned short getFFMemoryLoad();
protected: protected:
//Sets the common properties to all effects //Sets the common properties to all effects
void _setCommonProperties(struct ff_effect *event, struct ff_envelope *ffenvelope, void _setCommonProperties(struct ff_effect *event, struct ff_envelope *ffenvelope,
const Effect* effect, const Envelope *envelope ); const Effect* effect, const Envelope *envelope );
//Specific Effect Settings //Specific Effect Settings
void _updateConstantEffect( const Effect* effect ); void _updateConstantEffect( const Effect* effect );
void _updateRampEffect( const Effect* effect ); void _updateRampEffect( const Effect* effect );
void _updatePeriodicEffect( const Effect* effect ); void _updatePeriodicEffect( const Effect* effect );
void _updateConditionalEffect( const Effect* effect ); void _updateConditionalEffect( const Effect* effect );
//void _updateCustomEffect( const Effect* effect ); //void _updateCustomEffect( const Effect* effect );
void _upload( struct ff_effect* ffeffect, const Effect* effect); void _upload( struct ff_effect* ffeffect, const Effect* effect);
void _stop( int handle); void _stop( int handle);
void _start( int handle); void _start( int handle);
void _unload( int handle); void _unload( int handle);
// Map of currently uploaded effects (handle => effect) // Map of currently uploaded effects (handle => effect)
typedef std::map<int, struct ff_effect *> EffectList; typedef std::map<int, struct ff_effect *> EffectList;
EffectList mEffectList; EffectList mEffectList;
// Joystick device (file) descriptor. // Joystick device (file) descriptor.
int mJoyStick; int mJoyStick;
}; };
} }
#endif //OIS_LinuxForceFeedBack_H #endif //OIS_LinuxForceFeedBack_H
/* /*
The zlib/libpng License The zlib/libpng License
Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com) Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
This software is provided 'as-is', without any express or implied warranty. In no event will 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. 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 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 applications, and to alter it and redistribute it freely, subject to the following
restrictions: restrictions:
1. The origin of this software must not be misrepresented; you must not claim that 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, you wrote the original software. If you use this software in a product,
an acknowledgment in the product documentation would be appreciated but is an acknowledgment in the product documentation would be appreciated but is
not required. not required.
2. Altered source versions must be plainly marked as such, and must not be 2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software. misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
*/ */
#ifndef OIS_LinuxInputManager_H #ifndef OIS_LinuxInputManager_H
#define OIS_LinuxInputManager_H #define OIS_LinuxInputManager_H
#include "linux/LinuxPrereqs.h" #include "linux/LinuxPrereqs.h"
#include "OISFactoryCreator.h" #include "OISFactoryCreator.h"
#include "OISInputManager.h" #include "OISInputManager.h"
#include <X11/Xlib.h> #include <X11/Xlib.h>
namespace OIS namespace OIS
{ {
/** /**
Linux X11 InputManager specialization - Using lowlevel joys Linux X11 InputManager specialization - Using lowlevel joys
*/ */
class LinuxInputManager : public InputManager, public FactoryCreator class LinuxInputManager : public InputManager, public FactoryCreator
{ {
public: public:
LinuxInputManager(); LinuxInputManager();
virtual ~LinuxInputManager(); virtual ~LinuxInputManager();
//InputManager Overrides //InputManager Overrides
/** @copydoc InputManager::_initialize */ /** @copydoc InputManager::_initialize */
void _initialize( ParamList &paramList ); void _initialize( ParamList &paramList );
//FactoryCreator Overrides //FactoryCreator Overrides
/** @copydoc FactoryCreator::deviceList */ /** @copydoc FactoryCreator::deviceList */
DeviceList freeDeviceList(); DeviceList freeDeviceList();
/** @copydoc FactoryCreator::totalDevices */ /** @copydoc FactoryCreator::totalDevices */
int totalDevices(Type iType); int totalDevices(Type iType);
/** @copydoc FactoryCreator::freeDevices */ /** @copydoc FactoryCreator::freeDevices */
int freeDevices(Type iType); int freeDevices(Type iType);
/** @copydoc FactoryCreator::vendorExist */ /** @copydoc FactoryCreator::vendorExist */
bool vendorExist(Type iType, const std::string & vendor); bool vendorExist(Type iType, const std::string & vendor);
/** @copydoc FactoryCreator::createObject */ /** @copydoc FactoryCreator::createObject */
Object* createObject(InputManager *creator, Type iType, bool bufferMode, const std::string & vendor = ""); Object* createObject(InputManager *creator, Type iType, bool bufferMode, const std::string & vendor = "");
/** @copydoc FactoryCreator::destroyObject */ /** @copydoc FactoryCreator::destroyObject */
void destroyObject(Object* obj); void destroyObject(Object* obj);
//Internal Items //Internal Items
//! Method for retrieving the XWindow Handle //! Method for retrieving the XWindow Handle
Window _getWindow() {return window;} Window _getWindow() {return window;}
//! Internal method for checking if regrabbing is needed //! Internal method for checking if regrabbing is needed
void _setGrabState(bool grab) {mGrabs = grab;} void _setGrabState(bool grab) {mGrabs = grab;}
bool _getGrabState() {return mGrabs;} bool _getGrabState() {return mGrabs;}
//! Internal method, used for flaggin keyboard as available/unavailable for creation //! Internal method, used for flaggin keyboard as available/unavailable for creation
void _setKeyboardUsed(bool used) {keyboardUsed = used; } void _setKeyboardUsed(bool used) {keyboardUsed = used; }
//! Internal method, used for flaggin mouse as available/unavailable for creation //! Internal method, used for flaggin mouse as available/unavailable for creation
void _setMouseUsed(bool used) { mouseUsed = used; } void _setMouseUsed(bool used) { mouseUsed = used; }
protected: protected:
//! internal class method for dealing with param list //! internal class method for dealing with param list
void _parseConfigSettings( ParamList &paramList ); void _parseConfigSettings( ParamList &paramList );
//! internal class method for finding attached devices //! internal class method for finding attached devices
void _enumerateDevices(); void _enumerateDevices();
//! List of unused joysticks ready to be used //! List of unused joysticks ready to be used
JoyStickInfoList unusedJoyStickList; JoyStickInfoList unusedJoyStickList;
//! Number of joysticks found //! Number of joysticks found
char joySticks; char joySticks;
//! Used to know if we used up keyboard //! Used to know if we used up keyboard
bool keyboardUsed; bool keyboardUsed;
//! Used to know if we used up mouse //! Used to know if we used up mouse
bool mouseUsed; bool mouseUsed;
//! X11 Stuff //! X11 Stuff
Window window; Window window;
/// Keyboard, Mouse Settings /// Keyboard, Mouse Settings
bool grabMouse, grabKeyboard; bool grabMouse, grabKeyboard;
bool mGrabs; bool mGrabs;
bool hideMouse; bool hideMouse;
}; };
} }
#endif #endif
/* /*
The zlib/libpng License The zlib/libpng License
Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com) Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
This software is provided 'as-is', without any express or implied warranty. In no event will 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. 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 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 applications, and to alter it and redistribute it freely, subject to the following
restrictions: restrictions:
1. The origin of this software must not be misrepresented; you must not claim that 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, you wrote the original software. If you use this software in a product,
an acknowledgment in the product documentation would be appreciated but is an acknowledgment in the product documentation would be appreciated but is
not required. not required.
2. Altered source versions must be plainly marked as such, and must not be 2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software. misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
*/ */
#ifndef _LINUX_JOYSTICK_H_EADER_ #ifndef _LINUX_JOYSTICK_H_EADER_
#define _LINUX_JOYSTICK_H_EADER_ #define _LINUX_JOYSTICK_H_EADER_
#include "linux/LinuxPrereqs.h" #include "linux/LinuxPrereqs.h"
#include "OISJoyStick.h" #include "OISJoyStick.h"
namespace OIS namespace OIS
{ {
/** /**
Linux specialization of JoyStick class.. This version is favored over the other.. and has the Linux specialization of JoyStick class.. This version is favored over the other.. and has the
*possibility* of Force Feedback.. notice I say possibility, i make no gaurantees under linux, *possibility* of Force Feedback.. notice I say possibility, i make no gaurantees under linux,
as FF support is sketchy at best AFAIK. as FF support is sketchy at best AFAIK.
*/ */
class LinuxJoyStick : public JoyStick class LinuxJoyStick : public JoyStick
{ {
public: public:
LinuxJoyStick(InputManager* creator, bool buffered, const JoyStickInfo& js); LinuxJoyStick(InputManager* creator, bool buffered, const JoyStickInfo& js);
virtual ~LinuxJoyStick(); virtual ~LinuxJoyStick();
/** @copydoc Object::setBuffered */ /** @copydoc Object::setBuffered */
virtual void setBuffered(bool buffered); virtual void setBuffered(bool buffered);
/** @copydoc Object::capture */ /** @copydoc Object::capture */
virtual void capture(); virtual void capture();
/** @copydoc Object::queryInterface */ /** @copydoc Object::queryInterface */
virtual Interface* queryInterface(Interface::IType type); virtual Interface* queryInterface(Interface::IType type);
/** @copydoc Object::_initialize */ /** @copydoc Object::_initialize */
virtual void _initialize(); virtual void _initialize();
/** /**
@remarks @remarks
For internal use only... Returns a structure to the manager, to make the device For internal use only... Returns a structure to the manager, to make the device
availiable for use again availiable for use again
*/ */
JoyStickInfo _getJoyInfo(); JoyStickInfo _getJoyInfo();
static JoyStickInfoList _scanJoys(); static JoyStickInfoList _scanJoys();
static void _clearJoys(JoyStickInfoList &joys); static void _clearJoys(JoyStickInfoList &joys);
protected: protected:
int mJoyStick; int mJoyStick;
LinuxForceFeedback* ff_effect; LinuxForceFeedback* ff_effect;
std::map <int, int> mButtonMap; std::map <int, int> mButtonMap;
std::map <int, int> mAxisMap; std::map <int, int> mAxisMap;
std::map <int, Range> mRanges; std::map <int, Range> mRanges;
}; };
} }
#endif //_LINUX_JOYSTICK_H_EADER_ #endif //_LINUX_JOYSTICK_H_EADER_
/* /*
The zlib/libpng License The zlib/libpng License
Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com) Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
This software is provided 'as-is', without any express or implied warranty. In no event will 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. 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 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 applications, and to alter it and redistribute it freely, subject to the following
restrictions: restrictions:
1. The origin of this software must not be misrepresented; you must not claim that 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, you wrote the original software. If you use this software in a product,
an acknowledgment in the product documentation would be appreciated but is an acknowledgment in the product documentation would be appreciated but is
not required. not required.
2. Altered source versions must be plainly marked as such, and must not be 2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software. misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
*/ */
#ifndef _LINUX_KEYBOARD_H_EADER_ #ifndef _LINUX_KEYBOARD_H_EADER_
#define _LINUX_KEYBOARD_H_EADER_ #define _LINUX_KEYBOARD_H_EADER_
#include "linux/LinuxPrereqs.h" #include "linux/LinuxPrereqs.h"
#include "OISKeyboard.h" #include "OISKeyboard.h"
#include <X11/Xlib.h> #include <X11/Xlib.h>
namespace OIS namespace OIS
{ {
/** Linux implementation of Keyboard object - uses x11 */ /** Linux implementation of Keyboard object - uses x11 */
class LinuxKeyboard : public Keyboard class LinuxKeyboard : public Keyboard
{ {
public: public:
LinuxKeyboard(InputManager* creator, bool buffered, bool grab); LinuxKeyboard(InputManager* creator, bool buffered, bool grab);
virtual ~LinuxKeyboard(); virtual ~LinuxKeyboard();
/** @copydoc Keyboard::isKeyDown */ /** @copydoc Keyboard::isKeyDown */
virtual bool isKeyDown( KeyCode key ) const; virtual bool isKeyDown( KeyCode key ) const;
/** @copydoc Keyboard::getAsString */ /** @copydoc Keyboard::getAsString */
virtual const std::string& getAsString( KeyCode kc ); virtual const std::string& getAsString( KeyCode kc );
/** @copydoc Keyboard::copyKeyStates */ /** @copydoc Keyboard::copyKeyStates */
virtual void copyKeyStates( char keys[256] ) const; virtual void copyKeyStates( char keys[256] ) const;
/** @copydoc Object::setBuffered */ /** @copydoc Object::setBuffered */
virtual void setBuffered(bool buffered); virtual void setBuffered(bool buffered);
/** @copydoc Object::capture */ /** @copydoc Object::capture */
virtual void capture(); virtual void capture();
/** @copydoc Object::queryInterface */ /** @copydoc Object::queryInterface */
virtual Interface* queryInterface(Interface::IType) {return 0;} virtual Interface* queryInterface(Interface::IType) {return 0;}
/** @copydoc Object::_initialize */ /** @copydoc Object::_initialize */
virtual void _initialize(); virtual void _initialize();
protected: protected:
inline bool _isKeyRepeat(XEvent &event) inline bool _isKeyRepeat(XEvent &event)
{ {
...@@ -74,25 +74,25 @@ namespace OIS ...@@ -74,25 +74,25 @@ namespace OIS
return false; return false;
} }
bool _injectKeyDown( KeySym key, int text ); bool _injectKeyDown( KeySym key, int text );
bool _injectKeyUp( KeySym key ); bool _injectKeyUp( KeySym key );
//! 1:1 Conversion Map between X Key Events and OIS KeyCodes //! 1:1 Conversion Map between X Key Events and OIS KeyCodes
typedef std::map<KeySym, KeyCode> XtoOIS_KeyMap; typedef std::map<KeySym, KeyCode> XtoOIS_KeyMap;
XtoOIS_KeyMap keyConversion; XtoOIS_KeyMap keyConversion;
//! Depressed Key List //! Depressed Key List
char KeyBuffer[256]; char KeyBuffer[256];
//! X11 Stuff //! X11 Stuff
Window window; Window window;
Display *display; Display *display;
bool grabKeyboard; bool grabKeyboard;
bool keyFocusLost; bool keyFocusLost;
std::string mGetString; std::string mGetString;
}; };
} }
#endif //_LINUX_KEYBOARD_H_EADER_ #endif //_LINUX_KEYBOARD_H_EADER_
/* /*
The zlib/libpng License The zlib/libpng License
Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com) Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
This software is provided 'as-is', without any express or implied warranty. In no event will 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. 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 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 applications, and to alter it and redistribute it freely, subject to the following
restrictions: restrictions:
1. The origin of this software must not be misrepresented; you must not claim that 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, you wrote the original software. If you use this software in a product,
an acknowledgment in the product documentation would be appreciated but is an acknowledgment in the product documentation would be appreciated but is
not required. not required.
2. Altered source versions must be plainly marked as such, and must not be 2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software. misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
*/ */
#ifndef _LINUX_MOUSE_H_EADER_ #ifndef _LINUX_MOUSE_H_EADER_
#define _LINUX_MOUSE_H_EADER_ #define _LINUX_MOUSE_H_EADER_
#include "linux/LinuxPrereqs.h" #include "linux/LinuxPrereqs.h"
#include "OISMouse.h" #include "OISMouse.h"
#include <X11/Xlib.h> #include <X11/Xlib.h>
namespace OIS namespace OIS
{ {
class LinuxMouse : public Mouse class LinuxMouse : public Mouse
{ {
public: public:
LinuxMouse(InputManager* creator, bool buffered, bool grab, bool hide); LinuxMouse(InputManager* creator, bool buffered, bool grab, bool hide);
virtual ~LinuxMouse(); virtual ~LinuxMouse();
/** @copydoc Object::setBuffered */ /** @copydoc Object::setBuffered */
virtual void setBuffered(bool buffered); virtual void setBuffered(bool buffered);
/** /**
@remarks @remarks
Note: Calling this will also update the keyboard (X11 updates in a single Note: Calling this will also update the keyboard (X11 updates in a single
event queue). Updates State and/or raises event for buffered mode.. event queue). Updates State and/or raises event for buffered mode..
*/ */
virtual void capture(); virtual void capture();
/** @copydoc Object::queryInterface */ /** @copydoc Object::queryInterface */
virtual Interface* queryInterface(Interface::IType) {return 0;} virtual Interface* queryInterface(Interface::IType) {return 0;}
/** @copydoc Object::_initialize */ /** @copydoc Object::_initialize */
virtual void _initialize(); virtual void _initialize();
void grab(bool grab); void grab(bool grab);
void hide(bool hide); void hide(bool hide);
protected: protected:
void _processXEvents(); void _processXEvents();
bool mMoved, mWarped; bool mMoved, mWarped;
//Since X11 provides us with absolute values, we need to keep track of relative values //Since X11 provides us with absolute values, we need to keep track of relative values
long oldXMouseX, oldXMouseY, oldXMouseZ; long oldXMouseX, oldXMouseY, oldXMouseZ;
Window window; //The X Window Window window; //The X Window
Display *display; //The X display Display *display; //The X display
Cursor cursor; //A blank cursor Cursor cursor; //A blank cursor
bool grabMouse; //Are we grabbing the mouse to the window? bool grabMouse; //Are we grabbing the mouse to the window?
bool hideMouse; //Are we hiding OS mouse? bool hideMouse; //Are we hiding OS mouse?
bool mouseFocusLost;//Has the mouse just lost focus? bool mouseFocusLost;//Has the mouse just lost focus?
}; };
} }
#endif //_LINUX_MOUSE_H_EADER_ #endif //_LINUX_MOUSE_H_EADER_
/* /*
The zlib/libpng License The zlib/libpng License
Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com) Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
This software is provided 'as-is', without any express or implied warranty. In no event will 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. 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 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 applications, and to alter it and redistribute it freely, subject to the following
restrictions: restrictions:
1. The origin of this software must not be misrepresented; you must not claim that 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, you wrote the original software. If you use this software in a product,
an acknowledgment in the product documentation would be appreciated but is an acknowledgment in the product documentation would be appreciated but is
not required. not required.
2. Altered source versions must be plainly marked as such, and must not be 2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software. misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
*/ */
#ifndef _LINUX_INPUTSYSTEM_PREREQS_H #ifndef _LINUX_INPUTSYSTEM_PREREQS_H
#define _LINUX_INPUTSYSTEM_PREREQS_H #define _LINUX_INPUTSYSTEM_PREREQS_H
//Bring in any auto generated config files //Bring in any auto generated config files
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
# include "config.h" # include "config.h"
#endif #endif
#include "OISPrereqs.h" #include "OISPrereqs.h"
//! Max number of elements to collect from buffered input //! Max number of elements to collect from buffered input
#define JOY_BUFFERSIZE 64 #define JOY_BUFFERSIZE 64
namespace OIS namespace OIS
{ {
class LinuxInputManager; class LinuxInputManager;
class LinuxKeyboard; class LinuxKeyboard;
class LinuxJoyStick; class LinuxJoyStick;
class LinuxMouse; class LinuxMouse;
class LinuxForceFeedback; class LinuxForceFeedback;
class Range class Range
{ {
public: public:
Range() {}; Range() {};
Range(int _min, int _max) : min(_min), max(_max) {}; Range(int _min, int _max) : min(_min), max(_max) {};
int min, max; int min, max;
}; };
class JoyStickInfo class JoyStickInfo
{ {
public: public:
JoyStickInfo(): devId(-1),joyFileD(-1),version(0),axes(0),buttons(0),hats(0) {} JoyStickInfo(): devId(-1),joyFileD(-1),version(0),axes(0),buttons(0),hats(0) {}
//! Device number (/dev/input/j#) or /dev/input/event# //! Device number (/dev/input/j#) or /dev/input/event#
int devId; int devId;
//! File descriptor //! File descriptor
int joyFileD; int joyFileD;
//! Driver version //! Driver version
int version; int version;
//! Joy vendor //! Joy vendor
std::string vendor; std::string vendor;
//! Number of axes //! Number of axes
unsigned char axes; unsigned char axes;
//! Number of buttons //! Number of buttons
unsigned char buttons; unsigned char buttons;
//! Number of hats //! Number of hats
unsigned char hats; unsigned char hats;
//! Maps Linux button values to OIS buttons values //! Maps Linux button values to OIS buttons values
std::map<int, int> button_map; std::map<int, int> button_map;
//! Maps Linux axis values to OIS axis //! Maps Linux axis values to OIS axis
std::map<int, int> axis_map; std::map<int, int> axis_map;
//! Maps OIS axis values to it's range //! Maps OIS axis values to it's range
std::map<int, Range> axis_range; std::map<int, Range> axis_range;
}; };
typedef std::vector< JoyStickInfo > JoyStickInfoList; typedef std::vector< JoyStickInfo > JoyStickInfoList;
} }
#endif //_LINUX_INPUTSYSTEM_PREREQS_H #endif //_LINUX_INPUTSYSTEM_PREREQS_H
/* /*
The zlib/libpng License The zlib/libpng License
Copyright (c) 2007 Phillip Copyright (c) 2007 Phillip
This software is provided 'as-is', without any express or implied warranty. In no event will 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. 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 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 applications, and to alter it and redistribute it freely, subject to the following
restrictions: restrictions:
1. The origin of this software must not be misrepresented; you must not claim that 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, you wrote the original software. If you use this software in a product,
an acknowledgment in the product documentation would be appreciated but is an acknowledgment in the product documentation would be appreciated but is
not required. not required.
2. Altered source versions must be plainly marked as such, and must not be 2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software. misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
*/ */
#ifndef OIS_MacHIDManager_Header #ifndef OIS_MacHIDManager_Header
#define OIS_MacHIDManager_Header #define OIS_MacHIDManager_Header
#include "OISPrereqs.h" #include "OISPrereqs.h"
#include "mac/MacPrereqs.h" #include "mac/MacPrereqs.h"
#include "OISFactoryCreator.h" #include "OISFactoryCreator.h"
#import <CoreFoundation/CFString.h> #import <CoreFoundation/CFString.h>
#import <IOKit/IOKitLib.h> #import <IOKit/IOKitLib.h>
#import <IOKit/IOCFPlugIn.h> #import <IOKit/IOCFPlugIn.h>
#import <IOKit/hid/IOHIDLib.h> #import <IOKit/hid/IOHIDLib.h>
#import <IOKit/hid/IOHIDKeys.h> #import <IOKit/hid/IOHIDKeys.h>
#import <Kernel/IOKit/hidsystem/IOHIDUsageTables.h> #import <Kernel/IOKit/hidsystem/IOHIDUsageTables.h>
namespace OIS namespace OIS
{ {
//Information needed to create Mac HID Devices //Information needed to create Mac HID Devices
class HidInfo class HidInfo
{ {
public: public:
HidInfo() : type(OISUnknown), numButtons(0), numHats(0), numAxes(0), inUse(false), interface(0) HidInfo() : type(OISUnknown), numButtons(0), numHats(0), numAxes(0), inUse(false), interface(0)
{ {
} }
//Useful tracking information //Useful tracking information
Type type; Type type;
std::string vendor; std::string vendor;
std::string productKey; std::string productKey;
std::string combinedKey; std::string combinedKey;
//Retain some count information for recreating devices without having to reparse //Retain some count information for recreating devices without having to reparse
int numButtons; int numButtons;
int numHats; int numHats;
int numAxes; int numAxes;
bool inUse; bool inUse;
//Used for opening a read/write/tracking interface to device //Used for opening a read/write/tracking interface to device
IOHIDDeviceInterface **interface; IOHIDDeviceInterface **interface;
}; };
typedef std::vector<HidInfo*> HidInfoList; typedef std::vector<HidInfo*> HidInfoList;
class MacHIDManager : public FactoryCreator class MacHIDManager : public FactoryCreator
{ {
public: public:
MacHIDManager(); MacHIDManager();
~MacHIDManager(); ~MacHIDManager();
void initialize(); void initialize();
void iterateAndOpenDevices(io_iterator_t iterator); void iterateAndOpenDevices(io_iterator_t iterator);
io_iterator_t lookUpDevices(int usage, int page); io_iterator_t lookUpDevices(int usage, int page);
//FactoryCreator Overrides //FactoryCreator Overrides
/** @copydoc FactoryCreator::deviceList */ /** @copydoc FactoryCreator::deviceList */
DeviceList freeDeviceList(); DeviceList freeDeviceList();
/** @copydoc FactoryCreator::totalDevices */ /** @copydoc FactoryCreator::totalDevices */
int totalDevices(Type iType); int totalDevices(Type iType);
/** @copydoc FactoryCreator::freeDevices */ /** @copydoc FactoryCreator::freeDevices */
int freeDevices(Type iType); int freeDevices(Type iType);
/** @copydoc FactoryCreator::vendorExist */ /** @copydoc FactoryCreator::vendorExist */
bool vendorExist(Type iType, const std::string & vendor); bool vendorExist(Type iType, const std::string & vendor);
/** @copydoc FactoryCreator::createObject */ /** @copydoc FactoryCreator::createObject */
Object* createObject(InputManager* creator, Type iType, bool bufferMode, const std::string & vendor = ""); Object* createObject(InputManager* creator, Type iType, bool bufferMode, const std::string & vendor = "");
/** @copydoc FactoryCreator::destroyObject */ /** @copydoc FactoryCreator::destroyObject */
void destroyObject(Object* obj); void destroyObject(Object* obj);
private: private:
HidInfo* enumerateDeviceProperties(CFMutableDictionaryRef propertyMap); HidInfo* enumerateDeviceProperties(CFMutableDictionaryRef propertyMap);
void parseDeviceProperties(CFDictionaryRef properties); void parseDeviceProperties(CFDictionaryRef properties);
void parseDevicePropertiesGroup(CFDictionaryRef properties); void parseDevicePropertiesGroup(CFDictionaryRef properties);
HidInfoList mDeviceList; HidInfoList mDeviceList;
}; };
} }
#endif #endif
/* /*
The zlib/libpng License The zlib/libpng License
Copyright (c) 2006 Chris Snyder Copyright (c) 2006 Chris Snyder
This software is provided 'as-is', without any express or implied warranty. In no event will 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. 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 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 applications, and to alter it and redistribute it freely, subject to the following
restrictions: restrictions:
1. The origin of this software must not be misrepresented; you must not claim that 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, you wrote the original software. If you use this software in a product,
an acknowledgment in the product documentation would be appreciated but is an acknowledgment in the product documentation would be appreciated but is
not required. not required.
2. Altered source versions must be plainly marked as such, and must not be 2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software. misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
*/ */
#ifndef OIS_MacHelpers_H #ifndef OIS_MacHelpers_H
#define OIS_MacHelpers_H #define OIS_MacHelpers_H
#include "mac/MacPrereqs.h" #include "mac/MacPrereqs.h"
#include "OISEvents.h" #include "OISEvents.h"
#include "OISKeyboard.h" #include "OISKeyboard.h"
#include "OISMouse.h" #include "OISMouse.h"
#include <Carbon/Carbon.h> #include <Carbon/Carbon.h>
// This is a hack needed to get the event handler working. // This is a hack needed to get the event handler working.
// The carbon lib expects a "OSStatus (*)(EventHandlerCallRef, EventRef, void*)", // The carbon lib expects a "OSStatus (*)(EventHandlerCallRef, EventRef, void*)",
// so I cannot give it a class member function (unless it is static which is pointless) // so I cannot give it a class member function (unless it is static which is pointless)
// Instead, I just pass the class* through the last paramter that gets passed to the // Instead, I just pass the class* through the last paramter that gets passed to the
// callback every time an event occurs. Then I dereference it and call the member function. // callback every time an event occurs. Then I dereference it and call the member function.
OSStatus KeyDownWrapper( EventHandlerCallRef nextHandler, EventRef theEvent, void* callClass ); OSStatus KeyDownWrapper( EventHandlerCallRef nextHandler, EventRef theEvent, void* callClass );
OSStatus KeyUpWrapper( EventHandlerCallRef nextHandler, EventRef theEvent, void* callClass ); OSStatus KeyUpWrapper( EventHandlerCallRef nextHandler, EventRef theEvent, void* callClass );
OSStatus KeyModWrapper( EventHandlerCallRef nextHandler, EventRef theEvent, void* callClass ); OSStatus KeyModWrapper( EventHandlerCallRef nextHandler, EventRef theEvent, void* callClass );
OSStatus MouseWrapper( EventHandlerCallRef nextHandler, EventRef theEvent, void* callClass ); OSStatus MouseWrapper( EventHandlerCallRef nextHandler, EventRef theEvent, void* callClass );
// This is needed for keeping an event stack for keyboard and mouse // This is needed for keeping an event stack for keyboard and mouse
namespace OIS namespace OIS
{ {
// used in the eventStack to store the type // used in the eventStack to store the type
enum Mac_EventType { MAC_KEYUP = 0, enum Mac_EventType { MAC_KEYUP = 0,
MAC_KEYDOWN = 1, MAC_KEYDOWN = 1,
MAC_KEYREPEAT, MAC_KEYREPEAT,
MAC_MOUSEDOWN, MAC_MOUSEDOWN,
MAC_MOUSEUP, MAC_MOUSEUP,
MAC_MOUSEMOVED, MAC_MOUSEMOVED,
MAC_MOUSESCROLL}; MAC_MOUSESCROLL};
typedef enum Mac_EventType MacEventType; typedef enum Mac_EventType MacEventType;
// only used by MacKeyboard // only used by MacKeyboard
typedef class Mac_KeyStackEvent typedef class Mac_KeyStackEvent
{ {
friend class MacKeyboard; friend class MacKeyboard;
private: private:
Mac_KeyStackEvent( KeyEvent event, MacEventType type ) : Event(event), Type(type) {} Mac_KeyStackEvent( KeyEvent event, MacEventType type ) : Event(event), Type(type) {}
MacEventType Type; MacEventType Type;
KeyEvent Event; KeyEvent Event;
} MacKeyStackEvent; } MacKeyStackEvent;
// only used by MacMouse // only used by MacMouse
typedef class Mac_MouseStackEvent typedef class Mac_MouseStackEvent
{ {
friend class MacMouse; friend class MacMouse;
private: private:
Mac_MouseStackEvent( MouseEvent event, MacEventType type, MouseButtonID button) : Event(event), Type(type), Button(button) {} Mac_MouseStackEvent( MouseEvent event, MacEventType type, MouseButtonID button) : Event(event), Type(type), Button(button) {}
MacEventType Type; MacEventType Type;
MouseEvent Event; MouseEvent Event;
MouseButtonID Button; MouseButtonID Button;
} MacMouseStackEvent; } MacMouseStackEvent;
} }
#endif #endif
/* /*
The zlib/libpng License The zlib/libpng License
Copyright (c) 2006 Chris Snyder Copyright (c) 2006 Chris Snyder
This software is provided 'as-is', without any express or implied warranty. In no event will 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. 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 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 applications, and to alter it and redistribute it freely, subject to the following
restrictions: restrictions:
1. The origin of this software must not be misrepresented; you must not claim that 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, you wrote the original software. If you use this software in a product,
an acknowledgment in the product documentation would be appreciated but is an acknowledgment in the product documentation would be appreciated but is
not required. not required.
2. Altered source versions must be plainly marked as such, and must not be 2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software. misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
*/ */
#ifndef OIS_MacInputManager_H #ifndef OIS_MacInputManager_H
#define OIS_MacInputManager_H #define OIS_MacInputManager_H
#include "OISInputManager.h" #include "OISInputManager.h"
#include "OISFactoryCreator.h" #include "OISFactoryCreator.h"
#include "mac/MacPrereqs.h" #include "mac/MacPrereqs.h"
#include <Carbon/Carbon.h> #include <Carbon/Carbon.h>
namespace OIS namespace OIS
{ {
class MacInputManager : public InputManager, public FactoryCreator class MacInputManager : public InputManager, public FactoryCreator
{ {
public: public:
MacInputManager(); MacInputManager();
virtual ~MacInputManager(); virtual ~MacInputManager();
//InputManager Overrides //InputManager Overrides
/** @copydoc InputManager::_initialize */ /** @copydoc InputManager::_initialize */
void _initialize( ParamList &paramList ); void _initialize( ParamList &paramList );
//FactoryCreator Overrides //FactoryCreator Overrides
/** @copydoc FactoryCreator::deviceList */ /** @copydoc FactoryCreator::deviceList */
DeviceList freeDeviceList(); DeviceList freeDeviceList();
/** @copydoc FactoryCreator::totalDevices */ /** @copydoc FactoryCreator::totalDevices */
int totalDevices(Type iType); int totalDevices(Type iType);
/** @copydoc FactoryCreator::freeDevices */ /** @copydoc FactoryCreator::freeDevices */
int freeDevices(Type iType); int freeDevices(Type iType);
/** @copydoc FactoryCreator::vendorExist */ /** @copydoc FactoryCreator::vendorExist */
bool vendorExist(Type iType, const std::string & vendor); bool vendorExist(Type iType, const std::string & vendor);
/** @copydoc FactoryCreator::createObject */ /** @copydoc FactoryCreator::createObject */
Object* createObject(InputManager* creator, Type iType, bool bufferMode, const std::string & vendor = ""); Object* createObject(InputManager* creator, Type iType, bool bufferMode, const std::string & vendor = "");
/** @copydoc FactoryCreator::destroyObject */ /** @copydoc FactoryCreator::destroyObject */
void destroyObject(Object* obj); void destroyObject(Object* obj);
//Internal Items //Internal Items
//! Internal method, used for flaggin keyboard as available/unavailable for creation //! Internal method, used for flaggin keyboard as available/unavailable for creation
void _setKeyboardUsed(bool used) {keyboardUsed = used; } void _setKeyboardUsed(bool used) {keyboardUsed = used; }
//! Internal method, used for flaggin mouse as available/unavailable for creation //! Internal method, used for flaggin mouse as available/unavailable for creation
void _setMouseUsed(bool used) { mouseUsed = used; } void _setMouseUsed(bool used) { mouseUsed = used; }
//! methodfor getting the event target //! methodfor getting the event target
EventTargetRef _getEventTarget() {return mEventTargetRef;} EventTargetRef _getEventTarget() {return mEventTargetRef;}
//! method for getting window //! method for getting window
WindowRef _getWindow() {return mWindow;} WindowRef _getWindow() {return mWindow;}
protected: protected:
void _parseConfigSettings( ParamList& paramList ); void _parseConfigSettings( ParamList& paramList );
void _enumerateDevices(); void _enumerateDevices();
static const std::string iName; static const std::string iName;
// Mac stuff // Mac stuff
EventTargetRef mEventTargetRef; EventTargetRef mEventTargetRef;
WindowRef mWindow; WindowRef mWindow;
// settings // settings
bool mHideMouse; bool mHideMouse;
bool mUseRepeat; bool mUseRepeat;
//! Used to know if we used up keyboard //! Used to know if we used up keyboard
bool keyboardUsed; bool keyboardUsed;
//! Used to know if we used up mouse //! Used to know if we used up mouse
bool mouseUsed; bool mouseUsed;
//! HID Manager class handling devices other than keyboard/mouse //! HID Manager class handling devices other than keyboard/mouse
MacHIDManager *mHIDManager; MacHIDManager *mHIDManager;
}; };
} }
#endif #endif
/* /*
The zlib/libpng License The zlib/libpng License
Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com) Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
This software is provided 'as-is', without any express or implied warranty. In no event will 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. 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 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 applications, and to alter it and redistribute it freely, subject to the following
restrictions: restrictions:
1. The origin of this software must not be misrepresented; you must not claim that 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, you wrote the original software. If you use this software in a product,
an acknowledgment in the product documentation would be appreciated but is an acknowledgment in the product documentation would be appreciated but is
not required. not required.
2. Altered source versions must be plainly marked as such, and must not be 2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software. misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
*/ */
#ifndef MAC_Joystick_H #ifndef MAC_Joystick_H
#define MAC_Joystick_H #define MAC_Joystick_H
#include "OISJoyStick.h" #include "OISJoyStick.h"
#include "mac/MacPrereqs.h" #include "mac/MacPrereqs.h"
#include "mac/MacHIDManager.h" #include "mac/MacHIDManager.h"
namespace OIS namespace OIS
{ {
struct AxisInfo struct AxisInfo
{ {
int min; int min;
int max; int max;
AxisInfo(int min, int max) AxisInfo(int min, int max)
: min(min), max(max) {} : min(min), max(max) {}
}; };
typedef struct cookie_struct typedef struct cookie_struct
{ {
std::map<IOHIDElementCookie, AxisInfo> axisCookies; std::map<IOHIDElementCookie, AxisInfo> axisCookies;
std::vector<IOHIDElementCookie> buttonCookies; std::vector<IOHIDElementCookie> buttonCookies;
} cookie_struct_t; } cookie_struct_t;
//class HidDeviceInfo //class HidDeviceInfo
class MacJoyStick : public JoyStick class MacJoyStick : public JoyStick
{ {
public: public:
MacJoyStick(const std::string& vendor, bool buffered, HidInfo* info, InputManager* creator, int devID); MacJoyStick(const std::string& vendor, bool buffered, HidInfo* info, InputManager* creator, int devID);
virtual ~MacJoyStick(); virtual ~MacJoyStick();
/** @copydoc Object::setBuffered */ /** @copydoc Object::setBuffered */
virtual void setBuffered(bool buffered); virtual void setBuffered(bool buffered);
/** @copydoc Object::capture */ /** @copydoc Object::capture */
virtual void capture(); virtual void capture();
/** @copydoc Object::queryInterface */ /** @copydoc Object::queryInterface */
virtual Interface* queryInterface(Interface::IType type); virtual Interface* queryInterface(Interface::IType type);
/** @copydoc Object::_initialize */ /** @copydoc Object::_initialize */
virtual void _initialize(); virtual void _initialize();
void _enumerateCookies(); void _enumerateCookies();
IOHIDQueueInterface** _createQueue(unsigned int depth = 8); IOHIDQueueInterface** _createQueue(unsigned int depth = 8);
protected: protected:
HidInfo* mInfo; HidInfo* mInfo;
cookie_struct_t mCookies; cookie_struct_t mCookies;
IOHIDQueueInterface** mQueue; IOHIDQueueInterface** mQueue;
}; };
} }
#endif #endif
/* /*
The zlib/libpng License The zlib/libpng License
Copyright (c) 2006 Chris Snyder Copyright (c) 2006 Chris Snyder
This software is provided 'as-is', without any express or implied warranty. In no event will 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. 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 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 applications, and to alter it and redistribute it freely, subject to the following
restrictions: restrictions:
1. The origin of this software must not be misrepresented; you must not claim that 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, you wrote the original software. If you use this software in a product,
an acknowledgment in the product documentation would be appreciated but is an acknowledgment in the product documentation would be appreciated but is
not required. not required.
2. Altered source versions must be plainly marked as such, and must not be 2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software. misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
*/ */
#ifndef OIS_MacKeyboard_H #ifndef OIS_MacKeyboard_H
#define OIS_MacKeyboard_H #define OIS_MacKeyboard_H
#include "OISKeyboard.h" #include "OISKeyboard.h"
#include "mac/MacHelpers.h" #include "mac/MacHelpers.h"
#include "mac/MacPrereqs.h" #include "mac/MacPrereqs.h"
#include <Carbon/Carbon.h> #include <Carbon/Carbon.h>
namespace OIS namespace OIS
{ {
class MacKeyboard : public Keyboard class MacKeyboard : public Keyboard
{ {
public: public:
MacKeyboard( InputManager* creator, bool buffered, bool repeat ); MacKeyboard( InputManager* creator, bool buffered, bool repeat );
virtual ~MacKeyboard(); virtual ~MacKeyboard();
// Sets buffered mode // Sets buffered mode
virtual void setBuffered( bool buffered ); virtual void setBuffered( bool buffered );
// unbuffered keydown check // unbuffered keydown check
virtual bool isKeyDown( KeyCode key ) const; virtual bool isKeyDown( KeyCode key ) const;
// This will send listener events if buffered is on. // This will send listener events if buffered is on.
// Note that in the mac implementation, unbuffered input is // Note that in the mac implementation, unbuffered input is
// automatically updated without calling this. // automatically updated without calling this.
virtual void capture(); virtual void capture();
// Copies the current key buffer // Copies the current key buffer
virtual void copyKeyStates( char keys[256] ) const; virtual void copyKeyStates( char keys[256] ) const;
// Returns a description of the given key // Returns a description of the given key
virtual std::string& getAsString( KeyCode key ); virtual std::string& getAsString( KeyCode key );
virtual Interface* queryInterface( Interface::IType type ) { return 0; } virtual Interface* queryInterface( Interface::IType type ) { return 0; }
// Public but reserved for internal use: // Public but reserved for internal use:
virtual void _initialize(); virtual void _initialize();
void _keyDownCallback( EventRef theEvent ); void _keyDownCallback( EventRef theEvent );
void _keyUpCallback( EventRef theEvent ); void _keyUpCallback( EventRef theEvent );
void _modChangeCallback( EventRef theEvent ); void _modChangeCallback( EventRef theEvent );
protected: protected:
// just to get this out of the way // just to get this out of the way
void populateKeyConversion(); void populateKeyConversion();
// updates the keybuffer and optionally the eventStack // updates the keybuffer and optionally the eventStack
void injectEvent(KeyCode kc, unsigned int time, MacEventType type, unsigned int txt = 0 ); void injectEvent(KeyCode kc, unsigned int time, MacEventType type, unsigned int txt = 0 );
typedef std::map<UInt32, KeyCode> VirtualtoOIS_KeyMap; typedef std::map<UInt32, KeyCode> VirtualtoOIS_KeyMap;
VirtualtoOIS_KeyMap keyConversion; VirtualtoOIS_KeyMap keyConversion;
std::string getString; std::string getString;
char KeyBuffer[256]; char KeyBuffer[256];
UInt32 prevModMask; UInt32 prevModMask;
// "universal procedure pointers" - required reference for callbacks // "universal procedure pointers" - required reference for callbacks
EventHandlerUPP keyDownUPP; EventHandlerUPP keyDownUPP;
EventHandlerUPP keyUpUPP; EventHandlerUPP keyUpUPP;
EventHandlerUPP keyModUPP; EventHandlerUPP keyModUPP;
// so we can delete the handlers on destruction // so we can delete the handlers on destruction
EventHandlerRef keyDownEventRef; EventHandlerRef keyDownEventRef;
EventHandlerRef keyUpEventRef; EventHandlerRef keyUpEventRef;
EventHandlerRef keyModEventRef; EventHandlerRef keyModEventRef;
// buffered events, fifo stack // buffered events, fifo stack
typedef std::list<MacKeyStackEvent> eventStack; typedef std::list<MacKeyStackEvent> eventStack;
eventStack pendingEvents; eventStack pendingEvents;
bool useRepeat; bool useRepeat;
}; };
} }
#endif #endif
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment