[Orxonox-commit 2803] r7506 - in code/branches/ois_update/src/external/ois: . linux mac win32
rgrieder at orxonox.net
rgrieder at orxonox.net
Thu Oct 7 20:21:34 CEST 2010
Author: rgrieder
Date: 2010-10-07 20:21:33 +0200 (Thu, 07 Oct 2010)
New Revision: 7506
Added:
code/branches/ois_update/src/external/ois/OISMultiTouch.h
code/branches/ois_update/src/external/ois/mac/MacJoyStick.cpp
code/branches/ois_update/src/external/ois/mac/MacJoyStick.h
Modified:
code/branches/ois_update/src/external/ois/OIS.h
code/branches/ois_update/src/external/ois/OISConfig.h
code/branches/ois_update/src/external/ois/OISInputManager.cpp
code/branches/ois_update/src/external/ois/OISKeyboard.h
code/branches/ois_update/src/external/ois/OISPrereqs.h
code/branches/ois_update/src/external/ois/ReadMe.txt
code/branches/ois_update/src/external/ois/VERSION
code/branches/ois_update/src/external/ois/changes_orxonox.diff
code/branches/ois_update/src/external/ois/linux/LinuxInputManager.cpp
code/branches/ois_update/src/external/ois/linux/LinuxInputManager.h
code/branches/ois_update/src/external/ois/linux/LinuxJoyStickEvents.cpp
code/branches/ois_update/src/external/ois/linux/LinuxKeyboard.cpp
code/branches/ois_update/src/external/ois/linux/LinuxKeyboard.h
code/branches/ois_update/src/external/ois/linux/LinuxMouse.cpp
code/branches/ois_update/src/external/ois/linux/LinuxPrereqs.h
code/branches/ois_update/src/external/ois/mac/MacHIDManager.cpp
code/branches/ois_update/src/external/ois/mac/MacHIDManager.h
code/branches/ois_update/src/external/ois/mac/MacInputManager.cpp
code/branches/ois_update/src/external/ois/win32/Win32ForceFeedback.cpp
code/branches/ois_update/src/external/ois/win32/Win32ForceFeedback.h
code/branches/ois_update/src/external/ois/win32/Win32InputManager.cpp
code/branches/ois_update/src/external/ois/win32/Win32InputManager.h
code/branches/ois_update/src/external/ois/win32/Win32JoyStick.cpp
code/branches/ois_update/src/external/ois/win32/Win32JoyStick.h
code/branches/ois_update/src/external/ois/win32/Win32KeyBoard.cpp
code/branches/ois_update/src/external/ois/win32/Win32KeyBoard.h
code/branches/ois_update/src/external/ois/win32/Win32Mouse.cpp
code/branches/ois_update/src/external/ois/win32/Win32Mouse.h
code/branches/ois_update/src/external/ois/win32/Win32Prereqs.h
Log:
Updated OIS source files to its current SVN trunk (r26).
Modified: code/branches/ois_update/src/external/ois/OIS.h
===================================================================
--- code/branches/ois_update/src/external/ois/OIS.h 2010-10-07 18:12:14 UTC (rev 7505)
+++ code/branches/ois_update/src/external/ois/OIS.h 2010-10-07 18:21:33 UTC (rev 7506)
@@ -28,6 +28,7 @@
#include "OISMouse.h"
#include "OISKeyboard.h"
#include "OISJoyStick.h"
+#include "OISMultiTouch.h"
#include "OISInputManager.h"
#include "OISFactoryCreator.h"
#include "OISException.h"
Modified: code/branches/ois_update/src/external/ois/OISConfig.h
===================================================================
--- code/branches/ois_update/src/external/ois/OISConfig.h 2010-10-07 18:12:14 UTC (rev 7505)
+++ code/branches/ois_update/src/external/ois/OISConfig.h 2010-10-07 18:21:33 UTC (rev 7506)
@@ -69,8 +69,6 @@
/**
@remarks
Build in support for Win32 XInput (Xbox 360 Controller)
- at notes
- Not Yet Implemented
*/
//#define OIS_WIN32_XINPUT_SUPPORT
Modified: code/branches/ois_update/src/external/ois/OISInputManager.cpp
===================================================================
--- code/branches/ois_update/src/external/ois/OISInputManager.cpp 2010-10-07 18:12:14 UTC (rev 7505)
+++ code/branches/ois_update/src/external/ois/OISInputManager.cpp 2010-10-07 18:21:33 UTC (rev 7506)
@@ -36,6 +36,8 @@
# include "linux/LinuxInputManager.h"
#elif defined OIS_APPLE_PLATFORM
# include "mac/MacInputManager.h"
+#elif defined OIS_IPHONE_PLATFORM
+# include "iphone/iPhoneInputManager.h"
#elif defined OIS_XBOX_PLATFORM
# include "xbox/XBoxInputManager.h"
#endif
@@ -58,6 +60,8 @@
m_lircSupport(0),
m_wiiMoteSupport(0)
{
+ mFactories.clear();
+ mFactoryObjects.clear();
}
//----------------------------------------------------------------------------//
@@ -110,6 +114,8 @@
im = new LinuxInputManager();
#elif defined OIS_APPLE_PLATFORM
im = new MacInputManager();
+#elif defined OIS_IPHONE_PLATFORM
+ im = new iPhoneInputManager();
#else
OIS_EXCEPT(E_General, "No platform library.. check build platform defines!");
#endif
Modified: code/branches/ois_update/src/external/ois/OISKeyboard.h
===================================================================
--- code/branches/ois_update/src/external/ois/OISKeyboard.h 2010-10-07 18:12:14 UTC (rev 7505)
+++ code/branches/ois_update/src/external/ois/OISKeyboard.h 2010-10-07 18:21:33 UTC (rev 7506)
@@ -183,7 +183,7 @@
class _OISExport KeyEvent : public EventArg
{
public:
- KeyEvent( Object* obj, KeyCode kc, unsigned int txt ) : EventArg(obj), key(kc), text(txt) {}
+ KeyEvent(Object* obj, KeyCode kc, unsigned int txt) : EventArg(obj), key(kc), text(txt) {}
virtual ~KeyEvent() {}
//! KeyCode of event
@@ -200,8 +200,8 @@
{
public:
virtual ~KeyListener() {}
- virtual bool keyPressed( const KeyEvent &arg ) = 0;
- virtual bool keyReleased( const KeyEvent &arg ) = 0;
+ virtual bool keyPressed(const KeyEvent &arg) = 0;
+ virtual bool keyReleased(const KeyEvent &arg) = 0;
};
/**
@@ -219,7 +219,7 @@
@param key
A KeyCode to check
*/
- virtual bool isKeyDown( KeyCode key ) const = 0;
+ virtual bool isKeyDown(KeyCode key) const = 0;
/**
@remarks
@@ -228,7 +228,7 @@
@param keyListener
Send a pointer to a class derived from KeyListener or 0 to clear the callback
*/
- virtual void setEventCallback( KeyListener *keyListener ) { mListener = keyListener;}
+ virtual void setEventCallback(KeyListener *keyListener) { mListener = keyListener;}
/**
@remarks
@@ -253,7 +253,7 @@
@param mode
Off, Unicode, Ascii
*/
- virtual void setTextTranslation( TextTranslationMode mode );
+ virtual void setTextTranslation(TextTranslationMode mode);
/**
@remarks
@@ -271,7 +271,7 @@
@returns
The string as determined from the current locale
*/
- virtual const std::string& getAsString( KeyCode kc ) = 0;
+ virtual const std::string& getAsString(KeyCode kc) = 0;
//! Enum of bit position of modifer
enum Modifier
@@ -285,14 +285,14 @@
@remarks
Check modifier status
*/
- bool isModifierDown( Modifier mod ) const;
+ bool isModifierDown(Modifier mod) const;
/**
@remarks
Copies the state of the keys into the sent buffer
(in the form of 1 is down and 0 is up)
*/
- virtual void copyKeyStates( char keys[256] ) const = 0;
+ virtual void copyKeyStates(char keys[256]) const = 0;
protected:
Keyboard(const std::string &vendor, bool buffered, int devID, InputManager* creator)
Added: code/branches/ois_update/src/external/ois/OISMultiTouch.h
===================================================================
--- code/branches/ois_update/src/external/ois/OISMultiTouch.h (rev 0)
+++ code/branches/ois_update/src/external/ois/OISMultiTouch.h 2010-10-07 18:21:33 UTC (rev 7506)
@@ -0,0 +1,169 @@
+/*
+The zlib/libpng License
+
+Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
+
+This software is provided 'as-is', without any express or implied warranty. In no event will
+the authors be held liable for any damages arising from the use of this software.
+
+Permission is granted to anyone to use this software for any purpose, including commercial
+applications, and to alter it and redistribute it freely, subject to the following
+restrictions:
+
+ 1. The origin of this software must not be misrepresented; you must not claim that
+ you wrote the original software. If you use this software in a product,
+ an acknowledgment in the product documentation would be appreciated but is
+ not required.
+
+ 2. Altered source versions must be plainly marked as such, and must not be
+ misrepresented as being the original software.
+
+ 3. This notice may not be removed or altered from any source distribution.
+*/
+#ifndef OIS_MultiTouch_H
+#define OIS_MultiTouch_H
+#include "OISObject.h"
+#include "OISEvents.h"
+
+#include <set>
+#include <vector>
+
+#define OIS_MAX_NUM_TOUCHES 4 // 4 finger touches are probably the highest we'll ever get
+
+namespace OIS
+{
+ /**
+ Represents the state of the multi-touch device
+ All members are valid for both buffered and non buffered mode
+ */
+
+ //! Touch Event type
+ enum MultiTypeEventTypeID
+ {
+ MT_None = 0, MT_Pressed, MT_Released, MT_Moved, MT_Cancelled
+ };
+
+ class _OISExport MultiTouchState
+ {
+ public:
+ MultiTouchState() : width(50), height(50), touchType(MT_None) {};
+
+ /** Represents the height/width of your display area.. used if touch clipping
+ or touch grabbed in case of X11 - defaults to 50.. Make sure to set this
+ and change when your size changes.. */
+ mutable int width, height;
+
+ //! X Axis component
+ Axis X;
+
+ //! Y Axis Component
+ Axis Y;
+
+ //! Z Axis Component
+ Axis Z;
+
+ int touchType;
+
+ inline bool touchIsType( MultiTypeEventTypeID touch ) const
+ {
+ return ((touchType & ( 1L << touch )) == 0) ? false : true;
+ }
+
+ //! Clear all the values
+ void clear()
+ {
+ X.clear();
+ Y.clear();
+ Z.clear();
+ touchType = MT_None;
+ }
+ };
+
+ /** Specialised for multi-touch events */
+ class _OISExport MultiTouchEvent : public EventArg
+ {
+ public:
+ MultiTouchEvent( Object *obj, const MultiTouchState &ms ) : EventArg(obj), state(ms) {}
+ virtual ~MultiTouchEvent() {}
+
+ //! The state of the touch - including axes
+ const MultiTouchState &state;
+ };
+
+ /**
+ To receive buffered touch input, derive a class from this, and implement the
+ methods here. Then set the call back to your MultiTouch instance with MultiTouch::setEventCallback
+ */
+ class _OISExport MultiTouchListener
+ {
+ public:
+ virtual ~MultiTouchListener() {}
+ virtual bool touchMoved( const MultiTouchEvent &arg ) = 0;
+ virtual bool touchPressed( const MultiTouchEvent &arg ) = 0;
+ virtual bool touchReleased( const MultiTouchEvent &arg ) = 0;
+ virtual bool touchCancelled( const MultiTouchEvent &arg ) = 0;
+ };
+
+ /**
+ MultiTouch base class. To be implemented by specific system (ie. iPhone UITouch)
+ This class is useful as you remain OS independent using this common interface.
+ */
+ class _OISExport MultiTouch : public Object
+ {
+ public:
+ virtual ~MultiTouch() {}
+
+ /**
+ @remarks
+ Register/unregister a MultiTouch Listener - Only one allowed for simplicity. If broadcasting
+ is necessary, just broadcast from the callback you registered.
+ @param touchListener
+ Send a pointer to a class derived from MultiTouchListener or 0 to clear the callback
+ */
+ virtual void setEventCallback( MultiTouchListener *touchListener ) {mListener = touchListener;}
+
+ /** @remarks Returns currently set callback.. or 0 */
+ MultiTouchListener* getEventCallback() {return mListener;}
+
+ /** @remarks Clear out the set of input states. Should be called after input has been processed by the application */
+ void clearStates(void) { mStates.clear(); }
+
+ /** @remarks Returns the state of the touch - is valid for both buffered and non buffered mode */
+ std::vector<MultiTouchState> getMultiTouchStates() const { return mStates; }
+
+ /** @remarks Returns the first n touch states. Useful if you know your app only needs to
+ process n touches. The return value is a vector to allow random access */
+ const std::vector<MultiTouchState> getFirstNTouchStates(int n) {
+ std::vector<MultiTouchState> states;
+ for( unsigned int i = 0; i < mStates.size(); i++ ) {
+ if(!(mStates[i].touchIsType(MT_None))) {
+ states.push_back(mStates[i]);
+ }
+ }
+ return states;
+ }
+
+ /** @remarks Returns the first n touch states. Useful if you know your app only needs to
+ process n touches. The return value is a vector to allow random access */
+ const std::vector<MultiTouchState> getMultiTouchStatesOfType(MultiTypeEventTypeID type) {
+ std::vector<MultiTouchState> states;
+ for( unsigned int i = 0; i < mStates.size(); i++ ) {
+ if(mStates[i].touchIsType(type)) {
+ states.push_back(mStates[i]);
+ }
+ }
+ return states;
+ }
+
+ protected:
+ MultiTouch(const std::string &vendor, bool buffered, int devID, InputManager* creator)
+ : Object(vendor, OISMultiTouch, buffered, devID, creator), mListener(0) {}
+
+ //! The state of the touch device, implemented in a vector to store the state from each finger touch
+ std::vector<MultiTouchState> mStates;
+
+ //! Used for buffered/actionmapping callback
+ MultiTouchListener *mListener;
+ };
+}
+#endif
Property changes on: code/branches/ois_update/src/external/ois/OISMultiTouch.h
___________________________________________________________________
Added: svn:eol-style
+ native
Modified: code/branches/ois_update/src/external/ois/OISPrereqs.h
===================================================================
--- code/branches/ois_update/src/external/ois/OISPrereqs.h 2010-10-07 18:12:14 UTC (rev 7505)
+++ code/branches/ois_update/src/external/ois/OISPrereqs.h 2010-10-07 18:21:33 UTC (rev 7506)
@@ -78,9 +78,15 @@
# endif
# endif
#elif defined( __APPLE_CC__ ) // Apple OS X
-# define OIS_APPLE_PLATFORM
-# undef _OISExport
-# define _OISExport __attribute__((visibility("default")))
+ // Device Simulator
+# if __IPHONE_OS_VERSION_MIN_REQUIRED >= 20201 || __IPHONE_OS_VERSION_MIN_REQUIRED >= 20000
+//# if __IPHONE_OS_VERSION_MIN_REQUIRED >= 30000 || __IPHONE_OS_VERSION_MIN_REQUIRED >= 30000
+# define OIS_IPHONE_PLATFORM
+# else
+# define OIS_APPLE_PLATFORM
+# endif
+# undef _OISExport
+# define _OISExport __attribute__((visibility("default")))
#else //Probably Linux
# define OIS_LINUX_PLATFORM
#endif
@@ -94,9 +100,9 @@
//-------------- Common Classes, Enums, and Typdef's -------------------------//
#define OIS_VERSION_MAJOR 1
-#define OIS_VERSION_MINOR 2
+#define OIS_VERSION_MINOR 4
#define OIS_VERSION_PATCH 0
-#define OIS_VERSION_NAME "Smash"
+#define OIS_VERSION_NAME "1.4.0"
#define OIS_VERSION ((OIS_VERSION_MAJOR << 16) | (OIS_VERSION_MINOR << 8) | OIS_VERSION_PATCH)
@@ -109,8 +115,10 @@
class Keyboard;
class Mouse;
class JoyStick;
+ class MultiTouch;
class KeyListener;
class MouseListener;
+ class MultiTouchListener;
class JoyStickListener;
class Interface;
class ForceFeedback;
@@ -129,11 +137,12 @@
//! Each Input class has a General Type variable, a form of RTTI
enum Type
{
- OISUnknown = 0,
- OISKeyboard = 1,
- OISMouse = 2,
- OISJoyStick = 3,
- OISTablet = 4
+ OISUnknown = 0,
+ OISKeyboard = 1,
+ OISMouse = 2,
+ OISJoyStick = 3,
+ OISTablet = 4,
+ OISMultiTouch = 5
};
//! Map of device objects connected and their respective vendors
Modified: code/branches/ois_update/src/external/ois/ReadMe.txt
===================================================================
--- code/branches/ois_update/src/external/ois/ReadMe.txt 2010-10-07 18:12:14 UTC (rev 7505)
+++ code/branches/ois_update/src/external/ois/ReadMe.txt 2010-10-07 18:21:33 UTC (rev 7506)
@@ -4,7 +4,7 @@
The zlib/libpng License
-Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
+Copyright (c) 2005-2010 Phillip Castaneda (pjcast -- www.wreckedgames.com)
This software is provided 'as-is', without any express or implied warranty. In no
event will the authors be held liable for any damages arising from the use of this
@@ -45,21 +45,16 @@
Win32/
Contains Visual Studio .Net Solution Files
- Contains CodeBlocks + MinGW + StlPort project files for OIS
+ Contains CodeBlocks project files for OIS
---- Dependencies ------------------------------------------------------
DirectInput 8
- Ogre & CEGUI 0.4.0 If building CEGUIOgre OIS Demo
- SDL/
- A test bed for an OIS InputManager with SDL as the backend. Not recommended;
- however, useful for platforms with non-native OIS ports for temporary use.
Linux/
---- Dependencies ------------------------------------------------------
X11
- Ogre (GLX Platform) & CEGUI 0.4.0 If building CEGUIOgre OIS Demo
- Newer Linux Kernel (2.6+ ?) for Event API - else, use --disable-joyevents
+ Newer Linux Kernel (2.6+ ?) for Event API
Steps to build on Linux:
./bootstrap
@@ -68,10 +63,8 @@
---- Configure build options --------------------------------------------
./configure --help --- List all configure options
- ./configure --disable-ogre --- Disables CEGUIOgre ActionMapping Demo
- ./configure --disable-joyevents --- Uses /dev/input/jsX instead of
- /dev/input/eventX
+
LinuxCB/
Contains CodeBlock files for building OIS and Demos with codeblocks
This project file looks for Ogre and other dependencies in /usr/local/lib
@@ -79,9 +72,5 @@
settings. It also installs libOIS to ~/libs
Mac/
-
- XCode-1.5/
- Non-complete native OIS port.
-
XCode-2.2/
- Working, complete, OIS port to OSX using SDL as a backend.
\ No newline at end of file
+ Working, mostly complete OSX vackend.
\ No newline at end of file
Modified: code/branches/ois_update/src/external/ois/VERSION
===================================================================
--- code/branches/ois_update/src/external/ois/VERSION 2010-10-07 18:12:14 UTC (rev 7505)
+++ code/branches/ois_update/src/external/ois/VERSION 2010-10-07 18:21:33 UTC (rev 7506)
@@ -1,3 +1,2 @@
-OIS v1_2 CVS updated on 2009/01/24
-Note that this is not CVS HEAD, but v1_2 branch!
-
+OIS SVN trunk updated on 2010/10/07 (revision 26)
+https://wgois.svn.sourceforge.net/svnroot/wgois/ois/trunk/
Modified: code/branches/ois_update/src/external/ois/changes_orxonox.diff
===================================================================
--- code/branches/ois_update/src/external/ois/changes_orxonox.diff 2010-10-07 18:12:14 UTC (rev 7505)
+++ code/branches/ois_update/src/external/ois/changes_orxonox.diff 2010-10-07 18:21:33 UTC (rev 7506)
@@ -36,7 +36,7 @@
--- win32/Win32ForceFeedback.cpp
+++ win32/Win32ForceFeedback.cpp
@@ -25,7 +25,7 @@
- #include <Math.h>
+ #include <math.h>
// 0 = No trace; 1 = Important traces; 2 = Debug traces
-#define OIS_WIN32_JOYFF_DEBUG 1
Modified: code/branches/ois_update/src/external/ois/linux/LinuxInputManager.cpp
===================================================================
--- code/branches/ois_update/src/external/ois/linux/LinuxInputManager.cpp 2010-10-07 18:12:14 UTC (rev 7505)
+++ code/branches/ois_update/src/external/ois/linux/LinuxInputManager.cpp 2010-10-07 18:21:33 UTC (rev 7506)
@@ -39,7 +39,6 @@
grabKeyboard = true;
hideMouse = true;
mGrabs = true;
- useXRepeat = false;
keyboardUsed = mouseUsed = false;
//Setup our internal factories
@@ -73,11 +72,6 @@
window = strtoul(i->second.c_str(), 0, 10);
//--------- Keyboard Settings ------------//
- i = paramList.find("XAutoRepeatOn");
- if( i != paramList.end() )
- if( i->second == "true" )
- useXRepeat = true;
-
i = paramList.find("x11_keyboard_grab");
if( i != paramList.end() )
if( i->second == "false" )
@@ -171,7 +165,7 @@
case OISKeyboard:
{
if( keyboardUsed == false )
- obj = new LinuxKeyboard(this, bufferMode, grabKeyboard, useXRepeat);
+ obj = new LinuxKeyboard(this, bufferMode, grabKeyboard);
break;
}
case OISMouse:
Modified: code/branches/ois_update/src/external/ois/linux/LinuxInputManager.h
===================================================================
--- code/branches/ois_update/src/external/ois/linux/LinuxInputManager.h 2010-10-07 18:12:14 UTC (rev 7505)
+++ code/branches/ois_update/src/external/ois/linux/LinuxInputManager.h 2010-10-07 18:21:33 UTC (rev 7506)
@@ -100,9 +100,6 @@
bool grabMouse, grabKeyboard;
bool mGrabs;
bool hideMouse;
-
- //! By default, keyboard disables XRepeatRate
- bool useXRepeat;
};
}
#endif
Modified: code/branches/ois_update/src/external/ois/linux/LinuxJoyStickEvents.cpp
===================================================================
--- code/branches/ois_update/src/external/ois/linux/LinuxJoyStickEvents.cpp 2010-10-07 18:12:14 UTC (rev 7505)
+++ code/branches/ois_update/src/external/ois/linux/LinuxJoyStickEvents.cpp 2010-10-07 18:21:33 UTC (rev 7506)
@@ -95,107 +95,110 @@
//We are in non blocking mode - we just read once, and try to fill up buffer
input_event js[JOY_BUFFERSIZE];
- int ret = read(mJoyStick, &js, sizeof(struct input_event) * JOY_BUFFERSIZE);
- if( ret <= 0 )
- return;
-
- //Determine how many whole events re read up
- ret /= sizeof(struct input_event);
- for(int i = 0; i < ret; ++i)
+ while(true)
{
- switch(js[i].type)
- {
- case EV_KEY: //Button
- {
- int button = mButtonMap[js[i].code];
-
- #ifdef OIS_LINUX_JOY_DEBUG
- cout << "\nButton Code: " << js[i].code << ", OIS Value: " << button << endl;
- #endif
-
- //Check to see whether push or released event...
- if(js[i].value)
- {
- mState.mButtons[button] = true;
- if( mBuffered && mListener )
- if(!mListener->buttonPressed(JoyStickEvent(this,mState), button)) return;
- }
- else
- {
- mState.mButtons[button] = false;
- if( mBuffered && mListener )
- if(!mListener->buttonReleased(JoyStickEvent(this,mState), button)) return;
- }
+ int ret = read(mJoyStick, &js, sizeof(struct input_event) * JOY_BUFFERSIZE);
+ if( ret < 0 )
break;
- }
- case EV_ABS: //Absolute Axis
+ //Determine how many whole events re read up
+ ret /= sizeof(struct input_event);
+ for(int i = 0; i < ret; ++i)
{
- //A Stick (BrakeDefine is the highest possible Axis)
- if( js[i].code <= ABS_BRAKE )
+ switch(js[i].type)
{
- int axis = mAxisMap[js[i].code];
- assert( axis < 32 && "Too many axes (Max supported is 32). Report this to OIS forums!" );
+ case EV_KEY: //Button
+ {
+ int button = mButtonMap[js[i].code];
- axisMoved[axis] = true;
+ #ifdef OIS_LINUX_JOY_DEBUG
+ cout << "\nButton Code: " << js[i].code << ", OIS Value: " << button << endl;
+ #endif
- //check for rescaling:
- if( mRanges[axis].min == JoyStick::MIN_AXIS && mRanges[axis].max != JoyStick::MAX_AXIS )
- { //Scale is perfect
- mState.mAxes[axis].abs = js[i].value;
+ //Check to see whether push or released event...
+ if(js[i].value)
+ {
+ mState.mButtons[button] = true;
+ if( mBuffered && mListener )
+ if(!mListener->buttonPressed(JoyStickEvent(this,mState), button)) return;
}
else
- { //Rescale
- float proportion = (float)(js[i].value-mRanges[axis].max)/(float)(mRanges[axis].min-mRanges[axis].max);
- mState.mAxes[axis].abs = (int)(32767.0f - (65535.0f * proportion));
+ {
+ mState.mButtons[button] = false;
+ if( mBuffered && mListener )
+ if(!mListener->buttonReleased(JoyStickEvent(this,mState), button)) return;
}
+ break;
}
- else if( js[i].code <= ABS_HAT3Y ) //A POV - Max four POVs allowed
+
+ case EV_ABS: //Absolute Axis
{
- //Normalise the POV to between 0-7
- //Even is X Axis, Odd is Y Axis
- unsigned char LinuxPovNumber = js[i].code - 16;
- short OIS_POVIndex = POV_MASK[LinuxPovNumber];
+ //A Stick (BrakeDefine is the highest possible Axis)
+ if( js[i].code <= ABS_BRAKE )
+ {
+ int axis = mAxisMap[js[i].code];
+ assert( axis < 32 && "Too many axes (Max supported is 32). Report this to OIS forums!" );
- //Handle X Axis first (Even) (left right)
- if((LinuxPovNumber & 0x0001) == 0)
- {
- //Why do this? Because, we use a bit field, and when this axis is east,
- //it can't possibly be west too. So clear out the two X axes, then refil
- //it in with the new direction bit.
- //Clear the East/West Bit Flags first
- mState.mPOV[OIS_POVIndex].direction &= 0x11110011;
- if( js[i].value == -1 ) //Left
- mState.mPOV[OIS_POVIndex].direction |= Pov::West;
- else if( js[i].value == 1 ) //Right
- mState.mPOV[OIS_POVIndex].direction |= Pov::East;
+ axisMoved[axis] = true;
+
+ //check for rescaling:
+ if( mRanges[axis].min == JoyStick::MIN_AXIS && mRanges[axis].max != JoyStick::MAX_AXIS )
+ { //Scale is perfect
+ mState.mAxes[axis].abs = js[i].value;
+ }
+ else
+ { //Rescale
+ float proportion = (float)(js[i].value-mRanges[axis].max)/(float)(mRanges[axis].min-mRanges[axis].max);
+ mState.mAxes[axis].abs = (int)(32767.0f - (65535.0f * proportion));
+ }
}
- //Handle Y Axis (Odd) (up down)
- else
+ else if( js[i].code <= ABS_HAT3Y ) //A POV - Max four POVs allowed
{
- //Clear the North/South Bit Flags first
- mState.mPOV[OIS_POVIndex].direction &= 0x11111100;
- if( js[i].value == -1 ) //Up
- mState.mPOV[OIS_POVIndex].direction |= Pov::North;
- else if( js[i].value == 1 ) //Down
- mState.mPOV[OIS_POVIndex].direction |= Pov::South;
+ //Normalise the POV to between 0-7
+ //Even is X Axis, Odd is Y Axis
+ unsigned char LinuxPovNumber = js[i].code - 16;
+ short OIS_POVIndex = POV_MASK[LinuxPovNumber];
+
+ //Handle X Axis first (Even) (left right)
+ if((LinuxPovNumber & 0x0001) == 0)
+ {
+ //Why do this? Because, we use a bit field, and when this axis is east,
+ //it can't possibly be west too. So clear out the two X axes, then refil
+ //it in with the new direction bit.
+ //Clear the East/West Bit Flags first
+ mState.mPOV[OIS_POVIndex].direction &= 0x11110011;
+ if( js[i].value == -1 ) //Left
+ mState.mPOV[OIS_POVIndex].direction |= Pov::West;
+ else if( js[i].value == 1 ) //Right
+ mState.mPOV[OIS_POVIndex].direction |= Pov::East;
+ }
+ //Handle Y Axis (Odd) (up down)
+ else
+ {
+ //Clear the North/South Bit Flags first
+ mState.mPOV[OIS_POVIndex].direction &= 0x11111100;
+ if( js[i].value == -1 ) //Up
+ mState.mPOV[OIS_POVIndex].direction |= Pov::North;
+ else if( js[i].value == 1 ) //Down
+ mState.mPOV[OIS_POVIndex].direction |= Pov::South;
+ }
+
+ if( mBuffered && mListener )
+ if( mListener->povMoved( JoyStickEvent(this,mState), OIS_POVIndex) == false )
+ return;
}
+ break;
+ }
- if( mBuffered && mListener )
- if( mListener->povMoved( JoyStickEvent(this,mState), OIS_POVIndex) == false )
- return;
+
+ case EV_REL: //Relative Axes (Do any joystick actually have a relative axis?)
+ #ifdef OIS_LINUX_JOY_DEBUG
+ cout << "\nWarning: Relatives axes not supported yet" << endl;
+ #endif
+ break;
+ default: break;
}
- break;
}
-
-
- case EV_REL: //Relative Axes (Do any joystick actually have a relative axis?)
-#ifdef OIS_LINUX_JOY_DEBUG
- cout << "\nWarning: Relatives axes not supported yet" << endl;
-#endif
- break;
- default: break;
- }
}
//All axes and POVs are combined into one movement per pair per captured frame
Modified: code/branches/ois_update/src/external/ois/linux/LinuxKeyboard.cpp
===================================================================
--- code/branches/ois_update/src/external/ois/linux/LinuxKeyboard.cpp 2010-10-07 18:12:14 UTC (rev 7505)
+++ code/branches/ois_update/src/external/ois/linux/LinuxKeyboard.cpp 2010-10-07 18:21:33 UTC (rev 7506)
@@ -32,7 +32,7 @@
using namespace OIS;
#include <iostream>
//-------------------------------------------------------------------//
-LinuxKeyboard::LinuxKeyboard(InputManager* creator, bool buffered, bool grab, bool useXRepeat)
+LinuxKeyboard::LinuxKeyboard(InputManager* creator, bool buffered, bool grab)
: Keyboard(creator->inputSystemName(), buffered, 0, creator)
{
setlocale(LC_CTYPE, ""); //Set the locale to (hopefully) the users LANG UTF-8 Env var
@@ -43,9 +43,6 @@
grabKeyboard = grab;
keyFocusLost = false;
- xAutoRepeat = useXRepeat;
- oldXAutoRepeat = false;
-
//X Key Map to KeyCode
keyConversion.insert(XtoOIS_KeyMap::value_type(XK_1, KC_1));
keyConversion.insert(XtoOIS_KeyMap::value_type(XK_2, KC_2));
@@ -212,20 +209,6 @@
XGrabKeyboard(display,window,True,GrabModeAsync,GrabModeAsync,CurrentTime);
keyFocusLost = false;
-
- if( xAutoRepeat == false )
- {
- //We do not want to blindly turn on autorepeat later when quiting if
- //it was not on to begin with.. So, let us check and see first
- XKeyboardState old;
- XGetKeyboardControl( display, &old );
- oldXAutoRepeat = false;
-
- if( old.global_auto_repeat == AutoRepeatModeOn )
- oldXAutoRepeat = true;
-
- XAutoRepeatOff( display );
- }
}
//-------------------------------------------------------------------//
@@ -233,9 +216,6 @@
{
if( display )
{
- if( oldXAutoRepeat )
- XAutoRepeatOn(display);
-
if( grabKeyboard )
XUngrabKeyboard(display, CurrentTime);
@@ -302,11 +282,12 @@
LinuxInputManager* linMan = static_cast<LinuxInputManager*>(mCreator);
while( XPending(display) > 0 )
- { XNextEvent(display, &event); if( KeyPress == event.type )
+ {
+ XNextEvent(display, &event); if(KeyPress == event.type)
{
unsigned int character = 0;
- if( mTextMode != Off )
+ if(mTextMode != Off)
{
unsigned char buffer[6] = {0,0,0,0,0,0};
XLookupString(&event.xkey, (char*)buffer, 6, &key, 0);
@@ -331,15 +312,19 @@
//Check for Alt-Tab
if( event.xkey.state & Mod1Mask && key == XK_Tab )
linMan->_setGrabState(false);
- } else if( KeyRelease == event.type )
+ }
+ else if(KeyRelease == event.type)
{
- //Mask out the modifier states X sets.. or we will get improper values
- event.xkey.state &= ~ShiftMask;
- event.xkey.state &= ~LockMask;
+ if(!_isKeyRepeat(event))
+ {
+ //Mask out the modifier states X sets.. or we will get improper values
+ event.xkey.state &= ~ShiftMask;
+ event.xkey.state &= ~LockMask;
- //Else, it is a valid key release
- XLookupString(&event.xkey,NULL,0,&key,NULL);
- _injectKeyUp(key); }
+ XLookupString(&event.xkey,NULL,0,&key,NULL);
+ _injectKeyUp(key);
+ }
+ }
}
//If grabbing mode is on.. Handle focus lost/gained via Alt-Tab and mouse clicks
Modified: code/branches/ois_update/src/external/ois/linux/LinuxKeyboard.h
===================================================================
--- code/branches/ois_update/src/external/ois/linux/LinuxKeyboard.h 2010-10-07 18:12:14 UTC (rev 7505)
+++ code/branches/ois_update/src/external/ois/linux/LinuxKeyboard.h 2010-10-07 18:21:33 UTC (rev 7506)
@@ -33,7 +33,7 @@
class LinuxKeyboard : public Keyboard
{
public:
- LinuxKeyboard(InputManager* creator, bool buffered, bool grab, bool useXRepeat );
+ LinuxKeyboard(InputManager* creator, bool buffered, bool grab);
virtual ~LinuxKeyboard();
/** @copydoc Keyboard::isKeyDown */
@@ -58,6 +58,23 @@
virtual void _initialize();
protected:
+ inline bool _isKeyRepeat(XEvent &event)
+ {
+ //When a key is repeated, there will be two events: released, followed by another immediate pressed. So check to see if another pressed is present
+ if(!XPending(display))
+ return false;
+
+ XEvent e;
+ XPeekEvent(display, &e);
+ if(e.type == KeyPress && e.xkey.keycode == event.xkey.keycode && (e.xkey.time - event.xkey.time) < 2)
+ {
+ XNextEvent(display, &e);
+ return true;
+ }
+
+ return false;
+ }
+
bool _injectKeyDown( KeySym key, int text );
bool _injectKeyUp( KeySym key );
@@ -74,9 +91,6 @@
bool grabKeyboard;
bool keyFocusLost;
- bool xAutoRepeat;
- bool oldXAutoRepeat;
-
std::string mGetString;
};
}
Modified: code/branches/ois_update/src/external/ois/linux/LinuxMouse.cpp
===================================================================
--- code/branches/ois_update/src/external/ois/linux/LinuxMouse.cpp 2010-10-07 18:12:14 UTC (rev 7505)
+++ code/branches/ois_update/src/external/ois/linux/LinuxMouse.cpp 2010-10-07 18:21:33 UTC (rev 7506)
@@ -172,15 +172,17 @@
}
//Compute this frames Relative X & Y motion
- mState.X.rel = event.xmotion.x - oldXMouseX;
- mState.Y.rel = event.xmotion.y - oldXMouseY;
+ int dx = event.xmotion.x - oldXMouseX;
+ int dy = event.xmotion.y - oldXMouseY;
//Store old values for next time to compute relative motion
oldXMouseX = event.xmotion.x;
oldXMouseY = event.xmotion.y;
- mState.X.abs += mState.X.rel;
- mState.Y.abs += mState.Y.rel;
+ mState.X.abs += dx;
+ mState.Y.abs += dy;
+ mState.X.rel += dx;
+ mState.Y.rel += dy;
//Check to see if we are grabbing the mouse to the window (requires clipping and warping)
if( grabMouse )
Modified: code/branches/ois_update/src/external/ois/linux/LinuxPrereqs.h
===================================================================
--- code/branches/ois_update/src/external/ois/linux/LinuxPrereqs.h 2010-10-07 18:12:14 UTC (rev 7505)
+++ code/branches/ois_update/src/external/ois/linux/LinuxPrereqs.h 2010-10-07 18:21:33 UTC (rev 7506)
@@ -31,7 +31,7 @@
#include "OISPrereqs.h"
//! Max number of elements to collect from buffered input
-#define JOY_BUFFERSIZE 10
+#define JOY_BUFFERSIZE 64
namespace OIS
{
Modified: code/branches/ois_update/src/external/ois/mac/MacHIDManager.cpp
===================================================================
--- code/branches/ois_update/src/external/ois/mac/MacHIDManager.cpp 2010-10-07 18:12:14 UTC (rev 7505)
+++ code/branches/ois_update/src/external/ois/mac/MacHIDManager.cpp 2010-10-07 18:21:33 UTC (rev 7506)
@@ -19,8 +19,9 @@
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
-*/
+ */
#include "mac/MacHIDManager.h"
+#include "mac/MacJoyStick.h"
#include "OISException.h"
#include "OISObject.h"
@@ -41,7 +42,7 @@
CFArrayRef getDictionaryItemAsRef(CFDictionaryRef dict, const char* keyName)
{
CFTypeRef temp = CFDictionaryGetValue(dict, OIS_CFString(keyName));
-
+
if(temp && CFGetTypeID(temp) == CFArrayGetTypeID())
return (CFArrayRef)temp;
else
@@ -52,7 +53,7 @@
CFStringRef getDictionaryItemAsRef(CFDictionaryRef dict, const char* keyName)
{
CFTypeRef temp = CFDictionaryGetValue(dict, OIS_CFString(keyName));
-
+
if(temp && CFGetTypeID(temp) == CFStringGetTypeID())
return (CFStringRef)temp;
else
@@ -63,7 +64,7 @@
CFNumberRef getDictionaryItemAsRef(CFDictionaryRef dict, const char* keyName)
{
CFTypeRef temp = CFDictionaryGetValue(dict, OIS_CFString(keyName));
-
+
if(temp && CFGetTypeID(temp) == CFNumberGetTypeID())
return (CFNumberRef)temp;
else
@@ -82,7 +83,7 @@
CFDictionaryRef getArrayItemAsRef(CFArrayRef array, CFIndex idx)
{
CFTypeRef temp = CFArrayGetValueAtIndex(array, idx);
-
+
if(temp && CFGetTypeID(temp) == CFDictionaryGetTypeID())
return (CFDictionaryRef)temp;
else
@@ -92,10 +93,10 @@
//------------------------------------------------------------------------------------------------------//
int getInt32(CFNumberRef ref)
{
- int r = 0;
- if (r)
- CFNumberGetValue(ref, kCFNumberIntType, &r);
- return r;
+ int r = 0;
+ if (r)
+ CFNumberGetValue(ref, kCFNumberIntType, &r);
+ return r;
}
//--------------------------------------------------------------------------------//
@@ -111,70 +112,97 @@
//------------------------------------------------------------------------------------------------------//
void MacHIDManager::initialize()
{
+ //Make the search more specific by adding usage flags
+ int usage = kHIDUsage_GD_Joystick;
+ int page = kHIDPage_GenericDesktop;
+
+ io_iterator_t iterator = lookUpDevices(usage, page);
+
+ if(iterator)
+ iterateAndOpenDevices(iterator);
+
+ //Doesn't support multiple usage flags, iterate twice
+ usage = kHIDUsage_GD_GamePad;
+ iterator = lookUpDevices(usage, page);
+
+ if(iterator)
+ iterateAndOpenDevices(iterator);
+}
+
+//------------------------------------------------------------------------------------------------------//
+io_iterator_t MacHIDManager::lookUpDevices(int usage, int page)
+{
CFMutableDictionaryRef deviceLookupMap = IOServiceMatching(kIOHIDDeviceKey);
if(!deviceLookupMap)
OIS_EXCEPT(E_General, "Could not setup HID device search parameters");
-
- //Make the search more specific by adding usage flags
- int usage = kHIDUsage_GD_GamePad | kHIDUsage_GD_Joystick,
- page = kHIDPage_GenericDesktop;
-
- CFNumberRef usageRef = CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &usage),
- pageRef = CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &page);
-
+
+ CFNumberRef usageRef = CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &usage);
+ CFNumberRef pageRef = CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &page);
+
CFDictionarySetValue(deviceLookupMap, CFSTR(kIOHIDPrimaryUsageKey), usageRef);
CFDictionarySetValue(deviceLookupMap, CFSTR(kIOHIDPrimaryUsagePageKey), pageRef);
-
+
//IOServiceGetMatchingServices consumes the map so we do not have to release it ourself
io_iterator_t iterator = 0;
IOReturn result = IOServiceGetMatchingServices(kIOMasterPortDefault, deviceLookupMap, &iterator);
- if (result == kIOReturnSuccess && iterator)
+
+ CFRelease(usageRef);
+ CFRelease(pageRef);
+
+ if(result == kIOReturnSuccess)
{
- io_object_t hidDevice = 0;
- while ((hidDevice = IOIteratorNext(iterator)) !=0)
+ return iterator;
+ }
+ //TODO: Throw exception instead?
+ else
+ {
+ return 0;
+ }
+}
+
+//------------------------------------------------------------------------------------------------------//
+void MacHIDManager::iterateAndOpenDevices(io_iterator_t iterator)
+{
+ io_object_t hidDevice = 0;
+ while ((hidDevice = IOIteratorNext(iterator)) !=0)
+ {
+ //Get the current registry items property map
+ CFMutableDictionaryRef propertyMap = 0;
+ if (IORegistryEntryCreateCFProperties(hidDevice, &propertyMap, kCFAllocatorDefault, kNilOptions) == KERN_SUCCESS && propertyMap)
{
- //Get the current registry items property map
- CFMutableDictionaryRef propertyMap = 0;
- if (IORegistryEntryCreateCFProperties(hidDevice, &propertyMap, kCFAllocatorDefault, kNilOptions) == KERN_SUCCESS && propertyMap)
+ //Go through device to find all needed info
+ HidInfo* hid = enumerateDeviceProperties(propertyMap);
+
+ if(hid)
{
- //Go through device to find all needed info
- HidInfo* hid = enumerateDeviceProperties(propertyMap);
- if(hid)
- mDeviceList.push_back(hid);
-
//todo - we need to hold an open interface so we do not have to enumerate again later
//should be able to watch for device removals also
-
- /// Testing opening / closing interface
- //IOCFPlugInInterface **pluginInterface = NULL;
- //SInt32 score = 0;
- //if (IOCreatePlugInInterfaceForService(hidDevice, kIOHIDDeviceUserClientTypeID, kIOCFPlugInInterfaceID, &pluginInterface, &score) == kIOReturnSuccess)
- //{
- // IOHIDDeviceInterface **interface;
- // HRESULT pluginResult = (*pluginInterface)->QueryInterface(pluginInterface, CFUUIDGetUUIDBytes(kIOHIDDeviceInterfaceID), (void **)&(interface));
- // if(pluginResult == S_OK)
- // cout << "Successfully created plugin interface for device\n";
- // else
- // cout << "Not able to create plugin interface\n";
-
- // IODestroyPlugInInterface(pluginInterface);
-
- // if ((*interface)->open(interface, 0) == KERN_SUCCESS)
- // cout << "Opened interface.\n";
- // else
- // cout << "Failed to open\n";
-
- // (*interface)->close(interface);
- //}
- //
+
+ // Testing opening / closing interface
+ IOCFPlugInInterface **pluginInterface = NULL;
+ SInt32 score = 0;
+ if (IOCreatePlugInInterfaceForService(hidDevice, kIOHIDDeviceUserClientTypeID, kIOCFPlugInInterfaceID, &pluginInterface, &score) == kIOReturnSuccess)
+ {
+ IOHIDDeviceInterface **interface;
+
+ HRESULT pluginResult = (*pluginInterface)->QueryInterface(pluginInterface, CFUUIDGetUUIDBytes(kIOHIDDeviceInterfaceID), (void **)&(interface));
+
+ if(pluginResult != S_OK)
+ OIS_EXCEPT(E_General, "Not able to create plugin interface");
+
+ IODestroyPlugInInterface(pluginInterface);
+
+ hid->interface = interface;
+
+ //Check for duplicates - some devices have multiple usage
+ if(std::find(mDeviceList.begin(), mDeviceList.end(), hid) == mDeviceList.end())
+ mDeviceList.push_back(hid);
+ }
}
}
-
- IOObjectRelease(iterator);
}
-
- CFRelease(usageRef);
- CFRelease(pageRef);
+
+ IOObjectRelease(iterator);
}
//------------------------------------------------------------------------------------------------------//
@@ -187,19 +215,19 @@
CFStringRef str = getDictionaryItemAsRef<CFStringRef>(propertyMap, kIOHIDManufacturerKey);
if (str)
info->vendor = CFStringGetCStringPtr(str, CFStringGetSystemEncoding());
-
+
str = getDictionaryItemAsRef<CFStringRef>(propertyMap, kIOHIDProductKey);
if (str)
info->productKey = CFStringGetCStringPtr(str, CFStringGetSystemEncoding());
-
+
info->combinedKey = info->vendor + " " + info->productKey;
-
+
//Go through all items in this device (i.e. buttons, hats, sticks, axes, etc)
CFArrayRef array = getDictionaryItemAsRef<CFArrayRef>(propertyMap, kIOHIDElementKey);
if (array)
for (int i = 0; i < CFArrayGetCount(array); i++)
parseDeviceProperties(getArrayItemAsRef<CFDictionaryRef>(array, i));
-
+
return info;
}
@@ -208,7 +236,7 @@
{
if(!properties)
return;
-
+
CFArrayRef array = getDictionaryItemAsRef<CFArrayRef>(properties, kIOHIDElementKey);
if (array)
{
@@ -226,34 +254,34 @@
{
switch(getInt32(getDictionaryItemAsRef<CFNumberRef>(element, kIOHIDElementUsagePageKey)))
{
- case kHIDPage_GenericDesktop:
- switch(getInt32(getDictionaryItemAsRef<CFNumberRef>(element, kIOHIDElementUsageKey)))
+ case kHIDPage_GenericDesktop:
+ switch(getInt32(getDictionaryItemAsRef<CFNumberRef>(element, kIOHIDElementUsageKey)))
{
- case kHIDUsage_GD_Pointer:
- cout << "\tkHIDUsage_GD_Pointer\n";
- parseDevicePropertiesGroup(element);
+ case kHIDUsage_GD_Pointer:
+ cout << "\tkHIDUsage_GD_Pointer\n";
+ parseDevicePropertiesGroup(element);
+ break;
+ case kHIDUsage_GD_X:
+ case kHIDUsage_GD_Y:
+ case kHIDUsage_GD_Z:
+ case kHIDUsage_GD_Rx:
+ case kHIDUsage_GD_Ry:
+ case kHIDUsage_GD_Rz:
+ cout << "\tAxis\n";
+ break;
+ case kHIDUsage_GD_Slider:
+ case kHIDUsage_GD_Dial:
+ case kHIDUsage_GD_Wheel:
+ cout << "\tUnsupported kHIDUsage_GD_Wheel\n";
+ break;
+ case kHIDUsage_GD_Hatswitch:
+ cout << "\tUnsupported - kHIDUsage_GD_Hatswitch\n";
+ break;
+ }
break;
- case kHIDUsage_GD_X:
- case kHIDUsage_GD_Y:
- case kHIDUsage_GD_Z:
- case kHIDUsage_GD_Rx:
- case kHIDUsage_GD_Ry:
- case kHIDUsage_GD_Rz:
- cout << "\tAxis\n";
+ case kHIDPage_Button:
+ cout << "\tkHIDPage_Button\n";
break;
- case kHIDUsage_GD_Slider:
- case kHIDUsage_GD_Dial:
- case kHIDUsage_GD_Wheel:
- cout << "\tUnsupported kHIDUsage_GD_Wheel\n";
- break;
- case kHIDUsage_GD_Hatswitch:
- cout << "\tUnsupported - kHIDUsage_GD_Hatswitch\n";
- break;
- }
- break;
- case kHIDPage_Button:
- cout << "\tkHIDPage_Button\n";
- break;
}
}
}
@@ -266,7 +294,7 @@
{
if(!properties)
return;
-
+
CFArrayRef array = getDictionaryItemAsRef<CFArrayRef>(properties, kIOHIDElementKey);
if(array)
{
@@ -277,29 +305,29 @@
{
switch(getInt32(getDictionaryItemAsRef<CFNumberRef>(element, kIOHIDElementUsagePageKey)))
{
- case kHIDPage_GenericDesktop:
- switch(getInt32(getDictionaryItemAsRef<CFNumberRef>(element, kIOHIDElementUsageKey)))
+ case kHIDPage_GenericDesktop:
+ switch(getInt32(getDictionaryItemAsRef<CFNumberRef>(element, kIOHIDElementUsageKey)))
{
- case kHIDUsage_GD_X:
- case kHIDUsage_GD_Y:
- case kHIDUsage_GD_Z:
- case kHIDUsage_GD_Rx:
- case kHIDUsage_GD_Ry:
- case kHIDUsage_GD_Rz:
- cout << "\t\tAxis\n";
+ case kHIDUsage_GD_X:
+ case kHIDUsage_GD_Y:
+ case kHIDUsage_GD_Z:
+ case kHIDUsage_GD_Rx:
+ case kHIDUsage_GD_Ry:
+ case kHIDUsage_GD_Rz:
+ cout << "\t\tAxis\n";
+ break;
+ case kHIDUsage_GD_Slider:
+ case kHIDUsage_GD_Dial:
+ case kHIDUsage_GD_Wheel:
+ cout << "\tUnsupported - kHIDUsage_GD_Wheel\n";
+ break;
+ case kHIDUsage_GD_Hatswitch:
+ cout << "\tUnsupported - kHIDUsage_GD_Hatswitch\n";
+ break;
+ }
break;
- case kHIDUsage_GD_Slider:
- case kHIDUsage_GD_Dial:
- case kHIDUsage_GD_Wheel:
- cout << "\tUnsupported - kHIDUsage_GD_Wheel\n";
+ case kHIDPage_Button:
break;
- case kHIDUsage_GD_Hatswitch:
- cout << "\tUnsupported - kHIDUsage_GD_Hatswitch\n";
- break;
- }
- break;
- case kHIDPage_Button:
- break;
}
}
}
@@ -316,7 +344,7 @@
if((*it)->inUse == false)
ret.insert(std::make_pair((*it)->type, (*it)->combinedKey));
}
-
+
return ret;
}
@@ -325,7 +353,7 @@
{
int ret = 0;
HidInfoList::iterator it = mDeviceList.begin(), end = mDeviceList.end();
-
+
for(; it != end; ++it)
{
if((*it)->type == iType)
@@ -340,13 +368,13 @@
{
int ret = 0;
HidInfoList::iterator it = mDeviceList.begin(), end = mDeviceList.end();
-
+
for(; it != end; ++it)
{
if((*it)->inUse == false && (*it)->type == iType)
ret++;
}
-
+
return ret;
}
@@ -354,7 +382,7 @@
bool MacHIDManager::vendorExist(Type iType, const std::string & vendor)
{
HidInfoList::iterator it = mDeviceList.begin(), end = mDeviceList.end();
-
+
for(; it != end; ++it)
{
if((*it)->type == iType && (*it)->combinedKey == vendor)
@@ -366,22 +394,34 @@
//--------------------------------------------------------------------------------//
Object* MacHIDManager::createObject(InputManager* creator, Type iType, bool bufferMode,
- const std::string & vendor)
+ const std::string & vendor)
{
Object *obj = 0;
-
+
HidInfoList::iterator it = mDeviceList.begin(), end = mDeviceList.end();
for(; it != end; ++it)
{
if((*it)->inUse == false && (*it)->type == iType && (vendor == "" || (*it)->combinedKey == vendor))
{
- //create device
+ switch(iType)
+ {
+ case OISJoyStick:
+ int totalDevs = totalDevices(iType);
+ int freeDevs = freeDevices(iType);
+ int devID = totalDevs - freeDevs;
+
+ obj = new MacJoyStick((*it)->combinedKey, bufferMode, *it, creator, devID);
+ (*it)->inUse = true;
+ return obj;
+ case OISTablet:
+ //Create MacTablet
+ break;
+ default:
+ break;
+ }
}
}
-
- if( obj == 0 )
- OIS_EXCEPT(E_InputDeviceNonExistant, "No devices match requested type.");
-
+
return obj;
}
Modified: code/branches/ois_update/src/external/ois/mac/MacHIDManager.h
===================================================================
--- code/branches/ois_update/src/external/ois/mac/MacHIDManager.h 2010-10-07 18:12:14 UTC (rev 7505)
+++ code/branches/ois_update/src/external/ois/mac/MacHIDManager.h 2010-10-07 18:21:33 UTC (rev 7506)
@@ -69,6 +69,9 @@
~MacHIDManager();
void initialize();
+
+ void iterateAndOpenDevices(io_iterator_t iterator);
+ io_iterator_t lookUpDevices(int usage, int page);
//FactoryCreator Overrides
/** @copydoc FactoryCreator::deviceList */
Modified: code/branches/ois_update/src/external/ois/mac/MacInputManager.cpp
===================================================================
--- code/branches/ois_update/src/external/ois/mac/MacInputManager.cpp 2010-10-07 18:12:14 UTC (rev 7505)
+++ code/branches/ois_update/src/external/ois/mac/MacInputManager.cpp 2010-10-07 18:21:33 UTC (rev 7506)
@@ -187,8 +187,11 @@
break;
}
default:
+ {
+ obj = mHIDManager->createObject(creator, iType, bufferMode, vendor);
break;
}
+ }
if( obj == 0 )
OIS_EXCEPT(E_InputDeviceNonExistant, "No devices match requested type.");
Added: code/branches/ois_update/src/external/ois/mac/MacJoyStick.cpp
===================================================================
--- code/branches/ois_update/src/external/ois/mac/MacJoyStick.cpp (rev 0)
+++ code/branches/ois_update/src/external/ois/mac/MacJoyStick.cpp 2010-10-07 18:21:33 UTC (rev 7506)
@@ -0,0 +1,325 @@
+/*
+ The zlib/libpng License
+
+ Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
+
+ This software is provided 'as-is', without any express or implied warranty. In no event will
+ the authors be held liable for any damages arising from the use of this software.
+
+ Permission is granted to anyone to use this software for any purpose, including commercial
+ applications, and to alter it and redistribute it freely, subject to the following
+ restrictions:
+
+ 1. The origin of this software must not be misrepresented; you must not claim that
+ you wrote the original software. If you use this software in a product,
+ an acknowledgment in the product documentation would be appreciated but is
+ not required.
+
+ 2. Altered source versions must be plainly marked as such, and must not be
+ misrepresented as being the original software.
+
+ 3. This notice may not be removed or altered from any source distribution.
+ */
+
+#include "mac/MacJoyStick.h"
+#include "mac/MacHIDManager.h"
+#include "mac/MacInputManager.h"
+#include "OISEvents.h"
+#include "OISException.h"
+
+#include <cassert>
+
+using namespace OIS;
+
+//--------------------------------------------------------------------------------------------------//
+MacJoyStick::MacJoyStick(const std::string &vendor, bool buffered, HidInfo* info, InputManager* creator, int devID) :
+JoyStick(vendor, buffered, devID, creator), mInfo(info)
+{
+
+}
+
+//--------------------------------------------------------------------------------------------------//
+MacJoyStick::~MacJoyStick()
+{
+ //TODO: check if the queue has been started first?
+ //(*mQueue)->stop(mQueue);
+ (*mQueue)->dispose(mQueue);
+ (*mQueue)->Release(mQueue);
+
+
+ //TODO: check if the interface has been opened first?
+ (*mInfo->interface)->close(mInfo->interface);
+ (*mInfo->interface)->Release(mInfo->interface);
+}
+
+//--------------------------------------------------------------------------------------------------//
+void MacJoyStick::_initialize()
+{
+ assert(mInfo && "Given HidInfo invalid");
+ assert(mInfo->interface && "Joystick interface invalid");
+
+ //TODO: Is this necessary?
+ //Clear old state
+ mState.mAxes.clear();
+
+ if ((*mInfo->interface)->open(mInfo->interface, 0) != KERN_SUCCESS)
+ OIS_EXCEPT(E_General, "MacJoyStick::_initialize() >> Could not initialize joy device!");
+
+ mState.clear();
+
+ _enumerateCookies();
+
+ mState.mButtons.resize(mInfo->numButtons);
+ mState.mAxes.resize(mInfo->numAxes);
+
+ mQueue = _createQueue();
+}
+
+class FindAxisCookie : public std::unary_function<std::pair<IOHIDElementCookie, AxisInfo>&, bool>
+{
+public:
+ FindAxisCookie(IOHIDElementCookie cookie) : m_Cookie(cookie) {}
+ bool operator()(const std::pair<IOHIDElementCookie, AxisInfo>& pair) const
+ {
+ return pair.first == m_Cookie;
+ }
+private:
+ IOHIDElementCookie m_Cookie;
+};
+
+//--------------------------------------------------------------------------------------------------//
+void MacJoyStick::capture()
+{
+ assert(mQueue && "Queue must be initialized before calling MacJoyStick::capture()");
+
+ AbsoluteTime zeroTime = {0,0};
+
+ IOHIDEventStruct event;
+ IOReturn result = (*mQueue)->getNextEvent(mQueue, &event, zeroTime, 0);
+ while(result == kIOReturnSuccess)
+ {
+ switch(event.type)
+ {
+ case kIOHIDElementTypeInput_Button:
+ {
+ std::vector<IOHIDElementCookie>::iterator buttonIt = std::find(mCookies.buttonCookies.begin(), mCookies.buttonCookies.end(), event.elementCookie);
+ int button = std::distance(mCookies.buttonCookies.begin(), buttonIt);
+ mState.mButtons[button] = (event.value == 1);
+
+ if(mBuffered && mListener)
+ {
+ if(event.value == 0)
+ mListener->buttonPressed(JoyStickEvent(this, mState), button);
+ else if(event.value == 1)
+ mListener->buttonReleased(JoyStickEvent(this, mState), button);
+ }
+ break;
+ }
+ case kIOHIDElementTypeInput_Misc:
+ //TODO: It's an axis! - kind of - for gamepads - or should this be a pov?
+ case kIOHIDElementTypeInput_Axis:
+ std::map<IOHIDElementCookie, AxisInfo>::iterator axisIt = std::find_if(mCookies.axisCookies.begin(), mCookies.axisCookies.end(), FindAxisCookie(event.elementCookie));
+ int axis = std::distance(mCookies.axisCookies.begin(), axisIt);
+
+ //Copied from LinuxJoyStickEvents.cpp, line 149
+ const AxisInfo& axisInfo = axisIt->second;
+ float proportion = (float) (event.value - axisInfo.max) / (float) (axisInfo.min - axisInfo.max);
+ mState.mAxes[axis].abs = -JoyStick::MIN_AXIS - (JoyStick::MAX_AXIS * 2 * proportion);
+
+ if(mBuffered && mListener) mListener->axisMoved(JoyStickEvent(this, mState), axis);
+ break;
+ }
+
+ result = (*mQueue)->getNextEvent(mQueue, &event, zeroTime, 0);
+ }
+}
+
+//--------------------------------------------------------------------------------------------------//
+void MacJoyStick::setBuffered(bool buffered)
+{
+ mBuffered = buffered;
+}
+
+//--------------------------------------------------------------------------------------------------//
+Interface* MacJoyStick::queryInterface(Interface::IType type)
+{
+ //Thought about using covariant return type here.. however,
+ //some devices may allow LED light changing, or other interface stuff
+
+ //f( ff_device && type == Interface::ForceFeedback )
+ //return ff_device;
+ //else
+ return 0;
+}
+
+//--------------------------------------------------------------------------------------------------//
+void MacJoyStick::_enumerateCookies()
+{
+ assert(mInfo && "Given HidInfo invalid");
+ assert(mInfo->interface && "Joystick interface invalid");
+
+ CFTypeRef object;
+ long number;
+ IOHIDElementCookie cookie;
+ long usage;
+ long usagePage;
+ int min;
+ int max;
+
+ CFDictionaryRef element;
+
+ // Copy all elements, since we're grabbing most of the elements
+ // for this device anyway, and thus, it's faster to iterate them
+ // ourselves. When grabbing only one or two elements, a matching
+ // dictionary should be passed in here instead of NULL.
+ CFArrayRef elements;
+ IOReturn success = reinterpret_cast<IOHIDDeviceInterface122*>(*mInfo->interface)->copyMatchingElements(mInfo->interface, NULL, &elements);
+
+ if (success == kIOReturnSuccess)
+ {
+ const CFIndex numOfElements = CFArrayGetCount(elements);
+ for (CFIndex i = 0; i < numOfElements; ++i)
+ {
+ element = static_cast<CFDictionaryRef>(CFArrayGetValueAtIndex(elements, i));
+
+ //Get cookie
+ object = (CFDictionaryGetValue(element,
+ CFSTR(kIOHIDElementCookieKey)));
+ if (object == 0 || CFGetTypeID(object) != CFNumberGetTypeID())
+ continue;
+ if(!CFNumberGetValue((CFNumberRef) object, kCFNumberLongType,
+ &number))
+ continue;
+ cookie = (IOHIDElementCookie) number;
+
+ //Get usage
+ object = CFDictionaryGetValue(element,
+ CFSTR(kIOHIDElementUsageKey));
+ if (object == 0 || CFGetTypeID(object) != CFNumberGetTypeID())
+ continue;
+ if (!CFNumberGetValue((CFNumberRef) object, kCFNumberLongType,
+ &number))
+ continue;
+ usage = number;
+
+ //Get min
+ object = CFDictionaryGetValue(element,
+ CFSTR(kIOHIDElementMinKey)); // kIOHIDElementMinKey or kIOHIDElementScaledMinKey?, no idea ...
+ if (object == 0 || CFGetTypeID(object) != CFNumberGetTypeID())
+ continue;
+ if (!CFNumberGetValue((CFNumberRef) object, kCFNumberIntType,
+ &number))
+ continue;
+ min = number;
+
+ //Get max
+ object = CFDictionaryGetValue(element,
+ CFSTR(kIOHIDElementMaxKey)); // kIOHIDElementMaxKey or kIOHIDElementScaledMaxKey?, no idea ...
+ if (object == 0 || CFGetTypeID(object) != CFNumberGetTypeID())
+ continue;
+ if (!CFNumberGetValue((CFNumberRef) object, kCFNumberIntType,
+ &number))
+ continue;
+ max = number;
+
+ //Get usage page
+ object = CFDictionaryGetValue(element,
+ CFSTR(kIOHIDElementUsagePageKey));
+
+ if (object == 0 || CFGetTypeID(object) != CFNumberGetTypeID())
+ continue;
+
+ if (!CFNumberGetValue((CFNumberRef) object, kCFNumberLongType,
+ &number))
+ continue;
+
+ usagePage = number;
+ switch(usagePage)
+ {
+ case kHIDPage_GenericDesktop:
+ switch(usage)
+ {
+ case kHIDUsage_GD_Pointer:
+ break;
+ case kHIDUsage_GD_X:
+ case kHIDUsage_GD_Y:
+ case kHIDUsage_GD_Z:
+ case kHIDUsage_GD_Rx:
+ case kHIDUsage_GD_Ry:
+ case kHIDUsage_GD_Rz:
+ mCookies.axisCookies.insert(std::make_pair(cookie, AxisInfo(min, max)));
+ break;
+ case kHIDUsage_GD_Slider:
+ case kHIDUsage_GD_Dial:
+ case kHIDUsage_GD_Wheel:
+ break;
+ case kHIDUsage_GD_Hatswitch:
+ break;
+ }
+ break;
+ case kHIDPage_Button:
+ mCookies.buttonCookies.push_back(cookie);
+ break;
+ }
+ }
+
+ mInfo->numButtons = mCookies.buttonCookies.size();
+ mInfo->numAxes = mCookies.axisCookies.size();
+
+ }
+ else
+ {
+ OIS_EXCEPT(E_General, "JoyStick elements could not be copied: copyMatchingElements failed with error: " + success);
+ }
+
+}
+
+//--------------------------------------------------------------------------------------------------//
+IOHIDQueueInterface** MacJoyStick::_createQueue(unsigned int depth)
+{
+ assert(mInfo && "Given HidInfo invalid");
+ assert(mInfo->interface && "Joystick interface invalid");
+
+ IOHIDQueueInterface** queue = (*mInfo->interface)->allocQueue(mInfo->interface);
+
+ if (queue)
+ {
+ //create the queue
+ IOReturn result = (*queue)->create(queue, 0, depth);
+
+ if(result == kIOReturnSuccess)
+ {
+ //add elements to the queue
+ std::map<IOHIDElementCookie, AxisInfo>::iterator axisIt = mCookies.axisCookies.begin();
+ for(; axisIt != mCookies.axisCookies.end(); ++axisIt)
+ {
+ result = (*queue)->addElement(queue, axisIt->first, 0);
+ }
+
+ std::vector<IOHIDElementCookie>::iterator buttonIt = mCookies.buttonCookies.begin();
+ for(; buttonIt != mCookies.buttonCookies.end(); ++buttonIt)
+ {
+ result = (*queue)->addElement(queue, (*buttonIt), 0);
+ }
+
+ //start data delivery to queue
+ result = (*queue)->start(queue);
+ if(result == kIOReturnSuccess)
+ {
+ return queue;
+ }
+ else
+ {
+ OIS_EXCEPT(E_General, "Queue could not be started.");
+ }
+ }
+ else
+ {
+ OIS_EXCEPT(E_General, "Queue could not be created.");
+ }
+ }
+ else
+ {
+ OIS_EXCEPT(E_General, "Queue allocation failed.");
+ }
+}
Property changes on: code/branches/ois_update/src/external/ois/mac/MacJoyStick.cpp
___________________________________________________________________
Added: svn:eol-style
+ native
Added: code/branches/ois_update/src/external/ois/mac/MacJoyStick.h
===================================================================
--- code/branches/ois_update/src/external/ois/mac/MacJoyStick.h (rev 0)
+++ code/branches/ois_update/src/external/ois/mac/MacJoyStick.h 2010-10-07 18:21:33 UTC (rev 7506)
@@ -0,0 +1,76 @@
+/*
+ The zlib/libpng License
+
+ Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
+
+ This software is provided 'as-is', without any express or implied warranty. In no event will
+ the authors be held liable for any damages arising from the use of this software.
+
+ Permission is granted to anyone to use this software for any purpose, including commercial
+ applications, and to alter it and redistribute it freely, subject to the following
+ restrictions:
+
+ 1. The origin of this software must not be misrepresented; you must not claim that
+ you wrote the original software. If you use this software in a product,
+ an acknowledgment in the product documentation would be appreciated but is
+ not required.
+
+ 2. Altered source versions must be plainly marked as such, and must not be
+ misrepresented as being the original software.
+
+ 3. This notice may not be removed or altered from any source distribution.
+ */
+#ifndef MAC_Joystick_H
+#define MAC_Joystick_H
+#include "OISJoyStick.h"
+#include "mac/MacPrereqs.h"
+#include "mac/MacHIDManager.h"
+
+namespace OIS
+{
+ struct AxisInfo
+ {
+ int min;
+ int max;
+
+ AxisInfo(int min, int max)
+ : min(min), max(max) {}
+ };
+
+ typedef struct cookie_struct
+ {
+ std::map<IOHIDElementCookie, AxisInfo> axisCookies;
+ std::vector<IOHIDElementCookie> buttonCookies;
+ } cookie_struct_t;
+
+ //class HidDeviceInfo
+
+ class MacJoyStick : public JoyStick
+ {
+ public:
+ MacJoyStick(const std::string& vendor, bool buffered, HidInfo* info, InputManager* creator, int devID);
+
+ virtual ~MacJoyStick();
+
+ /** @copydoc Object::setBuffered */
+ virtual void setBuffered(bool buffered);
+
+ /** @copydoc Object::capture */
+ virtual void capture();
+
+ /** @copydoc Object::queryInterface */
+ virtual Interface* queryInterface(Interface::IType type);
+
+ /** @copydoc Object::_initialize */
+ virtual void _initialize();
+
+ void _enumerateCookies();
+
+ IOHIDQueueInterface** _createQueue(unsigned int depth = 8);
+ protected:
+ HidInfo* mInfo;
+ cookie_struct_t mCookies;
+ IOHIDQueueInterface** mQueue;
+ };
+}
+#endif
Property changes on: code/branches/ois_update/src/external/ois/mac/MacJoyStick.h
___________________________________________________________________
Added: svn:eol-style
+ native
Modified: code/branches/ois_update/src/external/ois/win32/Win32ForceFeedback.cpp
===================================================================
--- code/branches/ois_update/src/external/ois/win32/Win32ForceFeedback.cpp 2010-10-07 18:12:14 UTC (rev 7505)
+++ code/branches/ois_update/src/external/ois/win32/Win32ForceFeedback.cpp 2010-10-07 18:21:33 UTC (rev 7506)
@@ -20,9 +20,9 @@
3. This notice may not be removed or altered from any source distribution.
*/
-#include "Win32/Win32ForceFeedback.h"
+#include "win32/Win32ForceFeedback.h"
#include "OISException.h"
-#include <Math.h>
+#include <math.h>
// 0 = No trace; 1 = Important traces; 2 = Debug traces
#define OIS_WIN32_JOYFF_DEBUG 0
Modified: code/branches/ois_update/src/external/ois/win32/Win32ForceFeedback.h
===================================================================
--- code/branches/ois_update/src/external/ois/win32/Win32ForceFeedback.h 2010-10-07 18:12:14 UTC (rev 7505)
+++ code/branches/ois_update/src/external/ois/win32/Win32ForceFeedback.h 2010-10-07 18:21:33 UTC (rev 7506)
@@ -25,7 +25,7 @@
#include "OISPrereqs.h"
#include "OISForceFeedback.h"
-#include "Win32/Win32Prereqs.h"
+#include "win32/Win32Prereqs.h"
namespace OIS
{
Modified: code/branches/ois_update/src/external/ois/win32/Win32InputManager.cpp
===================================================================
--- code/branches/ois_update/src/external/ois/win32/Win32InputManager.cpp 2010-10-07 18:12:14 UTC (rev 7505)
+++ code/branches/ois_update/src/external/ois/win32/Win32InputManager.cpp 2010-10-07 18:21:33 UTC (rev 7506)
@@ -20,10 +20,10 @@
3. This notice may not be removed or altered from any source distribution.
*/
-#include "Win32/Win32InputManager.h"
-#include "Win32/Win32Keyboard.h"
-#include "Win32/Win32Mouse.h"
-#include "Win32/Win32JoyStick.h"
+#include "win32/Win32InputManager.h"
+#include "win32/Win32KeyBoard.h"
+#include "win32/Win32Mouse.h"
+#include "win32/Win32JoyStick.h"
#include "OISException.h"
using namespace OIS;
@@ -74,7 +74,7 @@
hInst = GetModuleHandle(0);
- //Create the input system
+ //Create the device
hr = DirectInput8Create( hInst, DIRECTINPUT_VERSION, IID_IDirectInput8, (VOID**)&mDirectInput, NULL );
if (FAILED(hr))
OIS_EXCEPT( E_General, "Win32InputManager::Win32InputManager >> Not able to init DirectX8 Input!");
@@ -117,7 +117,20 @@
void Win32InputManager::_enumerateDevices()
{
//Enumerate all attached devices
- mDirectInput->EnumDevices(NULL , _DIEnumDevCallback, this, DIEDFL_ATTACHEDONLY);
+ mDirectInput->EnumDevices(NULL, _DIEnumDevCallback, this, DIEDFL_ATTACHEDONLY);
+
+#ifdef OIS_WIN32_XINPUT_SUPPORT
+ //let's check how many possible XInput devices we may have (max 4)...
+ for(int i = 0; i < 3; ++i)
+ {
+ XINPUT_STATE state;
+ if(XInputGetState(i, &state) != ERROR_DEVICE_NOT_CONNECTED)
+ { //Once we found 1, just check our whole list against devices
+ Win32JoyStick::CheckXInputDevices(unusedJoyStickList);
+ break;
+ }
+ }
+#endif
}
//--------------------------------------------------------------------------------//
@@ -133,6 +146,8 @@
GET_DIDEVICE_TYPE(lpddi->dwDevType) == DI8DEVTYPE_FLIGHT)
{
JoyStickInfo jsInfo;
+ jsInfo.isXInput = false;
+ jsInfo.productGuid = lpddi->guidProduct;
jsInfo.deviceID = lpddi->guidInstance;
jsInfo.vendor = lpddi->tszInstanceName;
jsInfo.devId = _this_->joySticks;
Modified: code/branches/ois_update/src/external/ois/win32/Win32InputManager.h
===================================================================
--- code/branches/ois_update/src/external/ois/win32/Win32InputManager.h 2010-10-07 18:12:14 UTC (rev 7505)
+++ code/branches/ois_update/src/external/ois/win32/Win32InputManager.h 2010-10-07 18:21:33 UTC (rev 7506)
@@ -25,7 +25,7 @@
#include "OISInputManager.h"
#include "OISFactoryCreator.h"
-#include "Win32/Win32Prereqs.h"
+#include "win32/Win32Prereqs.h"
namespace OIS
{
Modified: code/branches/ois_update/src/external/ois/win32/Win32JoyStick.cpp
===================================================================
--- code/branches/ois_update/src/external/ois/win32/Win32JoyStick.cpp 2010-10-07 18:12:14 UTC (rev 7505)
+++ code/branches/ois_update/src/external/ois/win32/Win32JoyStick.cpp 2010-10-07 18:21:33 UTC (rev 7506)
@@ -20,14 +20,29 @@
3. This notice may not be removed or altered from any source distribution.
*/
-#include "Win32/Win32JoyStick.h"
-#include "Win32/Win32InputManager.h"
-#include "Win32/Win32ForceFeedback.h"
+#include "win32/Win32JoyStick.h"
+#include "win32/Win32InputManager.h"
+#include "win32/Win32ForceFeedback.h"
#include "OISEvents.h"
#include "OISException.h"
#include <cassert>
+#include <wbemidl.h>
+#include <oleauto.h>
+//#include <wmsstd.h>
+#ifndef SAFE_RELEASE
+#define SAFE_RELEASE(x) \
+ if(x != NULL) \
+ { \
+ x->Release(); \
+ x = NULL; \
+ }
+#endif
+#ifdef OIS_WIN32_XINPUT_SUPPORT
+# pragma comment(lib, "xinput.lib")
+#endif
+
//DX Only defines macros for the JOYSTICK not JOYSTICK2, so fix it
#undef DIJOFS_BUTTON
#undef DIJOFS_POV
@@ -39,26 +54,26 @@
#define DIJOFS_SLIDER2(n) (FIELD_OFFSET(DIJOYSTATE2, rglASlider)+(n) * sizeof(LONG))
#define DIJOFS_SLIDER3(n) (FIELD_OFFSET(DIJOYSTATE2, rglFSlider)+(n) * sizeof(LONG))
+#define XINPUT_TRANSLATED_BUTTON_COUNT 12
+#define XINPUT_TRANSLATED_AXIS_COUNT 6
+
using namespace OIS;
//--------------------------------------------------------------------------------------------------//
-Win32JoyStick::Win32JoyStick( InputManager* creator, IDirectInput8* pDI,
- bool buffered, DWORD coopSettings, const JoyStickInfo &info )
- : JoyStick(info.vendor, buffered, info.devId, creator)
+Win32JoyStick::Win32JoyStick( InputManager* creator, IDirectInput8* pDI, bool buffered, DWORD coopSettings, const JoyStickInfo &info ) :
+ JoyStick(info.vendor, buffered, info.devId, creator),
+ mDirectInput(pDI),
+ coopSetting(coopSettings),
+ mJoyStick(0),
+ mJoyInfo(info),
+ mFfDevice(0)
{
- mDirectInput = pDI;
- coopSetting = coopSettings;
- mJoyStick = 0;
-
- deviceGuid = info.deviceID;
-
- ff_device = 0;
}
//--------------------------------------------------------------------------------------------------//
Win32JoyStick::~Win32JoyStick()
{
- delete ff_device;
+ delete mFfDevice;
if(mJoyStick)
{
@@ -68,80 +83,86 @@
}
//Return joystick to pool
- JoyStickInfo js;
- js.deviceID = deviceGuid;
- js.devId = mDevID;
- js.vendor = mVendor;
- static_cast<Win32InputManager*>(mCreator)->_returnJoyStick(js);
+ static_cast<Win32InputManager*>(mCreator)->_returnJoyStick(mJoyInfo);
}
//--------------------------------------------------------------------------------------------------//
void Win32JoyStick::_initialize()
{
- //Clear old state
- mState.mAxes.clear();
+ if (mJoyInfo.isXInput)
+ {
+ _enumerate();
+ }
+ else
+ {
+ //Clear old state
+ mState.mAxes.clear();
- if (ff_device)
- {
- delete ff_device;
- ff_device = 0;
- }
+ delete mFfDevice;
+ mFfDevice = 0;
- // Create direct input joystick device.
- if(FAILED(mDirectInput->CreateDevice(deviceGuid, &mJoyStick, NULL)))
- OIS_EXCEPT( E_General, "Win32JoyStick::_initialize() >> Could not initialize joy device!");
+ DIPROPDWORD dipdw;
- // Set DIJoystick2 data format.
- if(FAILED(mJoyStick->SetDataFormat(&c_dfDIJoystick2)))
- OIS_EXCEPT( E_General, "Win32JoyStick::_initialize() >> data format error!");
+ dipdw.diph.dwSize = sizeof(DIPROPDWORD);
+ dipdw.diph.dwHeaderSize = sizeof(DIPROPHEADER);
+ dipdw.diph.dwObj = 0;
+ dipdw.diph.dwHow = DIPH_DEVICE;
+ dipdw.dwData = JOYSTICK_DX_BUFFERSIZE;
- // Set cooperative level as specified when creating input manager.
- HWND hwin = ((Win32InputManager*)mCreator)->getWindowHandle();
- if(FAILED(mJoyStick->SetCooperativeLevel( hwin, coopSetting)))
- OIS_EXCEPT( E_General, "Win32JoyStick::_initialize() >> failed to set cooperation level!");
+ if(FAILED(mDirectInput->CreateDevice(mJoyInfo.deviceID, &mJoyStick, NULL)))
+ OIS_EXCEPT( E_General, "Win32JoyStick::_initialize() >> Could not initialize joy device!");
- // Set buffer size.
- DIPROPDWORD dipdw;
- dipdw.diph.dwSize = sizeof(DIPROPDWORD);
- dipdw.diph.dwHeaderSize = sizeof(DIPROPHEADER);
- dipdw.diph.dwObj = 0;
- dipdw.diph.dwHow = DIPH_DEVICE;
- dipdw.dwData = JOYSTICK_DX_BUFFERSIZE;
+ if(FAILED(mJoyStick->SetDataFormat(&c_dfDIJoystick2)))
+ OIS_EXCEPT( E_General, "Win32JoyStick::_initialize() >> data format error!");
- if( FAILED(mJoyStick->SetProperty(DIPROP_BUFFERSIZE, &dipdw.diph)) )
- OIS_EXCEPT( E_General, "Win32JoyStick::_initialize >> Failed to set buffer size property" );
+ HWND hwin = ((Win32InputManager*)mCreator)->getWindowHandle();
- // Enumerate all axes/buttons/sliders/force feedback/etc before aquiring
- _enumerate();
+ if(FAILED(mJoyStick->SetCooperativeLevel( hwin, coopSetting)))
+ OIS_EXCEPT( E_General, "Win32JoyStick::_initialize() >> failed to set cooperation level!");
- mState.clear();
+ if( FAILED(mJoyStick->SetProperty(DIPROP_BUFFERSIZE, &dipdw.diph)) )
+ OIS_EXCEPT( E_General, "Win32Mouse::Win32Mouse >> Failed to set buffer size property" );
- capture();
+ //Enumerate all axes/buttons/sliders/etc before aquiring
+ _enumerate();
+
+ mState.clear();
+
+ capture();
+ }
}
//--------------------------------------------------------------------------------------------------//
void Win32JoyStick::_enumerate()
{
- // Get joystick capabilities.
- mDIJoyCaps.dwSize = sizeof(DIDEVCAPS);
- if( FAILED(mJoyStick->GetCapabilities(&mDIJoyCaps)) )
- OIS_EXCEPT( E_General, "Win32JoyStick::_enumerate >> Failed to get capabilities" );
+ if (mJoyInfo.isXInput)
+ {
+ mPOVs = 1;
- // => Number of POVs
- mPOVs = (short)mDIJoyCaps.dwPOVs;
+ mState.mButtons.resize(XINPUT_TRANSLATED_BUTTON_COUNT);
+ mState.mAxes.resize(XINPUT_TRANSLATED_AXIS_COUNT);
+ }
+ else
+ {
+ // Get joystick capabilities.
+ mDIJoyCaps.dwSize = sizeof(DIDEVCAPS);
+ if( FAILED(mJoyStick->GetCapabilities(&mDIJoyCaps)) )
+ OIS_EXCEPT( E_General, "Win32JoyStick::_enumerate >> Failed to get capabilities" );
- // => Number of buttons and axes.
- mState.mButtons.resize(mDIJoyCaps.dwButtons);
- mState.mAxes.resize(mDIJoyCaps.dwAxes);
+ mPOVs = (short)mDIJoyCaps.dwPOVs;
- // Enumerate all Force Feedback effects (if any)
- mJoyStick->EnumEffects(DIEnumEffectsCallback, this, DIEFT_ALL);
+ mState.mButtons.resize(mDIJoyCaps.dwButtons);
+ mState.mAxes.resize(mDIJoyCaps.dwAxes);
- //Reset the axis mapping enumeration value
- _AxisNumber = 0;
+ //Reset the axis mapping enumeration value
+ _AxisNumber = 0;
- // Enumerate and set axis constraints (and check FF Axes)
- mJoyStick->EnumObjects(DIEnumDeviceObjectsCallback, this, DIDFT_AXIS);
+ //Enumerate Force Feedback (if any)
+ mJoyStick->EnumEffects(DIEnumEffectsCallback, this, DIEFT_ALL);
+
+ //Enumerate and set axis constraints (and check FF Axes)
+ mJoyStick->EnumObjects(DIEnumDeviceObjectsCallback, this, DIDFT_AXIS);
+ }
}
//--------------------------------------------------------------------------------------------------//
@@ -190,19 +211,19 @@
//Check if FF Axes, and if so, increment counter
if((lpddoi->dwFlags & DIDOI_FFACTUATOR) != 0 )
{
- if( _this->ff_device )
+ if( _this->mFfDevice )
{
- _this->ff_device->_addFFAxis();
+ _this->mFfDevice->_addFFAxis();
}
}
//Force the flags for gain and auto-center support to true,
//as DInput has no API to query the device for these capabilities
//(the only way to know is to try them ...)
- if( _this->ff_device )
+ if( _this->mFfDevice )
{
- _this->ff_device->_setGainSupport(true);
- _this->ff_device->_setAutoCenterSupport(true);
+ _this->mFfDevice->_setGainSupport(true);
+ _this->mFfDevice->_setAutoCenterSupport(true);
}
return DIENUM_CONTINUE;
@@ -214,10 +235,10 @@
Win32JoyStick* _this = (Win32JoyStick*)pvRef;
//Create the FF instance only after we know there is at least one effect type
- if( _this->ff_device == 0 )
- _this->ff_device = new Win32ForceFeedback(_this->mJoyStick, &_this->mDIJoyCaps);
+ if( _this->mFfDevice == 0 )
+ _this->mFfDevice = new Win32ForceFeedback(_this->mJoyStick, &_this->mDIJoyCaps);
- _this->ff_device->_addEffectSupport( pdei );
+ _this->mFfDevice->_addEffectSupport(pdei);
return DIENUM_CONTINUE;
}
@@ -225,6 +246,16 @@
//--------------------------------------------------------------------------------------------------//
void Win32JoyStick::capture()
{
+#ifdef OIS_WIN32_XINPUT_SUPPORT
+ //handle xbox controller differently
+ if (mJoyInfo.isXInput)
+ {
+ captureXInput();
+ return;
+ }
+#endif
+
+ //handle directinput based devices
DIDEVICEOBJECTDATA diBuff[JOYSTICK_DX_BUFFERSIZE];
DWORD entries = JOYSTICK_DX_BUFFERSIZE;
@@ -240,7 +271,7 @@
hr = mJoyStick->Acquire();
// Poll the device to read the current state
- mJoyStick->Poll();
+ mJoyStick->Poll();
hr = mJoyStick->GetDeviceData( sizeof(DIDEVICEOBJECTDATA), diBuff, &entries, 0 );
//Perhaps the user just tabbed away
if( FAILED(hr) )
@@ -352,6 +383,118 @@
}
//--------------------------------------------------------------------------------------------------//
+void Win32JoyStick::captureXInput()
+{
+#ifdef OIS_WIN32_XINPUT_SUPPORT
+ XINPUT_STATE inputState;
+ if (XInputGetState((DWORD)mJoyInfo.xInputDev, &inputState) != ERROR_SUCCESS)
+ memset(&inputState, 0, sizeof(inputState));
+
+ //Sticks and triggers
+ int value;
+ bool axisMoved[XINPUT_TRANSLATED_AXIS_COUNT] = {false,false,false,false,false,false};
+
+ //LeftY
+ value = -(int)inputState.Gamepad.sThumbLY;
+ mState.mAxes[0].rel = value - mState.mAxes[0].abs;
+ mState.mAxes[0].abs = value;
+ if(mState.mAxes[0].rel != 0)
+ axisMoved[0] = true;
+
+ //LeftX
+ mState.mAxes[1].rel = inputState.Gamepad.sThumbLX - mState.mAxes[1].abs;
+ mState.mAxes[1].abs = inputState.Gamepad.sThumbLX;
+
+ if(mState.mAxes[1].rel != 0)
+ axisMoved[1] = true;
+
+ //RightY
+ value = -(int)inputState.Gamepad.sThumbRY;
+ mState.mAxes[2].rel = value - mState.mAxes[2].abs;
+ mState.mAxes[2].abs = value;
+ if(mState.mAxes[2].rel != 0)
+ axisMoved[2] = true;
+
+ //RightX
+ mState.mAxes[3].rel = inputState.Gamepad.sThumbRX - mState.mAxes[3].abs;
+ mState.mAxes[3].abs = inputState.Gamepad.sThumbRX;
+ if(mState.mAxes[3].rel != 0)
+ axisMoved[3] = true;
+
+ //Left trigger
+ value = inputState.Gamepad.bLeftTrigger * 129;
+ if(value > JoyStick::MAX_AXIS)
+ value = JoyStick::MAX_AXIS;
+
+ mState.mAxes[4].rel = value - mState.mAxes[4].abs;
+ mState.mAxes[4].abs = value;
+ if(mState.mAxes[4].rel != 0)
+ axisMoved[4] = true;
+
+ //Right trigger
+ value = (int)inputState.Gamepad.bRightTrigger * 129;
+ if(value > JoyStick::MAX_AXIS)
+ value = JoyStick::MAX_AXIS;
+
+ mState.mAxes[5].rel = value - mState.mAxes[5].abs;
+ mState.mAxes[5].abs = value;
+ if(mState.mAxes[5].rel != 0)
+ axisMoved[5] = true;
+
+ //POV
+ int previousPov = mState.mPOV[0].direction;
+ int& pov = mState.mPOV[0].direction;
+ pov = Pov::Centered;
+ if (inputState.Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_UP)
+ pov |= Pov::North;
+ else if (inputState.Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_DOWN)
+ pov |= Pov::South;
+ if (inputState.Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_LEFT)
+ pov |= Pov::West;
+ else if (inputState.Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_RIGHT)
+ pov |= Pov::East;
+
+ //Buttons - The first 4 buttons don't need to be checked since they represent the dpad
+ bool previousButtons[XINPUT_TRANSLATED_BUTTON_COUNT];
+ std::copy(mState.mButtons.begin(), mState.mButtons.end(), previousButtons);
+ for (size_t i = 0; i < XINPUT_TRANSLATED_BUTTON_COUNT; i++)
+ mState.mButtons[i] = (inputState.Gamepad.wButtons & (1 << (i + 4))) != 0;
+
+ //Send events
+ if (mBuffered && mListener)
+ {
+ JoyStickEvent joystickEvent(this, mState);
+
+ //Axes
+ for (int i = 0; i < XINPUT_TRANSLATED_AXIS_COUNT; i++)
+ {
+ if (axisMoved[i] && !mListener->axisMoved(joystickEvent, i))
+ return;
+ }
+
+ //POV
+ if (previousPov != pov && !mListener->povMoved(joystickEvent, 0))
+ return;
+
+ //Buttons
+ for (int i = 0; i < XINPUT_TRANSLATED_BUTTON_COUNT; i++)
+ {
+ if (!previousButtons[i] && mState.mButtons[i])
+ {
+ if (!mListener->buttonPressed(joystickEvent, i))
+ return;
+ }
+ else if (previousButtons[i] && !mState.mButtons[i])
+ {
+ if (!mListener->buttonReleased(joystickEvent, i))
+ return;
+ }
+ }
+ }
+#endif
+}
+
+//--------------------------------------------------------------------------------------------------//
bool Win32JoyStick::_doButtonClick( int button, DIDEVICEOBJECTDATA& di )
{
if( di.dwData & 0x80 )
@@ -409,11 +552,132 @@
//--------------------------------------------------------------------------------------------------//
Interface* Win32JoyStick::queryInterface(Interface::IType type)
{
- //Thought about using covariant return type here.. however,
- //some devices may allow LED light changing, or other interface stuff
-
- if( ff_device && type == Interface::ForceFeedback )
- return ff_device;
+ if( mFfDevice && type == Interface::ForceFeedback )
+ return mFfDevice;
else
return 0;
}
+
+//--------------------------------------------------------------------------------------------------//
+void Win32JoyStick::CheckXInputDevices(JoyStickInfoList &joys)
+{
+ IWbemLocator* pIWbemLocator = NULL;
+ IEnumWbemClassObject* pEnumDevices = NULL;
+ IWbemClassObject* pDevices[20] = {0};
+ IWbemServices* pIWbemServices = NULL;
+ BSTR bstrNamespace = NULL;
+ BSTR bstrDeviceID = NULL;
+ BSTR bstrClassName = NULL;
+ DWORD uReturned = 0;
+ bool bIsXinputDevice= false;
+ DWORD iDevice = 0;
+ int xDevice = 0;
+ VARIANT var;
+ HRESULT hr;
+
+ if(joys.size() == 0)
+ return;
+
+ // CoInit if needed
+ hr = CoInitialize(NULL);
+ bool bCleanupCOM = SUCCEEDED(hr);
+
+ // Create WMI
+ hr = CoCreateInstance(__uuidof(WbemLocator), NULL, CLSCTX_INPROC_SERVER, __uuidof(IWbemLocator), (LPVOID*)&pIWbemLocator);
+ if( FAILED(hr) || pIWbemLocator == NULL )
+ goto LCleanup;
+
+ bstrNamespace = SysAllocString( L"\\\\.\\root\\cimv2" );
+ if( bstrNamespace == NULL )
+ goto LCleanup;
+
+ bstrClassName = SysAllocString( L"Win32_PNPEntity" );
+ if( bstrClassName == NULL )
+ goto LCleanup;
+
+ bstrDeviceID = SysAllocString( L"DeviceID" );
+ if( bstrDeviceID == NULL )
+ goto LCleanup;
+
+ // Connect to WMI
+ hr = pIWbemLocator->ConnectServer( bstrNamespace, NULL, NULL, 0L, 0L, NULL, NULL, &pIWbemServices );
+ if( FAILED(hr) || pIWbemServices == NULL )
+ goto LCleanup;
+
+ // Switch security level to IMPERSONATE.
+ CoSetProxyBlanket(pIWbemServices, RPC_C_AUTHN_WINNT, RPC_C_AUTHZ_NONE, NULL, RPC_C_AUTHN_LEVEL_CALL, RPC_C_IMP_LEVEL_IMPERSONATE, NULL, EOAC_NONE );
+
+ hr = pIWbemServices->CreateInstanceEnum( bstrClassName, 0, NULL, &pEnumDevices );
+ if( FAILED(hr) || pEnumDevices == NULL )
+ goto LCleanup;
+
+ // Loop over all devices
+ for( ;; )
+ {
+ // Get 20 at a time
+ hr = pEnumDevices->Next(5000, 20, pDevices, &uReturned);
+ if( FAILED(hr) )
+ goto LCleanup;
+
+ if( uReturned == 0 )
+ break;
+
+ for(iDevice = 0; iDevice < uReturned; iDevice++)
+ {
+ // For each device, get its device ID
+ hr = pDevices[iDevice]->Get(bstrDeviceID, 0L, &var, NULL, NULL);
+ if(SUCCEEDED(hr) && var.vt == VT_BSTR && var.bstrVal != NULL)
+ {
+ // Check if the device ID contains "IG_". If it does, then it's an XInput device - This information can not be found from DirectInput
+ if(wcsstr(var.bstrVal, L"IG_"))
+ {
+ // If it does, then get the VID/PID from var.bstrVal
+ DWORD dwPid = 0, dwVid = 0;
+ WCHAR* strVid = wcsstr( var.bstrVal, L"VID_" );
+ if(strVid && swscanf_s( strVid, L"VID_%4X", &dwVid ) != 1)
+ dwVid = 0;
+
+ WCHAR* strPid = wcsstr( var.bstrVal, L"PID_" );
+ if(strPid && swscanf_s( strPid, L"PID_%4X", &dwPid ) != 1)
+ dwPid = 0;
+
+ // Compare the VID/PID to the DInput device
+ DWORD dwVidPid = MAKELONG(dwVid, dwPid);
+ for(JoyStickInfoList::iterator i = joys.begin(); i != joys.end(); ++i)
+ {
+ if(dwVidPid == i->productGuid.Data1)
+ {
+ i->isXInput = true;
+ i->xInputDev = xDevice;
+ }
+ }
+
+ if(joys.size() == 0)
+ goto LCleanup;
+ }
+ }
+
+ SAFE_RELEASE(pDevices[iDevice]);
+ }
+ }
+
+LCleanup:
+ if(bstrNamespace)
+ SysFreeString(bstrNamespace);
+
+ if(bstrDeviceID)
+ SysFreeString(bstrDeviceID);
+
+ if(bstrClassName)
+ SysFreeString(bstrClassName);
+
+ for(iDevice=0; iDevice < 20; iDevice++)
+ SAFE_RELEASE(pDevices[iDevice]);
+
+ SAFE_RELEASE(pEnumDevices);
+ SAFE_RELEASE(pIWbemLocator);
+ SAFE_RELEASE(pIWbemServices);
+
+ if(bCleanupCOM)
+ CoUninitialize();
+}
Modified: code/branches/ois_update/src/external/ois/win32/Win32JoyStick.h
===================================================================
--- code/branches/ois_update/src/external/ois/win32/Win32JoyStick.h 2010-10-07 18:12:14 UTC (rev 7505)
+++ code/branches/ois_update/src/external/ois/win32/Win32JoyStick.h 2010-10-07 18:21:33 UTC (rev 7506)
@@ -24,7 +24,7 @@
#define _WIN32_JOYSTICK_H_EADER_
#include "OISJoyStick.h"
-#include "Win32/Win32Prereqs.h"
+#include "win32/Win32Prereqs.h"
namespace OIS
{
@@ -40,12 +40,23 @@
/** @copydoc Object::capture */
virtual void capture();
+ //! hanlde xinput
+ void captureXInput();
+
/** @copydoc Object::queryInterface */
virtual Interface* queryInterface(Interface::IType type);
/** @copydoc Object::_initialize */
virtual void _initialize();
+ /**
+ @remarks
+ Enum each PNP device using WMI and check each device ID to see if it contains
+ "IG_" (ex. "VID_045E&PID_028E&IG_00"). If it does, then it's an XInput device
+ Unfortunately this information can not be found by just using DirectInput
+ */
+ static void CheckXInputDevices(JoyStickInfoList &joys);
+
protected:
//! Enumerates all things
void _enumerate();
@@ -60,12 +71,12 @@
IDirectInput8* mDirectInput;
IDirectInputDevice8* mJoyStick;
DIDEVCAPS mDIJoyCaps;
-
DWORD coopSetting;
- GUID deviceGuid;
+ JoyStickInfo mJoyInfo;
+
//! A force feedback device
- Win32ForceFeedback* ff_device;
+ Win32ForceFeedback* mFfDevice;
//! Mapping
int _AxisNumber;
Modified: code/branches/ois_update/src/external/ois/win32/Win32KeyBoard.cpp
===================================================================
--- code/branches/ois_update/src/external/ois/win32/Win32KeyBoard.cpp 2010-10-07 18:12:14 UTC (rev 7505)
+++ code/branches/ois_update/src/external/ois/win32/Win32KeyBoard.cpp 2010-10-07 18:21:33 UTC (rev 7506)
@@ -20,8 +20,8 @@
3. This notice may not be removed or altered from any source distribution.
*/
-#include "Win32/Win32InputManager.h"
-#include "Win32/Win32KeyBoard.h"
+#include "win32/Win32InputManager.h"
+#include "win32/Win32KeyBoard.h"
#include "OISException.h"
#include "OISEvents.h"
#include <sstream>
@@ -286,7 +286,7 @@
}
//--------------------------------------------------------------------------------------------------//
-const std::string& Win32Keyboard::getAsString( KeyCode kc )
+const std::string& Win32Keyboard::getAsString(KeyCode kc)
{
char temp[256];
@@ -296,16 +296,16 @@
prop.diph.dwObj = static_cast<DWORD>(kc);
prop.diph.dwHow = DIPH_BYOFFSET;
- if ( SUCCEEDED( mKeyboard->GetProperty( DIPROP_KEYNAME, &prop.diph ) ) )
+ if (SUCCEEDED(mKeyboard->GetProperty(DIPROP_KEYNAME, &prop.diph)))
{
// convert the WCHAR in "wsz" to multibyte
- if ( WideCharToMultiByte( CP_ACP, 0, prop.wsz, -1, temp, sizeof(temp), NULL, NULL) )
- return mGetString.assign( temp );
+ if (WideCharToMultiByte(CP_ACP, 0, prop.wsz, -1, temp, sizeof(temp), NULL, NULL))
+ return mGetString.assign(temp);
}
std::stringstream ss;
ss << "Key_" << (int)kc;
- return mGetString.assign( ss.str() );
+ return mGetString.assign(ss.str());
}
//--------------------------------------------------------------------------------------------------//
Modified: code/branches/ois_update/src/external/ois/win32/Win32KeyBoard.h
===================================================================
--- code/branches/ois_update/src/external/ois/win32/Win32KeyBoard.h 2010-10-07 18:12:14 UTC (rev 7505)
+++ code/branches/ois_update/src/external/ois/win32/Win32KeyBoard.h 2010-10-07 18:21:33 UTC (rev 7506)
@@ -24,7 +24,7 @@
#define _WIN32_KEYBOARD_H_EADER_
#include "OISKeyboard.h"
-#include "Win32/Win32Prereqs.h"
+#include "win32/Win32Prereqs.h"
namespace OIS
{
@@ -41,17 +41,17 @@
@param coopSettings
A combination of DI Flags (see DX Help for info on input device settings)
*/
- Win32Keyboard( InputManager* creator, IDirectInput8* pDI, bool buffered, DWORD coopSettings );
+ Win32Keyboard(InputManager* creator, IDirectInput8* pDI, bool buffered, DWORD coopSettings);
virtual ~Win32Keyboard();
/** @copydoc Keyboard::isKeyDown */
- virtual bool isKeyDown( KeyCode key ) const;
+ virtual bool isKeyDown(KeyCode key) const;
/** @copydoc Keyboard::getAsString */
- virtual const std::string& getAsString( KeyCode kc );
+ virtual const std::string& getAsString(KeyCode kc);
/** @copydoc Keyboard::copyKeyStates */
- virtual void copyKeyStates( char keys[256] ) const;
+ virtual void copyKeyStates(char keys[256]) const;
/** @copydoc Object::setBuffered */
virtual void setBuffered(bool buffered);
Modified: code/branches/ois_update/src/external/ois/win32/Win32Mouse.cpp
===================================================================
--- code/branches/ois_update/src/external/ois/win32/Win32Mouse.cpp 2010-10-07 18:12:14 UTC (rev 7505)
+++ code/branches/ois_update/src/external/ois/win32/Win32Mouse.cpp 2010-10-07 18:21:33 UTC (rev 7506)
@@ -20,8 +20,8 @@
3. This notice may not be removed or altered from any source distribution.
*/
-#include "Win32/Win32Mouse.h"
-#include "Win32/Win32InputManager.h"
+#include "win32/Win32Mouse.h"
+#include "win32/Win32InputManager.h"
#include "OISException.h"
#include "OISEvents.h"
Modified: code/branches/ois_update/src/external/ois/win32/Win32Mouse.h
===================================================================
--- code/branches/ois_update/src/external/ois/win32/Win32Mouse.h 2010-10-07 18:12:14 UTC (rev 7505)
+++ code/branches/ois_update/src/external/ois/win32/Win32Mouse.h 2010-10-07 18:21:33 UTC (rev 7506)
@@ -24,7 +24,7 @@
#define _WIN32_MOUSE_H_EADER_
#include "OISMouse.h"
-#include "Win32/Win32Prereqs.h"
+#include "win32/Win32Prereqs.h"
namespace OIS
{
Modified: code/branches/ois_update/src/external/ois/win32/Win32Prereqs.h
===================================================================
--- code/branches/ois_update/src/external/ois/win32/Win32Prereqs.h 2010-10-07 18:12:14 UTC (rev 7505)
+++ code/branches/ois_update/src/external/ois/win32/Win32Prereqs.h 2010-10-07 18:21:33 UTC (rev 7506)
@@ -28,10 +28,14 @@
#include <windows.h>
#include <dinput.h>
+#ifdef OIS_WIN32_XINPUT_SUPPORT
+# include <XInput.h>
+#endif
+
//Max number of elements to collect from buffered DirectInput
#define KEYBOARD_DX_BUFFERSIZE 17
-#define MOUSE_DX_BUFFERSIZE 64
-#define JOYSTICK_DX_BUFFERSIZE 124
+#define MOUSE_DX_BUFFERSIZE 128
+#define JOYSTICK_DX_BUFFERSIZE 129
//MinGW defines
#if defined(OIS_MINGW_COMPILER)
@@ -54,10 +58,13 @@
public:
int devId;
GUID deviceID;
+ GUID productGuid;
std::string vendor;
+ bool isXInput;
+ int xInputDev;
};
- typedef std::vector< JoyStickInfo > JoyStickInfoList;
+ typedef std::vector<JoyStickInfo> JoyStickInfoList;
}
#endif //_WIN32_INPUTSYSTEM_PREREQS_H
More information about the Orxonox-commit
mailing list