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
The zlib/libpng License
Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
This software is provided 'as-is', without any express or implied warranty. In no event will
This software is provided 'as-is', without any express or implied warranty. In no event will
the authors be held liable for any damages arising from the use of this software.
the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose, including commercial
Permission is granted to anyone to use this software for any purpose, including commercial
applications, and to alter it and redistribute it freely, subject to the following
applications, and to alter it and redistribute it freely, subject to the following
restrictions:
restrictions:
1. The origin of this software must not be misrepresented; you must not claim that
1. The origin of this software must not be misrepresented; you must not claim that
you wrote the original software. If you use this software in a product,
you wrote the original software. If you use this software in a product,
an acknowledgment in the product documentation would be appreciated but is
an acknowledgment in the product documentation would be appreciated but is
not required.
not required.
2. Altered source versions must be plainly marked as such, and must not be
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
3. This notice may not be removed or altered from any source distribution.
*/
*/
#ifndef OIS_Prereqs_H
#ifndef OIS_Prereqs_H
#define OIS_Prereqs_H
#define OIS_Prereqs_H
//----------------------------------------------------------------------------//
//----------------------------------------------------------------------------//
// This Header File contains: forward declared classes
// This Header File contains: forward declared classes
// * Forward Declarations of all public API classes
// * Forward Declarations of all public API classes
// * Several typedef's used around the library
// * Several typedef's used around the library
// * Base class component types
// * Base class component types
// * Preprocessor definitons
// * Preprocessor definitons
//----------------------------------------------------------------------------//
//----------------------------------------------------------------------------//
//-------------- Common STL Containers ---------------------------------------//
//-------------- Common STL Containers ---------------------------------------//
#include <vector>
#include <vector>
#include <string>
#include <string>
#include <map>
#include <map>
#include "OISConfig.h"
#include "OISConfig.h"
// Default is blank for most OS's
// Default is blank for most OS's
#define _OISExport
#define _OISExport
//-------------- Determine Compiler ---------------------------------
//-------------- Determine Compiler ---------------------------------
#if defined( _MSC_VER )
#if defined( _MSC_VER )
# define OIS_MSVC_COMPILER
# define OIS_MSVC_COMPILER
#elif defined( __GNUC__ )
#elif defined( __GNUC__ )
# if defined( __WIN32__ ) || defined( _WIN32 )
# if defined( __WIN32__ ) || defined( _WIN32 )
# define OIS_MINGW_COMPILER
# define OIS_MINGW_COMPILER
# else
# else
# define OIS_GCC_COMPILER
# define OIS_GCC_COMPILER
# endif
# endif
#elif defined( __BORLANDC__ )
#elif defined( __BORLANDC__ )
# define OIS_BORLAND_COMPILER
# define OIS_BORLAND_COMPILER
#else
#else
# error No Recognized Compiler!
# error No Recognized Compiler!
#endif
#endif
// --------------- Determine Operating System Platform ---------------
// --------------- Determine Operating System Platform ---------------
#if defined( __WIN32__ ) || defined( _WIN32 ) // Windows 2000, XP, ETC
#if defined( __WIN32__ ) || defined( _WIN32 ) // Windows 2000, XP, ETC
# if defined ( _XBOX )
# if defined ( _XBOX )
# define OIS_XBOX_PLATFORM
# define OIS_XBOX_PLATFORM
# else
# else
# define OIS_WIN32_PLATFORM
# define OIS_WIN32_PLATFORM
# if defined( OIS_DYNAMIC_LIB )
# if defined( OIS_DYNAMIC_LIB )
# undef _OISExport
# undef _OISExport
//Ignorable Dll interface warning...
//Ignorable Dll interface warning...
# if !defined(OIS_MINGW_COMPILER)
# if !defined(OIS_MINGW_COMPILER)
# pragma warning (disable : 4251)
# pragma warning (disable : 4251)
# endif
# endif
# if defined( OIS_NONCLIENT_BUILD )
# if defined( OIS_NONCLIENT_BUILD )
# define _OISExport __declspec( dllexport )
# define _OISExport __declspec( dllexport )
# else
# else
# if defined(OIS_MINGW_COMPILER)
# if defined(OIS_MINGW_COMPILER)
# define _OISExport
# define _OISExport
# else
# else
# define _OISExport __declspec( dllimport )
# define _OISExport __declspec( dllimport )
# endif
# endif
# endif
# endif
# endif
# endif
# endif
# endif
#elif defined( __APPLE_CC__ ) // Apple OS X
#elif defined( __APPLE_CC__ ) // Apple OS X
// Device Simulator
// Device Simulator
# if __IPHONE_OS_VERSION_MIN_REQUIRED >= 20201 || __IPHONE_OS_VERSION_MIN_REQUIRED >= 20000
# 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
//# if __IPHONE_OS_VERSION_MIN_REQUIRED >= 30000 || __IPHONE_OS_VERSION_MIN_REQUIRED >= 30000
# define OIS_IPHONE_PLATFORM
# define OIS_IPHONE_PLATFORM
# else
# else
# define OIS_APPLE_PLATFORM
# define OIS_APPLE_PLATFORM
# endif
# endif
# undef _OISExport
# undef _OISExport
# define _OISExport __attribute__((visibility("default")))
# define _OISExport __attribute__((visibility("default")))
#else //Probably Linux
#else //Probably Linux
# define OIS_LINUX_PLATFORM
# define OIS_LINUX_PLATFORM
# include <unistd.h>
# include <unistd.h>
#endif
#endif
//Is Processor 32 or 64 bits...
//Is Processor 32 or 64 bits...
#if defined(__x86_64__)
#if defined(__x86_64__)
# define OIS_ARCH_64
# define OIS_ARCH_64
#else
#else
# define OIS_ARCH_32
# define OIS_ARCH_32
#endif
#endif
//-------------- Common Classes, Enums, and Typdef's -------------------------//
//-------------- Various helper preprocessor definitions ---------------------//
#define OIS_VERSION_MAJOR 1
#define OIS_VERSION_MINOR 4
#ifdef OIS_MSVC_COMPILER
#define OIS_VERSION_PATCH 0
# define OIS_INLINE_PRAGMA(x) __pragma(x) // x is intentionally not wrapped; __pragma rejects expressions beginning with '('.
#define OIS_VERSION_NAME "1.4.0"
#else
# define OIS_INLINE_PRAGMA(x)
#define OIS_VERSION ((OIS_VERSION_MAJOR << 16) | (OIS_VERSION_MINOR << 8) | OIS_VERSION_PATCH)
#endif
namespace
OIS
#define OIS_MACRO_BEGIN do {
{
//Forward Declarations
#define OIS_MACRO_END \
class
InputManager
;
} OIS_INLINE_PRAGMA(warning(push)) OIS_INLINE_PRAGMA(warning(disable:4127)) while (0) OIS_INLINE_PRAGMA(warning(pop))
class
FactoryCreator
;
class
Object
;
// This creative trickery taken from this StackOverflow answer:
class
Keyboard
;
// http://stackoverflow.com/questions/4030959/will-a-variablename-c-statement-be-a-no-op-at-all-times/4030983#4030983
class
Mouse
;
#define OIS_UNUSED(x)\
class
JoyStick
;
OIS_MACRO_BEGIN\
class
MultiTouch
;
((void)(true ? 0 : ((x), void(), 0)));\
class
KeyListener
;
OIS_MACRO_END
class
MouseListener
;
class
MultiTouchListener
;
//-------------- Common Classes, Enums, and Typdef's -------------------------//
class
JoyStickListener
;
#define OIS_VERSION_MAJOR 1
class
Interface
;
#define OIS_VERSION_MINOR 4
class
ForceFeedback
;
#define OIS_VERSION_PATCH 0
class
Effect
;
#define OIS_VERSION_NAME "1.4.0"
class
Exception
;
#define OIS_VERSION ((OIS_VERSION_MAJOR << 16) | (OIS_VERSION_MINOR << 8) | OIS_VERSION_PATCH)
//! Way to send OS nuetral parameters.. ie OS Window handles, modes, flags
typedef
std
::
multimap
<
std
::
string
,
std
::
string
>
ParamList
;
namespace
OIS
{
//! List of FactoryCreator's
//Forward Declarations
typedef
std
::
vector
<
FactoryCreator
*>
FactoryList
;
class
InputManager
;
class
FactoryCreator
;
//! Map of FactoryCreator created Objects
class
Object
;
typedef
std
::
map
<
Object
*
,
FactoryCreator
*>
FactoryCreatedObject
;
class
Keyboard
;
class
Mouse
;
//! Each Input class has a General Type variable, a form of RTTI
class
JoyStick
;
enum
Type
class
MultiTouch
;
{
class
KeyListener
;
OISUnknown
=
0
,
class
MouseListener
;
OISKeyboard
=
1
,
class
MultiTouchListener
;
OISMouse
=
2
,
class
JoyStickListener
;
OISJoyStick
=
3
,
class
Interface
;
OISTablet
=
4
,
class
ForceFeedback
;
OISMultiTouch
=
5
class
Effect
;
};
class
Exception
;
//! Map of device objects connected and their respective vendors
//! Way to send OS nuetral parameters.. ie OS Window handles, modes, flags
typedef
std
::
multimap
<
Type
,
std
::
string
>
DeviceList
;
typedef
std
::
multimap
<
std
::
string
,
std
::
string
>
ParamList
;
//-------- Shared common components ------------------------//
//! List of FactoryCreator's
typedef
std
::
vector
<
FactoryCreator
*>
FactoryList
;
//! Base type for all device components (button, axis, etc)
enum
ComponentType
//! Map of FactoryCreator created Objects
{
typedef
std
::
map
<
Object
*
,
FactoryCreator
*>
FactoryCreatedObject
;
OIS_Unknown
=
0
,
OIS_Button
=
1
,
//ie. Key, mouse button, joy button, etc
//! Each Input class has a General Type variable, a form of RTTI
OIS_Axis
=
2
,
//ie. A joystick or mouse axis
enum
Type
OIS_Slider
=
3
,
//
{
OIS_POV
=
4
,
//ie. Arrow direction keys
OISUnknown
=
0
,
OIS_Vector3
=
5
//ie. WiiMote orientation
OISKeyboard
=
1
,
};
OISMouse
=
2
,
OISJoyStick
=
3
,
//! Base of all device components (button, axis, etc)
OISTablet
=
4
,
class
_OISExport
Component
OISMultiTouch
=
5
{
};
public:
Component
()
:
cType
(
OIS_Unknown
)
{};
//! Map of device objects connected and their respective vendors
Component
(
ComponentType
type
)
:
cType
(
type
)
{};
typedef
std
::
multimap
<
Type
,
std
::
string
>
DeviceList
;
//! Indicates what type of coponent this is
ComponentType
cType
;
//-------- Shared common components ------------------------//
};
//! Base type for all device components (button, axis, etc)
//! Button can be a keyboard key, mouse button, etc
enum
ComponentType
class
_OISExport
Button
:
public
Component
{
{
OIS_Unknown
=
0
,
public:
OIS_Button
=
1
,
//ie. Key, mouse button, joy button, etc
Button
()
:
Component
(
OIS_Button
),
pushed
(
false
)
{}
OIS_Axis
=
2
,
//ie. A joystick or mouse axis
Button
(
bool
bPushed
)
:
Component
(
OIS_Button
),
pushed
(
bPushed
)
{}
OIS_Slider
=
3
,
//
//! true if pushed, false otherwise
OIS_POV
=
4
,
//ie. Arrow direction keys
bool
pushed
;
OIS_Vector3
=
5
//ie. WiiMote orientation
};
};
//! Axis component
//! Base of all device components (button, axis, etc)
class
_OISExport
Axis
:
public
Component
class
_OISExport
Component
{
{
public:
public:
Axis
()
:
Component
(
OIS_Axis
),
abs
(
0
),
rel
(
0
),
absOnly
(
false
)
{};
Component
()
:
cType
(
OIS_Unknown
)
{};
explicit
Component
(
ComponentType
type
)
:
cType
(
type
)
{};
//! Absoulte and Relative value components
//! Indicates what type of coponent this is
int
abs
,
rel
;
ComponentType
cType
;
};
//! Indicates if this Axis only supports Absoulte (ie JoyStick)
bool
absOnly
;
//! Button can be a keyboard key, mouse button, etc
class
_OISExport
Button
:
public
Component
//! Used internally by OIS
{
void
clear
()
public:
{
Button
()
:
Component
(
OIS_Button
),
pushed
(
false
)
{}
abs
=
rel
=
0
;
explicit
Button
(
bool
bPushed
)
:
Component
(
OIS_Button
),
pushed
(
bPushed
)
{}
}
//! true if pushed, false otherwise
};
bool
pushed
;
};
//! A 3D Vector component (perhaps an orientation, as in the WiiMote)
class
_OISExport
Vector3
:
public
Component
//! Axis component
{
class
_OISExport
Axis
:
public
Component
public:
{
Vector3
()
{}
public:
Vector3
(
float
_x
,
float
_y
,
float
_z
)
:
Component
(
OIS_Vector3
),
x
(
_x
),
y
(
_y
),
z
(
_z
)
{};
Axis
()
:
Component
(
OIS_Axis
),
abs
(
0
),
rel
(
0
),
absOnly
(
false
)
{};
//! X component of vector
//! Absoulte and Relative value components
float
x
;
int
abs
,
rel
;
//! Y component of vector
//! Indicates if this Axis only supports Absoulte (ie JoyStick)
float
y
;
bool
absOnly
;
//! Z component of vector
//! Used internally by OIS
float
z
;
void
clear
()
{
void
clear
()
abs
=
rel
=
0
;
{
}
x
=
y
=
z
=
0.0
f
;
};
}
};
//! A 3D Vector component (perhaps an orientation, as in the WiiMote)
}
class
_OISExport
Vector3
:
public
Component
{
#endif //end if prereq header defined
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
The zlib/libpng License
Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
This software is provided 'as-is', without any express or implied warranty. In no event will
This software is provided 'as-is', without any express or implied warranty. In no event will
the authors be held liable for any damages arising from the use of this software.
the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose, including commercial
Permission is granted to anyone to use this software for any purpose, including commercial
applications, and to alter it and redistribute it freely, subject to the following
applications, and to alter it and redistribute it freely, subject to the following
restrictions:
restrictions:
1. The origin of this software must not be misrepresented; you must not claim that
1. The origin of this software must not be misrepresented; you must not claim that
you wrote the original software. If you use this software in a product,
you wrote the original software. If you use this software in a product,
an acknowledgment in the product documentation would be appreciated but is
an acknowledgment in the product documentation would be appreciated but is
not required.
not required.
2. Altered source versions must be plainly marked as such, and must not be
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
3. This notice may not be removed or altered from any source distribution.
*/
*/
#ifndef OIS_SDLInputManager_H
#ifndef OIS_SDLInputManager_H
#define OIS_SDLInputManager_H
#define OIS_SDLInputManager_H
#include "OISInputManager.h"
#include "OISInputManager.h"
#include "SDL/SDLPrereqs.h"
#include "SDL/SDLPrereqs.h"
namespace
OIS
namespace
OIS
{
{
/**
/**
SDL Input Manager wrapper
SDL Input Manager wrapper
*/
*/
class
SDLInputManager
:
public
InputManager
class
SDLInputManager
:
public
InputManager
{
{
public:
public:
SDLInputManager
();
SDLInputManager
();
virtual
~
SDLInputManager
();
virtual
~
SDLInputManager
();
/** @copydoc InputManager::inputSystemName */
/** @copydoc InputManager::inputSystemName */
virtual
const
std
::
string
&
inputSystemName
()
{
return
iName
;
}
virtual
const
std
::
string
&
inputSystemName
()
{
return
iName
;
}
/** @copydoc InputManager::numJoysticks */
/** @copydoc InputManager::numJoysticks */
virtual
int
numJoySticks
();
virtual
int
numJoySticks
();
/** @copydoc InputManager::numMice */
/** @copydoc InputManager::numMice */
virtual
int
numMice
();
virtual
int
numMice
();
/** @copydoc InputManager::numKeyBoards */
/** @copydoc InputManager::numKeyBoards */
virtual
int
numKeyboards
();
virtual
int
numKeyboards
();
/** @copydoc InputManager::createInputObject */
/** @copydoc InputManager::createInputObject */
Object
*
createInputObject
(
Type
iType
,
bool
bufferMode
);
Object
*
createInputObject
(
Type
iType
,
bool
bufferMode
);
/** @copydoc InputManager::destroyInputObject */
/** @copydoc InputManager::destroyInputObject */
void
destroyInputObject
(
Object
*
obj
);
void
destroyInputObject
(
Object
*
obj
);
/** @copydoc InputManager::_initialize */
/** @copydoc InputManager::_initialize */
void
_initialize
(
ParamList
&
paramList
);
void
_initialize
(
ParamList
&
paramList
);
//Utility methods to coordinate between mouse and keyboard grabbing
//Utility methods to coordinate between mouse and keyboard grabbing
bool
_getGrabMode
()
{
return
mGrabbed
;};
bool
_getGrabMode
()
{
return
mGrabbed
;};
void
_setGrabMode
(
bool
grabbed
)
{
mGrabbed
=
grabbed
;}
void
_setGrabMode
(
bool
grabbed
)
{
mGrabbed
=
grabbed
;}
protected:
protected:
//! internal class method for dealing with param list
//! internal class method for dealing with param list
void
_parseConfigSettings
(
ParamList
&
paramList
);
void
_parseConfigSettings
(
ParamList
&
paramList
);
//! internal class method for finding attached devices
//! internal class method for finding attached devices
void
_enumerateDevices
();
void
_enumerateDevices
();
static
const
std
::
string
iName
;
static
const
std
::
string
iName
;
bool
mGrabbed
;
bool
mGrabbed
;
};
};
}
}
#endif
#endif
includes/SDL/SDLKeyboard.h
View file @
24236447
/*
/*
The zlib/libpng License
The zlib/libpng License
Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
This software is provided 'as-is', without any express or implied warranty. In no event will
This software is provided 'as-is', without any express or implied warranty. In no event will
the authors be held liable for any damages arising from the use of this software.
the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose, including commercial
Permission is granted to anyone to use this software for any purpose, including commercial
applications, and to alter it and redistribute it freely, subject to the following
applications, and to alter it and redistribute it freely, subject to the following
restrictions:
restrictions:
1. The origin of this software must not be misrepresented; you must not claim that
1. The origin of this software must not be misrepresented; you must not claim that
you wrote the original software. If you use this software in a product,
you wrote the original software. If you use this software in a product,
an acknowledgment in the product documentation would be appreciated but is
an acknowledgment in the product documentation would be appreciated but is
not required.
not required.
2. Altered source versions must be plainly marked as such, and must not be
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
3. This notice may not be removed or altered from any source distribution.
*/
*/
#ifndef _OIS_SDLKEYBOARD_H
#ifndef _OIS_SDLKEYBOARD_H
#define _OIS_SDLKEYBOARD_H
#define _OIS_SDLKEYBOARD_H
#include "OISKeyboard.h"
#include "OISKeyboard.h"
#include "SDL/SDLPrereqs.h"
#include "SDL/SDLPrereqs.h"
namespace
OIS
namespace
OIS
{
{
class
SDLKeyboard
:
public
Keyboard
class
SDLKeyboard
:
public
Keyboard
{
{
public:
public:
/**
/**
@remarks
@remarks
Constructor
Constructor
@param buffered
@param buffered
True for buffered input mode
True for buffered input mode
*/
*/
SDLKeyboard
(
bool
buffered
);
SDLKeyboard
(
bool
buffered
);
virtual
~
SDLKeyboard
();
virtual
~
SDLKeyboard
();
/** @copydoc Keyboard::isKeyDown */
/** @copydoc Keyboard::isKeyDown */
virtual
bool
isKeyDown
(
KeyCode
key
);
virtual
bool
isKeyDown
(
KeyCode
key
);
/** @copydoc Keyboard::getAsString */
/** @copydoc Keyboard::getAsString */
virtual
const
std
::
string
&
getAsString
(
KeyCode
kc
);
virtual
const
std
::
string
&
getAsString
(
KeyCode
kc
);
/** @copydoc Keyboard::copyKeyStates */
/** @copydoc Keyboard::copyKeyStates */
virtual
void
copyKeyStates
(
char
keys
[
256
]
);
virtual
void
copyKeyStates
(
char
keys
[
256
]
);
/** @copydoc Object::setBuffered */
/** @copydoc Object::setBuffered */
virtual
void
setBuffered
(
bool
buffered
);
virtual
void
setBuffered
(
bool
buffered
);
/** @copydoc Object::capture */
/** @copydoc Object::capture */
virtual
void
capture
();
virtual
void
capture
();
/** @copydoc Object::queryInterface */
/** @copydoc Object::queryInterface */
virtual
Interface
*
queryInterface
(
Interface
::
IType
type
)
{
return
0
;}
virtual
Interface
*
queryInterface
(
Interface
::
IType
type
)
{
return
0
;}
/** @copydoc Object::_initialize */
/** @copydoc Object::_initialize */
virtual
void
_initialize
();
virtual
void
_initialize
();
/** @copydoc Object::setTextTranslation */
/** @copydoc Object::setTextTranslation */
virtual
void
setTextTranslation
(
TextTranslationMode
mode
);
virtual
void
setTextTranslation
(
TextTranslationMode
mode
);
protected:
protected:
SDLKeyboard
()
{}
SDLKeyboard
()
{}
typedef
std
::
map
<
SDLKey
,
KeyCode
>
KeyMap
;
typedef
std
::
map
<
SDLKey
,
KeyCode
>
KeyMap
;
KeyMap
mKeyMap
;
KeyMap
mKeyMap
;
unsigned
char
KeyBuffer
[
256
];
unsigned
char
KeyBuffer
[
256
];
Uint8
*
mSDLBuff
;
Uint8
*
mSDLBuff
;
std
::
string
mGetString
;
std
::
string
mGetString
;
};
};
}
}
#endif
#endif
includes/SDL/SDLMouse.h
View file @
24236447
/*
/*
The zlib/libpng License
The zlib/libpng License
Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
This software is provided 'as-is', without any express or implied warranty. In no event will
This software is provided 'as-is', without any express or implied warranty. In no event will
the authors be held liable for any damages arising from the use of this software.
the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose, including commercial
Permission is granted to anyone to use this software for any purpose, including commercial
applications, and to alter it and redistribute it freely, subject to the following
applications, and to alter it and redistribute it freely, subject to the following
restrictions:
restrictions:
1. The origin of this software must not be misrepresented; you must not claim that
1. The origin of this software must not be misrepresented; you must not claim that
you wrote the original software. If you use this software in a product,
you wrote the original software. If you use this software in a product,
an acknowledgment in the product documentation would be appreciated but is
an acknowledgment in the product documentation would be appreciated but is
not required.
not required.
2. Altered source versions must be plainly marked as such, and must not be
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
3. This notice may not be removed or altered from any source distribution.
*/
*/
#ifndef _OIS_SDLMOUSE_H
#ifndef _OIS_SDLMOUSE_H
#define _OIS_SDLMOUSE_H
#define _OIS_SDLMOUSE_H
#include "OISMouse.h"
#include "OISMouse.h"
#include "SDL/SDLPrereqs.h"
#include "SDL/SDLPrereqs.h"
namespace
OIS
namespace
OIS
{
{
class
SDLMouse
:
public
Mouse
class
SDLMouse
:
public
Mouse
{
{
public:
public:
SDLMouse
(
bool
buffered
);
SDLMouse
(
bool
buffered
);
virtual
~
SDLMouse
();
virtual
~
SDLMouse
();
/** @copydoc Object::setBuffered */
/** @copydoc Object::setBuffered */
virtual
void
setBuffered
(
bool
buffered
);
virtual
void
setBuffered
(
bool
buffered
);
/** @copydoc Object::capture */
/** @copydoc Object::capture */
virtual
void
capture
();
virtual
void
capture
();
/** @copydoc Object::queryInterface */
/** @copydoc Object::queryInterface */
virtual
Interface
*
queryInterface
(
Interface
::
IType
type
)
{
return
0
;}
virtual
Interface
*
queryInterface
(
Interface
::
IType
type
)
{
return
0
;}
/** @copydoc Object::_initialize */
/** @copydoc Object::_initialize */
virtual
void
_initialize
();
virtual
void
_initialize
();
void
_setGrab
(
bool
grabbed
);
void
_setGrab
(
bool
grabbed
);
void
_setVisible
(
bool
visible
);
void
_setVisible
(
bool
visible
);
protected:
protected:
SDLMouse
()
{}
SDLMouse
()
{}
bool
mGrabbed
;
bool
mGrabbed
;
bool
mRegainFocus
;
bool
mRegainFocus
;
};
};
}
}
#endif
#endif
includes/SDL/SDLPrereqs.h
View file @
24236447
/*
/*
The zlib/libpng License
The zlib/libpng License
Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
This software is provided 'as-is', without any express or implied warranty. In no event will
This software is provided 'as-is', without any express or implied warranty. In no event will
the authors be held liable for any damages arising from the use of this software.
the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose, including commercial
Permission is granted to anyone to use this software for any purpose, including commercial
applications, and to alter it and redistribute it freely, subject to the following
applications, and to alter it and redistribute it freely, subject to the following
restrictions:
restrictions:
1. The origin of this software must not be misrepresented; you must not claim that
1. The origin of this software must not be misrepresented; you must not claim that
you wrote the original software. If you use this software in a product,
you wrote the original software. If you use this software in a product,
an acknowledgment in the product documentation would be appreciated but is
an acknowledgment in the product documentation would be appreciated but is
not required.
not required.
2. Altered source versions must be plainly marked as such, and must not be
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
3. This notice may not be removed or altered from any source distribution.
*/
*/
#ifndef OIS_SDLPrereqs_H
#ifndef OIS_SDLPrereqs_H
#define OIS_SDLPrereqs_H
#define OIS_SDLPrereqs_H
#include "OISPrereqs.h"
#include "OISPrereqs.h"
#ifdef OIS_APPLE_PLATFORM
#ifdef OIS_APPLE_PLATFORM
# include <SDL/SDL.h>
# include <SDL/SDL.h>
#else
#else
# include <SDL.h>
# include <SDL.h>
#endif
#endif
#define OIS_SDL_KEY_BUFF 16
#define OIS_SDL_KEY_BUFF 16
#define OIS_SDL_MOUSE_BUFF 50
#define OIS_SDL_MOUSE_BUFF 50
#define OIS_SDL_JOY_BUFF 80
#define OIS_SDL_JOY_BUFF 80
#endif
#endif
includes/iphone/iPhoneAccelerometer.h
View file @
24236447
#ifndef OIS_iPhoneAccelerometer_H
#ifndef OIS_iPhoneAccelerometer_H
#define OIS_iPhoneAccelerometer_H
#define OIS_iPhoneAccelerometer_H
#include "OISJoystick.h"
#include "OISJoystick.h"
#include "iphone/iPhonePrereqs.h"
#include "iphone/iPhonePrereqs.h"
#import <UIKit/UIKit.h>
#import <UIKit/UIKit.h>
@
class
iPhoneAccelerometerDelegate
;
@
class
iPhoneAccelerometerDelegate
;
class
JoyStickState
;
class
JoyStickState
;
namespace
OIS
namespace
OIS
{
{
class
iPhoneAccelerometer
:
public
JoyStick
class
iPhoneAccelerometer
:
public
JoyStick
{
{
public:
public:
iPhoneAccelerometer
(
InputManager
*
creator
,
bool
buffered
);
iPhoneAccelerometer
(
InputManager
*
creator
,
bool
buffered
);
virtual
~
iPhoneAccelerometer
();
virtual
~
iPhoneAccelerometer
();
/** @copydoc Object::setBuffered */
/** @copydoc Object::setBuffered */
virtual
void
setBuffered
(
bool
buffered
);
virtual
void
setBuffered
(
bool
buffered
);
void
setUpdateInterval
(
float
interval
)
{
void
setUpdateInterval
(
float
interval
)
{
mUpdateInterval
=
interval
;
mUpdateInterval
=
interval
;
[[
UIAccelerometer
sharedAccelerometer
]
setUpdateInterval
:
(
1.0
f
/
mUpdateInterval
)];
[[
UIAccelerometer
sharedAccelerometer
]
setUpdateInterval
:
(
1.0
f
/
mUpdateInterval
)];
}
}
Vector3
getAccelerometerVector3
(
void
)
{
return
mState
.
mVectors
[
0
];
}
Vector3
getAccelerometerVector3
(
void
)
{
return
mState
.
mVectors
[
0
];
}
/** @copydoc Object::capture */
/** @copydoc Object::capture */
virtual
void
capture
();
virtual
void
capture
();
/** @copydoc Object::queryInterface */
/** @copydoc Object::queryInterface */
virtual
Interface
*
queryInterface
(
Interface
::
IType
type
)
{
return
0
;}
virtual
Interface
*
queryInterface
(
Interface
::
IType
type
)
{
return
0
;}
/** @copydoc Object::_initialize */
/** @copydoc Object::_initialize */
virtual
void
_initialize
();
virtual
void
_initialize
();
void
didAccelerate
(
UIAcceleration
*
acceleration
);
void
didAccelerate
(
UIAcceleration
*
acceleration
);
protected:
protected:
iPhoneAccelerometerDelegate
*
accelerometerDelegate
;
iPhoneAccelerometerDelegate
*
accelerometerDelegate
;
/** The update frequency of the accelerometer. Represented in times per second. */
/** The update frequency of the accelerometer. Represented in times per second. */
float
mUpdateInterval
;
float
mUpdateInterval
;
Vector3
mTempState
;
Vector3
mTempState
;
};
};
}
}
#endif // OIS_iPhoneAccelerometer_H
#endif // OIS_iPhoneAccelerometer_H
includes/iphone/iPhoneHelpers.h
View file @
24236447
/*
/*
The zlib/libpng License
The zlib/libpng License
Copyright (c) 2006 Chris Snyder
Copyright (c) 2006 Chris Snyder
This software is provided 'as-is', without any express or implied warranty. In no event will
This software is provided 'as-is', without any express or implied warranty. In no event will
the authors be held liable for any damages arising from the use of this software.
the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose, including commercial
Permission is granted to anyone to use this software for any purpose, including commercial
applications, and to alter it and redistribute it freely, subject to the following
applications, and to alter it and redistribute it freely, subject to the following
restrictions:
restrictions:
1. The origin of this software must not be misrepresented; you must not claim that
1. The origin of this software must not be misrepresented; you must not claim that
you wrote the original software. If you use this software in a product,
you wrote the original software. If you use this software in a product,
an acknowledgment in the product documentation would be appreciated but is
an acknowledgment in the product documentation would be appreciated but is
not required.
not required.
2. Altered source versions must be plainly marked as such, and must not be
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
3. This notice may not be removed or altered from any source distribution.
*/
*/
#ifndef OIS_iPhoneHelpers_H
#ifndef OIS_iPhoneHelpers_H
#define OIS_iPhoneHelpers_H
#define OIS_iPhoneHelpers_H
#include "iphone/iPhonePrereqs.h"
#include "iphone/iPhonePrereqs.h"
#include "OISMultiTouch.h"
#include "OISMultiTouch.h"
// This is needed for keeping an event stack for keyboard and mouse
// This is needed for keeping an event stack for keyboard and mouse
namespace
OIS
namespace
OIS
{
{
// used in the eventStack to store the type
// used in the eventStack to store the type
enum
iPhone_EventType
{
iPhone_KEYUP
=
0
,
enum
iPhone_EventType
{
iPhone_KEYUP
=
0
,
iPhone_KEYDOWN
=
1
,
iPhone_KEYDOWN
=
1
,
iPhone_KEYREPEAT
,
iPhone_KEYREPEAT
,
iPhone_MOUSEDOWN
,
iPhone_MOUSEDOWN
,
iPhone_MOUSEUP
,
iPhone_MOUSEUP
,
iPhone_MOUSEMOVED
,
iPhone_MOUSEMOVED
,
iPhone_MOUSESCROLL
};
iPhone_MOUSESCROLL
};
typedef
enum
iPhone_EventType
iPhoneEventType
;
typedef
enum
iPhone_EventType
iPhoneEventType
;
// only used by iPhoneMultiTouch
// only used by iPhoneMultiTouch
typedef
class
iPhoneMultiTouchStackEvent
typedef
class
iPhoneMultiTouchStackEvent
{
{
friend
class
iPhoneMultiTouch
;
friend
class
iPhoneMultiTouch
;
private:
private:
iPhoneMultiTouchStackEvent
(
MultiTouchEvent
event
,
iPhoneEventType
type
)
:
Event
(
event
),
Type
(
type
)
{}
iPhoneMultiTouchStackEvent
(
MultiTouchEvent
event
,
iPhoneEventType
type
)
:
Event
(
event
),
Type
(
type
)
{}
iPhoneEventType
Type
;
iPhoneEventType
Type
;
MultiTouchEvent
Event
;
MultiTouchEvent
Event
;
}
iPhoneMultiTouchStackEvent
;
}
iPhoneMultiTouchStackEvent
;
}
}
#endif
#endif
includes/iphone/iPhoneInputManager.h
View file @
24236447
/*
/*
The zlib/libpng License
The zlib/libpng License
Copyright (c) 2006 Chris Snyder
Copyright (c) 2006 Chris Snyder
This software is provided 'as-is', without any express or implied warranty. In no event will
This software is provided 'as-is', without any express or implied warranty. In no event will
the authors be held liable for any damages arising from the use of this software.
the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose, including commercial
Permission is granted to anyone to use this software for any purpose, including commercial
applications, and to alter it and redistribute it freely, subject to the following
applications, and to alter it and redistribute it freely, subject to the following
restrictions:
restrictions:
1. The origin of this software must not be misrepresented; you must not claim that
1. The origin of this software must not be misrepresented; you must not claim that
you wrote the original software. If you use this software in a product,
you wrote the original software. If you use this software in a product,
an acknowledgment in the product documentation would be appreciated but is
an acknowledgment in the product documentation would be appreciated but is
not required.
not required.
2. Altered source versions must be plainly marked as such, and must not be
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
3. This notice may not be removed or altered from any source distribution.
*/
*/
#ifndef OIS_iPhoneInputManager_H
#ifndef OIS_iPhoneInputManager_H
#define OIS_iPhoneInputManager_H
#define OIS_iPhoneInputManager_H
#include "OISInputManager.h"
#include "OISInputManager.h"
#include "OISFactoryCreator.h"
#include "OISFactoryCreator.h"
#include "iphone/iPhonePrereqs.h"
#include "iphone/iPhonePrereqs.h"
#import <UIKit/UIKit.h>
#import <UIKit/UIKit.h>
namespace
OIS
{
namespace
OIS
{
class
iPhoneAccelerometer
;
class
iPhoneAccelerometer
;
class
iPhoneMultiTouch
;
class
iPhoneMultiTouch
;
}
}
@interface
InputDelegate
:
UIView
<
UIAccelerometerDelegate
>
{
@interface
InputDelegate
:
UIView
<
UIAccelerometerDelegate
>
{
OIS
::
iPhoneAccelerometer
*
accelerometerObject
;
OIS
::
iPhoneAccelerometer
*
accelerometerObject
;
OIS
::
iPhoneMultiTouch
*
touchObject
;
OIS
::
iPhoneMultiTouch
*
touchObject
;
}
}
@property
(
assign
)
OIS
::
iPhoneAccelerometer
*
accelerometerObject
;
@property
(
assign
)
OIS
::
iPhoneAccelerometer
*
accelerometerObject
;
@property
(
assign
)
OIS
::
iPhoneMultiTouch
*
touchObject
;
@property
(
assign
)
OIS
::
iPhoneMultiTouch
*
touchObject
;
@end
@end
namespace
OIS
namespace
OIS
{
{
class
iPhoneInputManager
:
public
InputManager
,
public
FactoryCreator
class
iPhoneInputManager
:
public
InputManager
,
public
FactoryCreator
{
{
public:
public:
iPhoneInputManager
();
iPhoneInputManager
();
virtual
~
iPhoneInputManager
();
virtual
~
iPhoneInputManager
();
//InputManager Overrides
//InputManager Overrides
/** @copydoc InputManager::_initialize */
/** @copydoc InputManager::_initialize */
void
_initialize
(
ParamList
&
paramList
);
void
_initialize
(
ParamList
&
paramList
);
//FactoryCreator Overrides
//FactoryCreator Overrides
/** @copydoc FactoryCreator::deviceList */
/** @copydoc FactoryCreator::deviceList */
DeviceList
freeDeviceList
();
DeviceList
freeDeviceList
();
/** @copydoc FactoryCreator::totalDevices */
/** @copydoc FactoryCreator::totalDevices */
int
totalDevices
(
Type
iType
);
int
totalDevices
(
Type
iType
);
/** @copydoc FactoryCreator::freeDevices */
/** @copydoc FactoryCreator::freeDevices */
int
freeDevices
(
Type
iType
);
int
freeDevices
(
Type
iType
);
/** @copydoc FactoryCreator::vendorExist */
/** @copydoc FactoryCreator::vendorExist */
bool
vendorExist
(
Type
iType
,
const
std
::
string
&
vendor
);
bool
vendorExist
(
Type
iType
,
const
std
::
string
&
vendor
);
/** @copydoc FactoryCreator::createObject */
/** @copydoc FactoryCreator::createObject */
Object
*
createObject
(
InputManager
*
creator
,
Type
iType
,
bool
bufferMode
,
const
std
::
string
&
vendor
=
""
);
Object
*
createObject
(
InputManager
*
creator
,
Type
iType
,
bool
bufferMode
,
const
std
::
string
&
vendor
=
""
);
/** @copydoc FactoryCreator::destroyObject */
/** @copydoc FactoryCreator::destroyObject */
void
destroyObject
(
Object
*
obj
);
void
destroyObject
(
Object
*
obj
);
//Internal Items
//Internal Items
//! Internal method, used for flagging multi-touch as available/unavailable for creation
//! Internal method, used for flagging multi-touch as available/unavailable for creation
void
_setMultiTouchUsed
(
bool
used
)
{
bMultiTouchUsed
=
used
;
}
void
_setMultiTouchUsed
(
bool
used
)
{
bMultiTouchUsed
=
used
;
}
//! Internal method, used for flagging accelerometer as available/unavailable for creation
//! Internal method, used for flagging accelerometer as available/unavailable for creation
void
_setAccelerometerUsed
(
bool
used
)
{
bAccelerometerUsed
=
used
;
}
void
_setAccelerometerUsed
(
bool
used
)
{
bAccelerometerUsed
=
used
;
}
//! methodfor getting the delegate
//! methodfor getting the delegate
InputDelegate
*
_getDelegate
()
{
return
mDelegate
;
}
InputDelegate
*
_getDelegate
()
{
return
mDelegate
;
}
//! method for getting window
//! method for getting window
UIWindow
*
_getWindow
()
{
return
mWindow
;
}
UIWindow
*
_getWindow
()
{
return
mWindow
;
}
protected:
protected:
void
_parseConfigSettings
(
ParamList
&
paramList
);
void
_parseConfigSettings
(
ParamList
&
paramList
);
// iPhone stuff
// iPhone stuff
UIWindow
*
mWindow
;
UIWindow
*
mWindow
;
InputDelegate
*
mDelegate
;
InputDelegate
*
mDelegate
;
// settings
// settings
bool
mHideMouse
;
bool
mHideMouse
;
//! Used to know if we used up multi-touch device
//! Used to know if we used up multi-touch device
bool
bMultiTouchUsed
;
bool
bMultiTouchUsed
;
//! Used to know if we used up accelerometer
//! Used to know if we used up accelerometer
bool
bAccelerometerUsed
;
bool
bAccelerometerUsed
;
};
};
}
}
#endif
#endif
includes/iphone/iPhoneMultiTouch.h
View file @
24236447
/*
/*
The zlib/libpng License
The zlib/libpng License
Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
This software is provided 'as-is', without any express or implied warranty. In no event will
This software is provided 'as-is', without any express or implied warranty. In no event will
the authors be held liable for any damages arising from the use of this software.
the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose, including commercial
Permission is granted to anyone to use this software for any purpose, including commercial
applications, and to alter it and redistribute it freely, subject to the following
applications, and to alter it and redistribute it freely, subject to the following
restrictions:
restrictions:
1. The origin of this software must not be misrepresented; you must not claim that
1. The origin of this software must not be misrepresented; you must not claim that
you wrote the original software. If you use this software in a product,
you wrote the original software. If you use this software in a product,
an acknowledgment in the product documentation would be appreciated but is
an acknowledgment in the product documentation would be appreciated but is
not required.
not required.
2. Altered source versions must be plainly marked as such, and must not be
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
3. This notice may not be removed or altered from any source distribution.
*/
*/
#ifndef OIS_iPhoneMultiTouch_H
#ifndef OIS_iPhoneMultiTouch_H
#define OIS_iPhoneMultiTouch_H
#define OIS_iPhoneMultiTouch_H
#include "OISMultiTouch.h"
#include "OISMultiTouch.h"
#include "iphone/iPhonePrereqs.h"
#include "iphone/iPhonePrereqs.h"
#import <UIKit/UIKit.h>
#import <UIKit/UIKit.h>
struct
CGPoint
;
struct
CGPoint
;
namespace
OIS
namespace
OIS
{
{
class
iPhoneMultiTouch
:
public
MultiTouch
class
iPhoneMultiTouch
:
public
MultiTouch
{
{
public:
public:
iPhoneMultiTouch
(
InputManager
*
creator
,
bool
buffered
);
iPhoneMultiTouch
(
InputManager
*
creator
,
bool
buffered
);
virtual
~
iPhoneMultiTouch
();
virtual
~
iPhoneMultiTouch
();
/** @copydoc Object::setBuffered */
/** @copydoc Object::setBuffered */
virtual
void
setBuffered
(
bool
buffered
);
virtual
void
setBuffered
(
bool
buffered
);
/** @copydoc Object::capture */
/** @copydoc Object::capture */
virtual
void
capture
();
virtual
void
capture
();
/** @copydoc Object::queryInterface */
/** @copydoc Object::queryInterface */
virtual
Interface
*
queryInterface
(
Interface
::
IType
type
)
{
return
0
;}
virtual
Interface
*
queryInterface
(
Interface
::
IType
type
)
{
return
0
;}
/** @copydoc Object::_initialize */
/** @copydoc Object::_initialize */
virtual
void
_initialize
();
virtual
void
_initialize
();
void
_touchBegan
(
UITouch
*
touch
);
void
_touchBegan
(
UITouch
*
touch
);
void
_touchEnded
(
UITouch
*
touch
);
void
_touchEnded
(
UITouch
*
touch
);
void
_touchMoved
(
UITouch
*
touch
);
void
_touchMoved
(
UITouch
*
touch
);
void
_touchCancelled
(
UITouch
*
touch
);
void
_touchCancelled
(
UITouch
*
touch
);
protected:
protected:
MultiTouchState
mTempState
;
MultiTouchState
mTempState
;
};
};
}
}
#endif // OIS_iPhoneTouch_H
#endif // OIS_iPhoneTouch_H
includes/iphone/iPhonePrereqs.h
View file @
24236447
/*
/*
The zlib/libpng License
The zlib/libpng License
Copyright (c) 2006 Chris Snyder
Copyright (c) 2006 Chris Snyder
This software is provided 'as-is', without any express or implied warranty. In no event will
This software is provided 'as-is', without any express or implied warranty. In no event will
the authors be held liable for any damages arising from the use of this software.
the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose, including commercial
Permission is granted to anyone to use this software for any purpose, including commercial
applications, and to alter it and redistribute it freely, subject to the following
applications, and to alter it and redistribute it freely, subject to the following
restrictions:
restrictions:
1. The origin of this software must not be misrepresented; you must not claim that
1. The origin of this software must not be misrepresented; you must not claim that
you wrote the original software. If you use this software in a product,
you wrote the original software. If you use this software in a product,
an acknowledgment in the product documentation would be appreciated but is
an acknowledgment in the product documentation would be appreciated but is
not required.
not required.
2. Altered source versions must be plainly marked as such, and must not be
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
3. This notice may not be removed or altered from any source distribution.
*/
*/
#ifndef OIS_iPhonePrereqs_H
#ifndef OIS_iPhonePrereqs_H
#define OIS_iPhonePrereqs_H
#define OIS_iPhonePrereqs_H
#include <string>
#include <string>
#include <list>
#include <list>
#include <CoreFoundation/CoreFoundation.h>
#include <CoreFoundation/CoreFoundation.h>
namespace
OIS
namespace
OIS
{
{
class
iPhoneInputManager
;
class
iPhoneInputManager
;
class
iPhoneAccelerometer
;
class
iPhoneAccelerometer
;
class
iPhoneMouse
;
class
iPhoneMouse
;
/**
/**
Simple wrapper class for CFString which will create a valid CFString and retain ownership until class instance is outof scope
Simple wrapper class for CFString which will create a valid CFString and retain ownership until class instance is outof scope
To Access the CFStringRef instance, simply cast to void*, pass into a function expecting a void* CFStringRef object, or access via cf_str() method
To Access the CFStringRef instance, simply cast to void*, pass into a function expecting a void* CFStringRef object, or access via cf_str() method
*/
*/
class
OIS_CFString
class
OIS_CFString
{
{
public:
public:
OIS_CFString
()
{
m_StringRef
=
CFStringCreateWithCString
(
NULL
,
""
,
kCFStringEncodingUTF8
);
}
OIS_CFString
()
{
m_StringRef
=
CFStringCreateWithCString
(
NULL
,
""
,
kCFStringEncodingUTF8
);
}
OIS_CFString
(
const
char
*
c_str
)
{
m_StringRef
=
CFStringCreateWithCString
(
NULL
,
c_str
,
kCFStringEncodingUTF8
);
}
OIS_CFString
(
const
char
*
c_str
)
{
m_StringRef
=
CFStringCreateWithCString
(
NULL
,
c_str
,
kCFStringEncodingUTF8
);
}
OIS_CFString
(
const
std
::
string
&
s_str
)
{
m_StringRef
=
CFStringCreateWithCString
(
NULL
,
s_str
.
c_str
(),
kCFStringEncodingUTF8
);
}
OIS_CFString
(
const
std
::
string
&
s_str
)
{
m_StringRef
=
CFStringCreateWithCString
(
NULL
,
s_str
.
c_str
(),
kCFStringEncodingUTF8
);
}
~
OIS_CFString
()
{
CFRelease
(
m_StringRef
);
}
~
OIS_CFString
()
{
CFRelease
(
m_StringRef
);
}
//Allow this class to be autoconverted to base class of StringRef (void*)
//Allow this class to be autoconverted to base class of StringRef (void*)
operator
void
*
()
{
return
(
void
*
)
m_StringRef
;
}
operator
void
*
()
{
return
(
void
*
)
m_StringRef
;
}
CFStringRef
cf_str
()
{
return
m_StringRef
;
}
CFStringRef
cf_str
()
{
return
m_StringRef
;
}
private:
private:
CFStringRef
m_StringRef
;
CFStringRef
m_StringRef
;
};
};
}
}
#endif
#endif
includes/linux/EventHelpers.h
View file @
24236447
/*
/*
The zlib/libpng License
The zlib/libpng License
Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
This software is provided 'as-is', without any express or implied warranty. In no event will
This software is provided 'as-is', without any express or implied warranty. In no event will
the authors be held liable for any damages arising from the use of this software.
the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose, including commercial
Permission is granted to anyone to use this software for any purpose, including commercial
applications, and to alter it and redistribute it freely, subject to the following
applications, and to alter it and redistribute it freely, subject to the following
restrictions:
restrictions:
1. The origin of this software must not be misrepresented; you must not claim that
1. The origin of this software must not be misrepresented; you must not claim that
you wrote the original software. If you use this software in a product,
you wrote the original software. If you use this software in a product,
an acknowledgment in the product documentation would be appreciated but is
an acknowledgment in the product documentation would be appreciated but is
not required.
not required.
2. Altered source versions must be plainly marked as such, and must not be
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
3. This notice may not be removed or altered from any source distribution.
*/
*/
#ifndef _LINUX_OISEVENT_HEADER_
#ifndef _LINUX_OISEVENT_HEADER_
#define _LINUX_OISEVENT_HEADER_
#define _LINUX_OISEVENT_HEADER_
#include "linux/LinuxPrereqs.h"
#include "linux/LinuxPrereqs.h"
#define OIS_MAX_DEVICES 32
#define OIS_MAX_DEVICES 32
#define OIS_DEVICE_NAME 128
#define OIS_DEVICE_NAME 128
namespace
OIS
namespace
OIS
{
{
class
EventUtils
class
EventUtils
{
{
public:
public:
static
bool
isJoyStick
(
int
deviceID
,
JoyStickInfo
&
js
);
static
bool
isJoyStick
(
int
deviceID
,
JoyStickInfo
&
js
);
static
bool
isMouse
(
int
)
{
return
false
;}
static
bool
isMouse
(
int
)
{
return
false
;}
static
bool
isKeyboard
(
int
)
{
return
false
;}
static
bool
isKeyboard
(
int
)
{
return
false
;}
//Double pointer is so that we can set the value of the sent pointer
//Double pointer is so that we can set the value of the sent pointer
static
void
enumerateForceFeedback
(
int
deviceID
,
LinuxForceFeedback
**
ff
);
static
void
enumerateForceFeedback
(
int
deviceID
,
LinuxForceFeedback
**
ff
);
static
void
removeForceFeedback
(
LinuxForceFeedback
**
ff
);
static
void
removeForceFeedback
(
LinuxForceFeedback
**
ff
);
static
std
::
string
getName
(
int
deviceID
);
static
std
::
string
getName
(
int
deviceID
);
static
std
::
string
getUniqueId
(
int
deviceID
);
static
std
::
string
getUniqueId
(
int
deviceID
);
static
std
::
string
getPhysicalLocation
(
int
deviceID
);
static
std
::
string
getPhysicalLocation
(
int
deviceID
);
};
};
}
}
#endif
#endif
includes/linux/LinuxForceFeedback.h
View file @
24236447
/*
/*
The zlib/libpng License
The zlib/libpng License
Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
This software is provided 'as-is', without any express or implied warranty. In no event will
This software is provided 'as-is', without any express or implied warranty. In no event will
the authors be held liable for any damages arising from the use of this software.
the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose, including commercial
Permission is granted to anyone to use this software for any purpose, including commercial
applications, and to alter it and redistribute it freely, subject to the following
applications, and to alter it and redistribute it freely, subject to the following
restrictions:
restrictions:
1. The origin of this software must not be misrepresented; you must not claim that
1. The origin of this software must not be misrepresented; you must not claim that
you wrote the original software. If you use this software in a product,
you wrote the original software. If you use this software in a product,
an acknowledgment in the product documentation would be appreciated but is
an acknowledgment in the product documentation would be appreciated but is
not required.
not required.
2. Altered source versions must be plainly marked as such, and must not be
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
3. This notice may not be removed or altered from any source distribution.
*/
*/
#ifndef OIS_LinuxForceFeedBack_H
#ifndef OIS_LinuxForceFeedBack_H
#define OIS_LinuxForceFeedBack_H
#define OIS_LinuxForceFeedBack_H
#include "linux/LinuxPrereqs.h"
#include "linux/LinuxPrereqs.h"
#include "OISForceFeedback.h"
#include "OISForceFeedback.h"
#include <linux/input.h>
#include <linux/input.h>
namespace
OIS
namespace
OIS
{
{
class
LinuxForceFeedback
:
public
ForceFeedback
class
LinuxForceFeedback
:
public
ForceFeedback
{
{
public:
public:
LinuxForceFeedback
(
int
deviceID
);
LinuxForceFeedback
(
int
deviceID
);
~
LinuxForceFeedback
();
~
LinuxForceFeedback
();
/** @copydoc ForceFeedback::setMasterGain */
/** @copydoc ForceFeedback::setMasterGain */
void
setMasterGain
(
float
);
void
setMasterGain
(
float
);
/** @copydoc ForceFeedback::setAutoCenterMode */
/** @copydoc ForceFeedback::setAutoCenterMode */
void
setAutoCenterMode
(
bool
);
void
setAutoCenterMode
(
bool
);
/** @copydoc ForceFeedback::upload */
/** @copydoc ForceFeedback::upload */
void
upload
(
const
Effect
*
effect
);
void
upload
(
const
Effect
*
effect
);
/** @copydoc ForceFeedback::modify */
/** @copydoc ForceFeedback::modify */
void
modify
(
const
Effect
*
effect
);
void
modify
(
const
Effect
*
effect
);
/** @copydoc ForceFeedback::remove */
/** @copydoc ForceFeedback::remove */
void
remove
(
const
Effect
*
effect
);
void
remove
(
const
Effect
*
effect
);
/** FF is not yet implemented fully on Linux.. just return -1 for now. todo, xxx */
/** FF is not yet implemented fully on Linux.. just return -1 for now. todo, xxx */
short
int
getFFAxesNumber
()
{
return
-
1
;
}
short
int
getFFAxesNumber
()
{
return
-
1
;
}
/** @copydoc ForceFeedback::getFFMemoryLoad */
/** @copydoc ForceFeedback::getFFMemoryLoad */
unsigned
short
getFFMemoryLoad
();
unsigned
short
getFFMemoryLoad
();
protected:
protected:
//Sets the common properties to all effects
//Sets the common properties to all effects
void
_setCommonProperties
(
struct
ff_effect
*
event
,
struct
ff_envelope
*
ffenvelope
,
void
_setCommonProperties
(
struct
ff_effect
*
event
,
struct
ff_envelope
*
ffenvelope
,
const
Effect
*
effect
,
const
Envelope
*
envelope
);
const
Effect
*
effect
,
const
Envelope
*
envelope
);
//Specific Effect Settings
//Specific Effect Settings
void
_updateConstantEffect
(
const
Effect
*
effect
);
void
_updateConstantEffect
(
const
Effect
*
effect
);
void
_updateRampEffect
(
const
Effect
*
effect
);
void
_updateRampEffect
(
const
Effect
*
effect
);
void
_updatePeriodicEffect
(
const
Effect
*
effect
);
void
_updatePeriodicEffect
(
const
Effect
*
effect
);
void
_updateConditionalEffect
(
const
Effect
*
effect
);
void
_updateConditionalEffect
(
const
Effect
*
effect
);
//void _updateCustomEffect( const Effect* effect );
//void _updateCustomEffect( const Effect* effect );
void
_upload
(
struct
ff_effect
*
ffeffect
,
const
Effect
*
effect
);
void
_upload
(
struct
ff_effect
*
ffeffect
,
const
Effect
*
effect
);
void
_stop
(
int
handle
);
void
_stop
(
int
handle
);
void
_start
(
int
handle
);
void
_start
(
int
handle
);
void
_unload
(
int
handle
);
void
_unload
(
int
handle
);
// Map of currently uploaded effects (handle => effect)
// Map of currently uploaded effects (handle => effect)
typedef
std
::
map
<
int
,
struct
ff_effect
*>
EffectList
;
typedef
std
::
map
<
int
,
struct
ff_effect
*>
EffectList
;
EffectList
mEffectList
;
EffectList
mEffectList
;
// Joystick device (file) descriptor.
// Joystick device (file) descriptor.
int
mJoyStick
;
int
mJoyStick
;
};
};
}
}
#endif //OIS_LinuxForceFeedBack_H
#endif //OIS_LinuxForceFeedBack_H
includes/linux/LinuxInputManager.h
View file @
24236447
/*
/*
The zlib/libpng License
The zlib/libpng License
Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
This software is provided 'as-is', without any express or implied warranty. In no event will
This software is provided 'as-is', without any express or implied warranty. In no event will
the authors be held liable for any damages arising from the use of this software.
the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose, including commercial
Permission is granted to anyone to use this software for any purpose, including commercial
applications, and to alter it and redistribute it freely, subject to the following
applications, and to alter it and redistribute it freely, subject to the following
restrictions:
restrictions:
1. The origin of this software must not be misrepresented; you must not claim that
1. The origin of this software must not be misrepresented; you must not claim that
you wrote the original software. If you use this software in a product,
you wrote the original software. If you use this software in a product,
an acknowledgment in the product documentation would be appreciated but is
an acknowledgment in the product documentation would be appreciated but is
not required.
not required.
2. Altered source versions must be plainly marked as such, and must not be
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
3. This notice may not be removed or altered from any source distribution.
*/
*/
#ifndef OIS_LinuxInputManager_H
#ifndef OIS_LinuxInputManager_H
#define OIS_LinuxInputManager_H
#define OIS_LinuxInputManager_H
#include "linux/LinuxPrereqs.h"
#include "linux/LinuxPrereqs.h"
#include "OISFactoryCreator.h"
#include "OISFactoryCreator.h"
#include "OISInputManager.h"
#include "OISInputManager.h"
#include <X11/Xlib.h>
#include <X11/Xlib.h>
namespace
OIS
namespace
OIS
{
{
/**
/**
Linux X11 InputManager specialization - Using lowlevel joys
Linux X11 InputManager specialization - Using lowlevel joys
*/
*/
class
LinuxInputManager
:
public
InputManager
,
public
FactoryCreator
class
LinuxInputManager
:
public
InputManager
,
public
FactoryCreator
{
{
public:
public:
LinuxInputManager
();
LinuxInputManager
();
virtual
~
LinuxInputManager
();
virtual
~
LinuxInputManager
();
//InputManager Overrides
//InputManager Overrides
/** @copydoc InputManager::_initialize */
/** @copydoc InputManager::_initialize */
void
_initialize
(
ParamList
&
paramList
);
void
_initialize
(
ParamList
&
paramList
);
//FactoryCreator Overrides
//FactoryCreator Overrides
/** @copydoc FactoryCreator::deviceList */
/** @copydoc FactoryCreator::deviceList */
DeviceList
freeDeviceList
();
DeviceList
freeDeviceList
();
/** @copydoc FactoryCreator::totalDevices */
/** @copydoc FactoryCreator::totalDevices */
int
totalDevices
(
Type
iType
);
int
totalDevices
(
Type
iType
);
/** @copydoc FactoryCreator::freeDevices */
/** @copydoc FactoryCreator::freeDevices */
int
freeDevices
(
Type
iType
);
int
freeDevices
(
Type
iType
);
/** @copydoc FactoryCreator::vendorExist */
/** @copydoc FactoryCreator::vendorExist */
bool
vendorExist
(
Type
iType
,
const
std
::
string
&
vendor
);
bool
vendorExist
(
Type
iType
,
const
std
::
string
&
vendor
);
/** @copydoc FactoryCreator::createObject */
/** @copydoc FactoryCreator::createObject */
Object
*
createObject
(
InputManager
*
creator
,
Type
iType
,
bool
bufferMode
,
const
std
::
string
&
vendor
=
""
);
Object
*
createObject
(
InputManager
*
creator
,
Type
iType
,
bool
bufferMode
,
const
std
::
string
&
vendor
=
""
);
/** @copydoc FactoryCreator::destroyObject */
/** @copydoc FactoryCreator::destroyObject */
void
destroyObject
(
Object
*
obj
);
void
destroyObject
(
Object
*
obj
);
//Internal Items
//Internal Items
//! Method for retrieving the XWindow Handle
//! Method for retrieving the XWindow Handle
Window
_getWindow
()
{
return
window
;}
Window
_getWindow
()
{
return
window
;}
//! Internal method for checking if regrabbing is needed
//! Internal method for checking if regrabbing is needed
void
_setGrabState
(
bool
grab
)
{
mGrabs
=
grab
;}
void
_setGrabState
(
bool
grab
)
{
mGrabs
=
grab
;}
bool
_getGrabState
()
{
return
mGrabs
;}
bool
_getGrabState
()
{
return
mGrabs
;}
//! Internal method, used for flaggin keyboard as available/unavailable for creation
//! Internal method, used for flaggin keyboard as available/unavailable for creation
void
_setKeyboardUsed
(
bool
used
)
{
keyboardUsed
=
used
;
}
void
_setKeyboardUsed
(
bool
used
)
{
keyboardUsed
=
used
;
}
//! Internal method, used for flaggin mouse as available/unavailable for creation
//! Internal method, used for flaggin mouse as available/unavailable for creation
void
_setMouseUsed
(
bool
used
)
{
mouseUsed
=
used
;
}
void
_setMouseUsed
(
bool
used
)
{
mouseUsed
=
used
;
}
protected:
protected:
//! internal class method for dealing with param list
//! internal class method for dealing with param list
void
_parseConfigSettings
(
ParamList
&
paramList
);
void
_parseConfigSettings
(
ParamList
&
paramList
);
//! internal class method for finding attached devices
//! internal class method for finding attached devices
void
_enumerateDevices
();
void
_enumerateDevices
();
//! List of unused joysticks ready to be used
//! List of unused joysticks ready to be used
JoyStickInfoList
unusedJoyStickList
;
JoyStickInfoList
unusedJoyStickList
;
//! Number of joysticks found
//! Number of joysticks found
char
joySticks
;
char
joySticks
;
//! Used to know if we used up keyboard
//! Used to know if we used up keyboard
bool
keyboardUsed
;
bool
keyboardUsed
;
//! Used to know if we used up mouse
//! Used to know if we used up mouse
bool
mouseUsed
;
bool
mouseUsed
;
//! X11 Stuff
//! X11 Stuff
Window
window
;
Window
window
;
/// Keyboard, Mouse Settings
/// Keyboard, Mouse Settings
bool
grabMouse
,
grabKeyboard
;
bool
grabMouse
,
grabKeyboard
;
bool
mGrabs
;
bool
mGrabs
;
bool
hideMouse
;
bool
hideMouse
;
};
};
}
}
#endif
#endif
includes/linux/LinuxJoyStickEvents.h
View file @
24236447
/*
/*
The zlib/libpng License
The zlib/libpng License
Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
This software is provided 'as-is', without any express or implied warranty. In no event will
This software is provided 'as-is', without any express or implied warranty. In no event will
the authors be held liable for any damages arising from the use of this software.
the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose, including commercial
Permission is granted to anyone to use this software for any purpose, including commercial
applications, and to alter it and redistribute it freely, subject to the following
applications, and to alter it and redistribute it freely, subject to the following
restrictions:
restrictions:
1. The origin of this software must not be misrepresented; you must not claim that
1. The origin of this software must not be misrepresented; you must not claim that
you wrote the original software. If you use this software in a product,
you wrote the original software. If you use this software in a product,
an acknowledgment in the product documentation would be appreciated but is
an acknowledgment in the product documentation would be appreciated but is
not required.
not required.
2. Altered source versions must be plainly marked as such, and must not be
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
3. This notice may not be removed or altered from any source distribution.
*/
*/
#ifndef _LINUX_JOYSTICK_H_EADER_
#ifndef _LINUX_JOYSTICK_H_EADER_
#define _LINUX_JOYSTICK_H_EADER_
#define _LINUX_JOYSTICK_H_EADER_
#include "linux/LinuxPrereqs.h"
#include "linux/LinuxPrereqs.h"
#include "OISJoyStick.h"
#include "OISJoyStick.h"
namespace
OIS
namespace
OIS
{
{
/**
/**
Linux specialization of JoyStick class.. This version is favored over the other.. and has the
Linux specialization of JoyStick class.. This version is favored over the other.. and has the
*possibility* of Force Feedback.. notice I say possibility, i make no gaurantees under linux,
*possibility* of Force Feedback.. notice I say possibility, i make no gaurantees under linux,
as FF support is sketchy at best AFAIK.
as FF support is sketchy at best AFAIK.
*/
*/
class
LinuxJoyStick
:
public
JoyStick
class
LinuxJoyStick
:
public
JoyStick
{
{
public:
public:
LinuxJoyStick
(
InputManager
*
creator
,
bool
buffered
,
const
JoyStickInfo
&
js
);
LinuxJoyStick
(
InputManager
*
creator
,
bool
buffered
,
const
JoyStickInfo
&
js
);
virtual
~
LinuxJoyStick
();
virtual
~
LinuxJoyStick
();
/** @copydoc Object::setBuffered */
/** @copydoc Object::setBuffered */
virtual
void
setBuffered
(
bool
buffered
);
virtual
void
setBuffered
(
bool
buffered
);
/** @copydoc Object::capture */
/** @copydoc Object::capture */
virtual
void
capture
();
virtual
void
capture
();
/** @copydoc Object::queryInterface */
/** @copydoc Object::queryInterface */
virtual
Interface
*
queryInterface
(
Interface
::
IType
type
);
virtual
Interface
*
queryInterface
(
Interface
::
IType
type
);
/** @copydoc Object::_initialize */
/** @copydoc Object::_initialize */
virtual
void
_initialize
();
virtual
void
_initialize
();
/**
/**
@remarks
@remarks
For internal use only... Returns a structure to the manager, to make the device
For internal use only... Returns a structure to the manager, to make the device
availiable for use again
availiable for use again
*/
*/
JoyStickInfo
_getJoyInfo
();
JoyStickInfo
_getJoyInfo
();
static
JoyStickInfoList
_scanJoys
();
static
JoyStickInfoList
_scanJoys
();
static
void
_clearJoys
(
JoyStickInfoList
&
joys
);
static
void
_clearJoys
(
JoyStickInfoList
&
joys
);
protected:
protected:
int
mJoyStick
;
int
mJoyStick
;
LinuxForceFeedback
*
ff_effect
;
LinuxForceFeedback
*
ff_effect
;
std
::
map
<
int
,
int
>
mButtonMap
;
std
::
map
<
int
,
int
>
mButtonMap
;
std
::
map
<
int
,
int
>
mAxisMap
;
std
::
map
<
int
,
int
>
mAxisMap
;
std
::
map
<
int
,
Range
>
mRanges
;
std
::
map
<
int
,
Range
>
mRanges
;
};
};
}
}
#endif //_LINUX_JOYSTICK_H_EADER_
#endif //_LINUX_JOYSTICK_H_EADER_
includes/linux/LinuxKeyboard.h
View file @
24236447
/*
/*
The zlib/libpng License
The zlib/libpng License
Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
This software is provided 'as-is', without any express or implied warranty. In no event will
This software is provided 'as-is', without any express or implied warranty. In no event will
the authors be held liable for any damages arising from the use of this software.
the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose, including commercial
Permission is granted to anyone to use this software for any purpose, including commercial
applications, and to alter it and redistribute it freely, subject to the following
applications, and to alter it and redistribute it freely, subject to the following
restrictions:
restrictions:
1. The origin of this software must not be misrepresented; you must not claim that
1. The origin of this software must not be misrepresented; you must not claim that
you wrote the original software. If you use this software in a product,
you wrote the original software. If you use this software in a product,
an acknowledgment in the product documentation would be appreciated but is
an acknowledgment in the product documentation would be appreciated but is
not required.
not required.
2. Altered source versions must be plainly marked as such, and must not be
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
3. This notice may not be removed or altered from any source distribution.
*/
*/
#ifndef _LINUX_KEYBOARD_H_EADER_
#ifndef _LINUX_KEYBOARD_H_EADER_
#define _LINUX_KEYBOARD_H_EADER_
#define _LINUX_KEYBOARD_H_EADER_
#include "linux/LinuxPrereqs.h"
#include "linux/LinuxPrereqs.h"
#include "OISKeyboard.h"
#include "OISKeyboard.h"
#include <X11/Xlib.h>
#include <X11/Xlib.h>
namespace
OIS
namespace
OIS
{
{
/** Linux implementation of Keyboard object - uses x11 */
/** Linux implementation of Keyboard object - uses x11 */
class
LinuxKeyboard
:
public
Keyboard
class
LinuxKeyboard
:
public
Keyboard
{
{
public:
public:
LinuxKeyboard
(
InputManager
*
creator
,
bool
buffered
,
bool
grab
);
LinuxKeyboard
(
InputManager
*
creator
,
bool
buffered
,
bool
grab
);
virtual
~
LinuxKeyboard
();
virtual
~
LinuxKeyboard
();
/** @copydoc Keyboard::isKeyDown */
/** @copydoc Keyboard::isKeyDown */
virtual
bool
isKeyDown
(
KeyCode
key
)
const
;
virtual
bool
isKeyDown
(
KeyCode
key
)
const
;
/** @copydoc Keyboard::getAsString */
/** @copydoc Keyboard::getAsString */
virtual
const
std
::
string
&
getAsString
(
KeyCode
kc
);
virtual
const
std
::
string
&
getAsString
(
KeyCode
kc
);
/** @copydoc Keyboard::copyKeyStates */
/** @copydoc Keyboard::copyKeyStates */
virtual
void
copyKeyStates
(
char
keys
[
256
]
)
const
;
virtual
void
copyKeyStates
(
char
keys
[
256
]
)
const
;
/** @copydoc Object::setBuffered */
/** @copydoc Object::setBuffered */
virtual
void
setBuffered
(
bool
buffered
);
virtual
void
setBuffered
(
bool
buffered
);
/** @copydoc Object::capture */
/** @copydoc Object::capture */
virtual
void
capture
();
virtual
void
capture
();
/** @copydoc Object::queryInterface */
/** @copydoc Object::queryInterface */
virtual
Interface
*
queryInterface
(
Interface
::
IType
)
{
return
0
;}
virtual
Interface
*
queryInterface
(
Interface
::
IType
)
{
return
0
;}
/** @copydoc Object::_initialize */
/** @copydoc Object::_initialize */
virtual
void
_initialize
();
virtual
void
_initialize
();
protected:
protected:
inline
bool
_isKeyRepeat
(
XEvent
&
event
)
inline
bool
_isKeyRepeat
(
XEvent
&
event
)
{
{
//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
))
if
(
!
XPending
(
display
))
return
false
;
return
false
;
...
@@ -74,25 +74,25 @@ namespace OIS
...
@@ -74,25 +74,25 @@ namespace OIS
return
false
;
return
false
;
}
}
bool
_injectKeyDown
(
KeySym
key
,
int
text
);
bool
_injectKeyDown
(
KeySym
key
,
int
text
);
bool
_injectKeyUp
(
KeySym
key
);
bool
_injectKeyUp
(
KeySym
key
);
//! 1:1 Conversion Map between X Key Events and OIS KeyCodes
//! 1:1 Conversion Map between X Key Events and OIS KeyCodes
typedef
std
::
map
<
KeySym
,
KeyCode
>
XtoOIS_KeyMap
;
typedef
std
::
map
<
KeySym
,
KeyCode
>
XtoOIS_KeyMap
;
XtoOIS_KeyMap
keyConversion
;
XtoOIS_KeyMap
keyConversion
;
//! Depressed Key List
//! Depressed Key List
char
KeyBuffer
[
256
];
char
KeyBuffer
[
256
];
//! X11 Stuff
//! X11 Stuff
Window
window
;
Window
window
;
Display
*
display
;
Display
*
display
;
bool
grabKeyboard
;
bool
grabKeyboard
;
bool
keyFocusLost
;
bool
keyFocusLost
;
std
::
string
mGetString
;
std
::
string
mGetString
;
};
};
}
}
#endif //_LINUX_KEYBOARD_H_EADER_
#endif //_LINUX_KEYBOARD_H_EADER_
includes/linux/LinuxMouse.h
View file @
24236447
/*
/*
The zlib/libpng License
The zlib/libpng License
Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
This software is provided 'as-is', without any express or implied warranty. In no event will
This software is provided 'as-is', without any express or implied warranty. In no event will
the authors be held liable for any damages arising from the use of this software.
the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose, including commercial
Permission is granted to anyone to use this software for any purpose, including commercial
applications, and to alter it and redistribute it freely, subject to the following
applications, and to alter it and redistribute it freely, subject to the following
restrictions:
restrictions:
1. The origin of this software must not be misrepresented; you must not claim that
1. The origin of this software must not be misrepresented; you must not claim that
you wrote the original software. If you use this software in a product,
you wrote the original software. If you use this software in a product,
an acknowledgment in the product documentation would be appreciated but is
an acknowledgment in the product documentation would be appreciated but is
not required.
not required.
2. Altered source versions must be plainly marked as such, and must not be
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
3. This notice may not be removed or altered from any source distribution.
*/
*/
#ifndef _LINUX_MOUSE_H_EADER_
#ifndef _LINUX_MOUSE_H_EADER_
#define _LINUX_MOUSE_H_EADER_
#define _LINUX_MOUSE_H_EADER_
#include "linux/LinuxPrereqs.h"
#include "linux/LinuxPrereqs.h"
#include "OISMouse.h"
#include "OISMouse.h"
#include <X11/Xlib.h>
#include <X11/Xlib.h>
namespace
OIS
namespace
OIS
{
{
class
LinuxMouse
:
public
Mouse
class
LinuxMouse
:
public
Mouse
{
{
public:
public:
LinuxMouse
(
InputManager
*
creator
,
bool
buffered
,
bool
grab
,
bool
hide
);
LinuxMouse
(
InputManager
*
creator
,
bool
buffered
,
bool
grab
,
bool
hide
);
virtual
~
LinuxMouse
();
virtual
~
LinuxMouse
();
/** @copydoc Object::setBuffered */
/** @copydoc Object::setBuffered */
virtual
void
setBuffered
(
bool
buffered
);
virtual
void
setBuffered
(
bool
buffered
);
/**
/**
@remarks
@remarks
Note: Calling this will also update the keyboard (X11 updates in a single
Note: Calling this will also update the keyboard (X11 updates in a single
event queue). Updates State and/or raises event for buffered mode..
event queue). Updates State and/or raises event for buffered mode..
*/
*/
virtual
void
capture
();
virtual
void
capture
();
/** @copydoc Object::queryInterface */
/** @copydoc Object::queryInterface */
virtual
Interface
*
queryInterface
(
Interface
::
IType
)
{
return
0
;}
virtual
Interface
*
queryInterface
(
Interface
::
IType
)
{
return
0
;}
/** @copydoc Object::_initialize */
/** @copydoc Object::_initialize */
virtual
void
_initialize
();
virtual
void
_initialize
();
void
grab
(
bool
grab
);
void
grab
(
bool
grab
);
void
hide
(
bool
hide
);
void
hide
(
bool
hide
);
protected:
protected:
void
_processXEvents
();
void
_processXEvents
();
bool
mMoved
,
mWarped
;
bool
mMoved
,
mWarped
;
//Since X11 provides us with absolute values, we need to keep track of relative values
//Since X11 provides us with absolute values, we need to keep track of relative values
long
oldXMouseX
,
oldXMouseY
,
oldXMouseZ
;
long
oldXMouseX
,
oldXMouseY
,
oldXMouseZ
;
Window
window
;
//The X Window
Window
window
;
//The X Window
Display
*
display
;
//The X display
Display
*
display
;
//The X display
Cursor
cursor
;
//A blank cursor
Cursor
cursor
;
//A blank cursor
bool
grabMouse
;
//Are we grabbing the mouse to the window?
bool
grabMouse
;
//Are we grabbing the mouse to the window?
bool
hideMouse
;
//Are we hiding OS mouse?
bool
hideMouse
;
//Are we hiding OS mouse?
bool
mouseFocusLost
;
//Has the mouse just lost focus?
bool
mouseFocusLost
;
//Has the mouse just lost focus?
};
};
}
}
#endif //_LINUX_MOUSE_H_EADER_
#endif //_LINUX_MOUSE_H_EADER_
includes/linux/LinuxPrereqs.h
View file @
24236447
/*
/*
The zlib/libpng License
The zlib/libpng License
Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
This software is provided 'as-is', without any express or implied warranty. In no event will
This software is provided 'as-is', without any express or implied warranty. In no event will
the authors be held liable for any damages arising from the use of this software.
the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose, including commercial
Permission is granted to anyone to use this software for any purpose, including commercial
applications, and to alter it and redistribute it freely, subject to the following
applications, and to alter it and redistribute it freely, subject to the following
restrictions:
restrictions:
1. The origin of this software must not be misrepresented; you must not claim that
1. The origin of this software must not be misrepresented; you must not claim that
you wrote the original software. If you use this software in a product,
you wrote the original software. If you use this software in a product,
an acknowledgment in the product documentation would be appreciated but is
an acknowledgment in the product documentation would be appreciated but is
not required.
not required.
2. Altered source versions must be plainly marked as such, and must not be
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
3. This notice may not be removed or altered from any source distribution.
*/
*/
#ifndef _LINUX_INPUTSYSTEM_PREREQS_H
#ifndef _LINUX_INPUTSYSTEM_PREREQS_H
#define _LINUX_INPUTSYSTEM_PREREQS_H
#define _LINUX_INPUTSYSTEM_PREREQS_H
//Bring in any auto generated config files
//Bring in any auto generated config files
#ifdef HAVE_CONFIG_H
#ifdef HAVE_CONFIG_H
# include "config.h"
# include "config.h"
#endif
#endif
#include "OISPrereqs.h"
#include "OISPrereqs.h"
//! Max number of elements to collect from buffered input
//! Max number of elements to collect from buffered input
#define JOY_BUFFERSIZE 64
#define JOY_BUFFERSIZE 64
namespace
OIS
namespace
OIS
{
{
class
LinuxInputManager
;
class
LinuxInputManager
;
class
LinuxKeyboard
;
class
LinuxKeyboard
;
class
LinuxJoyStick
;
class
LinuxJoyStick
;
class
LinuxMouse
;
class
LinuxMouse
;
class
LinuxForceFeedback
;
class
LinuxForceFeedback
;
class
Range
class
Range
{
{
public:
public:
Range
()
{};
Range
()
{};
Range
(
int
_min
,
int
_max
)
:
min
(
_min
),
max
(
_max
)
{};
Range
(
int
_min
,
int
_max
)
:
min
(
_min
),
max
(
_max
)
{};
int
min
,
max
;
int
min
,
max
;
};
};
class
JoyStickInfo
class
JoyStickInfo
{
{
public:
public:
JoyStickInfo
()
:
devId
(
-
1
),
joyFileD
(
-
1
),
version
(
0
),
axes
(
0
),
buttons
(
0
),
hats
(
0
)
{}
JoyStickInfo
()
:
devId
(
-
1
),
joyFileD
(
-
1
),
version
(
0
),
axes
(
0
),
buttons
(
0
),
hats
(
0
)
{}
//! Device number (/dev/input/j#) or /dev/input/event#
//! Device number (/dev/input/j#) or /dev/input/event#
int
devId
;
int
devId
;
//! File descriptor
//! File descriptor
int
joyFileD
;
int
joyFileD
;
//! Driver version
//! Driver version
int
version
;
int
version
;
//! Joy vendor
//! Joy vendor
std
::
string
vendor
;
std
::
string
vendor
;
//! Number of axes
//! Number of axes
unsigned
char
axes
;
unsigned
char
axes
;
//! Number of buttons
//! Number of buttons
unsigned
char
buttons
;
unsigned
char
buttons
;
//! Number of hats
//! Number of hats
unsigned
char
hats
;
unsigned
char
hats
;
//! Maps Linux button values to OIS buttons values
//! Maps Linux button values to OIS buttons values
std
::
map
<
int
,
int
>
button_map
;
std
::
map
<
int
,
int
>
button_map
;
//! Maps Linux axis values to OIS axis
//! Maps Linux axis values to OIS axis
std
::
map
<
int
,
int
>
axis_map
;
std
::
map
<
int
,
int
>
axis_map
;
//! Maps OIS axis values to it's range
//! Maps OIS axis values to it's range
std
::
map
<
int
,
Range
>
axis_range
;
std
::
map
<
int
,
Range
>
axis_range
;
};
};
typedef
std
::
vector
<
JoyStickInfo
>
JoyStickInfoList
;
typedef
std
::
vector
<
JoyStickInfo
>
JoyStickInfoList
;
}
}
#endif //_LINUX_INPUTSYSTEM_PREREQS_H
#endif //_LINUX_INPUTSYSTEM_PREREQS_H
includes/mac/MacHIDManager.h
View file @
24236447
/*
/*
The zlib/libpng License
The zlib/libpng License
Copyright (c) 2007 Phillip
Copyright (c) 2007 Phillip
This software is provided 'as-is', without any express or implied warranty. In no event will
This software is provided 'as-is', without any express or implied warranty. In no event will
the authors be held liable for any damages arising from the use of this software.
the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose, including commercial
Permission is granted to anyone to use this software for any purpose, including commercial
applications, and to alter it and redistribute it freely, subject to the following
applications, and to alter it and redistribute it freely, subject to the following
restrictions:
restrictions:
1. The origin of this software must not be misrepresented; you must not claim that
1. The origin of this software must not be misrepresented; you must not claim that
you wrote the original software. If you use this software in a product,
you wrote the original software. If you use this software in a product,
an acknowledgment in the product documentation would be appreciated but is
an acknowledgment in the product documentation would be appreciated but is
not required.
not required.
2. Altered source versions must be plainly marked as such, and must not be
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
3. This notice may not be removed or altered from any source distribution.
*/
*/
#ifndef OIS_MacHIDManager_Header
#ifndef OIS_MacHIDManager_Header
#define OIS_MacHIDManager_Header
#define OIS_MacHIDManager_Header
#include "OISPrereqs.h"
#include "OISPrereqs.h"
#include "mac/MacPrereqs.h"
#include "mac/MacPrereqs.h"
#include "OISFactoryCreator.h"
#include "OISFactoryCreator.h"
#import <CoreFoundation/CFString.h>
#import <CoreFoundation/CFString.h>
#import <IOKit/IOKitLib.h>
#import <IOKit/IOKitLib.h>
#import <IOKit/IOCFPlugIn.h>
#import <IOKit/IOCFPlugIn.h>
#import <IOKit/hid/IOHIDLib.h>
#import <IOKit/hid/IOHIDLib.h>
#import <IOKit/hid/IOHIDKeys.h>
#import <IOKit/hid/IOHIDKeys.h>
#import <Kernel/IOKit/hidsystem/IOHIDUsageTables.h>
#import <Kernel/IOKit/hidsystem/IOHIDUsageTables.h>
namespace
OIS
namespace
OIS
{
{
//Information needed to create Mac HID Devices
//Information needed to create Mac HID Devices
class
HidInfo
class
HidInfo
{
{
public:
public:
HidInfo
()
:
type
(
OISUnknown
),
numButtons
(
0
),
numHats
(
0
),
numAxes
(
0
),
inUse
(
false
),
interface
(
0
)
HidInfo
()
:
type
(
OISUnknown
),
numButtons
(
0
),
numHats
(
0
),
numAxes
(
0
),
inUse
(
false
),
interface
(
0
)
{
{
}
}
//Useful tracking information
//Useful tracking information
Type
type
;
Type
type
;
std
::
string
vendor
;
std
::
string
vendor
;
std
::
string
productKey
;
std
::
string
productKey
;
std
::
string
combinedKey
;
std
::
string
combinedKey
;
//Retain some count information for recreating devices without having to reparse
//Retain some count information for recreating devices without having to reparse
int
numButtons
;
int
numButtons
;
int
numHats
;
int
numHats
;
int
numAxes
;
int
numAxes
;
bool
inUse
;
bool
inUse
;
//Used for opening a read/write/tracking interface to device
//Used for opening a read/write/tracking interface to device
IOHIDDeviceInterface
**
interface
;
IOHIDDeviceInterface
**
interface
;
};
};
typedef
std
::
vector
<
HidInfo
*>
HidInfoList
;
typedef
std
::
vector
<
HidInfo
*>
HidInfoList
;
class
MacHIDManager
:
public
FactoryCreator
class
MacHIDManager
:
public
FactoryCreator
{
{
public:
public:
MacHIDManager
();
MacHIDManager
();
~
MacHIDManager
();
~
MacHIDManager
();
void
initialize
();
void
initialize
();
void
iterateAndOpenDevices
(
io_iterator_t
iterator
);
void
iterateAndOpenDevices
(
io_iterator_t
iterator
);
io_iterator_t
lookUpDevices
(
int
usage
,
int
page
);
io_iterator_t
lookUpDevices
(
int
usage
,
int
page
);
//FactoryCreator Overrides
//FactoryCreator Overrides
/** @copydoc FactoryCreator::deviceList */
/** @copydoc FactoryCreator::deviceList */
DeviceList
freeDeviceList
();
DeviceList
freeDeviceList
();
/** @copydoc FactoryCreator::totalDevices */
/** @copydoc FactoryCreator::totalDevices */
int
totalDevices
(
Type
iType
);
int
totalDevices
(
Type
iType
);
/** @copydoc FactoryCreator::freeDevices */
/** @copydoc FactoryCreator::freeDevices */
int
freeDevices
(
Type
iType
);
int
freeDevices
(
Type
iType
);
/** @copydoc FactoryCreator::vendorExist */
/** @copydoc FactoryCreator::vendorExist */
bool
vendorExist
(
Type
iType
,
const
std
::
string
&
vendor
);
bool
vendorExist
(
Type
iType
,
const
std
::
string
&
vendor
);
/** @copydoc FactoryCreator::createObject */
/** @copydoc FactoryCreator::createObject */
Object
*
createObject
(
InputManager
*
creator
,
Type
iType
,
bool
bufferMode
,
const
std
::
string
&
vendor
=
""
);
Object
*
createObject
(
InputManager
*
creator
,
Type
iType
,
bool
bufferMode
,
const
std
::
string
&
vendor
=
""
);
/** @copydoc FactoryCreator::destroyObject */
/** @copydoc FactoryCreator::destroyObject */
void
destroyObject
(
Object
*
obj
);
void
destroyObject
(
Object
*
obj
);
private:
private:
HidInfo
*
enumerateDeviceProperties
(
CFMutableDictionaryRef
propertyMap
);
HidInfo
*
enumerateDeviceProperties
(
CFMutableDictionaryRef
propertyMap
);
void
parseDeviceProperties
(
CFDictionaryRef
properties
);
void
parseDeviceProperties
(
CFDictionaryRef
properties
);
void
parseDevicePropertiesGroup
(
CFDictionaryRef
properties
);
void
parseDevicePropertiesGroup
(
CFDictionaryRef
properties
);
HidInfoList
mDeviceList
;
HidInfoList
mDeviceList
;
};
};
}
}
#endif
#endif
includes/mac/MacHelpers.h
View file @
24236447
/*
/*
The zlib/libpng License
The zlib/libpng License
Copyright (c) 2006 Chris Snyder
Copyright (c) 2006 Chris Snyder
This software is provided 'as-is', without any express or implied warranty. In no event will
This software is provided 'as-is', without any express or implied warranty. In no event will
the authors be held liable for any damages arising from the use of this software.
the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose, including commercial
Permission is granted to anyone to use this software for any purpose, including commercial
applications, and to alter it and redistribute it freely, subject to the following
applications, and to alter it and redistribute it freely, subject to the following
restrictions:
restrictions:
1. The origin of this software must not be misrepresented; you must not claim that
1. The origin of this software must not be misrepresented; you must not claim that
you wrote the original software. If you use this software in a product,
you wrote the original software. If you use this software in a product,
an acknowledgment in the product documentation would be appreciated but is
an acknowledgment in the product documentation would be appreciated but is
not required.
not required.
2. Altered source versions must be plainly marked as such, and must not be
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
3. This notice may not be removed or altered from any source distribution.
*/
*/
#ifndef OIS_MacHelpers_H
#ifndef OIS_MacHelpers_H
#define OIS_MacHelpers_H
#define OIS_MacHelpers_H
#include "mac/MacPrereqs.h"
#include "mac/MacPrereqs.h"
#include "OISEvents.h"
#include "OISEvents.h"
#include "OISKeyboard.h"
#include "OISKeyboard.h"
#include "OISMouse.h"
#include "OISMouse.h"
#include <Carbon/Carbon.h>
#include <Carbon/Carbon.h>
// This is a hack needed to get the event handler working.
// This is a hack needed to get the event handler working.
// The carbon lib expects a "OSStatus (*)(EventHandlerCallRef, EventRef, void*)",
// The carbon lib expects a "OSStatus (*)(EventHandlerCallRef, EventRef, void*)",
// so I cannot give it a class member function (unless it is static which is pointless)
// so I cannot give it a class member function (unless it is static which is pointless)
// Instead, I just pass the class* through the last paramter that gets passed to the
// Instead, I just pass the class* through the last paramter that gets passed to the
// callback every time an event occurs. Then I dereference it and call the member function.
// callback every time an event occurs. Then I dereference it and call the member function.
OSStatus
KeyDownWrapper
(
EventHandlerCallRef
nextHandler
,
EventRef
theEvent
,
void
*
callClass
);
OSStatus
KeyDownWrapper
(
EventHandlerCallRef
nextHandler
,
EventRef
theEvent
,
void
*
callClass
);
OSStatus
KeyUpWrapper
(
EventHandlerCallRef
nextHandler
,
EventRef
theEvent
,
void
*
callClass
);
OSStatus
KeyUpWrapper
(
EventHandlerCallRef
nextHandler
,
EventRef
theEvent
,
void
*
callClass
);
OSStatus
KeyModWrapper
(
EventHandlerCallRef
nextHandler
,
EventRef
theEvent
,
void
*
callClass
);
OSStatus
KeyModWrapper
(
EventHandlerCallRef
nextHandler
,
EventRef
theEvent
,
void
*
callClass
);
OSStatus
MouseWrapper
(
EventHandlerCallRef
nextHandler
,
EventRef
theEvent
,
void
*
callClass
);
OSStatus
MouseWrapper
(
EventHandlerCallRef
nextHandler
,
EventRef
theEvent
,
void
*
callClass
);
// This is needed for keeping an event stack for keyboard and mouse
// This is needed for keeping an event stack for keyboard and mouse
namespace
OIS
namespace
OIS
{
{
// used in the eventStack to store the type
// used in the eventStack to store the type
enum
Mac_EventType
{
MAC_KEYUP
=
0
,
enum
Mac_EventType
{
MAC_KEYUP
=
0
,
MAC_KEYDOWN
=
1
,
MAC_KEYDOWN
=
1
,
MAC_KEYREPEAT
,
MAC_KEYREPEAT
,
MAC_MOUSEDOWN
,
MAC_MOUSEDOWN
,
MAC_MOUSEUP
,
MAC_MOUSEUP
,
MAC_MOUSEMOVED
,
MAC_MOUSEMOVED
,
MAC_MOUSESCROLL
};
MAC_MOUSESCROLL
};
typedef
enum
Mac_EventType
MacEventType
;
typedef
enum
Mac_EventType
MacEventType
;
// only used by MacKeyboard
// only used by MacKeyboard
typedef
class
Mac_KeyStackEvent
typedef
class
Mac_KeyStackEvent
{
{
friend
class
MacKeyboard
;
friend
class
MacKeyboard
;
private:
private:
Mac_KeyStackEvent
(
KeyEvent
event
,
MacEventType
type
)
:
Event
(
event
),
Type
(
type
)
{}
Mac_KeyStackEvent
(
KeyEvent
event
,
MacEventType
type
)
:
Event
(
event
),
Type
(
type
)
{}
MacEventType
Type
;
MacEventType
Type
;
KeyEvent
Event
;
KeyEvent
Event
;
}
MacKeyStackEvent
;
}
MacKeyStackEvent
;
// only used by MacMouse
// only used by MacMouse
typedef
class
Mac_MouseStackEvent
typedef
class
Mac_MouseStackEvent
{
{
friend
class
MacMouse
;
friend
class
MacMouse
;
private:
private:
Mac_MouseStackEvent
(
MouseEvent
event
,
MacEventType
type
,
MouseButtonID
button
)
:
Event
(
event
),
Type
(
type
),
Button
(
button
)
{}
Mac_MouseStackEvent
(
MouseEvent
event
,
MacEventType
type
,
MouseButtonID
button
)
:
Event
(
event
),
Type
(
type
),
Button
(
button
)
{}
MacEventType
Type
;
MacEventType
Type
;
MouseEvent
Event
;
MouseEvent
Event
;
MouseButtonID
Button
;
MouseButtonID
Button
;
}
MacMouseStackEvent
;
}
MacMouseStackEvent
;
}
}
#endif
#endif
includes/mac/MacInputManager.h
View file @
24236447
/*
/*
The zlib/libpng License
The zlib/libpng License
Copyright (c) 2006 Chris Snyder
Copyright (c) 2006 Chris Snyder
This software is provided 'as-is', without any express or implied warranty. In no event will
This software is provided 'as-is', without any express or implied warranty. In no event will
the authors be held liable for any damages arising from the use of this software.
the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose, including commercial
Permission is granted to anyone to use this software for any purpose, including commercial
applications, and to alter it and redistribute it freely, subject to the following
applications, and to alter it and redistribute it freely, subject to the following
restrictions:
restrictions:
1. The origin of this software must not be misrepresented; you must not claim that
1. The origin of this software must not be misrepresented; you must not claim that
you wrote the original software. If you use this software in a product,
you wrote the original software. If you use this software in a product,
an acknowledgment in the product documentation would be appreciated but is
an acknowledgment in the product documentation would be appreciated but is
not required.
not required.
2. Altered source versions must be plainly marked as such, and must not be
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
3. This notice may not be removed or altered from any source distribution.
*/
*/
#ifndef OIS_MacInputManager_H
#ifndef OIS_MacInputManager_H
#define OIS_MacInputManager_H
#define OIS_MacInputManager_H
#include "OISInputManager.h"
#include "OISInputManager.h"
#include "OISFactoryCreator.h"
#include "OISFactoryCreator.h"
#include "mac/MacPrereqs.h"
#include "mac/MacPrereqs.h"
#include <Carbon/Carbon.h>
#include <Carbon/Carbon.h>
namespace
OIS
namespace
OIS
{
{
class
MacInputManager
:
public
InputManager
,
public
FactoryCreator
class
MacInputManager
:
public
InputManager
,
public
FactoryCreator
{
{
public:
public:
MacInputManager
();
MacInputManager
();
virtual
~
MacInputManager
();
virtual
~
MacInputManager
();
//InputManager Overrides
//InputManager Overrides
/** @copydoc InputManager::_initialize */
/** @copydoc InputManager::_initialize */
void
_initialize
(
ParamList
&
paramList
);
void
_initialize
(
ParamList
&
paramList
);
//FactoryCreator Overrides
//FactoryCreator Overrides
/** @copydoc FactoryCreator::deviceList */
/** @copydoc FactoryCreator::deviceList */
DeviceList
freeDeviceList
();
DeviceList
freeDeviceList
();
/** @copydoc FactoryCreator::totalDevices */
/** @copydoc FactoryCreator::totalDevices */
int
totalDevices
(
Type
iType
);
int
totalDevices
(
Type
iType
);
/** @copydoc FactoryCreator::freeDevices */
/** @copydoc FactoryCreator::freeDevices */
int
freeDevices
(
Type
iType
);
int
freeDevices
(
Type
iType
);
/** @copydoc FactoryCreator::vendorExist */
/** @copydoc FactoryCreator::vendorExist */
bool
vendorExist
(
Type
iType
,
const
std
::
string
&
vendor
);
bool
vendorExist
(
Type
iType
,
const
std
::
string
&
vendor
);
/** @copydoc FactoryCreator::createObject */
/** @copydoc FactoryCreator::createObject */
Object
*
createObject
(
InputManager
*
creator
,
Type
iType
,
bool
bufferMode
,
const
std
::
string
&
vendor
=
""
);
Object
*
createObject
(
InputManager
*
creator
,
Type
iType
,
bool
bufferMode
,
const
std
::
string
&
vendor
=
""
);
/** @copydoc FactoryCreator::destroyObject */
/** @copydoc FactoryCreator::destroyObject */
void
destroyObject
(
Object
*
obj
);
void
destroyObject
(
Object
*
obj
);
//Internal Items
//Internal Items
//! Internal method, used for flaggin keyboard as available/unavailable for creation
//! Internal method, used for flaggin keyboard as available/unavailable for creation
void
_setKeyboardUsed
(
bool
used
)
{
keyboardUsed
=
used
;
}
void
_setKeyboardUsed
(
bool
used
)
{
keyboardUsed
=
used
;
}
//! Internal method, used for flaggin mouse as available/unavailable for creation
//! Internal method, used for flaggin mouse as available/unavailable for creation
void
_setMouseUsed
(
bool
used
)
{
mouseUsed
=
used
;
}
void
_setMouseUsed
(
bool
used
)
{
mouseUsed
=
used
;
}
//! methodfor getting the event target
//! methodfor getting the event target
EventTargetRef
_getEventTarget
()
{
return
mEventTargetRef
;}
EventTargetRef
_getEventTarget
()
{
return
mEventTargetRef
;}
//! method for getting window
//! method for getting window
WindowRef
_getWindow
()
{
return
mWindow
;}
WindowRef
_getWindow
()
{
return
mWindow
;}
protected:
protected:
void
_parseConfigSettings
(
ParamList
&
paramList
);
void
_parseConfigSettings
(
ParamList
&
paramList
);
void
_enumerateDevices
();
void
_enumerateDevices
();
static
const
std
::
string
iName
;
static
const
std
::
string
iName
;
// Mac stuff
// Mac stuff
EventTargetRef
mEventTargetRef
;
EventTargetRef
mEventTargetRef
;
WindowRef
mWindow
;
WindowRef
mWindow
;
// settings
// settings
bool
mHideMouse
;
bool
mHideMouse
;
bool
mUseRepeat
;
bool
mUseRepeat
;
//! Used to know if we used up keyboard
//! Used to know if we used up keyboard
bool
keyboardUsed
;
bool
keyboardUsed
;
//! Used to know if we used up mouse
//! Used to know if we used up mouse
bool
mouseUsed
;
bool
mouseUsed
;
//! HID Manager class handling devices other than keyboard/mouse
//! HID Manager class handling devices other than keyboard/mouse
MacHIDManager
*
mHIDManager
;
MacHIDManager
*
mHIDManager
;
};
};
}
}
#endif
#endif
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