Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
fengzch-das
OIS
Commits
24236447
Commit
24236447
authored
Sep 17, 2015
by
TheOnlyJoey
Browse files
Merge pull request #5 from hymerman/tidying
General tidy-up
parents
c546989f
ed6e1ba6
Changes
136
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
1680 additions
and
1660 deletions
+1680
-1660
includes/OISPrereqs.h
includes/OISPrereqs.h
+247
-227
includes/SDL/SDLInputManager.h
includes/SDL/SDLInputManager.h
+73
-73
includes/SDL/SDLKeyboard.h
includes/SDL/SDLKeyboard.h
+79
-79
includes/SDL/SDLMouse.h
includes/SDL/SDLMouse.h
+59
-59
includes/SDL/SDLPrereqs.h
includes/SDL/SDLPrereqs.h
+38
-38
includes/iphone/iPhoneAccelerometer.h
includes/iphone/iPhoneAccelerometer.h
+50
-50
includes/iphone/iPhoneHelpers.h
includes/iphone/iPhoneHelpers.h
+56
-56
includes/iphone/iPhoneInputManager.h
includes/iphone/iPhoneInputManager.h
+110
-110
includes/iphone/iPhoneMultiTouch.h
includes/iphone/iPhoneMultiTouch.h
+64
-64
includes/iphone/iPhonePrereqs.h
includes/iphone/iPhonePrereqs.h
+56
-56
includes/linux/EventHelpers.h
includes/linux/EventHelpers.h
+49
-49
includes/linux/LinuxForceFeedback.h
includes/linux/LinuxForceFeedback.h
+85
-85
includes/linux/LinuxInputManager.h
includes/linux/LinuxInputManager.h
+105
-105
includes/linux/LinuxJoyStickEvents.h
includes/linux/LinuxJoyStickEvents.h
+72
-72
includes/linux/LinuxKeyboard.h
includes/linux/LinuxKeyboard.h
+82
-82
includes/linux/LinuxMouse.h
includes/linux/LinuxMouse.h
+75
-75
includes/linux/LinuxPrereqs.h
includes/linux/LinuxPrereqs.h
+82
-82
includes/mac/MacHIDManager.h
includes/mac/MacHIDManager.h
+103
-103
includes/mac/MacHelpers.h
includes/mac/MacHelpers.h
+94
-94
includes/mac/MacInputManager.h
includes/mac/MacInputManager.h
+101
-101
No files found.
includes/OISPrereqs.h
View file @
24236447
/*
The zlib/libpng License
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
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
// * Forward Declarations of all public API classes
// * Several typedef's used around the library
// * Base class component types
// * Preprocessor definitons
//----------------------------------------------------------------------------//
//-------------- 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 )
# undef _OISExport
//Ignorable Dll interface warning...
# if !defined(OIS_MINGW_COMPILER)
# pragma warning (disable : 4251)
# endif
# if defined( OIS_NONCLIENT_BUILD )
# define _OISExport __declspec( dllexport )
# else
# if defined(OIS_MINGW_COMPILER)
# define _OISExport
# else
# define _OISExport __declspec( dllimport )
# endif
# endif
# endif
# endif
#elif defined( __APPLE_CC__ ) // Apple OS X
// Device Simulator
# if __IPHONE_OS_VERSION_MIN_REQUIRED >= 20201 || __IPHONE_OS_VERSION_MIN_REQUIRED >= 20000
//# if __IPHONE_OS_VERSION_MIN_REQUIRED >= 30000 || __IPHONE_OS_VERSION_MIN_REQUIRED >= 30000
# define OIS_IPHONE_PLATFORM
# else
# define OIS_APPLE_PLATFORM
# endif
# undef _OISExport
# define _OISExport __attribute__((visibility("default")))
#else //Probably Linux
# define OIS_LINUX_PLATFORM
# include <unistd.h>
#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 4
#define OIS_VERSION_PATCH 0
#define OIS_VERSION_NAME "1.4.0"
#define OIS_VERSION ((OIS_VERSION_MAJOR << 16) | (OIS_VERSION_MINOR << 8) | OIS_VERSION_PATCH)
namespace
OIS
{
//Forward Declarations
class
InputManager
;
class
FactoryCreator
;
class
Object
;
class
Keyboard
;
class
Mouse
;
class
JoyStick
;
class
MultiTouch
;
class
KeyListener
;
class
MouseListener
;
class
MultiTouchListener
;
class
JoyStickListener
;
class
Interface
;
class
ForceFeedback
;
class
Effect
;
class
Exception
;
//! Way to send OS nuetral parameters.. ie OS Window handles, modes, flags
typedef
std
::
multimap
<
std
::
string
,
std
::
string
>
ParamList
;
//! List of FactoryCreator's
typedef
std
::
vector
<
FactoryCreator
*>
FactoryList
;
//! Map of FactoryCreator created Objects
typedef
std
::
map
<
Object
*
,
FactoryCreator
*>
FactoryCreatedObject
;
//! Each Input class has a General Type variable, a form of RTTI
enum
Type
{
OISUnknown
=
0
,
OISKeyboard
=
1
,
OISMouse
=
2
,
OISJoyStick
=
3
,
OISTablet
=
4
,
OISMultiTouch
=
5
};
//! Map of device objects connected and their respective vendors
typedef
std
::
multimap
<
Type
,
std
::
string
>
DeviceList
;
//-------- Shared common components ------------------------//
//! Base type for all device components (button, axis, etc)
enum
ComponentType
{
OIS_Unknown
=
0
,
OIS_Button
=
1
,
//ie. Key, mouse button, joy button, etc
OIS_Axis
=
2
,
//ie. A joystick or mouse axis
OIS_Slider
=
3
,
//
OIS_POV
=
4
,
//ie. Arrow direction keys
OIS_Vector3
=
5
//ie. WiiMote orientation
};
//! Base of all device components (button, axis, etc)
class
_OISExport
Component
{
public:
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
class
_OISExport
Button
:
public
Component
{
public:
Button
()
:
Component
(
OIS_Button
),
pushed
(
false
)
{}
Button
(
bool
bPushed
)
:
Component
(
OIS_Button
),
pushed
(
bPushed
)
{}
//! true if pushed, false otherwise
bool
pushed
;
};
//! Axis component
class
_OISExport
Axis
:
public
Component
{
public:
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
;
}
};
//! A 3D Vector component (perhaps an orientation, as in the WiiMote)
class
_OISExport
Vector3
:
public
Component
{
public:
Vector3
()
{}
Vector3
(
float
_x
,
float
_y
,
float
_z
)
:
Component
(
OIS_Vector3
),
x
(
_x
),
y
(
_y
),
z
(
_z
)
{};
//! X component of vector
float
x
;
//! Y component of vector
float
y
;
//! Z component of vector
float
z
;
void
clear
()
{
x
=
y
=
z
=
0.0
f
;
}
};
}
#endif //end if prereq header defined
/*
The zlib/libpng License
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
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
// * Forward Declarations of all public API classes
// * Several typedef's used around the library
// * Base class component types
// * Preprocessor definitons
//----------------------------------------------------------------------------//
//-------------- 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 )
# undef _OISExport
//Ignorable Dll interface warning...
# if !defined(OIS_MINGW_COMPILER)
# pragma warning (disable : 4251)
# endif
# if defined( OIS_NONCLIENT_BUILD )
# define _OISExport __declspec( dllexport )
# else
# if defined(OIS_MINGW_COMPILER)
# define _OISExport
# else
# define _OISExport __declspec( dllimport )
# endif
# endif
# endif
# endif
#elif defined( __APPLE_CC__ ) // Apple OS X
// Device Simulator
# if __IPHONE_OS_VERSION_MIN_REQUIRED >= 20201 || __IPHONE_OS_VERSION_MIN_REQUIRED >= 20000
//# if __IPHONE_OS_VERSION_MIN_REQUIRED >= 30000 || __IPHONE_OS_VERSION_MIN_REQUIRED >= 30000
# define OIS_IPHONE_PLATFORM
# else
# define OIS_APPLE_PLATFORM
# endif
# undef _OISExport
# define _OISExport __attribute__((visibility("default")))
#else //Probably Linux
# define OIS_LINUX_PLATFORM
# include <unistd.h>
#endif
//Is Processor 32 or 64 bits...
#if defined(__x86_64__)
# define OIS_ARCH_64
#else
# define OIS_ARCH_32
#endif
//-------------- Various helper preprocessor definitions ---------------------//
#ifdef OIS_MSVC_COMPILER
# define OIS_INLINE_PRAGMA(x) __pragma(x) // x is intentionally not wrapped; __pragma rejects expressions beginning with '('.
#else
# define OIS_INLINE_PRAGMA(x)
#endif
#define OIS_MACRO_BEGIN do {
#define OIS_MACRO_END \
} OIS_INLINE_PRAGMA(warning(push)) OIS_INLINE_PRAGMA(warning(disable:4127)) while (0) OIS_INLINE_PRAGMA(warning(pop))
// This creative trickery taken from this StackOverflow answer:
// http://stackoverflow.com/questions/4030959/will-a-variablename-c-statement-be-a-no-op-at-all-times/4030983#4030983
#define OIS_UNUSED(x)\
OIS_MACRO_BEGIN\
((void)(true ? 0 : ((x), void(), 0)));\
OIS_MACRO_END
//-------------- Common Classes, Enums, and Typdef's -------------------------//
#define OIS_VERSION_MAJOR 1
#define OIS_VERSION_MINOR 4
#define OIS_VERSION_PATCH 0
#define OIS_VERSION_NAME "1.4.0"
#define OIS_VERSION ((OIS_VERSION_MAJOR << 16) | (OIS_VERSION_MINOR << 8) | OIS_VERSION_PATCH)
namespace
OIS
{
//Forward Declarations
class
InputManager
;
class
FactoryCreator
;
class
Object
;
class
Keyboard
;
class
Mouse
;
class
JoyStick
;
class
MultiTouch
;
class
KeyListener
;
class
MouseListener
;
class
MultiTouchListener
;
class
JoyStickListener
;
class
Interface
;
class
ForceFeedback
;
class
Effect
;
class
Exception
;
//! Way to send OS nuetral parameters.. ie OS Window handles, modes, flags
typedef
std
::
multimap
<
std
::
string
,
std
::
string
>
ParamList
;
//! List of FactoryCreator's
typedef
std
::
vector
<
FactoryCreator
*>
FactoryList
;
//! Map of FactoryCreator created Objects
typedef
std
::
map
<
Object
*
,
FactoryCreator
*>
FactoryCreatedObject
;
//! Each Input class has a General Type variable, a form of RTTI
enum
Type
{
OISUnknown
=
0
,
OISKeyboard
=
1
,
OISMouse
=
2
,
OISJoyStick
=
3
,
OISTablet
=
4
,
OISMultiTouch
=
5
};
//! Map of device objects connected and their respective vendors
typedef
std
::
multimap
<
Type
,
std
::
string
>
DeviceList
;
//-------- Shared common components ------------------------//
//! Base type for all device components (button, axis, etc)
enum
ComponentType
{
OIS_Unknown
=
0
,
OIS_Button
=
1
,
//ie. Key, mouse button, joy button, etc
OIS_Axis
=
2
,
//ie. A joystick or mouse axis
OIS_Slider
=
3
,
//
OIS_POV
=
4
,
//ie. Arrow direction keys
OIS_Vector3
=
5
//ie. WiiMote orientation
};
//! Base of all device components (button, axis, etc)
class
_OISExport
Component
{
public:
Component
()
:
cType
(
OIS_Unknown
)
{};
explicit
Component
(
ComponentType
type
)
:
cType
(
type
)
{};
//! Indicates what type of coponent this is
ComponentType
cType
;
};
//! Button can be a keyboard key, mouse button, etc
class
_OISExport
Button
:
public
Component
{
public:
Button
()
:
Component
(
OIS_Button
),
pushed
(
false
)
{}
explicit
Button
(
bool
bPushed
)
:
Component
(
OIS_Button
),
pushed
(
bPushed
)
{}
//! true if pushed, false otherwise
bool
pushed
;
};
//! Axis component
class
_OISExport
Axis
:
public
Component
{
public:
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
;
}
};
//! A 3D Vector component (perhaps an orientation, as in the WiiMote)
class
_OISExport
Vector3
:
public
Component
{
public:
Vector3
()
{}
Vector3
(
float
_x
,
float
_y
,
float
_z
)
:
Component
(
OIS_Vector3
),
x
(
_x
),
y
(
_y
),
z
(
_z
)
{};
//! X component of vector
float
x
;
//! Y component of vector
float
y
;
//! Z component of vector
float
z
;
void
clear
()
{
x
=
y
=
z
=
0.0
f
;
}
};
}
#endif //end if prereq header defined
includes/SDL/SDLInputManager.h
View file @
24236447
/*
The zlib/libpng License
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
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_SDLInputManager_H
#define OIS_SDLInputManager_H
#include "OISInputManager.h"
#include "SDL/SDLPrereqs.h"
namespace
OIS
{
/**
SDL Input Manager wrapper
*/
class
SDLInputManager
:
public
InputManager
{
public:
SDLInputManager
();
virtual
~
SDLInputManager
();
/** @copydoc InputManager::inputSystemName */
virtual
const
std
::
string
&
inputSystemName
()
{
return
iName
;
}
/** @copydoc InputManager::numJoysticks */
virtual
int
numJoySticks
();
/** @copydoc InputManager::numMice */
virtual
int
numMice
();
/** @copydoc InputManager::numKeyBoards */
virtual
int
numKeyboards
();
/** @copydoc InputManager::createInputObject */
Object
*
createInputObject
(
Type
iType
,
bool
bufferMode
);
/** @copydoc InputManager::destroyInputObject */
void
destroyInputObject
(
Object
*
obj
);
/** @copydoc InputManager::_initialize */
void
_initialize
(
ParamList
&
paramList
);
//Utility methods to coordinate between mouse and keyboard grabbing
bool
_getGrabMode
()
{
return
mGrabbed
;};
void
_setGrabMode
(
bool
grabbed
)
{
mGrabbed
=
grabbed
;}
protected:
//! internal class method for dealing with param list
void
_parseConfigSettings
(
ParamList
&
paramList
);
//! internal class method for finding attached devices
void
_enumerateDevices
();
static
const
std
::
string
iName
;
bool
mGrabbed
;
};
}
#endif
/*
The zlib/libpng License
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
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_SDLInputManager_H
#define OIS_SDLInputManager_H
#include "OISInputManager.h"
#include "SDL/SDLPrereqs.h"
namespace
OIS
{
/**
SDL Input Manager wrapper
*/
class
SDLInputManager
:
public
InputManager
{
public:
SDLInputManager
();
virtual
~
SDLInputManager
();
/** @copydoc InputManager::inputSystemName */
virtual
const
std
::
string
&
inputSystemName
()
{
return
iName
;
}
/** @copydoc InputManager::numJoysticks */
virtual
int
numJoySticks
();
/** @copydoc InputManager::numMice */
virtual
int
numMice
();
/** @copydoc InputManager::numKeyBoards */
virtual
int
numKeyboards
();
/** @copydoc InputManager::createInputObject */
Object
*
createInputObject
(
Type
iType
,
bool
bufferMode
);
/** @copydoc InputManager::destroyInputObject */
void
destroyInputObject
(
Object
*
obj
);
/** @copydoc InputManager::_initialize */
void
_initialize
(
ParamList
&
paramList
);
//Utility methods to coordinate between mouse and keyboard grabbing
bool
_getGrabMode
()
{
return
mGrabbed
;};
void
_setGrabMode
(
bool
grabbed
)
{
mGrabbed
=
grabbed
;}
protected:
//! internal class method for dealing with param list
void
_parseConfigSettings
(
ParamList
&
paramList
);
//! internal class method for finding attached devices
void
_enumerateDevices
();
static
const
std
::
string
iName
;
bool
mGrabbed
;
};
}
#endif
includes/SDL/SDLKeyboard.h
View file @
24236447
/*
The zlib/libpng License
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
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_SDLKEYBOARD_H
#define _OIS_SDLKEYBOARD_H
#include "OISKeyboard.h"
#include "SDL/SDLPrereqs.h"
namespace
OIS
{
class
SDLKeyboard
:
public
Keyboard
{
public:
/**
@remarks
Constructor
@param buffered
True for buffered input mode
*/
SDLKeyboard
(
bool
buffered
);
virtual
~
SDLKeyboard
();
/** @copydoc Keyboard::isKeyDown */
virtual
bool
isKeyDown
(
KeyCode
key
);
/** @copydoc Keyboard::getAsString */
virtual
const
std
::
string
&
getAsString
(
KeyCode
kc
);
/** @copydoc Keyboard::copyKeyStates */
virtual
void
copyKeyStates
(
char
keys
[
256
]
);
/** @copydoc Object::setBuffered */
virtual
void
setBuffered
(
bool
buffered
);
/** @copydoc Object::capture */
virtual
void
capture
();
/** @copydoc Object::queryInterface */
virtual
Interface
*
queryInterface
(
Interface
::
IType
type
)
{
return
0
;}
/** @copydoc Object::_initialize */
virtual
void
_initialize
();
/** @copydoc Object::setTextTranslation */
virtual
void
setTextTranslation
(
TextTranslationMode
mode
);
protected:
SDLKeyboard
()
{}
typedef
std
::
map
<
SDLKey
,
KeyCode
>
KeyMap
;
KeyMap
mKeyMap
;
unsigned
char
KeyBuffer
[
256
];
Uint8
*
mSDLBuff
;
std
::
string
mGetString
;
};
}
#endif
/*
The zlib/libpng License
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
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_SDLKEYBOARD_H
#define _OIS_SDLKEYBOARD_H
#include "OISKeyboard.h"
#include "SDL/SDLPrereqs.h"
namespace
OIS
{
class
SDLKeyboard
:
public
Keyboard
{
public:
/**
@remarks
Constructor
@param buffered
True for buffered input mode
*/
SDLKeyboard
(
bool
buffered
);
virtual
~
SDLKeyboard
();
/** @copydoc Keyboard::isKeyDown */
virtual
bool
isKeyDown
(
KeyCode
key
);
/** @copydoc Keyboard::getAsString */
virtual
const
std
::
string
&
getAsString
(
KeyCode
kc
);
/** @copydoc Keyboard::copyKeyStates */
virtual
void
copyKeyStates
(
char
keys
[
256
]
);
/** @copydoc Object::setBuffered */
virtual
void
setBuffered
(
bool
buffered
);
/** @copydoc Object::capture */
virtual
void
capture
();
/** @copydoc Object::queryInterface */
virtual
Interface
*
queryInterface
(
Interface
::
IType
type
)
{
return
0
;}
/** @copydoc Object::_initialize */
virtual
void
_initialize
();
/** @copydoc Object::setTextTranslation */
virtual
void
setTextTranslation
(
TextTranslationMode
mode
);
protected:
SDLKeyboard
()
{}
typedef
std
::
map
<
SDLKey
,
KeyCode
>
KeyMap
;
KeyMap
mKeyMap
;
unsigned
char
KeyBuffer
[
256
];
Uint8
*
mSDLBuff
;
std
::
string
mGetString
;
};
}
#endif
includes/SDL/SDLMouse.h
View file @
24236447
/*
The zlib/libpng License
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
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_SDLMOUSE_H
#define _OIS_SDLMOUSE_H
#include "OISMouse.h"
#include "SDL/SDLPrereqs.h"
namespace
OIS
{
class
SDLMouse
:
public
Mouse
{
public:
SDLMouse
(
bool
buffered
);
virtual
~
SDLMouse
();
/** @copydoc Object::setBuffered */
virtual
void
setBuffered
(
bool
buffered
);
/** @copydoc Object::capture */
virtual
void
capture
();
/** @copydoc Object::queryInterface */
virtual
Interface
*
queryInterface
(
Interface
::
IType
type
)
{
return
0
;}
/** @copydoc Object::_initialize */
virtual
void
_initialize
();
void
_setGrab
(
bool
grabbed
);
void
_setVisible
(
bool
visible
);
protected:
SDLMouse
()
{}
bool
mGrabbed
;
bool
mRegainFocus
;
};
}
#endif
/*
The zlib/libpng License
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
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_SDLMOUSE_H
#define _OIS_SDLMOUSE_H
#include "OISMouse.h"
#include "SDL/SDLPrereqs.h"
namespace
OIS
{
class
SDLMouse
:
public
Mouse
{
public:
SDLMouse
(
bool
buffered
);
virtual
~
SDLMouse
();
/** @copydoc Object::setBuffered */
virtual
void
setBuffered
(
bool
buffered
);
/** @copydoc Object::capture */
virtual
void
capture
();
/** @copydoc Object::queryInterface */
virtual
Interface
*
queryInterface
(
Interface
::
IType
type
)
{
return
0
;}
/** @copydoc Object::_initialize */
virtual
void
_initialize
();
void
_setGrab
(
bool
grabbed
);
void
_setVisible
(
bool
visible
);
protected:
SDLMouse
()
{}
bool
mGrabbed
;
bool
mRegainFocus
;
};
}
#endif
includes/SDL/SDLPrereqs.h
View file @
24236447
/*
The zlib/libpng License
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
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_SDLPrereqs_H
#define OIS_SDLPrereqs_H
#include "OISPrereqs.h"
#ifdef OIS_APPLE_PLATFORM
# include <SDL/SDL.h>
#else
# include <SDL.h>
#endif
#define OIS_SDL_KEY_BUFF 16
#define OIS_SDL_MOUSE_BUFF 50
#define OIS_SDL_JOY_BUFF 80
#endif
/*
The zlib/libpng License
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
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_SDLPrereqs_H
#define OIS_SDLPrereqs_H
#include "OISPrereqs.h"
#ifdef OIS_APPLE_PLATFORM
# include <SDL/SDL.h>
#else
# include <SDL.h>
#endif
#define OIS_SDL_KEY_BUFF 16
#define OIS_SDL_MOUSE_BUFF 50
#define OIS_SDL_JOY_BUFF 80
#endif
includes/iphone/iPhoneAccelerometer.h
View file @
24236447
#ifndef OIS_iPhoneAccelerometer_H
#define OIS_iPhoneAccelerometer_H
#include "OISJoystick.h"
#include "iphone/iPhonePrereqs.h"
#import <UIKit/UIKit.h>
@
class
iPhoneAccelerometerDelegate
;
class
JoyStickState
;
namespace
OIS
{
class
iPhoneAccelerometer
:
public
JoyStick
{
public:
iPhoneAccelerometer
(
InputManager
*
creator
,
bool
buffered
);
virtual
~
iPhoneAccelerometer
();
/** @copydoc Object::setBuffered */
virtual
void
setBuffered
(
bool
buffered
);
void
setUpdateInterval
(
float
interval
)
{
mUpdateInterval
=
interval
;
[[
UIAccelerometer
sharedAccelerometer
]
setUpdateInterval
:
(
1.0
f
/
mUpdateInterval
)];
}
Vector3
getAccelerometerVector3
(
void
)
{
return
mState
.
mVectors
[
0
];
}
/** @copydoc Object::capture */
virtual
void
capture
();
/** @copydoc Object::queryInterface */
virtual
Interface
*
queryInterface
(
Interface
::
IType
type
)
{
return
0
;}
/** @copydoc Object::_initialize */
virtual
void
_initialize
();
void
didAccelerate
(
UIAcceleration
*
acceleration
);
protected:
iPhoneAccelerometerDelegate
*
accelerometerDelegate
;
/** The update frequency of the accelerometer. Represented in times per second. */
float
mUpdateInterval
;
Vector3
mTempState
;
};
}
#endif // OIS_iPhoneAccelerometer_H
#ifndef OIS_iPhoneAccelerometer_H
#define OIS_iPhoneAccelerometer_H
#include "OISJoystick.h"
#include "iphone/iPhonePrereqs.h"
#import <UIKit/UIKit.h>
@
class
iPhoneAccelerometerDelegate
;
class
JoyStickState
;
namespace
OIS
{
class
iPhoneAccelerometer
:
public
JoyStick
{
public:
iPhoneAccelerometer
(
InputManager
*
creator
,
bool
buffered
);
virtual
~
iPhoneAccelerometer
();
/** @copydoc Object::setBuffered */
virtual
void
setBuffered
(
bool
buffered
);
void
setUpdateInterval
(
float
interval
)
{
mUpdateInterval
=
interval
;
[[
UIAccelerometer
sharedAccelerometer
]
setUpdateInterval
:
(
1.0
f
/
mUpdateInterval
)];
}
Vector3
getAccelerometerVector3
(
void
)
{
return
mState
.
mVectors
[
0
];
}
/** @copydoc Object::capture */
virtual
void
capture
();
/** @copydoc Object::queryInterface */
virtual
Interface
*
queryInterface
(
Interface
::
IType
type
)
{
return
0
;}
/** @copydoc Object::_initialize */
virtual
void
_initialize
();
void
didAccelerate
(
UIAcceleration
*
acceleration
);
protected:
iPhoneAccelerometerDelegate
*
accelerometerDelegate
;
/** The update frequency of the accelerometer. Represented in times per second. */
float
mUpdateInterval
;
Vector3
mTempState
;
};
}
#endif // OIS_iPhoneAccelerometer_H
includes/iphone/iPhoneHelpers.h
View file @
24236447
/*
The zlib/libpng License
Copyright (c) 2006 Chris Snyder
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_iPhoneHelpers_H
#define OIS_iPhoneHelpers_H
#include "iphone/iPhonePrereqs.h"
#include "OISMultiTouch.h"
// This is needed for keeping an event stack for keyboard and mouse
namespace
OIS
{
// used in the eventStack to store the type
enum
iPhone_EventType
{
iPhone_KEYUP
=
0
,
iPhone_KEYDOWN
=
1
,
iPhone_KEYREPEAT
,
iPhone_MOUSEDOWN
,
iPhone_MOUSEUP
,
iPhone_MOUSEMOVED
,
iPhone_MOUSESCROLL
};
typedef
enum
iPhone_EventType
iPhoneEventType
;
// only used by iPhoneMultiTouch
typedef
class
iPhoneMultiTouchStackEvent
{
friend
class
iPhoneMultiTouch
;
private:
iPhoneMultiTouchStackEvent
(
MultiTouchEvent
event
,
iPhoneEventType
type
)
:
Event
(
event
),
Type
(
type
)
{}
iPhoneEventType
Type
;
MultiTouchEvent
Event
;
}
iPhoneMultiTouchStackEvent
;
}
#endif
/*
The zlib/libpng License
Copyright (c) 2006 Chris Snyder
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_iPhoneHelpers_H
#define OIS_iPhoneHelpers_H
#include "iphone/iPhonePrereqs.h"
#include "OISMultiTouch.h"
// This is needed for keeping an event stack for keyboard and mouse
namespace
OIS
{
// used in the eventStack to store the type
enum
iPhone_EventType
{
iPhone_KEYUP
=
0
,
iPhone_KEYDOWN
=
1
,
iPhone_KEYREPEAT
,
iPhone_MOUSEDOWN
,
iPhone_MOUSEUP
,
iPhone_MOUSEMOVED
,
iPhone_MOUSESCROLL
};
typedef
enum
iPhone_EventType
iPhoneEventType
;
// only used by iPhoneMultiTouch
typedef
class
iPhoneMultiTouchStackEvent
{
friend
class
iPhoneMultiTouch
;
private:
iPhoneMultiTouchStackEvent
(
MultiTouchEvent
event
,
iPhoneEventType
type
)
:
Event
(
event
),
Type
(
type
)
{}
iPhoneEventType
Type
;
MultiTouchEvent
Event
;
}
iPhoneMultiTouchStackEvent
;
}
#endif
includes/iphone/iPhoneInputManager.h
View file @
24236447
/*
The zlib/libpng License
Copyright (c) 2006 Chris Snyder
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_iPhoneInputManager_H
#define OIS_iPhoneInputManager_H
#include "OISInputManager.h"
#include "OISFactoryCreator.h"
#include "iphone/iPhonePrereqs.h"
#import <UIKit/UIKit.h>
namespace
OIS
{
class
iPhoneAccelerometer
;
class
iPhoneMultiTouch
;
}
@interface
InputDelegate
:
UIView
<
UIAccelerometerDelegate
>
{
OIS
::
iPhoneAccelerometer
*
accelerometerObject
;
OIS
::
iPhoneMultiTouch
*
touchObject
;
}
@property
(
assign
)
OIS
::
iPhoneAccelerometer
*
accelerometerObject
;
@property
(
assign
)
OIS
::
iPhoneMultiTouch
*
touchObject
;
@end
namespace
OIS
{
class
iPhoneInputManager
:
public
InputManager
,
public
FactoryCreator
{
public:
iPhoneInputManager
();
virtual
~
iPhoneInputManager
();
//InputManager Overrides
/** @copydoc InputManager::_initialize */
void
_initialize
(
ParamList
&
paramList
);
//FactoryCreator Overrides
/** @copydoc FactoryCreator::deviceList */
DeviceList
freeDeviceList
();
/** @copydoc FactoryCreator::totalDevices */
int
totalDevices
(
Type
iType
);
/** @copydoc FactoryCreator::freeDevices */
int
freeDevices
(
Type
iType
);
/** @copydoc FactoryCreator::vendorExist */
bool
vendorExist
(
Type
iType
,
const
std
::
string
&
vendor
);
/** @copydoc FactoryCreator::createObject */
Object
*
createObject
(
InputManager
*
creator
,
Type
iType
,
bool
bufferMode
,
const
std
::
string
&
vendor
=
""
);
/** @copydoc FactoryCreator::destroyObject */
void
destroyObject
(
Object
*
obj
);
//Internal Items
//! Internal method, used for flagging multi-touch as available/unavailable for creation
void
_setMultiTouchUsed
(
bool
used
)
{
bMultiTouchUsed
=
used
;
}
//! Internal method, used for flagging accelerometer as available/unavailable for creation
void
_setAccelerometerUsed
(
bool
used
)
{
bAccelerometerUsed
=
used
;
}
//! methodfor getting the delegate
InputDelegate
*
_getDelegate
()
{
return
mDelegate
;
}
//! method for getting window
UIWindow
*
_getWindow
()
{
return
mWindow
;
}
protected:
void
_parseConfigSettings
(
ParamList
&
paramList
);
// iPhone stuff
UIWindow
*
mWindow
;
InputDelegate
*
mDelegate
;
// settings
bool
mHideMouse
;
//! Used to know if we used up multi-touch device
bool
bMultiTouchUsed
;
//! Used to know if we used up accelerometer
bool
bAccelerometerUsed
;
};
}
#endif
/*
The zlib/libpng License
Copyright (c) 2006 Chris Snyder
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_iPhoneInputManager_H
#define OIS_iPhoneInputManager_H
#include "OISInputManager.h"
#include "OISFactoryCreator.h"
#include "iphone/iPhonePrereqs.h"
#import <UIKit/UIKit.h>
namespace
OIS
{
class
iPhoneAccelerometer
;
class
iPhoneMultiTouch
;
}
@interface
InputDelegate
:
UIView
<
UIAccelerometerDelegate
>
{
OIS
::
iPhoneAccelerometer
*
accelerometerObject
;
OIS
::
iPhoneMultiTouch
*
touchObject
;
}
@property
(
assign
)
OIS
::
iPhoneAccelerometer
*
accelerometerObject
;
@property
(
assign
)
OIS
::
iPhoneMultiTouch
*
touchObject
;
@end
namespace
OIS
{
class
iPhoneInputManager
:
public
InputManager
,
public
FactoryCreator
{
public:
iPhoneInputManager
();
virtual
~
iPhoneInputManager
();
//InputManager Overrides
/** @copydoc InputManager::_initialize */
void
_initialize
(
ParamList
&
paramList
);
//FactoryCreator Overrides
/** @copydoc FactoryCreator::deviceList */
DeviceList
freeDeviceList
();
/** @copydoc FactoryCreator::totalDevices */
int
totalDevices
(
Type
iType
);
/** @copydoc FactoryCreator::freeDevices */
int
freeDevices
(
Type
iType
);
/** @copydoc FactoryCreator::vendorExist */
bool
vendorExist
(
Type
iType
,
const
std
::
string
&
vendor
);
/** @copydoc FactoryCreator::createObject */
Object
*
createObject
(
InputManager
*
creator
,
Type
iType
,
bool
bufferMode
,
const
std
::
string
&
vendor
=
""
);
/** @copydoc FactoryCreator::destroyObject */
void
destroyObject
(
Object
*
obj
);
//Internal Items
//! Internal method, used for flagging multi-touch as available/unavailable for creation
void
_setMultiTouchUsed
(
bool
used
)
{
bMultiTouchUsed
=
used
;
}
//! Internal method, used for flagging accelerometer as available/unavailable for creation
void
_setAccelerometerUsed
(
bool
used
)
{
bAccelerometerUsed
=
used
;
}
//! methodfor getting the delegate
InputDelegate
*
_getDelegate
()
{
return
mDelegate
;
}
//! method for getting window
UIWindow
*
_getWindow
()
{
return
mWindow
;
}
protected:
void
_parseConfigSettings
(
ParamList
&
paramList
);
// iPhone stuff
UIWindow
*
mWindow
;
InputDelegate
*
mDelegate
;
// settings
bool
mHideMouse
;
//! Used to know if we used up multi-touch device
bool
bMultiTouchUsed
;
//! Used to know if we used up accelerometer
bool
bAccelerometerUsed
;
};
}
#endif
includes/iphone/iPhoneMultiTouch.h
View file @
24236447
/*
The zlib/libpng License
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
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_iPhoneMultiTouch_H
#define OIS_iPhoneMultiTouch_H
#include "OISMultiTouch.h"
#include "iphone/iPhonePrereqs.h"
#import <UIKit/UIKit.h>
struct
CGPoint
;
namespace
OIS
{
class
iPhoneMultiTouch
:
public
MultiTouch
{
public:
iPhoneMultiTouch
(
InputManager
*
creator
,
bool
buffered
);
virtual
~
iPhoneMultiTouch
();
/** @copydoc Object::setBuffered */
virtual
void
setBuffered
(
bool
buffered
);
/** @copydoc Object::capture */
virtual
void
capture
();
/** @copydoc Object::queryInterface */
virtual
Interface
*
queryInterface
(
Interface
::
IType
type
)
{
return
0
;}
/** @copydoc Object::_initialize */
virtual
void
_initialize
();
void
_touchBegan
(
UITouch
*
touch
);
void
_touchEnded
(
UITouch
*
touch
);
void
_touchMoved
(
UITouch
*
touch
);
void
_touchCancelled
(
UITouch
*
touch
);
protected:
MultiTouchState
mTempState
;
};
}
#endif // OIS_iPhoneTouch_H
/*
The zlib/libpng License
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
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_iPhoneMultiTouch_H
#define OIS_iPhoneMultiTouch_H
#include "OISMultiTouch.h"
#include "iphone/iPhonePrereqs.h"
#import <UIKit/UIKit.h>
struct
CGPoint
;
namespace
OIS
{
class
iPhoneMultiTouch
:
public
MultiTouch
{
public:
iPhoneMultiTouch
(
InputManager
*
creator
,
bool
buffered
);
virtual
~
iPhoneMultiTouch
();
/** @copydoc Object::setBuffered */
virtual
void
setBuffered
(
bool
buffered
);
/** @copydoc Object::capture */
virtual
void
capture
();
/** @copydoc Object::queryInterface */
virtual
Interface
*
queryInterface
(
Interface
::
IType
type
)
{
return
0
;}
/** @copydoc Object::_initialize */
virtual
void
_initialize
();
void
_touchBegan
(
UITouch
*
touch
);
void
_touchEnded
(
UITouch
*
touch
);
void
_touchMoved
(
UITouch
*
touch
);
void
_touchCancelled
(
UITouch
*
touch
);
protected:
MultiTouchState
mTempState
;
};
}
#endif // OIS_iPhoneTouch_H
includes/iphone/iPhonePrereqs.h
View file @
24236447
/*
The zlib/libpng License
Copyright (c) 2006 Chris Snyder
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_iPhonePrereqs_H
#define OIS_iPhonePrereqs_H
#include <string>
#include <list>
#include <CoreFoundation/CoreFoundation.h>
namespace
OIS
{
class
iPhoneInputManager
;
class
iPhoneAccelerometer
;
class
iPhoneMouse
;
/**
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
*/
class
OIS_CFString
{
public:
OIS_CFString
()
{
m_StringRef
=
CFStringCreateWithCString
(
NULL
,
""
,
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
()
{
CFRelease
(
m_StringRef
);
}
//Allow this class to be autoconverted to base class of StringRef (void*)
operator
void
*
()
{
return
(
void
*
)
m_StringRef
;
}
CFStringRef
cf_str
()
{
return
m_StringRef
;
}
private:
CFStringRef
m_StringRef
;
};
}
#endif
/*
The zlib/libpng License
Copyright (c) 2006 Chris Snyder
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_iPhonePrereqs_H
#define OIS_iPhonePrereqs_H
#include <string>
#include <list>
#include <CoreFoundation/CoreFoundation.h>
namespace
OIS
{
class
iPhoneInputManager
;
class
iPhoneAccelerometer
;
class
iPhoneMouse
;
/**
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
*/
class
OIS_CFString
{
public:
OIS_CFString
()
{
m_StringRef
=
CFStringCreateWithCString
(
NULL
,
""
,
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
()
{
CFRelease
(
m_StringRef
);
}
//Allow this class to be autoconverted to base class of StringRef (void*)
operator
void
*
()
{
return
(
void
*
)
m_StringRef
;
}
CFStringRef
cf_str
()
{
return
m_StringRef
;
}
private:
CFStringRef
m_StringRef
;
};
}
#endif
includes/linux/EventHelpers.h
View file @
24236447
/*
The zlib/libpng License
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
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 _LINUX_OISEVENT_HEADER_
#define _LINUX_OISEVENT_HEADER_
#include "linux/LinuxPrereqs.h"
#define OIS_MAX_DEVICES 32
#define OIS_DEVICE_NAME 128
namespace
OIS
{
class
EventUtils
{
public:
static
bool
isJoyStick
(
int
deviceID
,
JoyStickInfo
&
js
);
static
bool
isMouse
(
int
)
{
return
false
;}
static
bool
isKeyboard
(
int
)
{
return
false
;}
//Double pointer is so that we can set the value of the sent pointer
static
void
enumerateForceFeedback
(
int
deviceID
,
LinuxForceFeedback
**
ff
);
static
void
removeForceFeedback
(
LinuxForceFeedback
**
ff
);
static
std
::
string
getName
(
int
deviceID
);
static
std
::
string
getUniqueId
(
int
deviceID
);
static
std
::
string
getPhysicalLocation
(
int
deviceID
);
};
}
#endif
/*
The zlib/libpng License
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
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 _LINUX_OISEVENT_HEADER_
#define _LINUX_OISEVENT_HEADER_
#include "linux/LinuxPrereqs.h"
#define OIS_MAX_DEVICES 32
#define OIS_DEVICE_NAME 128
namespace
OIS
{
class
EventUtils
{
public:
static
bool
isJoyStick
(
int
deviceID
,
JoyStickInfo
&
js
);
static
bool
isMouse
(
int
)
{
return
false
;}
static
bool
isKeyboard
(
int
)
{
return
false
;}
//Double pointer is so that we can set the value of the sent pointer
static
void
enumerateForceFeedback
(
int
deviceID
,
LinuxForceFeedback
**
ff
);
static
void
removeForceFeedback
(
LinuxForceFeedback
**
ff
);
static
std
::
string
getName
(
int
deviceID
);
static
std
::
string
getUniqueId
(
int
deviceID
);
static
std
::
string
getPhysicalLocation
(
int
deviceID
);
};
}
#endif
includes/linux/LinuxForceFeedback.h
View file @
24236447
/*
The zlib/libpng License
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
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_LinuxForceFeedBack_H
#define OIS_LinuxForceFeedBack_H
#include "linux/LinuxPrereqs.h"
#include "OISForceFeedback.h"
#include <linux/input.h>
namespace
OIS
{
class
LinuxForceFeedback
:
public
ForceFeedback
{
public:
LinuxForceFeedback
(
int
deviceID
);
~
LinuxForceFeedback
();
/** @copydoc ForceFeedback::setMasterGain */
void
setMasterGain
(
float
);
/** @copydoc ForceFeedback::setAutoCenterMode */
void
setAutoCenterMode
(
bool
);
/** @copydoc ForceFeedback::upload */
void
upload
(
const
Effect
*
effect
);
/** @copydoc ForceFeedback::modify */
void
modify
(
const
Effect
*
effect
);
/** @copydoc ForceFeedback::remove */
void
remove
(
const
Effect
*
effect
);
/** FF is not yet implemented fully on Linux.. just return -1 for now. todo, xxx */
short
int
getFFAxesNumber
()
{
return
-
1
;
}
/** @copydoc ForceFeedback::getFFMemoryLoad */
unsigned
short
getFFMemoryLoad
();
protected:
//Sets the common properties to all effects
void
_setCommonProperties
(
struct
ff_effect
*
event
,
struct
ff_envelope
*
ffenvelope
,
const
Effect
*
effect
,
const
Envelope
*
envelope
);
//Specific Effect Settings
void
_updateConstantEffect
(
const
Effect
*
effect
);
void
_updateRampEffect
(
const
Effect
*
effect
);
void
_updatePeriodicEffect
(
const
Effect
*
effect
);
void
_updateConditionalEffect
(
const
Effect
*
effect
);
//void _updateCustomEffect( const Effect* effect );
void
_upload
(
struct
ff_effect
*
ffeffect
,
const
Effect
*
effect
);
void
_stop
(
int
handle
);
void
_start
(
int
handle
);
void
_unload
(
int
handle
);
// Map of currently uploaded effects (handle => effect)
typedef
std
::
map
<
int
,
struct
ff_effect
*>
EffectList
;
EffectList
mEffectList
;
// Joystick device (file) descriptor.
int
mJoyStick
;
};
}
#endif //OIS_LinuxForceFeedBack_H
/*
The zlib/libpng License
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
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_LinuxForceFeedBack_H
#define OIS_LinuxForceFeedBack_H
#include "linux/LinuxPrereqs.h"
#include "OISForceFeedback.h"
#include <linux/input.h>
namespace
OIS
{
class
LinuxForceFeedback
:
public
ForceFeedback
{
public:
LinuxForceFeedback
(
int
deviceID
);
~
LinuxForceFeedback
();
/** @copydoc ForceFeedback::setMasterGain */
void
setMasterGain
(
float
);
/** @copydoc ForceFeedback::setAutoCenterMode */
void
setAutoCenterMode
(
bool
);
/** @copydoc ForceFeedback::upload */
void
upload
(
const
Effect
*
effect
);
/** @copydoc ForceFeedback::modify */
void
modify
(
const
Effect
*
effect
);
/** @copydoc ForceFeedback::remove */
void
remove
(
const
Effect
*
effect
);
/** FF is not yet implemented fully on Linux.. just return -1 for now. todo, xxx */
short
int
getFFAxesNumber
()
{
return
-
1
;
}
/** @copydoc ForceFeedback::getFFMemoryLoad */
unsigned
short
getFFMemoryLoad
();
protected:
//Sets the common properties to all effects
void
_setCommonProperties
(
struct
ff_effect
*
event
,
struct
ff_envelope
*
ffenvelope
,
const
Effect
*
effect
,
const
Envelope
*
envelope
);
//Specific Effect Settings
void
_updateConstantEffect
(
const
Effect
*
effect
);
void
_updateRampEffect
(
const
Effect
*
effect
);
void
_updatePeriodicEffect
(
const
Effect
*
effect
);
void
_updateConditionalEffect
(
const
Effect
*
effect
);
//void _updateCustomEffect( const Effect* effect );
void
_upload
(
struct
ff_effect
*
ffeffect
,
const
Effect
*
effect
);
void
_stop
(
int
handle
);
void
_start
(
int
handle
);
void
_unload
(
int
handle
);
// Map of currently uploaded effects (handle => effect)
typedef
std
::
map
<
int
,
struct
ff_effect
*>
EffectList
;
EffectList
mEffectList
;
// Joystick device (file) descriptor.
int
mJoyStick
;
};
}
#endif //OIS_LinuxForceFeedBack_H
includes/linux/LinuxInputManager.h
View file @
24236447
/*
The zlib/libpng License
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
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_LinuxInputManager_H
#define OIS_LinuxInputManager_H
#include "linux/LinuxPrereqs.h"
#include "OISFactoryCreator.h"
#include "OISInputManager.h"
#include <X11/Xlib.h>
namespace
OIS
{
/**
Linux X11 InputManager specialization - Using lowlevel joys
*/
class
LinuxInputManager
:
public
InputManager
,
public
FactoryCreator
{
public:
LinuxInputManager
();
virtual
~
LinuxInputManager
();
//InputManager Overrides
/** @copydoc InputManager::_initialize */
void
_initialize
(
ParamList
&
paramList
);
//FactoryCreator Overrides
/** @copydoc FactoryCreator::deviceList */
DeviceList
freeDeviceList
();
/** @copydoc FactoryCreator::totalDevices */
int
totalDevices
(
Type
iType
);
/** @copydoc FactoryCreator::freeDevices */
int
freeDevices
(
Type
iType
);
/** @copydoc FactoryCreator::vendorExist */
bool
vendorExist
(
Type
iType
,
const
std
::
string
&
vendor
);
/** @copydoc FactoryCreator::createObject */
Object
*
createObject
(
InputManager
*
creator
,
Type
iType
,
bool
bufferMode
,
const
std
::
string
&
vendor
=
""
);
/** @copydoc FactoryCreator::destroyObject */
void
destroyObject
(
Object
*
obj
);
//Internal Items
//! Method for retrieving the XWindow Handle
Window
_getWindow
()
{
return
window
;}
//! Internal method for checking if regrabbing is needed
void
_setGrabState
(
bool
grab
)
{
mGrabs
=
grab
;}
bool
_getGrabState
()
{
return
mGrabs
;}
//! Internal method, used for flaggin keyboard as available/unavailable for creation
void
_setKeyboardUsed
(
bool
used
)
{
keyboardUsed
=
used
;
}
//! Internal method, used for flaggin mouse as available/unavailable for creation
void
_setMouseUsed
(
bool
used
)
{
mouseUsed
=
used
;
}
protected:
//! internal class method for dealing with param list
void
_parseConfigSettings
(
ParamList
&
paramList
);
//! internal class method for finding attached devices
void
_enumerateDevices
();
//! List of unused joysticks ready to be used
JoyStickInfoList
unusedJoyStickList
;
//! Number of joysticks found
char
joySticks
;
//! Used to know if we used up keyboard
bool
keyboardUsed
;
//! Used to know if we used up mouse
bool
mouseUsed
;
//! X11 Stuff
Window
window
;
/// Keyboard, Mouse Settings
bool
grabMouse
,
grabKeyboard
;
bool
mGrabs
;
bool
hideMouse
;
};
}
#endif
/*
The zlib/libpng License
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
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_LinuxInputManager_H
#define OIS_LinuxInputManager_H
#include "linux/LinuxPrereqs.h"
#include "OISFactoryCreator.h"
#include "OISInputManager.h"
#include <X11/Xlib.h>
namespace
OIS
{
/**
Linux X11 InputManager specialization - Using lowlevel joys
*/
class
LinuxInputManager
:
public
InputManager
,
public
FactoryCreator
{
public:
LinuxInputManager
();
virtual
~
LinuxInputManager
();
//InputManager Overrides
/** @copydoc InputManager::_initialize */
void
_initialize
(
ParamList
&
paramList
);
//FactoryCreator Overrides
/** @copydoc FactoryCreator::deviceList */
DeviceList
freeDeviceList
();
/** @copydoc FactoryCreator::totalDevices */
int
totalDevices
(
Type
iType
);
/** @copydoc FactoryCreator::freeDevices */
int
freeDevices
(
Type
iType
);
/** @copydoc FactoryCreator::vendorExist */
bool
vendorExist
(
Type
iType
,
const
std
::
string
&
vendor
);
/** @copydoc FactoryCreator::createObject */
Object
*
createObject
(
InputManager
*
creator
,
Type
iType
,
bool
bufferMode
,
const
std
::
string
&
vendor
=
""
);
/** @copydoc FactoryCreator::destroyObject */
void
destroyObject
(
Object
*
obj
);
//Internal Items
//! Method for retrieving the XWindow Handle
Window
_getWindow
()
{
return
window
;}
//! Internal method for checking if regrabbing is needed
void
_setGrabState
(
bool
grab
)
{
mGrabs
=
grab
;}
bool
_getGrabState
()
{
return
mGrabs
;}
//! Internal method, used for flaggin keyboard as available/unavailable for creation
void
_setKeyboardUsed
(
bool
used
)
{
keyboardUsed
=
used
;
}
//! Internal method, used for flaggin mouse as available/unavailable for creation
void
_setMouseUsed
(
bool
used
)
{
mouseUsed
=
used
;
}
protected:
//! internal class method for dealing with param list
void
_parseConfigSettings
(
ParamList
&
paramList
);
//! internal class method for finding attached devices
void
_enumerateDevices
();
//! List of unused joysticks ready to be used
JoyStickInfoList
unusedJoyStickList
;
//! Number of joysticks found
char
joySticks
;
//! Used to know if we used up keyboard
bool
keyboardUsed
;
//! Used to know if we used up mouse
bool
mouseUsed
;
//! X11 Stuff
Window
window
;
/// Keyboard, Mouse Settings
bool
grabMouse
,
grabKeyboard
;
bool
mGrabs
;
bool
hideMouse
;
};
}
#endif
includes/linux/LinuxJoyStickEvents.h
View file @
24236447
/*
The zlib/libpng License
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
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 _LINUX_JOYSTICK_H_EADER_
#define _LINUX_JOYSTICK_H_EADER_
#include "linux/LinuxPrereqs.h"
#include "OISJoyStick.h"
namespace
OIS
{
/**
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,
as FF support is sketchy at best AFAIK.
*/
class
LinuxJoyStick
:
public
JoyStick
{
public:
LinuxJoyStick
(
InputManager
*
creator
,
bool
buffered
,
const
JoyStickInfo
&
js
);
virtual
~
LinuxJoyStick
();
/** @copydoc Object::setBuffered */
virtual
void
setBuffered
(
bool
buffered
);
/** @copydoc Object::capture */
virtual
void
capture
();
/** @copydoc Object::queryInterface */
virtual
Interface
*
queryInterface
(
Interface
::
IType
type
);
/** @copydoc Object::_initialize */
virtual
void
_initialize
();
/**
@remarks
For internal use only... Returns a structure to the manager, to make the device
availiable for use again
*/
JoyStickInfo
_getJoyInfo
();
static
JoyStickInfoList
_scanJoys
();
static
void
_clearJoys
(
JoyStickInfoList
&
joys
);
protected:
int
mJoyStick
;
LinuxForceFeedback
*
ff_effect
;
std
::
map
<
int
,
int
>
mButtonMap
;
std
::
map
<
int
,
int
>
mAxisMap
;
std
::
map
<
int
,
Range
>
mRanges
;
};
}
#endif //_LINUX_JOYSTICK_H_EADER_
/*
The zlib/libpng License
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
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 _LINUX_JOYSTICK_H_EADER_
#define _LINUX_JOYSTICK_H_EADER_
#include "linux/LinuxPrereqs.h"
#include "OISJoyStick.h"
namespace
OIS
{
/**
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,
as FF support is sketchy at best AFAIK.
*/
class
LinuxJoyStick
:
public
JoyStick
{
public:
LinuxJoyStick
(
InputManager
*
creator
,
bool
buffered
,
const
JoyStickInfo
&
js
);
virtual
~
LinuxJoyStick
();
/** @copydoc Object::setBuffered */
virtual
void
setBuffered
(
bool
buffered
);
/** @copydoc Object::capture */
virtual
void
capture
();
/** @copydoc Object::queryInterface */
virtual
Interface
*
queryInterface
(
Interface
::
IType
type
);
/** @copydoc Object::_initialize */
virtual
void
_initialize
();
/**
@remarks
For internal use only... Returns a structure to the manager, to make the device
availiable for use again
*/
JoyStickInfo
_getJoyInfo
();
static
JoyStickInfoList
_scanJoys
();
static
void
_clearJoys
(
JoyStickInfoList
&
joys
);
protected:
int
mJoyStick
;
LinuxForceFeedback
*
ff_effect
;
std
::
map
<
int
,
int
>
mButtonMap
;
std
::
map
<
int
,
int
>
mAxisMap
;
std
::
map
<
int
,
Range
>
mRanges
;
};
}
#endif //_LINUX_JOYSTICK_H_EADER_
includes/linux/LinuxKeyboard.h
View file @
24236447
/*
The zlib/libpng License
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
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 _LINUX_KEYBOARD_H_EADER_
#define _LINUX_KEYBOARD_H_EADER_
#include "linux/LinuxPrereqs.h"
#include "OISKeyboard.h"
#include <X11/Xlib.h>
namespace
OIS
{
/** Linux implementation of Keyboard object - uses x11 */
class
LinuxKeyboard
:
public
Keyboard
{
public:
LinuxKeyboard
(
InputManager
*
creator
,
bool
buffered
,
bool
grab
);
virtual
~
LinuxKeyboard
();
/** @copydoc Keyboard::isKeyDown */
virtual
bool
isKeyDown
(
KeyCode
key
)
const
;
/** @copydoc Keyboard::getAsString */
virtual
const
std
::
string
&
getAsString
(
KeyCode
kc
);
/** @copydoc Keyboard::copyKeyStates */
virtual
void
copyKeyStates
(
char
keys
[
256
]
)
const
;
/** @copydoc Object::setBuffered */
virtual
void
setBuffered
(
bool
buffered
);
/** @copydoc Object::capture */
virtual
void
capture
();
/** @copydoc Object::queryInterface */
virtual
Interface
*
queryInterface
(
Interface
::
IType
)
{
return
0
;}
/** @copydoc Object::_initialize */
virtual
void
_initialize
();
/*
The zlib/libpng License
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
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 _LINUX_KEYBOARD_H_EADER_
#define _LINUX_KEYBOARD_H_EADER_
#include "linux/LinuxPrereqs.h"
#include "OISKeyboard.h"
#include <X11/Xlib.h>
namespace
OIS
{
/** Linux implementation of Keyboard object - uses x11 */
class
LinuxKeyboard
:
public
Keyboard
{
public:
LinuxKeyboard
(
InputManager
*
creator
,
bool
buffered
,
bool
grab
);
virtual
~
LinuxKeyboard
();
/** @copydoc Keyboard::isKeyDown */
virtual
bool
isKeyDown
(
KeyCode
key
)
const
;
/** @copydoc Keyboard::getAsString */
virtual
const
std
::
string
&
getAsString
(
KeyCode
kc
);
/** @copydoc Keyboard::copyKeyStates */
virtual
void
copyKeyStates
(
char
keys
[
256
]
)
const
;
/** @copydoc Object::setBuffered */
virtual
void
setBuffered
(
bool
buffered
);
/** @copydoc Object::capture */
virtual
void
capture
();
/** @copydoc Object::queryInterface */
virtual
Interface
*
queryInterface
(
Interface
::
IType
)
{
return
0
;}
/** @copydoc Object::_initialize */
virtual
void
_initialize
();
protected:
inline
bool
_isKeyRepeat
(
XEvent
&
event
)
{
//When a key is repeated, there will be two events: released, followed by another immediate pressed. So check to see if another pressed is present
//When a key is repeated, there will be two events: released, followed by another immediate pressed. So check to see if another pressed is present
if
(
!
XPending
(
display
))
return
false
;
...
...
@@ -74,25 +74,25 @@ namespace OIS
return
false
;
}
bool
_injectKeyDown
(
KeySym
key
,
int
text
);
bool
_injectKeyUp
(
KeySym
key
);
//! 1:1 Conversion Map between X Key Events and OIS KeyCodes
typedef
std
::
map
<
KeySym
,
KeyCode
>
XtoOIS_KeyMap
;
XtoOIS_KeyMap
keyConversion
;
//! Depressed Key List
char
KeyBuffer
[
256
];
//! X11 Stuff
Window
window
;
Display
*
display
;
bool
grabKeyboard
;
bool
keyFocusLost
;
std
::
string
mGetString
;
};
}
#endif //_LINUX_KEYBOARD_H_EADER_
bool
_injectKeyDown
(
KeySym
key
,
int
text
);
bool
_injectKeyUp
(
KeySym
key
);
//! 1:1 Conversion Map between X Key Events and OIS KeyCodes
typedef
std
::
map
<
KeySym
,
KeyCode
>
XtoOIS_KeyMap
;
XtoOIS_KeyMap
keyConversion
;
//! Depressed Key List
char
KeyBuffer
[
256
];
//! X11 Stuff
Window
window
;
Display
*
display
;
bool
grabKeyboard
;
bool
keyFocusLost
;
std
::
string
mGetString
;
};
}
#endif //_LINUX_KEYBOARD_H_EADER_
includes/linux/LinuxMouse.h
View file @
24236447
/*
The zlib/libpng License
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
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 _LINUX_MOUSE_H_EADER_
#define _LINUX_MOUSE_H_EADER_
#include "linux/LinuxPrereqs.h"
#include "OISMouse.h"
#include <X11/Xlib.h>
namespace
OIS
{
class
LinuxMouse
:
public
Mouse
{
public:
LinuxMouse
(
InputManager
*
creator
,
bool
buffered
,
bool
grab
,
bool
hide
);
virtual
~
LinuxMouse
();
/** @copydoc Object::setBuffered */
virtual
void
setBuffered
(
bool
buffered
);
/**
@remarks
Note: Calling this will also update the keyboard (X11 updates in a single
event queue). Updates State and/or raises event for buffered mode..
*/
virtual
void
capture
();
/** @copydoc Object::queryInterface */
virtual
Interface
*
queryInterface
(
Interface
::
IType
)
{
return
0
;}
/** @copydoc Object::_initialize */
virtual
void
_initialize
();
void
grab
(
bool
grab
);
void
hide
(
bool
hide
);
protected:
void
_processXEvents
();
bool
mMoved
,
mWarped
;
//Since X11 provides us with absolute values, we need to keep track of relative values
long
oldXMouseX
,
oldXMouseY
,
oldXMouseZ
;
Window
window
;
//The X Window
Display
*
display
;
//The X display
Cursor
cursor
;
//A blank cursor
bool
grabMouse
;
//Are we grabbing the mouse to the window?
bool
hideMouse
;
//Are we hiding OS mouse?
bool
mouseFocusLost
;
//Has the mouse just lost focus?
};
}
#endif //_LINUX_MOUSE_H_EADER_
/*
The zlib/libpng License
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
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 _LINUX_MOUSE_H_EADER_
#define _LINUX_MOUSE_H_EADER_
#include "linux/LinuxPrereqs.h"
#include "OISMouse.h"
#include <X11/Xlib.h>
namespace
OIS
{
class
LinuxMouse
:
public
Mouse
{
public:
LinuxMouse
(
InputManager
*
creator
,
bool
buffered
,
bool
grab
,
bool
hide
);
virtual
~
LinuxMouse
();
/** @copydoc Object::setBuffered */
virtual
void
setBuffered
(
bool
buffered
);
/**
@remarks
Note: Calling this will also update the keyboard (X11 updates in a single
event queue). Updates State and/or raises event for buffered mode..
*/
virtual
void
capture
();
/** @copydoc Object::queryInterface */
virtual
Interface
*
queryInterface
(
Interface
::
IType
)
{
return
0
;}
/** @copydoc Object::_initialize */
virtual
void
_initialize
();
void
grab
(
bool
grab
);
void
hide
(
bool
hide
);
protected:
void
_processXEvents
();
bool
mMoved
,
mWarped
;
//Since X11 provides us with absolute values, we need to keep track of relative values
long
oldXMouseX
,
oldXMouseY
,
oldXMouseZ
;
Window
window
;
//The X Window
Display
*
display
;
//The X display
Cursor
cursor
;
//A blank cursor
bool
grabMouse
;
//Are we grabbing the mouse to the window?
bool
hideMouse
;
//Are we hiding OS mouse?
bool
mouseFocusLost
;
//Has the mouse just lost focus?
};
}
#endif //_LINUX_MOUSE_H_EADER_
includes/linux/LinuxPrereqs.h
View file @
24236447
/*
The zlib/libpng License
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
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 _LINUX_INPUTSYSTEM_PREREQS_H
#define _LINUX_INPUTSYSTEM_PREREQS_H
//Bring in any auto generated config files
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "OISPrereqs.h"
//! Max number of elements to collect from buffered input
#define JOY_BUFFERSIZE 64
namespace
OIS
{
class
LinuxInputManager
;
class
LinuxKeyboard
;
class
LinuxJoyStick
;
class
LinuxMouse
;
class
LinuxForceFeedback
;
class
Range
{
public:
Range
()
{};
Range
(
int
_min
,
int
_max
)
:
min
(
_min
),
max
(
_max
)
{};
int
min
,
max
;
};
class
JoyStickInfo
{
public:
JoyStickInfo
()
:
devId
(
-
1
),
joyFileD
(
-
1
),
version
(
0
),
axes
(
0
),
buttons
(
0
),
hats
(
0
)
{}
//! Device number (/dev/input/j#) or /dev/input/event#
int
devId
;
//! File descriptor
int
joyFileD
;
//! Driver version
int
version
;
//! Joy vendor
std
::
string
vendor
;
//! Number of axes
unsigned
char
axes
;
//! Number of buttons
unsigned
char
buttons
;
//! Number of hats
unsigned
char
hats
;
//! Maps Linux button values to OIS buttons values
std
::
map
<
int
,
int
>
button_map
;
//! Maps Linux axis values to OIS axis
std
::
map
<
int
,
int
>
axis_map
;
//! Maps OIS axis values to it's range
std
::
map
<
int
,
Range
>
axis_range
;
};
typedef
std
::
vector
<
JoyStickInfo
>
JoyStickInfoList
;
}
#endif //_LINUX_INPUTSYSTEM_PREREQS_H
/*
The zlib/libpng License
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
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 _LINUX_INPUTSYSTEM_PREREQS_H
#define _LINUX_INPUTSYSTEM_PREREQS_H
//Bring in any auto generated config files
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "OISPrereqs.h"
//! Max number of elements to collect from buffered input
#define JOY_BUFFERSIZE 64
namespace
OIS
{
class
LinuxInputManager
;
class
LinuxKeyboard
;
class
LinuxJoyStick
;
class
LinuxMouse
;
class
LinuxForceFeedback
;
class
Range
{
public:
Range
()
{};
Range
(
int
_min
,
int
_max
)
:
min
(
_min
),
max
(
_max
)
{};
int
min
,
max
;
};
class
JoyStickInfo
{
public:
JoyStickInfo
()
:
devId
(
-
1
),
joyFileD
(
-
1
),
version
(
0
),
axes
(
0
),
buttons
(
0
),
hats
(
0
)
{}
//! Device number (/dev/input/j#) or /dev/input/event#
int
devId
;
//! File descriptor
int
joyFileD
;
//! Driver version
int
version
;
//! Joy vendor
std
::
string
vendor
;
//! Number of axes
unsigned
char
axes
;
//! Number of buttons
unsigned
char
buttons
;
//! Number of hats
unsigned
char
hats
;
//! Maps Linux button values to OIS buttons values
std
::
map
<
int
,
int
>
button_map
;
//! Maps Linux axis values to OIS axis
std
::
map
<
int
,
int
>
axis_map
;
//! Maps OIS axis values to it's range
std
::
map
<
int
,
Range
>
axis_range
;
};
typedef
std
::
vector
<
JoyStickInfo
>
JoyStickInfoList
;
}
#endif //_LINUX_INPUTSYSTEM_PREREQS_H
includes/mac/MacHIDManager.h
View file @
24236447
/*
The zlib/libpng License
Copyright (c) 2007 Phillip
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_MacHIDManager_Header
#define OIS_MacHIDManager_Header
#include "OISPrereqs.h"
#include "mac/MacPrereqs.h"
#include "OISFactoryCreator.h"
#import <CoreFoundation/CFString.h>
#import <IOKit/IOKitLib.h>
#import <IOKit/IOCFPlugIn.h>
#import <IOKit/hid/IOHIDLib.h>
#import <IOKit/hid/IOHIDKeys.h>
#import <Kernel/IOKit/hidsystem/IOHIDUsageTables.h>
namespace
OIS
{
//Information needed to create Mac HID Devices
class
HidInfo
{
public:
HidInfo
()
:
type
(
OISUnknown
),
numButtons
(
0
),
numHats
(
0
),
numAxes
(
0
),
inUse
(
false
),
interface
(
0
)
{
}
//Useful tracking information
Type
type
;
std
::
string
vendor
;
std
::
string
productKey
;
std
::
string
combinedKey
;
//Retain some count information for recreating devices without having to reparse
int
numButtons
;
int
numHats
;
int
numAxes
;
bool
inUse
;
//Used for opening a read/write/tracking interface to device
IOHIDDeviceInterface
**
interface
;
};
typedef
std
::
vector
<
HidInfo
*>
HidInfoList
;
class
MacHIDManager
:
public
FactoryCreator
{
public:
MacHIDManager
();
~
MacHIDManager
();
void
initialize
();
void
iterateAndOpenDevices
(
io_iterator_t
iterator
);
io_iterator_t
lookUpDevices
(
int
usage
,
int
page
);
//FactoryCreator Overrides
/** @copydoc FactoryCreator::deviceList */
DeviceList
freeDeviceList
();
/** @copydoc FactoryCreator::totalDevices */
int
totalDevices
(
Type
iType
);
/** @copydoc FactoryCreator::freeDevices */
int
freeDevices
(
Type
iType
);
/** @copydoc FactoryCreator::vendorExist */
bool
vendorExist
(
Type
iType
,
const
std
::
string
&
vendor
);
/** @copydoc FactoryCreator::createObject */
Object
*
createObject
(
InputManager
*
creator
,
Type
iType
,
bool
bufferMode
,
const
std
::
string
&
vendor
=
""
);
/** @copydoc FactoryCreator::destroyObject */
void
destroyObject
(
Object
*
obj
);
private:
HidInfo
*
enumerateDeviceProperties
(
CFMutableDictionaryRef
propertyMap
);
void
parseDeviceProperties
(
CFDictionaryRef
properties
);
void
parseDevicePropertiesGroup
(
CFDictionaryRef
properties
);
HidInfoList
mDeviceList
;
};
}
#endif
/*
The zlib/libpng License
Copyright (c) 2007 Phillip
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_MacHIDManager_Header
#define OIS_MacHIDManager_Header
#include "OISPrereqs.h"
#include "mac/MacPrereqs.h"
#include "OISFactoryCreator.h"
#import <CoreFoundation/CFString.h>
#import <IOKit/IOKitLib.h>
#import <IOKit/IOCFPlugIn.h>
#import <IOKit/hid/IOHIDLib.h>
#import <IOKit/hid/IOHIDKeys.h>
#import <Kernel/IOKit/hidsystem/IOHIDUsageTables.h>
namespace
OIS
{
//Information needed to create Mac HID Devices
class
HidInfo
{
public:
HidInfo
()
:
type
(
OISUnknown
),
numButtons
(
0
),
numHats
(
0
),
numAxes
(
0
),
inUse
(
false
),
interface
(
0
)
{
}
//Useful tracking information
Type
type
;
std
::
string
vendor
;
std
::
string
productKey
;
std
::
string
combinedKey
;
//Retain some count information for recreating devices without having to reparse
int
numButtons
;
int
numHats
;
int
numAxes
;
bool
inUse
;
//Used for opening a read/write/tracking interface to device
IOHIDDeviceInterface
**
interface
;
};
typedef
std
::
vector
<
HidInfo
*>
HidInfoList
;
class
MacHIDManager
:
public
FactoryCreator
{
public:
MacHIDManager
();
~
MacHIDManager
();
void
initialize
();
void
iterateAndOpenDevices
(
io_iterator_t
iterator
);
io_iterator_t
lookUpDevices
(
int
usage
,
int
page
);
//FactoryCreator Overrides
/** @copydoc FactoryCreator::deviceList */
DeviceList
freeDeviceList
();
/** @copydoc FactoryCreator::totalDevices */
int
totalDevices
(
Type
iType
);
/** @copydoc FactoryCreator::freeDevices */
int
freeDevices
(
Type
iType
);
/** @copydoc FactoryCreator::vendorExist */
bool
vendorExist
(
Type
iType
,
const
std
::
string
&
vendor
);
/** @copydoc FactoryCreator::createObject */
Object
*
createObject
(
InputManager
*
creator
,
Type
iType
,
bool
bufferMode
,
const
std
::
string
&
vendor
=
""
);
/** @copydoc FactoryCreator::destroyObject */
void
destroyObject
(
Object
*
obj
);
private:
HidInfo
*
enumerateDeviceProperties
(
CFMutableDictionaryRef
propertyMap
);
void
parseDeviceProperties
(
CFDictionaryRef
properties
);
void
parseDevicePropertiesGroup
(
CFDictionaryRef
properties
);
HidInfoList
mDeviceList
;
};
}
#endif
includes/mac/MacHelpers.h
View file @
24236447
/*
The zlib/libpng License
Copyright (c) 2006 Chris Snyder
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_MacHelpers_H
#define OIS_MacHelpers_H
#include "mac/MacPrereqs.h"
#include "OISEvents.h"
#include "OISKeyboard.h"
#include "OISMouse.h"
#include <Carbon/Carbon.h>
// This is a hack needed to get the event handler working.
// 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)
// 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.
OSStatus
KeyDownWrapper
(
EventHandlerCallRef
nextHandler
,
EventRef
theEvent
,
void
*
callClass
);
OSStatus
KeyUpWrapper
(
EventHandlerCallRef
nextHandler
,
EventRef
theEvent
,
void
*
callClass
);
OSStatus
KeyModWrapper
(
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
namespace
OIS
{
// used in the eventStack to store the type
enum
Mac_EventType
{
MAC_KEYUP
=
0
,
MAC_KEYDOWN
=
1
,
MAC_KEYREPEAT
,
MAC_MOUSEDOWN
,
MAC_MOUSEUP
,
MAC_MOUSEMOVED
,
MAC_MOUSESCROLL
};
typedef
enum
Mac_EventType
MacEventType
;
// only used by MacKeyboard
typedef
class
Mac_KeyStackEvent
{
friend
class
MacKeyboard
;
private:
Mac_KeyStackEvent
(
KeyEvent
event
,
MacEventType
type
)
:
Event
(
event
),
Type
(
type
)
{}
MacEventType
Type
;
KeyEvent
Event
;
}
MacKeyStackEvent
;
// only used by MacMouse
typedef
class
Mac_MouseStackEvent
{
friend
class
MacMouse
;
private:
Mac_MouseStackEvent
(
MouseEvent
event
,
MacEventType
type
,
MouseButtonID
button
)
:
Event
(
event
),
Type
(
type
),
Button
(
button
)
{}
MacEventType
Type
;
MouseEvent
Event
;
MouseButtonID
Button
;
}
MacMouseStackEvent
;
}
#endif
/*
The zlib/libpng License
Copyright (c) 2006 Chris Snyder
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_MacHelpers_H
#define OIS_MacHelpers_H
#include "mac/MacPrereqs.h"
#include "OISEvents.h"
#include "OISKeyboard.h"
#include "OISMouse.h"
#include <Carbon/Carbon.h>
// This is a hack needed to get the event handler working.
// 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)
// 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.
OSStatus
KeyDownWrapper
(
EventHandlerCallRef
nextHandler
,
EventRef
theEvent
,
void
*
callClass
);
OSStatus
KeyUpWrapper
(
EventHandlerCallRef
nextHandler
,
EventRef
theEvent
,
void
*
callClass
);
OSStatus
KeyModWrapper
(
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
namespace
OIS
{
// used in the eventStack to store the type
enum
Mac_EventType
{
MAC_KEYUP
=
0
,
MAC_KEYDOWN
=
1
,
MAC_KEYREPEAT
,
MAC_MOUSEDOWN
,
MAC_MOUSEUP
,
MAC_MOUSEMOVED
,
MAC_MOUSESCROLL
};
typedef
enum
Mac_EventType
MacEventType
;
// only used by MacKeyboard
typedef
class
Mac_KeyStackEvent
{
friend
class
MacKeyboard
;
private:
Mac_KeyStackEvent
(
KeyEvent
event
,
MacEventType
type
)
:
Event
(
event
),
Type
(
type
)
{}
MacEventType
Type
;
KeyEvent
Event
;
}
MacKeyStackEvent
;
// only used by MacMouse
typedef
class
Mac_MouseStackEvent
{
friend
class
MacMouse
;
private:
Mac_MouseStackEvent
(
MouseEvent
event
,
MacEventType
type
,
MouseButtonID
button
)
:
Event
(
event
),
Type
(
type
),
Button
(
button
)
{}
MacEventType
Type
;
MouseEvent
Event
;
MouseButtonID
Button
;
}
MacMouseStackEvent
;
}
#endif
includes/mac/MacInputManager.h
View file @
24236447
/*
The zlib/libpng License
Copyright (c) 2006 Chris Snyder
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_MacInputManager_H
#define OIS_MacInputManager_H
#include "OISInputManager.h"
#include "OISFactoryCreator.h"
#include "mac/MacPrereqs.h"
#include <Carbon/Carbon.h>
namespace
OIS
{
class
MacInputManager
:
public
InputManager
,
public
FactoryCreator
{
public:
MacInputManager
();
virtual
~
MacInputManager
();
//InputManager Overrides
/** @copydoc InputManager::_initialize */
void
_initialize
(
ParamList
&
paramList
);
//FactoryCreator Overrides
/** @copydoc FactoryCreator::deviceList */
DeviceList
freeDeviceList
();
/** @copydoc FactoryCreator::totalDevices */
int
totalDevices
(
Type
iType
);
/** @copydoc FactoryCreator::freeDevices */
int
freeDevices
(
Type
iType
);
/** @copydoc FactoryCreator::vendorExist */
bool
vendorExist
(
Type
iType
,
const
std
::
string
&
vendor
);
/** @copydoc FactoryCreator::createObject */
Object
*
createObject
(
InputManager
*
creator
,
Type
iType
,
bool
bufferMode
,
const
std
::
string
&
vendor
=
""
);
/** @copydoc FactoryCreator::destroyObject */
void
destroyObject
(
Object
*
obj
);
//Internal Items
//! Internal method, used for flaggin keyboard as available/unavailable for creation
void
_setKeyboardUsed
(
bool
used
)
{
keyboardUsed
=
used
;
}
//! Internal method, used for flaggin mouse as available/unavailable for creation
void
_setMouseUsed
(
bool
used
)
{
mouseUsed
=
used
;
}
//! methodfor getting the event target
EventTargetRef
_getEventTarget
()
{
return
mEventTargetRef
;}
//! method for getting window
WindowRef
_getWindow
()
{
return
mWindow
;}
protected:
void
_parseConfigSettings
(
ParamList
&
paramList
);
void
_enumerateDevices
();
static
const
std
::
string
iName
;
// Mac stuff
EventTargetRef
mEventTargetRef
;
WindowRef
mWindow
;
// settings
bool
mHideMouse
;
bool
mUseRepeat
;
//! Used to know if we used up keyboard
bool
keyboardUsed
;
//! Used to know if we used up mouse
bool
mouseUsed
;
//! HID Manager class handling devices other than keyboard/mouse
MacHIDManager
*
mHIDManager
;
};
}
#endif
/*
The zlib/libpng License
Copyright (c) 2006 Chris Snyder
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_MacInputManager_H
#define OIS_MacInputManager_H
#include "OISInputManager.h"
#include "OISFactoryCreator.h"
#include "mac/MacPrereqs.h"
#include <Carbon/Carbon.h>
namespace
OIS
{
class
MacInputManager
:
public
InputManager
,
public
FactoryCreator
{
public:
MacInputManager
();
virtual
~
MacInputManager
();
//InputManager Overrides
/** @copydoc InputManager::_initialize */
void
_initialize
(
ParamList
&
paramList
);
//FactoryCreator Overrides
/** @copydoc FactoryCreator::deviceList */
DeviceList
freeDeviceList
();
/** @copydoc FactoryCreator::totalDevices */
int
totalDevices
(
Type
iType
);
/** @copydoc FactoryCreator::freeDevices */
int
freeDevices
(
Type
iType
);
/** @copydoc FactoryCreator::vendorExist */
bool
vendorExist
(
Type
iType
,
const
std
::
string
&
vendor
);
/** @copydoc FactoryCreator::createObject */
Object
*
createObject
(
InputManager
*
creator
,
Type
iType
,
bool
bufferMode
,
const
std
::
string
&
vendor
=
""
);
/** @copydoc FactoryCreator::destroyObject */
void
destroyObject
(
Object
*
obj
);
//Internal Items
//! Internal method, used for flaggin keyboard as available/unavailable for creation
void
_setKeyboardUsed
(
bool
used
)
{
keyboardUsed
=
used
;
}
//! Internal method, used for flaggin mouse as available/unavailable for creation
void
_setMouseUsed
(
bool
used
)
{
mouseUsed
=
used
;
}
//! methodfor getting the event target
EventTargetRef
_getEventTarget
()
{
return
mEventTargetRef
;}
//! method for getting window
WindowRef
_getWindow
()
{
return
mWindow
;}
protected:
void
_parseConfigSettings
(
ParamList
&
paramList
);
void
_enumerateDevices
();
static
const
std
::
string
iName
;
// Mac stuff
EventTargetRef
mEventTargetRef
;
WindowRef
mWindow
;
// settings
bool
mHideMouse
;
bool
mUseRepeat
;
//! Used to know if we used up keyboard
bool
keyboardUsed
;
//! Used to know if we used up mouse
bool
mouseUsed
;
//! HID Manager class handling devices other than keyboard/mouse
MacHIDManager
*
mHIDManager
;
};
}
#endif
Prev
1
2
3
4
5
6
7
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment