Index: code/branches/input/src/ois/OISJoyStick.cpp
===================================================================
--- code/branches/input/src/ois/OISJoyStick.cpp	(revision 1298)
+++ code/branches/input/src/ois/OISJoyStick.cpp	(revision 1304)
@@ -36,5 +36,5 @@
 
 //----------------------------------------------------------------------------//
-int JoyStick::getNumberOfComponents(ComponentType cType)
+int JoyStick::getNumberOfComponents(ComponentType cType) const
 {
 	switch( cType )
@@ -56,5 +56,5 @@
 
 //----------------------------------------------------------------------------//
-float JoyStick::getVector3Sensitivity()
+float JoyStick::getVector3Sensitivity() const
 {
 	return mVector3Sensitivity;
@@ -68,5 +68,5 @@
 
 //----------------------------------------------------------------------------//
-JoyStickListener* JoyStick::getEventCallback()
+JoyStickListener* JoyStick::getEventCallback() const
 {
 	return mListener;
Index: code/branches/input/src/ois/OISJoyStick.h
===================================================================
--- code/branches/input/src/ois/OISJoyStick.h	(revision 1298)
+++ code/branches/input/src/ois/OISJoyStick.h	(revision 1304)
@@ -168,5 +168,5 @@
 			The ComponentType you are interested in knowing about
 		*/
-		int getNumberOfComponents(ComponentType cType);
+		int getNumberOfComponents(ComponentType cType) const;
 
 		/**
@@ -184,5 +184,5 @@
 			Returns the sensitivity cutoff for Vector3 Component
 		*/
-		float getVector3Sensitivity();
+		float getVector3Sensitivity() const;
 
 		/**
@@ -196,5 +196,5 @@
 
 		/** @remarks Returns currently set callback.. or null */
-		JoyStickListener* getEventCallback();
+		JoyStickListener* getEventCallback() const;
 
 		/** @remarks Returns the state of the joystick - is valid for both buffered and non buffered mode */
Index: code/branches/input/src/ois/OISKeyboard.cpp
===================================================================
--- code/branches/input/src/ois/OISKeyboard.cpp	(revision 1298)
+++ code/branches/input/src/ois/OISKeyboard.cpp	(revision 1304)
@@ -33,5 +33,5 @@
 
 //----------------------------------------------------------------------//
-bool Keyboard::isModifierDown( Modifier mod )
+bool Keyboard::isModifierDown( Modifier mod ) const
 {
 #if defined(OIS_MSVC_COMPILER)
Index: code/branches/input/src/ois/OISKeyboard.h
===================================================================
--- code/branches/input/src/ois/OISKeyboard.h	(revision 1298)
+++ code/branches/input/src/ois/OISKeyboard.h	(revision 1304)
@@ -220,5 +220,5 @@
 			A KeyCode to check
 		*/
-		virtual bool isKeyDown( KeyCode key ) = 0;
+		virtual bool isKeyDown( KeyCode key ) const = 0;
 
 		/**
@@ -235,5 +235,5 @@
 			Returns currently set callback.. or 0
 		*/
-		KeyListener* getEventCallback() {return mListener;}
+		KeyListener* getEventCallback() const {return mListener;}
 
 		//! TextTranslation Mode
@@ -260,5 +260,5 @@
 			Returns current translation mode
 		*/
-		TextTranslationMode getTextTranslation(){return mTextMode;}
+		TextTranslationMode getTextTranslation() const {return mTextMode;}
 		
 		/**
@@ -286,5 +286,5 @@
 			Check modifier status
 		*/
-		bool isModifierDown( Modifier mod );
+		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] ) = 0;
+		virtual void copyKeyStates( char keys[256] ) const = 0;
 		
 	protected:
Index: code/branches/input/src/ois/OISMouse.h
===================================================================
--- code/branches/input/src/ois/OISMouse.h	(revision 1298)
+++ code/branches/input/src/ois/OISMouse.h	(revision 1304)
@@ -120,5 +120,5 @@
 
 		/** @remarks Returns currently set callback.. or 0 */
-		MouseListener* getEventCallback() {return mListener;}
+		MouseListener* getEventCallback() const {return mListener;}
 
 		/** @remarks Returns the state of the mouse - is valid for both buffered and non buffered mode */
Index: code/branches/input/src/ois/OISObject.h
===================================================================
--- code/branches/input/src/ois/OISObject.h	(revision 1298)
+++ code/branches/input/src/ois/OISObject.h	(revision 1304)
@@ -45,5 +45,5 @@
 
 		/** @remarks Returns this input object's creator */
-		InputManager* getCreator() { return mCreator; }
+		InputManager* getCreator() const { return mCreator; }
 
 		/** @remarks Sets buffered mode	*/
Index: code/branches/input/src/ois/linux/LinuxKeyboard.cpp
===================================================================
--- code/branches/input/src/ois/linux/LinuxKeyboard.cpp	(revision 1298)
+++ code/branches/input/src/ois/linux/LinuxKeyboard.cpp	(revision 1304)
@@ -290,5 +290,5 @@
 
 //-------------------------------------------------------------------//
-bool LinuxKeyboard::isKeyDown( KeyCode key )
+bool LinuxKeyboard::isKeyDown( KeyCode key ) const
 {
 	return (KeyBuffer[key]);
@@ -449,5 +449,5 @@
 
 //-------------------------------------------------------------------//
-void LinuxKeyboard::copyKeyStates( char keys[256] )
+void LinuxKeyboard::copyKeyStates( char keys[256] ) const
 {
 	memcpy( keys, KeyBuffer, 256 );
Index: code/branches/input/src/ois/linux/LinuxKeyboard.h
===================================================================
--- code/branches/input/src/ois/linux/LinuxKeyboard.h	(revision 1298)
+++ code/branches/input/src/ois/linux/LinuxKeyboard.h	(revision 1304)
@@ -38,5 +38,5 @@
 
 		/** @copydoc Keyboard::isKeyDown */
-		virtual bool isKeyDown( KeyCode key );
+		virtual bool isKeyDown( KeyCode key ) const;
 
 		/** @copydoc Keyboard::getAsString */
@@ -44,5 +44,5 @@
 
 		/** @copydoc Keyboard::copyKeyStates */
-		virtual void copyKeyStates( char keys[256] );
+		virtual void copyKeyStates( char keys[256] ) const;
 
 		/** @copydoc Object::setBuffered */
Index: code/branches/input/src/ois/mac/MacKeyboard.cpp
===================================================================
--- code/branches/input/src/ois/mac/MacKeyboard.cpp	(revision 1298)
+++ code/branches/input/src/ois/mac/MacKeyboard.cpp	(revision 1304)
@@ -130,5 +130,5 @@
 
 //-------------------------------------------------------------------//
-bool MacKeyboard::isKeyDown( KeyCode key )
+bool MacKeyboard::isKeyDown( KeyCode key ) const
 {
 	return (bool)KeyBuffer[key];
@@ -321,5 +321,5 @@
 
 //-------------------------------------------------------------------//
-void MacKeyboard::copyKeyStates( char keys[256] )
+void MacKeyboard::copyKeyStates( char keys[256] ) const
 {
 	memcpy( keys, KeyBuffer, 256 );
Index: code/branches/input/src/ois/mac/MacKeyboard.h
===================================================================
--- code/branches/input/src/ois/mac/MacKeyboard.h	(revision 1298)
+++ code/branches/input/src/ois/mac/MacKeyboard.h	(revision 1304)
@@ -43,5 +43,5 @@
         
         // unbuffered keydown check
-        virtual bool isKeyDown( KeyCode key );
+        virtual bool isKeyDown( KeyCode key ) const;
         
         // This will send listener events if buffered is on.
@@ -51,5 +51,5 @@
         
         // Copies the current key buffer
-        virtual void copyKeyStates( char keys[256] );
+        virtual void copyKeyStates( char keys[256] ) const;
         
         // Returns a description of the given key
Index: code/branches/input/src/ois/win32/Win32JoyStick.cpp
===================================================================
--- code/branches/input/src/ois/win32/Win32JoyStick.cpp	(revision 1298)
+++ code/branches/input/src/ois/win32/Win32JoyStick.cpp	(revision 1304)
@@ -149,6 +149,6 @@
 	diptr.diph.dwHow        = DIPH_BYID;
 	diptr.diph.dwObj        = lpddoi->dwType;
-	//Add the high bit in so that an axis value of zero does not mean a null userdata
-	diptr.uData             = 0x80000000 | _this->_AxisNumber;
+	//Add a magic number to recognise we set seomthing
+	diptr.uData             = 0x13130000 | _this->_AxisNumber;
 
 	//Check if axis is slider, if so, do not treat as regular axis
@@ -166,5 +166,6 @@
 
 	//Increase for next time through
-	_this->_AxisNumber += 1;
+	if(GUID_Slider != lpddoi->guidType)
+		_this->_AxisNumber += 1;
 
 	//Set range
@@ -238,79 +239,80 @@
 	for(unsigned int i = 0; i < entries; ++i)
 	{
-		//First check to see if event entry is a Axis we enumerated earlier
-		if( diBuff[i].uAppData != 0xFFFFFFFF && diBuff[i].uAppData > 0 )
+		//This may seem outof order, but is in order of the way these variables
+		//are declared in the JoyStick State 2 structure.
+		switch(diBuff[i].dwOfs)
 		{
-			int axis = (int)(0x7FFFFFFF & diBuff[i].uAppData); //Mask out the high bit
-			assert( axis >= 0 && axis < (int)mState.mAxes.size() && "Axis out of range!");
-			mState.mAxes[axis].abs = diBuff[i].dwData;
-			axisMoved[axis] = true;
-		}
-		else
-		{
-			//This may seem outof order, but is in order of the way these variables
-			//are declared in the JoyStick State 2 structure.
-			switch(diBuff[i].dwOfs)
+		//------ slider -//
+		case DIJOFS_SLIDER0(0):
+			sliderMoved[0] = true;
+			mState.mSliders[0].abX = diBuff[i].dwData;
+			break;
+		case DIJOFS_SLIDER0(1):
+			sliderMoved[0] = true;
+			mState.mSliders[0].abY = diBuff[i].dwData;
+			break;
+		//----- Max 4 POVs Next ---------------//
+		case DIJOFS_POV(0):
+			if(!_changePOV(0,diBuff[i]))
+				return;
+			break;
+		case DIJOFS_POV(1):
+			if(!_changePOV(1,diBuff[i]))
+				return;
+			break;
+		case DIJOFS_POV(2):
+			if(!_changePOV(2,diBuff[i]))
+				return;
+			break;
+		case DIJOFS_POV(3):
+			if(!_changePOV(3,diBuff[i]))
+				return;
+			break;
+		case DIJOFS_SLIDER1(0):
+			sliderMoved[1] = true;
+			mState.mSliders[1].abX = diBuff[i].dwData;
+			break;
+		case DIJOFS_SLIDER1(1):
+			sliderMoved[1] = true;
+			mState.mSliders[1].abY = diBuff[i].dwData;
+			break;
+		case DIJOFS_SLIDER2(0):
+			sliderMoved[2] = true;
+			mState.mSliders[2].abX = diBuff[i].dwData;
+			break;
+		case DIJOFS_SLIDER2(1):
+			sliderMoved[2] = true;
+			mState.mSliders[2].abY = diBuff[i].dwData;
+			break;
+		case DIJOFS_SLIDER3(0):
+			sliderMoved[3] = true;
+			mState.mSliders[3].abX = diBuff[i].dwData;
+			break;
+		case DIJOFS_SLIDER3(1):
+			sliderMoved[3] = true;
+			mState.mSliders[3].abY = diBuff[i].dwData;
+			break;
+		//-----------------------------------------//
+		default:
+			//Handle Button Events Easily using the DX Offset Macros
+			if( diBuff[i].dwOfs >= DIJOFS_BUTTON(0) && diBuff[i].dwOfs < DIJOFS_BUTTON(128) )
 			{
-			//------ slider -//
-			case DIJOFS_SLIDER0(0):
-				sliderMoved[0] = true;
-				mState.mSliders[0].abX = diBuff[i].dwData;
-				break;
-			case DIJOFS_SLIDER0(1):
-				sliderMoved[0] = true;
-				mState.mSliders[0].abY = diBuff[i].dwData;
-				break;
-			//----- Max 4 POVs Next ---------------//
-			case DIJOFS_POV(0):
-				if(!_changePOV(0,diBuff[i]))
+				if(!_doButtonClick((diBuff[i].dwOfs - DIJOFS_BUTTON(0)), diBuff[i]))
 					return;
-				break;
-			case DIJOFS_POV(1):
-				if(!_changePOV(1,diBuff[i]))
-					return;
-				break;
-			case DIJOFS_POV(2):
-				if(!_changePOV(2,diBuff[i]))
-					return;
-				break;
-			case DIJOFS_POV(3):
-				if(!_changePOV(3,diBuff[i]))
-					return;
-				break;
-			case DIJOFS_SLIDER1(0):
-				sliderMoved[1] = true;
-				mState.mSliders[1].abX = diBuff[i].dwData;
-				break;
-			case DIJOFS_SLIDER1(1):
-				sliderMoved[1] = true;
-				mState.mSliders[1].abY = diBuff[i].dwData;
-				break;
-			case DIJOFS_SLIDER2(0):
-				sliderMoved[2] = true;
-				mState.mSliders[2].abX = diBuff[i].dwData;
-				break;
-			case DIJOFS_SLIDER2(1):
-				sliderMoved[2] = true;
-				mState.mSliders[2].abY = diBuff[i].dwData;
-				break;
-			case DIJOFS_SLIDER3(0):
-				sliderMoved[3] = true;
-				mState.mSliders[3].abX = diBuff[i].dwData;
-				break;
-			case DIJOFS_SLIDER3(1):
-				sliderMoved[3] = true;
-				mState.mSliders[3].abY = diBuff[i].dwData;
-				break;
-			//-----------------------------------------//
-			default:
-				//Handle Button Events Easily using the DX Offset Macros
-				if( diBuff[i].dwOfs >= DIJOFS_BUTTON(0) && diBuff[i].dwOfs < DIJOFS_BUTTON(128) )
+			}
+			else if((short)(diBuff[i].uAppData >> 16) == 0x1313)
+			{	//If it was nothing else, might be axis enumerated earlier (determined by magic number)
+				int axis = (int)(0x0000FFFF & diBuff[i].uAppData); //Mask out the high bit
+				assert( axis >= 0 && axis < (int)mState.mAxes.size() && "Axis out of range!");
+
+				if(axis >= 0 && axis < (int)mState.mAxes.size())
 				{
-					if(!_doButtonClick((diBuff[i].dwOfs - DIJOFS_BUTTON(0)), diBuff[i]))
-						return;
+					mState.mAxes[axis].abs = diBuff[i].dwData;
+					axisMoved[axis] = true;
 				}
-				break;
-			} //end case
-		} //End else
+			}
+
+			break;
+		} //end case
 	} //end for
 
Index: code/branches/input/src/ois/win32/Win32KeyBoard.cpp
===================================================================
--- code/branches/input/src/ois/win32/Win32KeyBoard.cpp	(revision 1298)
+++ code/branches/input/src/ois/win32/Win32KeyBoard.cpp	(revision 1304)
@@ -105,4 +105,6 @@
 	DWORD entries = KEYBOARD_DX_BUFFERSIZE;
 	HRESULT hr;
+	//Only one keyboard allowed per app, so static is ok
+	static bool verifyAfterAltTab = false;
 
 	hr = mKeyboard->GetDeviceData( sizeof(DIDEVICEOBJECTDATA), diBuff, &entries, 0 );
@@ -110,6 +112,10 @@
 	{
 		hr = mKeyboard->Acquire();
+		if (hr == E_ACCESSDENIED)
+			verifyAfterAltTab = true;
+
 		while( hr == DIERR_INPUTLOST )
 			hr = mKeyboard->Acquire();
+
 		return;
 	}
@@ -121,5 +127,5 @@
 	for(unsigned int i = 0; i < entries; ++i )
 	{
-		//If the mListener returns false, that means that we are probably deleted...
+		//If the listener returns false, that means that we are probably deleted...
 		//send no more events and just leave as the this pointer is invalid now...
 		bool ret = true;
@@ -159,4 +165,37 @@
 		if(ret == false)
 			break;
+	}
+
+	// If a lost device/access denied was detected, recover gracefully with new events
+	if(verifyAfterAltTab)
+	{
+		bool ret = true;
+		
+		//Copy old buffer to temp location to compare against
+		unsigned char keyBufferCopy[256];
+		memcpy(keyBufferCopy, KeyBuffer, 256);
+
+		//Update new state
+		_read();
+
+		for (unsigned i = 0; i < 256; i++)
+		{
+			if (keyBufferCopy[i] != KeyBuffer[i])
+			{
+				if (mListener)
+				{
+					if (KeyBuffer[i])
+						ret = mListener->keyPressed( KeyEvent( this, (KeyCode)i, _translateText((KeyCode)i) ) );
+					else
+						ret = mListener->keyReleased( KeyEvent( this, (KeyCode)i, 0 ) );
+				}
+			}
+
+			//If user returned false from callback, return immediately
+			if(ret == false)
+				return;
+		}
+
+		verifyAfterAltTab = false;
 	}
 }
@@ -243,5 +282,5 @@
 
 //--------------------------------------------------------------------------------------------------//
-bool Win32Keyboard::isKeyDown( KeyCode key )
+bool Win32Keyboard::isKeyDown( KeyCode key ) const
 {
 	return (KeyBuffer[key] & 0x80) != 0;
@@ -272,5 +311,5 @@
 
 //--------------------------------------------------------------------------------------------------//
-void Win32Keyboard::copyKeyStates( char keys[256] )
+void Win32Keyboard::copyKeyStates( char keys[256] ) const
 {
 	for(int i = 0; i < 256; ++i)
Index: code/branches/input/src/ois/win32/Win32KeyBoard.h
===================================================================
--- code/branches/input/src/ois/win32/Win32KeyBoard.h	(revision 1298)
+++ code/branches/input/src/ois/win32/Win32KeyBoard.h	(revision 1304)
@@ -46,5 +46,5 @@
 
 		/** @copydoc Keyboard::isKeyDown */
-		virtual bool isKeyDown( KeyCode key );
+		virtual bool isKeyDown( KeyCode key ) const;
 		
 		/** @copydoc Keyboard::getAsString */
@@ -52,5 +52,5 @@
 
 		/** @copydoc Keyboard::copyKeyStates */
-		virtual void copyKeyStates( char keys[256] );
+		virtual void copyKeyStates( char keys[256] ) const;
 
 		/** @copydoc Object::setBuffered */
