Index: code/branches/kicklib/src/external/ois/CMakeLists.txt
===================================================================
--- code/branches/kicklib/src/external/ois/CMakeLists.txt	(revision 7940)
+++ code/branches/kicklib/src/external/ois/CMakeLists.txt	(revision 8071)
@@ -31,8 +31,9 @@
   OISKeyboard.h
   OISMouse.h
+  OISMultiTouch.h
   OISObject.h
   OISPrereqs.h
 
-COMPILATION_BEGIN OISCompilation.cpp
+  #COMPILATION_BEGIN OISCompilation.cpp
   OISEffect.cpp
   OISException.cpp
@@ -42,5 +43,5 @@
   OISKeyboard.cpp
   OISObject.cpp
-COMPILATION_END
+  #COMPILATION_END
 )
 IF(WIN32)
@@ -51,6 +52,4 @@
   ADD_SUBDIRECTORY(linux)
 ENDIF()
-
-INCLUDE_DIRECTORIES(.)
 
 ORXONOX_ADD_LIBRARY(ois_orxonox
@@ -66,3 +65,5 @@
 IF(WIN32)
   TARGET_LINK_LIBRARIES(ois_orxonox ${DIRECTX_LIBRARIES})
+ELSEIF(APPLE)
+  TARGET_LINK_LIBRARIES(ois_orxonox "/System/Library/Frameworks/IOKit.framework" "/System/Library/Frameworks/Carbon.framework")
 ENDIF()
Index: code/branches/kicklib/src/external/ois/OIS.h
===================================================================
--- code/branches/kicklib/src/external/ois/OIS.h	(revision 7940)
+++ code/branches/kicklib/src/external/ois/OIS.h	(revision 8071)
@@ -29,4 +29,5 @@
 #include "OISKeyboard.h"
 #include "OISJoyStick.h"
+#include "OISMultiTouch.h"
 #include "OISInputManager.h"
 #include "OISFactoryCreator.h"
Index: code/branches/kicklib/src/external/ois/OISConfig.h
===================================================================
--- code/branches/kicklib/src/external/ois/OISConfig.h	(revision 7940)
+++ code/branches/kicklib/src/external/ois/OISConfig.h	(revision 8071)
@@ -70,6 +70,4 @@
 @remarks
 	Build in support for Win32 XInput (Xbox 360 Controller)
-@notes
-	Not Yet Implemented
 */
 //#define OIS_WIN32_XINPUT_SUPPORT
Index: code/branches/kicklib/src/external/ois/OISInputManager.cpp
===================================================================
--- code/branches/kicklib/src/external/ois/OISInputManager.cpp	(revision 7940)
+++ code/branches/kicklib/src/external/ois/OISInputManager.cpp	(revision 8071)
@@ -37,4 +37,6 @@
 #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"
@@ -59,4 +61,6 @@
 	m_wiiMoteSupport(0)
 {
+    mFactories.clear();
+    mFactoryObjects.clear();
 }
 
@@ -111,4 +115,6 @@
 #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!");
Index: code/branches/kicklib/src/external/ois/OISKeyboard.h
===================================================================
--- code/branches/kicklib/src/external/ois/OISKeyboard.h	(revision 7940)
+++ code/branches/kicklib/src/external/ois/OISKeyboard.h	(revision 8071)
@@ -184,5 +184,5 @@
 	{
 	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() {}
 
@@ -201,6 +201,6 @@
 	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;		
 	};
 
@@ -220,5 +220,5 @@
 			A KeyCode to check
 		*/
-		virtual bool isKeyDown( KeyCode key ) const = 0;
+		virtual bool isKeyDown(KeyCode key) const = 0;
 
 		/**
@@ -229,5 +229,5 @@
 			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;}
 
 		/**
@@ -254,5 +254,5 @@
 			Off, Unicode, Ascii
 		*/
-		virtual void setTextTranslation( TextTranslationMode mode );
+		virtual void setTextTranslation(TextTranslationMode mode);
 
 		/**
@@ -272,5 +272,5 @@
 			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
@@ -286,5 +286,5 @@
 			Check modifier status
 		*/
-		bool isModifierDown( Modifier mod ) const;
+		bool isModifierDown(Modifier mod) const;
 
 		/**
@@ -293,5 +293,5 @@
 			(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:
Index: code/branches/kicklib/src/external/ois/OISMultiTouch.h
===================================================================
--- code/branches/kicklib/src/external/ois/OISMultiTouch.h	(revision 8071)
+++ code/branches/kicklib/src/external/ois/OISMultiTouch.h	(revision 8071)
@@ -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
Index: code/branches/kicklib/src/external/ois/OISPrereqs.h
===================================================================
--- code/branches/kicklib/src/external/ois/OISPrereqs.h	(revision 7940)
+++ code/branches/kicklib/src/external/ois/OISPrereqs.h	(revision 8071)
@@ -79,7 +79,13 @@
 #	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
@@ -95,7 +101,7 @@
 //-------------- 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)
@@ -110,6 +116,8 @@
 	class Mouse;
 	class JoyStick;
+    class MultiTouch;
 	class KeyListener;
 	class MouseListener;
+    class MultiTouchListener;
 	class JoyStickListener;
 	class Interface;
@@ -130,9 +138,10 @@
     enum Type
 	{
-		OISUnknown   = 0,
-		OISKeyboard  = 1,
-		OISMouse     = 2,
-		OISJoyStick  = 3,
-		OISTablet    = 4
+		OISUnknown       = 0,
+		OISKeyboard      = 1,
+		OISMouse         = 2,
+		OISJoyStick      = 3,
+		OISTablet        = 4,
+		OISMultiTouch    = 5
 	};
 
Index: code/branches/kicklib/src/external/ois/ReadMe.txt
===================================================================
--- code/branches/kicklib/src/external/ois/ReadMe.txt	(revision 7940)
+++ code/branches/kicklib/src/external/ois/ReadMe.txt	(revision 8071)
@@ -5,5 +5,5 @@
 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 
@@ -46,19 +46,14 @@
 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:
@@ -69,7 +64,5 @@
 	---- 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/
@@ -80,8 +73,4 @@
 
 Mac/
-	
-	XCode-1.5/
-		Non-complete native OIS port.
-
 	XCode-2.2/
-		Working, complete, OIS port to OSX using SDL as a backend.
+		Working, mostly complete OSX vackend.
Index: code/branches/kicklib/src/external/ois/VERSION
===================================================================
--- code/branches/kicklib/src/external/ois/VERSION	(revision 7940)
+++ code/branches/kicklib/src/external/ois/VERSION	(revision 8071)
@@ -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/
Index: code/branches/kicklib/src/external/ois/changes_orxonox.diff
===================================================================
--- code/branches/kicklib/src/external/ois/changes_orxonox.diff	(revision 7940)
+++ code/branches/kicklib/src/external/ois/changes_orxonox.diff	(revision 8071)
@@ -10,4 +10,6 @@
  			//Ignorable Dll interface warning...
  #           if !defined(OIS_MINGW_COMPILER)
+
+
 --- linux/EventHelpers.cpp	(revision 5668)
 +++ linux/EventHelpers.cpp	(working copy)
@@ -37,5 +39,5 @@
 +++ win32/Win32ForceFeedback.cpp
 @@ -25,7 +25,7 @@
- #include <Math.h>
+ #include <math.h>
  
  // 0 = No trace; 1 = Important traces; 2 = Debug traces
@@ -45,2 +47,22 @@
  #if (defined (_DEBUG) || defined(OIS_WIN32_JOYFF_DEBUG))
    #include <iostream>
+
+
+--- mac/MacHIDManager.cpp
++++ mac/MacHIDManager.cpp
+@@ -406,6 +406,7 @@
+ 			switch(iType)
+ 			{
+ 				case OISJoyStick:
++                {
+ 					int totalDevs = totalDevices(iType);
+ 					int freeDevs = freeDevices(iType);
+ 					int devID = totalDevs - freeDevs;
+@@ -413,6 +414,7 @@
+ 					obj = new MacJoyStick((*it)->combinedKey, bufferMode, *it, creator, devID);
+ 					(*it)->inUse = true;
+ 					return obj;
++                }
+ 				case OISTablet:
+ 					//Create MacTablet
+ 					break;
Index: code/branches/kicklib/src/external/ois/linux/LinuxInputManager.cpp
===================================================================
--- code/branches/kicklib/src/external/ois/linux/LinuxInputManager.cpp	(revision 7940)
+++ code/branches/kicklib/src/external/ois/linux/LinuxInputManager.cpp	(revision 8071)
@@ -40,5 +40,4 @@
 	hideMouse = true;
 	mGrabs = true;
-	useXRepeat = false;
 	keyboardUsed = mouseUsed = false;
 
@@ -74,9 +73,4 @@
 
 	//--------- 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() )
@@ -172,5 +166,5 @@
 	{
 		if( keyboardUsed == false )
-			obj = new LinuxKeyboard(this, bufferMode, grabKeyboard, useXRepeat);
+			obj = new LinuxKeyboard(this, bufferMode, grabKeyboard);
 		break;
 	}
Index: code/branches/kicklib/src/external/ois/linux/LinuxInputManager.h
===================================================================
--- code/branches/kicklib/src/external/ois/linux/LinuxInputManager.h	(revision 7940)
+++ code/branches/kicklib/src/external/ois/linux/LinuxInputManager.h	(revision 8071)
@@ -101,7 +101,4 @@
 		bool mGrabs;
 		bool hideMouse;
-
-		//! By default, keyboard disables XRepeatRate
-		bool useXRepeat;
 	};
 }
Index: code/branches/kicklib/src/external/ois/linux/LinuxJoyStickEvents.cpp
===================================================================
--- code/branches/kicklib/src/external/ois/linux/LinuxJoyStickEvents.cpp	(revision 7940)
+++ code/branches/kicklib/src/external/ois/linux/LinuxJoyStickEvents.cpp	(revision 8071)
@@ -96,104 +96,107 @@
 	//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)
+		int ret = read(mJoyStick, &js, sizeof(struct input_event) * JOY_BUFFERSIZE);
+        if( ret < 0 )
+			break;
+
+		//Determine how many whole events re read up
+		ret /= sizeof(struct input_event);
+		for(int i = 0; i < ret; ++i)
 		{
-		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;
-			}
-			break;
-		}
-
-		case EV_ABS:  //Absolute Axis
-		{
-			//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!" );
-
-				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;
+			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
-				{	//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;
 				}
-			}
-			else if( js[i].code <= ABS_HAT3Y ) //A POV - Max four POVs allowed
-			{
-				//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)
+				break;
+			}
+
+			case EV_ABS:  //Absolute Axis
+			{
+				//A Stick (BrakeDefine is the highest possible Axis)
+				if( js[i].code <= ABS_BRAKE )
 				{
-					//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;
+					int axis = mAxisMap[js[i].code];
+					assert( axis < 32 && "Too many axes (Max supported is 32). Report this to OIS forums!" );
+
+					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;
 				}
-
-				if( mBuffered && mListener )
-					if( mListener->povMoved( JoyStickEvent(this,mState), OIS_POVIndex) == false )
-						return;
-			}
-			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;
+				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;
+			}
 		}
 	}
Index: code/branches/kicklib/src/external/ois/linux/LinuxKeyboard.cpp
===================================================================
--- code/branches/kicklib/src/external/ois/linux/LinuxKeyboard.cpp	(revision 7940)
+++ code/branches/kicklib/src/external/ois/linux/LinuxKeyboard.cpp	(revision 8071)
@@ -33,5 +33,5 @@
 #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)
 {
@@ -43,7 +43,4 @@
 	grabKeyboard = grab;
 	keyFocusLost = false;
-
-	xAutoRepeat = useXRepeat;
-	oldXAutoRepeat = false;
 
 	//X Key Map to KeyCode
@@ -213,18 +210,4 @@
 
 	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 );
-	}
 }
 
@@ -234,7 +217,4 @@
 	if( display )
 	{
-		if( oldXAutoRepeat )
-			XAutoRepeatOn(display);
-
 		if( grabKeyboard )
 			XUngrabKeyboard(display, CurrentTime);
@@ -303,9 +283,10 @@
 
 	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};
@@ -332,13 +313,17 @@
 			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;
-
-			//Else, it is a valid key release
-			XLookupString(&event.xkey,NULL,0,&key,NULL);
-			_injectKeyUp(key); 		}
+			if(!_isKeyRepeat(event))
+			{
+				//Mask out the modifier states X sets.. or we will get improper values
+				event.xkey.state &= ~ShiftMask;
+				event.xkey.state &= ~LockMask;
+
+				XLookupString(&event.xkey,NULL,0,&key,NULL);
+				_injectKeyUp(key);
+			}
+		}
 	}
 
Index: code/branches/kicklib/src/external/ois/linux/LinuxKeyboard.h
===================================================================
--- code/branches/kicklib/src/external/ois/linux/LinuxKeyboard.h	(revision 7940)
+++ code/branches/kicklib/src/external/ois/linux/LinuxKeyboard.h	(revision 8071)
@@ -34,5 +34,5 @@
 	{
 	public:
-		LinuxKeyboard(InputManager* creator, bool buffered, bool grab, bool useXRepeat );
+		LinuxKeyboard(InputManager* creator, bool buffered, bool grab);
 		virtual ~LinuxKeyboard();
 
@@ -59,4 +59,21 @@
 
 	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 );
@@ -75,7 +92,4 @@
 		bool keyFocusLost;
 
-		bool xAutoRepeat;
-		bool oldXAutoRepeat;
-
 		std::string mGetString;
 	};
Index: code/branches/kicklib/src/external/ois/linux/LinuxMouse.cpp
===================================================================
--- code/branches/kicklib/src/external/ois/linux/LinuxMouse.cpp	(revision 7940)
+++ code/branches/kicklib/src/external/ois/linux/LinuxMouse.cpp	(revision 8071)
@@ -173,6 +173,6 @@
 
 			//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
@@ -180,6 +180,8 @@
 			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)
Index: code/branches/kicklib/src/external/ois/linux/LinuxPrereqs.h
===================================================================
--- code/branches/kicklib/src/external/ois/linux/LinuxPrereqs.h	(revision 7940)
+++ code/branches/kicklib/src/external/ois/linux/LinuxPrereqs.h	(revision 8071)
@@ -32,5 +32,5 @@
 
 //! Max number of elements to collect from buffered input
-#define JOY_BUFFERSIZE 10
+#define JOY_BUFFERSIZE 64
 
 namespace OIS
Index: code/branches/kicklib/src/external/ois/mac/CMakeLists.txt
===================================================================
--- code/branches/kicklib/src/external/ois/mac/CMakeLists.txt	(revision 7940)
+++ code/branches/kicklib/src/external/ois/mac/CMakeLists.txt	(revision 8071)
@@ -3,14 +3,16 @@
   MacHIDManager.h
   MacInputManager.h
+  MacJoyStick.h
   MacKeyboard.h
   MacMouse.h
   MacPrereqs.h
 
-COMPILATION_BEGIN OISMacCompilation.cpp
+  #COMPILATION_BEGIN OISMacCompilation.cpp
   MacHelpers.cpp
   MacHIDManager.cpp
   MacInputManager.cpp
+  MacJoyStick.cpp
   MacKeyboard.cpp
   MacMouse.cpp
-COMPILATION_END
+  #COMPILATION_END
 )
Index: code/branches/kicklib/src/external/ois/mac/MacHIDManager.cpp
===================================================================
--- code/branches/kicklib/src/external/ois/mac/MacHIDManager.cpp	(revision 7940)
+++ code/branches/kicklib/src/external/ois/mac/MacHIDManager.cpp	(revision 8071)
@@ -20,6 +20,7 @@
  
  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"
@@ -42,5 +43,5 @@
 {
 	CFTypeRef temp = CFDictionaryGetValue(dict, OIS_CFString(keyName));
-
+	
 	if(temp && CFGetTypeID(temp) == CFArrayGetTypeID())
 		return (CFArrayRef)temp;
@@ -53,5 +54,5 @@
 {
 	CFTypeRef temp = CFDictionaryGetValue(dict, OIS_CFString(keyName));
-
+	
 	if(temp && CFGetTypeID(temp) == CFStringGetTypeID())
 		return (CFStringRef)temp;
@@ -64,5 +65,5 @@
 {
 	CFTypeRef temp = CFDictionaryGetValue(dict, OIS_CFString(keyName));
-
+	
 	if(temp && CFGetTypeID(temp) == CFNumberGetTypeID())
 		return (CFNumberRef)temp;
@@ -83,5 +84,5 @@
 {
 	CFTypeRef temp = CFArrayGetValueAtIndex(array, idx);
-
+	
 	if(temp && CFGetTypeID(temp) == CFDictionaryGetTypeID())
 		return (CFDictionaryRef)temp;
@@ -93,8 +94,8 @@
 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,69 +112,96 @@
 //------------------------------------------------------------------------------------------------------//
 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)
-	{
-		io_object_t hidDevice = 0;
-		while ((hidDevice = IOIteratorNext(iterator)) !=0)
+	
+	CFRelease(usageRef);
+	CFRelease(pageRef);
+	
+	if(result == kIOReturnSuccess)
+	{
+		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);
 }
 
@@ -188,11 +216,11 @@
 	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);
@@ -200,5 +228,5 @@
 		for (int i = 0; i < CFArrayGetCount(array); i++)
 			parseDeviceProperties(getArrayItemAsRef<CFDictionaryRef>(array, i));
-
+	
 	return info;
 }
@@ -209,5 +237,5 @@
 	if(!properties)
 		return;
-
+	
 	CFArrayRef array = getDictionaryItemAsRef<CFArrayRef>(properties, kIOHIDElementKey);
 	if (array)
@@ -227,32 +255,32 @@
 					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;
 					}
 				}
@@ -267,5 +295,5 @@
 	if(!properties)
 		return;
-
+	
 	CFArrayRef array = getDictionaryItemAsRef<CFArrayRef>(properties, kIOHIDElementKey);
 	if(array)
@@ -278,27 +306,27 @@
 				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;
 				}
 			}
@@ -317,5 +345,5 @@
 			ret.insert(std::make_pair((*it)->type, (*it)->combinedKey));
 	}
-
+	
 	return ret;
 }
@@ -326,5 +354,5 @@
 	int ret = 0;
 	HidInfoList::iterator it = mDeviceList.begin(), end = mDeviceList.end();
-
+	
 	for(; it != end; ++it)
 	{
@@ -341,5 +369,5 @@
 	int ret = 0;
 	HidInfoList::iterator it = mDeviceList.begin(), end = mDeviceList.end();
-
+	
 	for(; it != end; ++it)
 	{
@@ -347,5 +375,5 @@
 			ret++;
 	}
-
+	
 	return ret;
 }
@@ -355,5 +383,5 @@
 {
 	HidInfoList::iterator it = mDeviceList.begin(), end = mDeviceList.end();
-
+	
 	for(; it != end; ++it)
 	{
@@ -367,8 +395,8 @@
 //--------------------------------------------------------------------------------//
 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)
@@ -376,11 +404,25 @@
 		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;
 }
Index: code/branches/kicklib/src/external/ois/mac/MacHIDManager.h
===================================================================
--- code/branches/kicklib/src/external/ois/mac/MacHIDManager.h	(revision 7940)
+++ code/branches/kicklib/src/external/ois/mac/MacHIDManager.h	(revision 8071)
@@ -70,4 +70,7 @@
 
 		void initialize();
+		
+		void iterateAndOpenDevices(io_iterator_t iterator);
+		io_iterator_t lookUpDevices(int usage, int page);
 
 		//FactoryCreator Overrides
Index: code/branches/kicklib/src/external/ois/mac/MacInputManager.cpp
===================================================================
--- code/branches/kicklib/src/external/ois/mac/MacInputManager.cpp	(revision 7940)
+++ code/branches/kicklib/src/external/ois/mac/MacInputManager.cpp	(revision 8071)
@@ -188,5 +188,8 @@
 	}
 	default:
+	{
+		obj = mHIDManager->createObject(creator, iType, bufferMode, vendor);
 		break;
+	}
 	}
 
Index: code/branches/kicklib/src/external/ois/mac/MacJoyStick.cpp
===================================================================
--- code/branches/kicklib/src/external/ois/mac/MacJoyStick.cpp	(revision 8071)
+++ code/branches/kicklib/src/external/ois/mac/MacJoyStick.cpp	(revision 8071)
@@ -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.");
+	}
+}
Index: code/branches/kicklib/src/external/ois/mac/MacJoyStick.h
===================================================================
--- code/branches/kicklib/src/external/ois/mac/MacJoyStick.h	(revision 8071)
+++ code/branches/kicklib/src/external/ois/mac/MacJoyStick.h	(revision 8071)
@@ -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
Index: code/branches/kicklib/src/external/ois/mac/MacKeyboard.cpp
===================================================================
--- code/branches/kicklib/src/external/ois/mac/MacKeyboard.cpp	(revision 7940)
+++ code/branches/kicklib/src/external/ois/mac/MacKeyboard.cpp	(revision 8071)
@@ -199,17 +199,9 @@
 	char macChar;
 	
-	// TODO clean this up
 	if (mTextMode == Unicode)
 	{
 		//get string size
 		UInt32 stringsize;
-		//status = GetEventParameter( theEvent, 'kuni', typeUnicodeText, NULL, 0, &stringsize, NULL);
-		//status = GetEventParameter( theEvent, 'kuni', typeUnicodeText, NULL, sizeof(UniChar)*10, NULL, &text );
 		status = GetEventParameter( theEvent, 'kuni', typeUnicodeText, NULL, sizeof(UniChar) * 10, &stringsize, &text );
-		std::cout << "String length: " << stringsize << std::endl;
-		
-		//wstring unitext;
-		//for (int i=0;i<10;i++) unitext += (wchar_t)text[i];
-		//wcout << "Unicode out: " << unitext << endl;
 		
 		if(stringsize > 0)
Index: code/branches/kicklib/src/external/ois/win32/Win32ForceFeedback.cpp
===================================================================
--- code/branches/kicklib/src/external/ois/win32/Win32ForceFeedback.cpp	(revision 7940)
+++ code/branches/kicklib/src/external/ois/win32/Win32ForceFeedback.cpp	(revision 8071)
@@ -21,7 +21,7 @@
     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
Index: code/branches/kicklib/src/external/ois/win32/Win32ForceFeedback.h
===================================================================
--- code/branches/kicklib/src/external/ois/win32/Win32ForceFeedback.h	(revision 7940)
+++ code/branches/kicklib/src/external/ois/win32/Win32ForceFeedback.h	(revision 8071)
@@ -26,5 +26,5 @@
 #include "OISPrereqs.h"
 #include "OISForceFeedback.h"
-#include "Win32/Win32Prereqs.h"
+#include "win32/Win32Prereqs.h"
 
 namespace OIS
Index: code/branches/kicklib/src/external/ois/win32/Win32InputManager.cpp
===================================================================
--- code/branches/kicklib/src/external/ois/win32/Win32InputManager.cpp	(revision 7940)
+++ code/branches/kicklib/src/external/ois/win32/Win32InputManager.cpp	(revision 8071)
@@ -21,8 +21,8 @@
     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"
 
@@ -75,5 +75,5 @@
 	hInst = GetModuleHandle(0);
 
-	//Create the input system
+	//Create the device
 	hr = DirectInput8Create( hInst, DIRECTINPUT_VERSION, IID_IDirectInput8, (VOID**)&mDirectInput, NULL );
     if (FAILED(hr))	
@@ -118,5 +118,18 @@
 {
 	//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
 }
 
@@ -134,4 +147,6 @@
 	{
 		JoyStickInfo jsInfo;
+		jsInfo.isXInput = false;
+		jsInfo.productGuid = lpddi->guidProduct;
 		jsInfo.deviceID = lpddi->guidInstance;
 		jsInfo.vendor = lpddi->tszInstanceName;
Index: code/branches/kicklib/src/external/ois/win32/Win32InputManager.h
===================================================================
--- code/branches/kicklib/src/external/ois/win32/Win32InputManager.h	(revision 7940)
+++ code/branches/kicklib/src/external/ois/win32/Win32InputManager.h	(revision 8071)
@@ -26,5 +26,5 @@
 #include "OISInputManager.h"
 #include "OISFactoryCreator.h"
-#include "Win32/Win32Prereqs.h"
+#include "win32/Win32Prereqs.h"
 
 namespace OIS
Index: code/branches/kicklib/src/external/ois/win32/Win32JoyStick.cpp
===================================================================
--- code/branches/kicklib/src/external/ois/win32/Win32JoyStick.cpp	(revision 7940)
+++ code/branches/kicklib/src/external/ois/win32/Win32JoyStick.cpp	(revision 8071)
@@ -21,11 +21,26 @@
     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
@@ -40,18 +55,18 @@
 #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)
-{
-	mDirectInput = pDI;
-	coopSetting = coopSettings;
-	mJoyStick = 0;
-
-	deviceGuid = info.deviceID;
-
-	ff_device = 0;
+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)
+{
 }
 
@@ -59,5 +74,5 @@
 Win32JoyStick::~Win32JoyStick()
 {
-	delete ff_device;
+	delete mFfDevice;
 
 	if(mJoyStick)
@@ -69,9 +84,5 @@
 
 	//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);
 }
 
@@ -79,43 +90,45 @@
 void Win32JoyStick::_initialize()
 {
-	//Clear old state
-	mState.mAxes.clear();
-
-	if (ff_device)
-	{
-		delete ff_device;
-		ff_device = 0;
-	}
-
-	// Create direct input joystick device.
-	if(FAILED(mDirectInput->CreateDevice(deviceGuid, &mJoyStick, NULL)))
-		OIS_EXCEPT( E_General, "Win32JoyStick::_initialize() >> Could not initialize joy device!");
-
-	// Set DIJoystick2 data format.
-	if(FAILED(mJoyStick->SetDataFormat(&c_dfDIJoystick2)))
-		OIS_EXCEPT( E_General, "Win32JoyStick::_initialize() >> data format error!");
-
-	// 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!");
-
-	// 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->SetProperty(DIPROP_BUFFERSIZE, &dipdw.diph)) )
-		OIS_EXCEPT( E_General, "Win32JoyStick::_initialize >> Failed to set buffer size property" );
-
-	// Enumerate all axes/buttons/sliders/force feedback/etc before aquiring
-	_enumerate();
-
-	mState.clear();
-
-	capture();
+    if (mJoyInfo.isXInput)
+    {
+        _enumerate();
+    }
+    else
+    {
+	    //Clear old state
+	    mState.mAxes.clear();
+
+	    delete mFfDevice;
+	    mFfDevice = 0;
+
+	    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(mDirectInput->CreateDevice(mJoyInfo.deviceID, &mJoyStick, NULL)))
+		    OIS_EXCEPT( E_General, "Win32JoyStick::_initialize() >> Could not initialize joy device!");
+
+	    if(FAILED(mJoyStick->SetDataFormat(&c_dfDIJoystick2)))
+		    OIS_EXCEPT( E_General, "Win32JoyStick::_initialize() >> data format error!");
+
+	    HWND hwin = ((Win32InputManager*)mCreator)->getWindowHandle();
+
+	    if(FAILED(mJoyStick->SetCooperativeLevel( hwin, coopSetting)))
+		    OIS_EXCEPT( E_General, "Win32JoyStick::_initialize() >> failed to set cooperation level!");
+
+	    if( FAILED(mJoyStick->SetProperty(DIPROP_BUFFERSIZE, &dipdw.diph)) )
+		    OIS_EXCEPT( E_General, "Win32Mouse::Win32Mouse >> Failed to set buffer size property" );
+
+	    //Enumerate all axes/buttons/sliders/etc before aquiring
+	    _enumerate();
+
+	    mState.clear();
+
+	    capture();
+    }
 }
 
@@ -123,24 +136,32 @@
 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" );
-
-	// => Number of POVs
-	mPOVs = (short)mDIJoyCaps.dwPOVs;
-
-	// => Number of buttons and axes.
-	mState.mButtons.resize(mDIJoyCaps.dwButtons);
-	mState.mAxes.resize(mDIJoyCaps.dwAxes);
-
-	// Enumerate all Force Feedback effects (if any)
-	mJoyStick->EnumEffects(DIEnumEffectsCallback, this, DIEFT_ALL);
-
-	//Reset the axis mapping enumeration value
-	_AxisNumber = 0;
-
-	// Enumerate and set axis constraints (and check FF Axes)
-	mJoyStick->EnumObjects(DIEnumDeviceObjectsCallback, this, DIDFT_AXIS);
+    if (mJoyInfo.isXInput)
+    {
+        mPOVs = 1;
+
+        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" );
+
+	    mPOVs = (short)mDIJoyCaps.dwPOVs;
+
+	    mState.mButtons.resize(mDIJoyCaps.dwButtons);
+	    mState.mAxes.resize(mDIJoyCaps.dwAxes);
+
+	    //Reset the axis mapping enumeration value
+	    _AxisNumber = 0;
+
+	    //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);
+    }
 }
 
@@ -191,7 +212,7 @@
 	if((lpddoi->dwFlags & DIDOI_FFACTUATOR) != 0 )
 	{
-		if( _this->ff_device )
+		if( _this->mFfDevice )
 		{
-			_this->ff_device->_addFFAxis();
+			_this->mFfDevice->_addFFAxis();
 		}
 	}
@@ -200,8 +221,8 @@
 	//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 )
-	{
-	    _this->ff_device->_setGainSupport(true);
-	    _this->ff_device->_setAutoCenterSupport(true);
+	if( _this->mFfDevice )
+	{
+	    _this->mFfDevice->_setGainSupport(true);
+	    _this->mFfDevice->_setAutoCenterSupport(true);
 	}
 
@@ -215,8 +236,8 @@
 
 	//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);
-
-	_this->ff_device->_addEffectSupport( pdei );
+	if( _this->mFfDevice == 0 )
+		_this->mFfDevice = new Win32ForceFeedback(_this->mJoyStick, &_this->mDIJoyCaps);
+
+	_this->mFfDevice->_addEffectSupport(pdei);
 
 	return DIENUM_CONTINUE;
@@ -226,4 +247,14 @@
 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;
@@ -241,5 +272,5 @@
 
 		// 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
@@ -353,4 +384,116 @@
 
 //--------------------------------------------------------------------------------------------------//
+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 )
 {
@@ -410,10 +553,131 @@
 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();
+}
Index: code/branches/kicklib/src/external/ois/win32/Win32JoyStick.h
===================================================================
--- code/branches/kicklib/src/external/ois/win32/Win32JoyStick.h	(revision 7940)
+++ code/branches/kicklib/src/external/ois/win32/Win32JoyStick.h	(revision 8071)
@@ -25,5 +25,5 @@
 
 #include "OISJoyStick.h"
-#include "Win32/Win32Prereqs.h"
+#include "win32/Win32Prereqs.h"
 
 namespace OIS
@@ -41,4 +41,7 @@
 		virtual void capture();
 
+		//! hanlde xinput
+		void captureXInput();
+
 		/** @copydoc Object::queryInterface */
 		virtual Interface* queryInterface(Interface::IType type);
@@ -46,4 +49,12 @@
 		/** @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:
@@ -61,10 +72,10 @@
 		IDirectInputDevice8* mJoyStick;
 		DIDEVCAPS mDIJoyCaps;
+		DWORD coopSetting;
 
-		DWORD coopSetting;
-		GUID deviceGuid;
+        JoyStickInfo mJoyInfo;
 
 		//! A force feedback device
-		Win32ForceFeedback* ff_device;
+		Win32ForceFeedback* mFfDevice;
 
 		//! Mapping
Index: code/branches/kicklib/src/external/ois/win32/Win32KeyBoard.cpp
===================================================================
--- code/branches/kicklib/src/external/ois/win32/Win32KeyBoard.cpp	(revision 7940)
+++ code/branches/kicklib/src/external/ois/win32/Win32KeyBoard.cpp	(revision 8071)
@@ -21,6 +21,6 @@
     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"
@@ -287,5 +287,5 @@
 
 //--------------------------------------------------------------------------------------------------//
-const std::string& Win32Keyboard::getAsString( KeyCode kc )
+const std::string& Win32Keyboard::getAsString(KeyCode kc)
 {
 	char temp[256];
@@ -297,14 +297,14 @@
 	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());
 }
 
Index: code/branches/kicklib/src/external/ois/win32/Win32KeyBoard.h
===================================================================
--- code/branches/kicklib/src/external/ois/win32/Win32KeyBoard.h	(revision 7940)
+++ code/branches/kicklib/src/external/ois/win32/Win32KeyBoard.h	(revision 8071)
@@ -25,5 +25,5 @@
 
 #include "OISKeyboard.h"
-#include "Win32/Win32Prereqs.h"
+#include "win32/Win32Prereqs.h"
 
 namespace OIS
@@ -42,15 +42,15 @@
 			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 */
Index: code/branches/kicklib/src/external/ois/win32/Win32Mouse.cpp
===================================================================
--- code/branches/kicklib/src/external/ois/win32/Win32Mouse.cpp	(revision 7940)
+++ code/branches/kicklib/src/external/ois/win32/Win32Mouse.cpp	(revision 8071)
@@ -21,6 +21,6 @@
     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"
Index: code/branches/kicklib/src/external/ois/win32/Win32Mouse.h
===================================================================
--- code/branches/kicklib/src/external/ois/win32/Win32Mouse.h	(revision 7940)
+++ code/branches/kicklib/src/external/ois/win32/Win32Mouse.h	(revision 8071)
@@ -25,5 +25,5 @@
 
 #include "OISMouse.h"
-#include "Win32/Win32Prereqs.h"
+#include "win32/Win32Prereqs.h"
 
 namespace OIS
Index: code/branches/kicklib/src/external/ois/win32/Win32Prereqs.h
===================================================================
--- code/branches/kicklib/src/external/ois/win32/Win32Prereqs.h	(revision 7940)
+++ code/branches/kicklib/src/external/ois/win32/Win32Prereqs.h	(revision 8071)
@@ -29,8 +29,12 @@
 #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
@@ -55,8 +59,11 @@
 		int devId;
 		GUID deviceID;
+		GUID productGuid;
 		std::string vendor;
+        bool isXInput;
+		int xInputDev;
 	};
 
-	typedef std::vector< JoyStickInfo > JoyStickInfoList;
+	typedef std::vector<JoyStickInfo> JoyStickInfoList;
 }
 
