Commit 01314637 authored by Ben Hymers's avatar Ben Hymers
Browse files

Removed all trailing whitespace

parent b408932f
...@@ -67,7 +67,7 @@ void LIRCControl::capture() ...@@ -67,7 +67,7 @@ void LIRCControl::capture()
LIRCEvent events[OIS_LIRC_EVENT_BUFFER]; LIRCEvent events[OIS_LIRC_EVENT_BUFFER];
if( entries > OIS_LIRC_EVENT_BUFFER ) if( entries > OIS_LIRC_EVENT_BUFFER )
entries = OIS_LIRC_EVENT_BUFFER; entries = OIS_LIRC_EVENT_BUFFER;
mRingBuffer.Read(events, entries); mRingBuffer.Read(events, entries);
//Loop through each event //Loop through each event
......
...@@ -8,16 +8,16 @@ Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com) ...@@ -8,16 +8,16 @@ Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
This software is provided 'as-is', without any express or implied warranty. In no event will This software is provided 'as-is', without any express or implied warranty. In no event will
the authors be held liable for any damages arising from the use of this software. the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose, including commercial Permission is granted to anyone to use this software for any purpose, including commercial
applications, and to alter it and redistribute it freely, subject to the following applications, and to alter it and redistribute it freely, subject to the following
restrictions: restrictions:
1. The origin of this software must not be misrepresented; you must not claim that 1. The origin of this software must not be misrepresented; you must not claim that
you wrote the original software. If you use this software in a product, you wrote the original software. If you use this software in a product,
an acknowledgment in the product documentation would be appreciated but is an acknowledgment in the product documentation would be appreciated but is
not required. not required.
2. Altered source versions must be plainly marked as such, and must not be 2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software. misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
...@@ -58,7 +58,7 @@ public: ...@@ -58,7 +58,7 @@ public:
//Thread Stuff //Thread Stuff
//! Boost thread execution object (only alive when at least 1 lirc is alive) //! Boost thread execution object (only alive when at least 1 lirc is alive)
boost::thread *mThreadHandler; boost::thread *mThreadHandler;
//! Gaurds access to the active lirc list //! Gaurds access to the active lirc list
boost::mutex mLircListMutex; boost::mutex mLircListMutex;
...@@ -151,13 +151,13 @@ void LIRCFactoryCreator::discoverRemotes() ...@@ -151,13 +151,13 @@ void LIRCFactoryCreator::discoverRemotes()
{ {
std::ostringstream istr; std::ostringstream istr;
istr << "LIST " << mUnusedRemotes[i] << "\n"; istr << "LIST " << mUnusedRemotes[i] << "\n";
mWrapped->mSocket.write_some(boost::asio::buffer(istr.str())); mWrapped->mSocket.write_some(boost::asio::buffer(istr.str()));
RemoteInfo information; RemoteInfo information;
int buttonCount = 0; int buttonCount = 0;
start = data = false; start = data = false;
for(;;) for(;;)
{ {
boost::asio::read_until(mWrapped->mSocket, buffer, '\n'); boost::asio::read_until(mWrapped->mSocket, buffer, '\n');
...@@ -263,7 +263,7 @@ void LIRCFactoryCreator::threadUpdate() ...@@ -263,7 +263,7 @@ void LIRCFactoryCreator::threadUpdate()
while( mWrapped->mSocket.in_avail() > 0 ) while( mWrapped->mSocket.in_avail() > 0 )
{ {
boost::asio::read_until(mWrapped->mSocket, buffer, '\n'); boost::asio::read_until(mWrapped->mSocket, buffer, '\n');
stream >> code; //64 bit value, ignorable stream >> code; //64 bit value, ignorable
stream >> repeat; //Repeat rate starting at zero (we ignore, for now) stream >> repeat; //Repeat rate starting at zero (we ignore, for now)
stream >> button; //Button name stream >> button; //Button name
...@@ -281,7 +281,7 @@ void LIRCFactoryCreator::threadUpdate() ...@@ -281,7 +281,7 @@ void LIRCFactoryCreator::threadUpdate()
} }
catch(...) catch(...)
{ //Hmm, what should we do if we get a socket error here.. Ignore it I suppose, { //Hmm, what should we do if we get a socket error here.. Ignore it I suppose,
} //and wait till the used remote objects get shutdown. We could try to } //and wait till the used remote objects get shutdown. We could try to
//reconnect, but how do we know if we will even get the same remotes. //reconnect, but how do we know if we will even get the same remotes.
boost::xtime_get(&timer, boost::TIME_UTC); boost::xtime_get(&timer, boost::TIME_UTC);
...@@ -359,7 +359,7 @@ Object* LIRCFactoryCreator::createObject(InputManager* creator, Type iType, bool ...@@ -359,7 +359,7 @@ Object* LIRCFactoryCreator::createObject(InputManager* creator, Type iType, bool
return obj; return obj;
} }
} }
OIS_EXCEPT(E_InputDeviceNonExistant, "No Device found which matches description!"); OIS_EXCEPT(E_InputDeviceNonExistant, "No Device found which matches description!");
} }
...@@ -392,7 +392,7 @@ void LIRCFactoryCreator::destroyObject(Object* obj) ...@@ -392,7 +392,7 @@ void LIRCFactoryCreator::destroyObject(Object* obj)
//Move from used to unused list //Move from used to unused list
mUnusedRemotes.push_back(i->first); mUnusedRemotes.push_back(i->first);
mUpdateRemotes.erase(i); mUpdateRemotes.erase(i);
delete obj; delete obj;
remotes_alive = (int)mUpdateRemotes.size(); remotes_alive = (int)mUpdateRemotes.size();
......
...@@ -8,16 +8,16 @@ Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com) ...@@ -8,16 +8,16 @@ Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
This software is provided 'as-is', without any express or implied warranty. In no event will This software is provided 'as-is', without any express or implied warranty. In no event will
the authors be held liable for any damages arising from the use of this software. the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose, including commercial Permission is granted to anyone to use this software for any purpose, including commercial
applications, and to alter it and redistribute it freely, subject to the following applications, and to alter it and redistribute it freely, subject to the following
restrictions: restrictions:
1. The origin of this software must not be misrepresented; you must not claim that 1. The origin of this software must not be misrepresented; you must not claim that
you wrote the original software. If you use this software in a product, you wrote the original software. If you use this software in a product,
an acknowledgment in the product documentation would be appreciated but is an acknowledgment in the product documentation would be appreciated but is
not required. not required.
2. Altered source versions must be plainly marked as such, and must not be 2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software. misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
...@@ -80,7 +80,7 @@ namespace OIS ...@@ -80,7 +80,7 @@ namespace OIS
//! List of vendor named remotes that are not used yet //! List of vendor named remotes that are not used yet
std::vector<std::string> mUnusedRemotes; std::vector<std::string> mUnusedRemotes;
//! Information about enumerated remotes //! Information about enumerated remotes
std::map<std::string, RemoteInfo> mJoyStickInformation; std::map<std::string, RemoteInfo> mJoyStickInformation;
......
...@@ -8,16 +8,16 @@ Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com) ...@@ -8,16 +8,16 @@ Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
This software is provided 'as-is', without any express or implied warranty. In no event will This software is provided 'as-is', without any express or implied warranty. In no event will
the authors be held liable for any damages arising from the use of this software. the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose, including commercial Permission is granted to anyone to use this software for any purpose, including commercial
applications, and to alter it and redistribute it freely, subject to the following applications, and to alter it and redistribute it freely, subject to the following
restrictions: restrictions:
1. The origin of this software must not be misrepresented; you must not claim that 1. The origin of this software must not be misrepresented; you must not claim that
you wrote the original software. If you use this software in a product, you wrote the original software. If you use this software in a product,
an acknowledgment in the product documentation would be appreciated but is an acknowledgment in the product documentation would be appreciated but is
not required. not required.
2. Altered source versions must be plainly marked as such, and must not be 2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software. misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
...@@ -84,10 +84,10 @@ namespace OIS ...@@ -84,10 +84,10 @@ namespace OIS
LIRCEvent *buffer; LIRCEvent *buffer;
//! Index of next writable byte. Set by RingBuffer_AdvanceWriteIndex. //! Index of next writable byte. Set by RingBuffer_AdvanceWriteIndex.
volatile int writeIndex; volatile int writeIndex;
//! Index of next readable byte. Set by RingBuffer_AdvanceReadIndex. //! Index of next readable byte. Set by RingBuffer_AdvanceReadIndex.
volatile int readIndex; volatile int readIndex;
public: public:
LIRCRingBuffer( unsigned int numEntries ) LIRCRingBuffer( unsigned int numEntries )
...@@ -112,7 +112,7 @@ namespace OIS ...@@ -112,7 +112,7 @@ namespace OIS
unsigned int RoundUpToNextPowerOf2( unsigned int n ) unsigned int RoundUpToNextPowerOf2( unsigned int n )
{ {
int numBits = 0; int numBits = 0;
if( ((n-1) & n) == 0) if( ((n-1) & n) == 0)
return n; //Already Power of two. return n; //Already Power of two.
while( n > 0 ) while( n > 0 )
...@@ -140,7 +140,7 @@ namespace OIS ...@@ -140,7 +140,7 @@ namespace OIS
{ {
int size1 = 0, size2 = 0, numWritten; int size1 = 0, size2 = 0, numWritten;
int data1Ptr = 0, data2Ptr = 0; int data1Ptr = 0, data2Ptr = 0;
numWritten = GetWriteRegions( numEntries, data1Ptr, size1, data2Ptr, size2 ); numWritten = GetWriteRegions( numEntries, data1Ptr, size1, data2Ptr, size2 );
if( size2 > 0 ) if( size2 > 0 )
...@@ -168,9 +168,9 @@ namespace OIS ...@@ -168,9 +168,9 @@ namespace OIS
int Read( LIRCEvent *data, int numEntries ) int Read( LIRCEvent *data, int numEntries )
{ {
int size1 = 0, size2 = 0, numRead, data1Ptr = 0, data2Ptr = 0; int size1 = 0, size2 = 0, numRead, data1Ptr = 0, data2Ptr = 0;
numRead = GetReadRegions( numEntries, data1Ptr, size1, data2Ptr, size2 ); numRead = GetReadRegions( numEntries, data1Ptr, size1, data2Ptr, size2 );
if( size2 > 0 ) if( size2 > 0 )
{ {
memcpy( data, &buffer[data1Ptr], sizeof(LIRCEvent) * size1 ); memcpy( data, &buffer[data1Ptr], sizeof(LIRCEvent) * size1 );
...@@ -193,9 +193,9 @@ namespace OIS ...@@ -193,9 +193,9 @@ namespace OIS
{ {
int index; int index;
int available = GetWriteAvailable(); int available = GetWriteAvailable();
if( numEntries > available ) if( numEntries > available )
numEntries = available; numEntries = available;
//Check to see if write is not contiguous. //Check to see if write is not contiguous.
index = writeIndex & smallMask; index = writeIndex & smallMask;
if( (index + numEntries) > bufferSize ) if( (index + numEntries) > bufferSize )
...@@ -216,15 +216,15 @@ namespace OIS ...@@ -216,15 +216,15 @@ namespace OIS
} }
return numEntries; return numEntries;
} }
int GetReadRegions( int numEntries, int &dataPtr1, int &sizePtr1, int &dataPtr2, int &sizePtr2 ) int GetReadRegions( int numEntries, int &dataPtr1, int &sizePtr1, int &dataPtr2, int &sizePtr2 )
{ {
int index; int index;
int available = GetReadAvailable( ); int available = GetReadAvailable( );
if( numEntries > available ) if( numEntries > available )
numEntries = available; numEntries = available;
// Check to see if read is not contiguous // Check to see if read is not contiguous
index = readIndex & smallMask; index = readIndex & smallMask;
if( (index + numEntries) > bufferSize ) if( (index + numEntries) > bufferSize )
......
/* /*
The zlib/libpng License The zlib/libpng License
Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com) Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
This software is provided 'as-is', without any express or implied warranty. In no event will This software is provided 'as-is', without any express or implied warranty. In no event will
the authors be held liable for any damages arising from the use of this software. the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose, including commercial Permission is granted to anyone to use this software for any purpose, including commercial
applications, and to alter it and redistribute it freely, subject to the following applications, and to alter it and redistribute it freely, subject to the following
restrictions: restrictions:
1. The origin of this software must not be misrepresented; you must not claim that 1. The origin of this software must not be misrepresented; you must not claim that
you wrote the original software. If you use this software in a product, you wrote the original software. If you use this software in a product,
an acknowledgment in the product documentation would be appreciated but is an acknowledgment in the product documentation would be appreciated but is
not required. not required.
2. Altered source versions must be plainly marked as such, and must not be 2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software. misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
*/ */
#include "iphone/iPhoneAccelerometer.h" #include "iphone/iPhoneAccelerometer.h"
...@@ -30,7 +30,7 @@ iPhoneAccelerometer::iPhoneAccelerometer( InputManager* creator, bool buffered ) ...@@ -30,7 +30,7 @@ iPhoneAccelerometer::iPhoneAccelerometer( InputManager* creator, bool buffered )
: JoyStick(creator->inputSystemName(), buffered, 0, creator) : JoyStick(creator->inputSystemName(), buffered, 0, creator)
{ {
iPhoneInputManager *man = static_cast<iPhoneInputManager*>(mCreator); iPhoneInputManager *man = static_cast<iPhoneInputManager*>(mCreator);
man->_setAccelerometerUsed(true); man->_setAccelerometerUsed(true);
[man->_getDelegate() setAccelerometerObject:this]; [man->_getDelegate() setAccelerometerObject:this];
[[UIAccelerometer sharedAccelerometer] setDelegate:man->_getDelegate()]; [[UIAccelerometer sharedAccelerometer] setDelegate:man->_getDelegate()];
...@@ -40,7 +40,7 @@ iPhoneAccelerometer::iPhoneAccelerometer( InputManager* creator, bool buffered ) ...@@ -40,7 +40,7 @@ iPhoneAccelerometer::iPhoneAccelerometer( InputManager* creator, bool buffered )
iPhoneAccelerometer::~iPhoneAccelerometer() iPhoneAccelerometer::~iPhoneAccelerometer()
{ {
iPhoneInputManager *man = static_cast<iPhoneInputManager*>(mCreator); iPhoneInputManager *man = static_cast<iPhoneInputManager*>(mCreator);
man->_setAccelerometerUsed(false); man->_setAccelerometerUsed(false);
[man->_getDelegate() setAccelerometerObject:nil]; [man->_getDelegate() setAccelerometerObject:nil];
} }
...@@ -64,7 +64,7 @@ void iPhoneAccelerometer::setBuffered( bool buffered ) ...@@ -64,7 +64,7 @@ void iPhoneAccelerometer::setBuffered( bool buffered )
void iPhoneAccelerometer::didAccelerate(UIAcceleration *acceleration) void iPhoneAccelerometer::didAccelerate(UIAcceleration *acceleration)
{ {
mTempState.clear(); mTempState.clear();
mTempState.x = acceleration.x; mTempState.x = acceleration.x;
mTempState.y = acceleration.y; mTempState.y = acceleration.y;
mTempState.z = acceleration.z; mTempState.z = acceleration.z;
......
/* /*
The zlib/libpng License The zlib/libpng License
Copyright (c) 2006 Chris Snyder Copyright (c) 2006 Chris Snyder
This software is provided 'as-is', without any express or implied warranty. In no event will This software is provided 'as-is', without any express or implied warranty. In no event will
the authors be held liable for any damages arising from the use of this software. the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose, including commercial Permission is granted to anyone to use this software for any purpose, including commercial
applications, and to alter it and redistribute it freely, subject to the following applications, and to alter it and redistribute it freely, subject to the following
restrictions: restrictions:
1. The origin of this software must not be misrepresented; you must not claim that 1. The origin of this software must not be misrepresented; you must not claim that
you wrote the original software. If you use this software in a product, you wrote the original software. If you use this software in a product,
an acknowledgment in the product documentation would be appreciated but is an acknowledgment in the product documentation would be appreciated but is
not required. not required.
2. Altered source versions must be plainly marked as such, and must not be 2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software. misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
*/ */
...@@ -108,9 +108,9 @@ iPhoneInputManager::~iPhoneInputManager() ...@@ -108,9 +108,9 @@ iPhoneInputManager::~iPhoneInputManager()
void iPhoneInputManager::_initialize( ParamList &paramList ) void iPhoneInputManager::_initialize( ParamList &paramList )
{ {
_parseConfigSettings( paramList ); _parseConfigSettings( paramList );
mDelegate = [[InputDelegate alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; mDelegate = [[InputDelegate alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Set flags that we want to accept multiple finger touches and be the only one to receive touch events // Set flags that we want to accept multiple finger touches and be the only one to receive touch events
[mDelegate setMultipleTouchEnabled:YES]; [mDelegate setMultipleTouchEnabled:YES];
[mDelegate setExclusiveTouch:YES]; [mDelegate setExclusiveTouch:YES];
...@@ -137,7 +137,7 @@ void iPhoneInputManager::_parseConfigSettings( ParamList &paramList ) ...@@ -137,7 +137,7 @@ void iPhoneInputManager::_parseConfigSettings( ParamList &paramList )
// graphics libraries, if that fails then try at the application level. // graphics libraries, if that fails then try at the application level.
mWindow = [[UIApplication sharedApplication] keyWindow]; mWindow = [[UIApplication sharedApplication] keyWindow];
} }
if(mWindow == nil) if(mWindow == nil)
OIS_EXCEPT( E_General, "iPhoneInputManager::_parseConfigSettings >> Unable to find a window or event target" ); OIS_EXCEPT( E_General, "iPhoneInputManager::_parseConfigSettings >> Unable to find a window or event target" );
} }
...@@ -188,7 +188,7 @@ bool iPhoneInputManager::vendorExist(Type iType, const std::string & vendor) ...@@ -188,7 +188,7 @@ bool iPhoneInputManager::vendorExist(Type iType, const std::string & vendor)
} }
//--------------------------------------------------------------------------------// //--------------------------------------------------------------------------------//
Object* iPhoneInputManager::createObject(InputManager* creator, Type iType, bool bufferMode, Object* iPhoneInputManager::createObject(InputManager* creator, Type iType, bool bufferMode,
const std::string & vendor) const std::string & vendor)
{ {
Object *obj = 0; Object *obj = 0;
......
/* /*
The zlib/libpng License The zlib/libpng License
Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com) Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
This software is provided 'as-is', without any express or implied warranty. In no event will This software is provided 'as-is', without any express or implied warranty. In no event will
the authors be held liable for any damages arising from the use of this software. the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose, including commercial Permission is granted to anyone to use this software for any purpose, including commercial
applications, and to alter it and redistribute it freely, subject to the following applications, and to alter it and redistribute it freely, subject to the following
restrictions: restrictions:
1. The origin of this software must not be misrepresented; you must not claim that 1. The origin of this software must not be misrepresented; you must not claim that
you wrote the original software. If you use this software in a product, you wrote the original software. If you use this software in a product,
an acknowledgment in the product documentation would be appreciated but is an acknowledgment in the product documentation would be appreciated but is
not required. not required.
2. Altered source versions must be plainly marked as such, and must not be 2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software. misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
*/ */
#include "iphone/iPhoneMultiTouch.h" #include "iphone/iPhoneMultiTouch.h"
...@@ -38,7 +38,7 @@ iPhoneMultiTouch::iPhoneMultiTouch( InputManager* creator, bool buffered ) ...@@ -38,7 +38,7 @@ iPhoneMultiTouch::iPhoneMultiTouch( InputManager* creator, bool buffered )
iPhoneMultiTouch::~iPhoneMultiTouch() iPhoneMultiTouch::~iPhoneMultiTouch()
{ {
iPhoneInputManager *man = static_cast<iPhoneInputManager*>(mCreator); iPhoneInputManager *man = static_cast<iPhoneInputManager*>(mCreator);
man->_setMultiTouchUsed(false); man->_setMultiTouchUsed(false);
[man->_getDelegate() setTouchObject:nil]; [man->_getDelegate() setTouchObject:nil];
} }
...@@ -70,11 +70,11 @@ void iPhoneMultiTouch::capture() ...@@ -70,11 +70,11 @@ void iPhoneMultiTouch::capture()
iState->X.rel = mTempState.X.rel; iState->X.rel = mTempState.X.rel;
iState->Y.rel = mTempState.Y.rel; iState->Y.rel = mTempState.Y.rel;
iState->Z.rel = mTempState.Z.rel; iState->Z.rel = mTempState.Z.rel;
// Update absolute position // Update absolute position
iState->X.abs += mTempState.X.rel; iState->X.abs += mTempState.X.rel;
iState->Y.abs += mTempState.Y.rel; iState->Y.abs += mTempState.Y.rel;
if(iState->X.abs > iState->width) if(iState->X.abs > iState->width)
iState->X.abs = iState->width; iState->X.abs = iState->width;
else if(iState->X.abs < 0) else if(iState->X.abs < 0)
...@@ -84,9 +84,9 @@ void iPhoneMultiTouch::capture() ...@@ -84,9 +84,9 @@ void iPhoneMultiTouch::capture()
iState->Y.abs = iState->height; iState->Y.abs = iState->height;
else if(iState->Y.abs < 0) else if(iState->Y.abs < 0)
iState->Y.abs = 0; iState->Y.abs = 0;
iState->Z.abs += mTempState.Z.rel; iState->Z.abs += mTempState.Z.rel;
//Fire off event //Fire off event
if(mListener && mBuffered) if(mListener && mBuffered)
mListener->touchMoved(MultiTouchEvent(this, *iState)); mListener->touchMoved(MultiTouchEvent(this, *iState));
......
...@@ -57,7 +57,7 @@ DeviceComponentInfo getComponentInfo( int deviceID ) ...@@ -57,7 +57,7 @@ DeviceComponentInfo getComponentInfo( int deviceID )
//Read "all" (hence 0) components of the device //Read "all" (hence 0) components of the device
#ifdef OIS_LINUX_JOY_DEBUG #ifdef OIS_LINUX_JOY_DEBUG
cout << "EventUtils::getComponentInfo(" << deviceID cout << "EventUtils::getComponentInfo(" << deviceID
<< ") : Reading device events features" << endl; << ") : Reading device events features" << endl;
#endif #endif
if (ioctl(deviceID, EVIOCGBIT(0, sizeof(ev_bits)), ev_bits) == -1) if (ioctl(deviceID, EVIOCGBIT(0, sizeof(ev_bits)), ev_bits) == -1)
...@@ -76,7 +76,7 @@ DeviceComponentInfo getComponentInfo( int deviceID ) ...@@ -76,7 +76,7 @@ DeviceComponentInfo getComponentInfo( int deviceID )
memset( abs_bits, 0, sizeof(abs_bits) ); memset( abs_bits, 0, sizeof(abs_bits) );
#ifdef OIS_LINUX_JOY_DEBUG #ifdef OIS_LINUX_JOY_DEBUG
cout << "EventUtils::getComponentInfo(" << deviceID cout << "EventUtils::getComponentInfo(" << deviceID
<< ") : Reading device absolute axis features" << endl; << ") : Reading device absolute axis features" << endl;
#endif #endif
...@@ -110,15 +110,15 @@ DeviceComponentInfo getComponentInfo( int deviceID ) ...@@ -110,15 +110,15 @@ DeviceComponentInfo getComponentInfo( int deviceID )
{ {
unsigned char rel_bits[1 + REL_MAX/8/sizeof(unsigned char)]; unsigned char rel_bits[1 + REL_MAX/8/sizeof(unsigned char)];
memset( rel_bits, 0, sizeof(rel_bits) ); memset( rel_bits, 0, sizeof(rel_bits) );
#ifdef OIS_LINUX_JOY_DEBUG #ifdef OIS_LINUX_JOY_DEBUG
cout << "EventUtils::getComponentInfo(" << deviceID cout << "EventUtils::getComponentInfo(" << deviceID
<< ") : Reading device relative axis features" << endl; << ") : Reading device relative axis features" << endl;
#endif #endif
if (ioctl(deviceID, EVIOCGBIT(i, sizeof(rel_bits)), rel_bits) == -1) if (ioctl(deviceID, EVIOCGBIT(i, sizeof(rel_bits)), rel_bits) == -1)
OIS_EXCEPT( E_General, "Could not read device relative axis features"); OIS_EXCEPT( E_General, "Could not read device relative axis features");
for (int j = 0; j < REL_MAX; j++) for (int j = 0; j < REL_MAX; j++)
{ {
if( isBitSet(rel_bits, j) ) if( isBitSet(rel_bits, j) )
...@@ -131,15 +131,15 @@ DeviceComponentInfo getComponentInfo( int deviceID ) ...@@ -131,15 +131,15 @@ DeviceComponentInfo getComponentInfo( int deviceID )
{ {
unsigned char key_bits[1 + KEY_MAX/8/sizeof(unsigned char)]; unsigned char key_bits[1 + KEY_MAX/8/sizeof(unsigned char)];
memset( key_bits, 0, sizeof(key_bits) ); memset( key_bits, 0, sizeof(key_bits) );
#ifdef OIS_LINUX_JOY_DEBUG #ifdef OIS_LINUX_JOY_DEBUG
cout << "EventUtils::getComponentInfo(" << deviceID cout << "EventUtils::getComponentInfo(" << deviceID
<< ") : Reading device buttons features" << endl; << ") : Reading device buttons features" << endl;
#endif #endif
if (ioctl(deviceID, EVIOCGBIT(i, sizeof(key_bits)), key_bits) == -1) if (ioctl(deviceID, EVIOCGBIT(i, sizeof(key_bits)), key_bits) == -1)
OIS_EXCEPT( E_General, "Could not read device buttons features"); OIS_EXCEPT( E_General, "Could not read device buttons features");
for (int j = 0; j < KEY_MAX; j++) for (int j = 0; j < KEY_MAX; j++)
{ {
if( isBitSet(key_bits, j) ) if( isBitSet(key_bits, j) )
...@@ -157,7 +157,7 @@ DeviceComponentInfo getComponentInfo( int deviceID ) ...@@ -157,7 +157,7 @@ DeviceComponentInfo getComponentInfo( int deviceID )
//-----------------------------------------------------------------------------// //-----------------------------------------------------------------------------//
bool EventUtils::isJoyStick( int deviceID, JoyStickInfo &js ) bool EventUtils::isJoyStick( int deviceID, JoyStickInfo &js )
{ {
if( deviceID == -1 ) if( deviceID == -1 )
OIS_EXCEPT( E_General, "Error with File Descriptor" ); OIS_EXCEPT( E_General, "Error with File Descriptor" );
DeviceComponentInfo info = getComponentInfo( deviceID ); DeviceComponentInfo info = getComponentInfo( deviceID );
...@@ -172,7 +172,7 @@ bool EventUtils::isJoyStick( int deviceID, JoyStickInfo &js ) ...@@ -172,7 +172,7 @@ bool EventUtils::isJoyStick( int deviceID, JoyStickInfo &js )
for(vector<int>::iterator i = info.buttons.begin(), e = info.buttons.end(); i != e; ++i ) for(vector<int>::iterator i = info.buttons.begin(), e = info.buttons.end(); i != e; ++i )
{ {
//Check to ensure we find at least one joy only button //Check to ensure we find at least one joy only button
if( (*i >= BTN_JOYSTICK && *i < BTN_GAMEPAD) if( (*i >= BTN_JOYSTICK && *i < BTN_GAMEPAD)
|| (*i >= BTN_GAMEPAD && *i < BTN_DIGI) || (*i >= BTN_GAMEPAD && *i < BTN_DIGI)
|| (*i >= BTN_WHEEL && *i < KEY_OK) ) || (*i >= BTN_WHEEL && *i < KEY_OK) )
joyButtonFound = true; joyButtonFound = true;
...@@ -180,7 +180,7 @@ bool EventUtils::isJoyStick( int deviceID, JoyStickInfo &js ) ...@@ -180,7 +180,7 @@ bool EventUtils::isJoyStick( int deviceID, JoyStickInfo &js )
js.button_map[*i] = buttons++; js.button_map[*i] = buttons++;
#ifdef OIS_LINUX_JOY_DEBUG #ifdef OIS_LINUX_JOY_DEBUG
cout << "Button Mapping ID (hex): " << hex << *i cout << "Button Mapping ID (hex): " << hex << *i
<< " OIS Button Num: " << dec << buttons-1 << endl; << " OIS Button Num: " << dec << buttons-1 << endl;
#endif #endif
} }
...@@ -212,7 +212,7 @@ bool EventUtils::isJoyStick( int deviceID, JoyStickInfo &js ) ...@@ -212,7 +212,7 @@ bool EventUtils::isJoyStick( int deviceID, JoyStickInfo &js )
js.axis_map[*i] = axes; js.axis_map[*i] = axes;
#ifdef OIS_LINUX_JOY_DEBUG #ifdef OIS_LINUX_JOY_DEBUG
cout << "EventUtils::isJoyStick(" << deviceID cout << "EventUtils::isJoyStick(" << deviceID
<< ") : Reading device absolute axis #" << *i << " features" << endl; << ") : Reading device absolute axis #" << *i << " features" << endl;
#endif #endif
...@@ -222,7 +222,7 @@ bool EventUtils::isJoyStick( int deviceID, JoyStickInfo &js ) ...@@ -222,7 +222,7 @@ bool EventUtils::isJoyStick( int deviceID, JoyStickInfo &js )
js.axis_range[axes] = Range(absinfo.minimum, absinfo.maximum); js.axis_range[axes] = Range(absinfo.minimum, absinfo.maximum);
#ifdef OIS_LINUX_JOY_DEBUG #ifdef OIS_LINUX_JOY_DEBUG
cout << "Axis Mapping ID (hex): " << hex << *i cout << "Axis Mapping ID (hex): " << hex << *i
<< " OIS Axis Num: " << dec << axes << endl; << " OIS Axis Num: " << dec << axes << endl;
#endif #endif
...@@ -237,7 +237,7 @@ bool EventUtils::isJoyStick( int deviceID, JoyStickInfo &js ) ...@@ -237,7 +237,7 @@ bool EventUtils::isJoyStick( int deviceID, JoyStickInfo &js )
string EventUtils::getName( int deviceID ) string EventUtils::getName( int deviceID )
{ {
#ifdef OIS_LINUX_JOY_DEBUG #ifdef OIS_LINUX_JOY_DEBUG
cout << "EventUtils::getName(" << deviceID cout << "EventUtils::getName(" << deviceID
<< ") : Reading device name" << endl; << ") : Reading device name" << endl;
#endif #endif
...@@ -251,7 +251,7 @@ string EventUtils::getName( int deviceID ) ...@@ -251,7 +251,7 @@ string EventUtils::getName( int deviceID )
string EventUtils::getUniqueId( int deviceID ) string EventUtils::getUniqueId( int deviceID )
{ {
#ifdef OIS_LINUX_JOY_DEBUG #ifdef OIS_LINUX_JOY_DEBUG
cout << "EventUtils::getUniqueId(" << deviceID cout << "EventUtils::getUniqueId(" << deviceID
<< ") : Reading device unique Id" << endl; << ") : Reading device unique Id" << endl;
#endif #endif
...@@ -266,7 +266,7 @@ string EventUtils::getUniqueId( int deviceID ) ...@@ -266,7 +266,7 @@ string EventUtils::getUniqueId( int deviceID )
string EventUtils::getPhysicalLocation( int deviceID ) string EventUtils::getPhysicalLocation( int deviceID )
{ {
#ifdef OIS_LINUX_JOY_DEBUG #ifdef OIS_LINUX_JOY_DEBUG
cout << "EventUtils::getPhysicalLocation(" << deviceID cout << "EventUtils::getPhysicalLocation(" << deviceID
<< ") : Reading device physical location" << endl; << ") : Reading device physical location" << endl;
#endif #endif
...@@ -318,7 +318,7 @@ void EventUtils::enumerateForceFeedback( int deviceID, LinuxForceFeedback** ff ) ...@@ -318,7 +318,7 @@ void EventUtils::enumerateForceFeedback( int deviceID, LinuxForceFeedback** ff )
memset(ff_bits, 0, sizeof(ff_bits)); memset(ff_bits, 0, sizeof(ff_bits));
#ifdef OIS_LINUX_JOY_DEBUG #ifdef OIS_LINUX_JOY_DEBUG
cout << "EventUtils::enumerateForceFeedback(" << deviceID cout << "EventUtils::enumerateForceFeedback(" << deviceID
<< ") : Reading device force feedback features" << endl; << ") : Reading device force feedback features" << endl;
#endif #endif
...@@ -359,7 +359,7 @@ void EventUtils::enumerateForceFeedback( int deviceID, LinuxForceFeedback** ff ) ...@@ -359,7 +359,7 @@ void EventUtils::enumerateForceFeedback( int deviceID, LinuxForceFeedback** ff )
//FF device properties //FF device properties
if (isBitSet(ff_bits, FF_GAIN)) if (isBitSet(ff_bits, FF_GAIN))
(*ff)->_setGainSupport(true); (*ff)->_setGainSupport(true);
if (isBitSet(ff_bits, FF_AUTOCENTER)) if (isBitSet(ff_bits, FF_AUTOCENTER))
(*ff)->_setAutoCenterSupport(true); (*ff)->_setAutoCenterSupport(true);
......
...@@ -64,7 +64,7 @@ unsigned short LinuxForceFeedback::getFFMemoryLoad() ...@@ -64,7 +64,7 @@ unsigned short LinuxForceFeedback::getFFMemoryLoad()
if (ioctl(mJoyStick, EVIOCGEFFECTS, &nEffects) == -1) if (ioctl(mJoyStick, EVIOCGEFFECTS, &nEffects) == -1)
OIS_EXCEPT(E_General, "Unknown error reading max number of uploaded effects."); OIS_EXCEPT(E_General, "Unknown error reading max number of uploaded effects.");
#if (OIS_LINUX_JOYFF_DEBUG > 1) #if (OIS_LINUX_JOYFF_DEBUG > 1)
cout << "LinuxForceFeedback("<< mJoyStick cout << "LinuxForceFeedback("<< mJoyStick
<< ") : Read device max number of uploaded effects : " << nEffects << endl; << ") : Read device max number of uploaded effects : " << nEffects << endl;
#endif #endif
...@@ -77,7 +77,7 @@ void LinuxForceFeedback::setMasterGain(float value) ...@@ -77,7 +77,7 @@ void LinuxForceFeedback::setMasterGain(float value)
if (!mSetGainSupport) if (!mSetGainSupport)
{ {
#if (OIS_LINUX_JOYFF_DEBUG > 0) #if (OIS_LINUX_JOYFF_DEBUG > 0)
cout << "LinuxForceFeedback("<< mJoyStick << ") : Setting master gain " cout << "LinuxForceFeedback("<< mJoyStick << ") : Setting master gain "
<< "is not supported by the device" << endl; << "is not supported by the device" << endl;
#endif #endif
return; return;
...@@ -95,7 +95,7 @@ void LinuxForceFeedback::setMasterGain(float value) ...@@ -95,7 +95,7 @@ void LinuxForceFeedback::setMasterGain(float value)
event.value = (__s32)(value * 0xFFFFUL); event.value = (__s32)(value * 0xFFFFUL);
#if (OIS_LINUX_JOYFF_DEBUG > 0) #if (OIS_LINUX_JOYFF_DEBUG > 0)
cout << "LinuxForceFeedback("<< mJoyStick << ") : Setting master gain to " cout << "LinuxForceFeedback("<< mJoyStick << ") : Setting master gain to "
<< value << " => " << event.value << endl; << value << " => " << event.value << endl;
#endif #endif
...@@ -110,7 +110,7 @@ void LinuxForceFeedback::setAutoCenterMode(bool enabled) ...@@ -110,7 +110,7 @@ void LinuxForceFeedback::setAutoCenterMode(bool enabled)
if (!mSetAutoCenterSupport) if (!mSetAutoCenterSupport)
{ {
#if (OIS_LINUX_JOYFF_DEBUG > 0) #if (OIS_LINUX_JOYFF_DEBUG > 0)
cout << "LinuxForceFeedback("<< mJoyStick << ") : Setting auto-center mode " cout << "LinuxForceFeedback("<< mJoyStick << ") : Setting auto-center mode "
<< "is not supported by the device" << endl; << "is not supported by the device" << endl;
#endif #endif
return; return;
...@@ -124,7 +124,7 @@ void LinuxForceFeedback::setAutoCenterMode(bool enabled) ...@@ -124,7 +124,7 @@ void LinuxForceFeedback::setAutoCenterMode(bool enabled)
event.value = (__s32)(enabled*0xFFFFFFFFUL); event.value = (__s32)(enabled*0xFFFFFFFFUL);
#if (OIS_LINUX_JOYFF_DEBUG > 0) #if (OIS_LINUX_JOYFF_DEBUG > 0)
cout << "LinuxForceFeedback("<< mJoyStick << ") : Toggling auto-center to " cout << "LinuxForceFeedback("<< mJoyStick << ") : Toggling auto-center to "
<< enabled << " => 0x" << hex << event.value << dec << endl; << enabled << " => 0x" << hex << event.value << dec << endl;
#endif #endif
...@@ -138,23 +138,23 @@ void LinuxForceFeedback::upload( const Effect* effect ) ...@@ -138,23 +138,23 @@ void LinuxForceFeedback::upload( const Effect* effect )
{ {
switch( effect->force ) switch( effect->force )
{ {
case OIS::Effect::ConstantForce: case OIS::Effect::ConstantForce:
_updateConstantEffect(effect); _updateConstantEffect(effect);
break; break;
case OIS::Effect::ConditionalForce: case OIS::Effect::ConditionalForce:
_updateConditionalEffect(effect); _updateConditionalEffect(effect);
break; break;
case OIS::Effect::PeriodicForce: case OIS::Effect::PeriodicForce:
_updatePeriodicEffect(effect); _updatePeriodicEffect(effect);
break; break;
case OIS::Effect::RampForce: case OIS::Effect::RampForce:
_updateRampEffect(effect); _updateRampEffect(effect);
break; break;
case OIS::Effect::CustomForce: case OIS::Effect::CustomForce:
//_updateCustomEffect(effect); //_updateCustomEffect(effect);
//break; //break;
default: default:
OIS_EXCEPT(E_NotImplemented, "Requested force not implemented yet, sorry!"); OIS_EXCEPT(E_NotImplemented, "Requested force not implemented yet, sorry!");
break; break;
} }
} }
...@@ -220,8 +220,8 @@ void LinuxForceFeedback::remove( const Effect* effect ) ...@@ -220,8 +220,8 @@ void LinuxForceFeedback::remove( const Effect* effect )
//--------------------------------------------------------------// //--------------------------------------------------------------//
void LinuxForceFeedback::_setCommonProperties(struct ff_effect *event, void LinuxForceFeedback::_setCommonProperties(struct ff_effect *event,
struct ff_envelope *ffenvelope, struct ff_envelope *ffenvelope,
const Effect* effect, const Envelope *envelope ) const Effect* effect, const Envelope *envelope )
{ {
memset(event, 0, sizeof(struct ff_effect)); memset(event, 0, sizeof(struct ff_effect));
...@@ -232,23 +232,23 @@ void LinuxForceFeedback::_setCommonProperties(struct ff_effect *event, ...@@ -232,23 +232,23 @@ void LinuxForceFeedback::_setCommonProperties(struct ff_effect *event,
ffenvelope->fade_length = LinuxDuration(envelope->fadeLength); ffenvelope->fade_length = LinuxDuration(envelope->fadeLength);
ffenvelope->fade_level = LinuxPositiveLevel(envelope->fadeLevel); ffenvelope->fade_level = LinuxPositiveLevel(envelope->fadeLevel);
} }
#if (OIS_LINUX_JOYFF_DEBUG > 1) #if (OIS_LINUX_JOYFF_DEBUG > 1)
cout << endl; cout << endl;
if (envelope && ffenvelope) if (envelope && ffenvelope)
{ {
cout << " Enveloppe :" << endl cout << " Enveloppe :" << endl
<< " AttackLen : " << envelope->attackLength << " AttackLen : " << envelope->attackLength
<< " => " << ffenvelope->attack_length << endl << " => " << ffenvelope->attack_length << endl
<< " AttackLvl : " << envelope->attackLevel << " AttackLvl : " << envelope->attackLevel
<< " => " << ffenvelope->attack_level << endl << " => " << ffenvelope->attack_level << endl
<< " FadeLen : " << envelope->fadeLength << " FadeLen : " << envelope->fadeLength
<< " => " << ffenvelope->fade_length << endl << " => " << ffenvelope->fade_length << endl
<< " FadeLvl : " << envelope->fadeLevel << " FadeLvl : " << envelope->fadeLevel
<< " => " << ffenvelope->fade_level << endl; << " => " << ffenvelope->fade_level << endl;
} }
#endif #endif
event->direction = (__u16)(1 + (effect->direction*45.0+135.0)*0xFFFFUL/360.0); event->direction = (__u16)(1 + (effect->direction*45.0+135.0)*0xFFFFUL/360.0);
#if (OIS_LINUX_JOYFF_DEBUG > 1) #if (OIS_LINUX_JOYFF_DEBUG > 1)
...@@ -262,9 +262,9 @@ void LinuxForceFeedback::_setCommonProperties(struct ff_effect *event, ...@@ -262,9 +262,9 @@ void LinuxForceFeedback::_setCommonProperties(struct ff_effect *event,
#if (OIS_LINUX_JOYFF_DEBUG > 1) #if (OIS_LINUX_JOYFF_DEBUG > 1)
cout << " Trigger :" << endl cout << " Trigger :" << endl
<< " Button : " << effect->trigger_button << " Button : " << effect->trigger_button
<< " => " << event->trigger.button << endl << " => " << event->trigger.button << endl
<< " Interval : " << effect->trigger_interval << " Interval : " << effect->trigger_interval
<< " => " << event->trigger.interval << endl; << " => " << event->trigger.interval << endl;
#endif #endif
...@@ -273,9 +273,9 @@ void LinuxForceFeedback::_setCommonProperties(struct ff_effect *event, ...@@ -273,9 +273,9 @@ void LinuxForceFeedback::_setCommonProperties(struct ff_effect *event,
#if (OIS_LINUX_JOYFF_DEBUG > 1) #if (OIS_LINUX_JOYFF_DEBUG > 1)
cout << " Replay :" << endl cout << " Replay :" << endl
<< " Length : " << effect->replay_length << " Length : " << effect->replay_length
<< " => " << event->replay.length << endl << " => " << event->replay.length << endl
<< " Delay : " << effect->replay_delay << " Delay : " << effect->replay_delay
<< " => " << event->replay.delay << endl; << " => " << event->replay.delay << endl;
#endif #endif
} }
...@@ -361,7 +361,7 @@ void LinuxForceFeedback::_updatePeriodicEffect( const Effect* eff ) ...@@ -361,7 +361,7 @@ void LinuxForceFeedback::_updatePeriodicEffect( const Effect* eff )
//event.u.periodic.waveform = FF_CUSTOM; //event.u.periodic.waveform = FF_CUSTOM;
//break; //break;
default: default:
OIS_EXCEPT(E_General, "No such available effect for Periodic force!"); OIS_EXCEPT(E_General, "No such available effect for Periodic force!");
break; break;
} }
...@@ -400,19 +400,19 @@ void LinuxForceFeedback::_updateConditionalEffect( const Effect* eff ) ...@@ -400,19 +400,19 @@ void LinuxForceFeedback::_updateConditionalEffect( const Effect* eff )
switch( eff->type ) switch( eff->type )
{ {
case OIS::Effect::Friction: case OIS::Effect::Friction:
event.type = FF_FRICTION; event.type = FF_FRICTION;
break; break;
case OIS::Effect::Damper: case OIS::Effect::Damper:
event.type = FF_DAMPER; event.type = FF_DAMPER;
break; break;
case OIS::Effect::Inertia: case OIS::Effect::Inertia:
event.type = FF_INERTIA; event.type = FF_INERTIA;
break; break;
case OIS::Effect::Spring: case OIS::Effect::Spring:
event.type = FF_SPRING; event.type = FF_SPRING;
break; break;
default: default:
OIS_EXCEPT(E_General, "No such available effect for Conditional force!"); OIS_EXCEPT(E_General, "No such available effect for Conditional force!");
break; break;
} }
...@@ -422,7 +422,7 @@ void LinuxForceFeedback::_updateConditionalEffect( const Effect* eff ) ...@@ -422,7 +422,7 @@ void LinuxForceFeedback::_updateConditionalEffect( const Effect* eff )
event.u.condition[0].left_saturation = LinuxSignedLevel(effect->leftSaturation); event.u.condition[0].left_saturation = LinuxSignedLevel(effect->leftSaturation);
event.u.condition[0].right_coeff = LinuxSignedLevel(effect->rightCoeff); event.u.condition[0].right_coeff = LinuxSignedLevel(effect->rightCoeff);
event.u.condition[0].left_coeff = LinuxSignedLevel(effect->leftCoeff); event.u.condition[0].left_coeff = LinuxSignedLevel(effect->leftCoeff);
event.u.condition[0].deadband = LinuxPositiveLevel(effect->deadband);// Unit ?? event.u.condition[0].deadband = LinuxPositiveLevel(effect->deadband);// Unit ??
event.u.condition[0].center = LinuxSignedLevel(effect->center); // Unit ?? TODO ? event.u.condition[0].center = LinuxSignedLevel(effect->center); // Unit ?? TODO ?
// TODO support for second condition // TODO support for second condition
...@@ -461,7 +461,7 @@ void LinuxForceFeedback::_upload( struct ff_effect* ffeffect, const Effect* effe ...@@ -461,7 +461,7 @@ void LinuxForceFeedback::_upload( struct ff_effect* ffeffect, const Effect* effe
if( linEffect == 0 ) if( linEffect == 0 )
{ {
#if (OIS_LINUX_JOYFF_DEBUG > 1) #if (OIS_LINUX_JOYFF_DEBUG > 1)
cout << endl << "LinuxForceFeedback("<< mJoyStick << ") : Adding new effect : " cout << endl << "LinuxForceFeedback("<< mJoyStick << ") : Adding new effect : "
<< Effect::getEffectTypeName(effect->type) << endl; << Effect::getEffectTypeName(effect->type) << endl;
#endif #endif
...@@ -487,7 +487,7 @@ void LinuxForceFeedback::_upload( struct ff_effect* ffeffect, const Effect* effe ...@@ -487,7 +487,7 @@ void LinuxForceFeedback::_upload( struct ff_effect* ffeffect, const Effect* effe
else else
{ {
#if (OIS_LINUX_JOYFF_DEBUG > 1) #if (OIS_LINUX_JOYFF_DEBUG > 1)
cout << endl << "LinuxForceFeedback("<< mJoyStick << ") : Replacing effect : " cout << endl << "LinuxForceFeedback("<< mJoyStick << ") : Replacing effect : "
<< Effect::getEffectTypeName(effect->type) << endl; << Effect::getEffectTypeName(effect->type) << endl;
#endif #endif
...@@ -504,7 +504,7 @@ void LinuxForceFeedback::_upload( struct ff_effect* ffeffect, const Effect* effe ...@@ -504,7 +504,7 @@ void LinuxForceFeedback::_upload( struct ff_effect* ffeffect, const Effect* effe
} }
#if (OIS_LINUX_JOYFF_DEBUG > 1) #if (OIS_LINUX_JOYFF_DEBUG > 1)
cout << "LinuxForceFeedback("<< mJoyStick cout << "LinuxForceFeedback("<< mJoyStick
<< ") : Effect handle : " << effect->_handle << endl; << ") : Effect handle : " << effect->_handle << endl;
#endif #endif
} }
...@@ -518,7 +518,7 @@ void LinuxForceFeedback::_stop( int handle) { ...@@ -518,7 +518,7 @@ void LinuxForceFeedback::_stop( int handle) {
stop.value = 0; stop.value = 0;
#if (OIS_LINUX_JOYFF_DEBUG > 1) #if (OIS_LINUX_JOYFF_DEBUG > 1)
cout << endl << "LinuxForceFeedback("<< mJoyStick cout << endl << "LinuxForceFeedback("<< mJoyStick
<< ") : Stopping effect with handle " << handle << endl; << ") : Stopping effect with handle " << handle << endl;
#endif #endif
...@@ -536,7 +536,7 @@ void LinuxForceFeedback::_start( int handle) { ...@@ -536,7 +536,7 @@ void LinuxForceFeedback::_start( int handle) {
play.value = 1; // Play once. play.value = 1; // Play once.
#if (OIS_LINUX_JOYFF_DEBUG > 1) #if (OIS_LINUX_JOYFF_DEBUG > 1)
cout << endl << "LinuxForceFeedback("<< mJoyStick cout << endl << "LinuxForceFeedback("<< mJoyStick
<< ") : Starting effect with handle " << handle << endl; << ") : Starting effect with handle " << handle << endl;
#endif #endif
...@@ -549,7 +549,7 @@ void LinuxForceFeedback::_start( int handle) { ...@@ -549,7 +549,7 @@ void LinuxForceFeedback::_start( int handle) {
void LinuxForceFeedback::_unload( int handle) void LinuxForceFeedback::_unload( int handle)
{ {
#if (OIS_LINUX_JOYFF_DEBUG > 1) #if (OIS_LINUX_JOYFF_DEBUG > 1)
cout << endl << "LinuxForceFeedback("<< mJoyStick cout << endl << "LinuxForceFeedback("<< mJoyStick
<< ") : Removing effect with handle " << handle << endl; << ") : Removing effect with handle " << handle << endl;
#endif #endif
......
...@@ -6,16 +6,16 @@ Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com) ...@@ -6,16 +6,16 @@ Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
This software is provided 'as-is', without any express or implied warranty. In no event will This software is provided 'as-is', without any express or implied warranty. In no event will
the authors be held liable for any damages arising from the use of this software. the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose, including commercial Permission is granted to anyone to use this software for any purpose, including commercial
applications, and to alter it and redistribute it freely, subject to the following applications, and to alter it and redistribute it freely, subject to the following
restrictions: restrictions:
1. The origin of this software must not be misrepresented; you must not claim that 1. The origin of this software must not be misrepresented; you must not claim that
you wrote the original software. If you use this software in a product, you wrote the original software. If you use this software in a product,
an acknowledgment in the product documentation would be appreciated but is an acknowledgment in the product documentation would be appreciated but is
not required. not required.
2. Altered source versions must be plainly marked as such, and must not be 2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software. misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
...@@ -66,7 +66,7 @@ void LinuxInputManager::_initialize( ParamList &paramList ) ...@@ -66,7 +66,7 @@ void LinuxInputManager::_initialize( ParamList &paramList )
void LinuxInputManager::_parseConfigSettings( ParamList &paramList ) void LinuxInputManager::_parseConfigSettings( ParamList &paramList )
{ {
ParamList::iterator i = paramList.find("WINDOW"); ParamList::iterator i = paramList.find("WINDOW");
if( i == paramList.end() ) if( i == paramList.end() )
{ {
printf("OIS: No Window specified... Not using x11 keyboard/mouse\n"); printf("OIS: No Window specified... Not using x11 keyboard/mouse\n");
return; return;
......
...@@ -31,7 +31,7 @@ restrictions: ...@@ -31,7 +31,7 @@ restrictions:
#include "OISException.h" #include "OISException.h"
#include <fcntl.h> //Needed to Open a file descriptor #include <fcntl.h> //Needed to Open a file descriptor
#include <cassert> #include <cassert>
#include <linux/input.h> #include <linux/input.h>
...@@ -190,7 +190,7 @@ void LinuxJoyStick::capture() ...@@ -190,7 +190,7 @@ void LinuxJoyStick::capture()
break; break;
} }
case EV_REL: //Relative Axes (Do any joystick actually have a relative axis?) case EV_REL: //Relative Axes (Do any joystick actually have a relative axis?)
#ifdef OIS_LINUX_JOY_DEBUG #ifdef OIS_LINUX_JOY_DEBUG
cout << "\nWarning: Relatives axes not supported yet" << endl; cout << "\nWarning: Relatives axes not supported yet" << endl;
......
...@@ -6,16 +6,16 @@ Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com) ...@@ -6,16 +6,16 @@ Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
This software is provided 'as-is', without any express or implied warranty. In no event will This software is provided 'as-is', without any express or implied warranty. In no event will
the authors be held liable for any damages arising from the use of this software. the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose, including commercial Permission is granted to anyone to use this software for any purpose, including commercial
applications, and to alter it and redistribute it freely, subject to the following applications, and to alter it and redistribute it freely, subject to the following
restrictions: restrictions:
1. The origin of this software must not be misrepresented; you must not claim that 1. The origin of this software must not be misrepresented; you must not claim that
you wrote the original software. If you use this software in a product, you wrote the original software. If you use this software in a product,
an acknowledgment in the product documentation would be appreciated but is an acknowledgment in the product documentation would be appreciated but is
not required. not required.
2. Altered source versions must be plainly marked as such, and must not be 2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software. misrepresented as being the original software.
3. This notice may not be removed or altered friosom any source distribution. 3. This notice may not be removed or altered friosom any source distribution.
...@@ -157,7 +157,7 @@ void LinuxMouse::_processXEvents() ...@@ -157,7 +157,7 @@ void LinuxMouse::_processXEvents()
XEvent event; XEvent event;
//Poll x11 for events mouse events //Poll x11 for events mouse events
while( XPending(display) > 0 ) while( XPending(display) > 0 )
{ {
XNextEvent(display, &event); XNextEvent(display, &event);
...@@ -174,7 +174,7 @@ void LinuxMouse::_processXEvents() ...@@ -174,7 +174,7 @@ void LinuxMouse::_processXEvents()
//Compute this frames Relative X & Y motion //Compute this frames Relative X & Y motion
int dx = event.xmotion.x - oldXMouseX; int dx = event.xmotion.x - oldXMouseX;
int dy = event.xmotion.y - oldXMouseY; int dy = event.xmotion.y - oldXMouseY;
//Store old values for next time to compute relative motion //Store old values for next time to compute relative motion
oldXMouseX = event.xmotion.x; oldXMouseX = event.xmotion.x;
oldXMouseY = event.xmotion.y; oldXMouseY = event.xmotion.y;
......
/* /*
The zlib/libpng License The zlib/libpng License
Copyright (c) 2006 Phillip Castaneda Copyright (c) 2006 Phillip Castaneda
This software is provided 'as-is', without any express or implied warranty. In no event will This software is provided 'as-is', without any express or implied warranty. In no event will
the authors be held liable for any damages arising from the use of this software. the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose, including commercial Permission is granted to anyone to use this software for any purpose, including commercial
applications, and to alter it and redistribute it freely, subject to the following applications, and to alter it and redistribute it freely, subject to the following
restrictions: restrictions:
1. The origin of this software must not be misrepresented; you must not claim that 1. The origin of this software must not be misrepresented; you must not claim that
you wrote the original software. If you use this software in a product, you wrote the original software. If you use this software in a product,
an acknowledgment in the product documentation would be appreciated but is an acknowledgment in the product documentation would be appreciated but is
not required. not required.
2. Altered source versions must be plainly marked as such, and must not be 2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software. misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
*/ */
#include "mac/MacHIDManager.h" #include "mac/MacHIDManager.h"
...@@ -42,7 +42,7 @@ template<> ...@@ -42,7 +42,7 @@ template<>
CFArrayRef getDictionaryItemAsRef(CFDictionaryRef dict, const char* keyName) CFArrayRef getDictionaryItemAsRef(CFDictionaryRef dict, const char* keyName)
{ {
CFTypeRef temp = CFDictionaryGetValue(dict, OIS_CFString(keyName)); CFTypeRef temp = CFDictionaryGetValue(dict, OIS_CFString(keyName));
if(temp && CFGetTypeID(temp) == CFArrayGetTypeID()) if(temp && CFGetTypeID(temp) == CFArrayGetTypeID())
return (CFArrayRef)temp; return (CFArrayRef)temp;
else else
...@@ -53,7 +53,7 @@ template<> ...@@ -53,7 +53,7 @@ template<>
CFStringRef getDictionaryItemAsRef(CFDictionaryRef dict, const char* keyName) CFStringRef getDictionaryItemAsRef(CFDictionaryRef dict, const char* keyName)
{ {
CFTypeRef temp = CFDictionaryGetValue(dict, OIS_CFString(keyName)); CFTypeRef temp = CFDictionaryGetValue(dict, OIS_CFString(keyName));
if(temp && CFGetTypeID(temp) == CFStringGetTypeID()) if(temp && CFGetTypeID(temp) == CFStringGetTypeID())
return (CFStringRef)temp; return (CFStringRef)temp;
else else
...@@ -64,7 +64,7 @@ template<> ...@@ -64,7 +64,7 @@ template<>
CFNumberRef getDictionaryItemAsRef(CFDictionaryRef dict, const char* keyName) CFNumberRef getDictionaryItemAsRef(CFDictionaryRef dict, const char* keyName)
{ {
CFTypeRef temp = CFDictionaryGetValue(dict, OIS_CFString(keyName)); CFTypeRef temp = CFDictionaryGetValue(dict, OIS_CFString(keyName));
if(temp && CFGetTypeID(temp) == CFNumberGetTypeID()) if(temp && CFGetTypeID(temp) == CFNumberGetTypeID())
return (CFNumberRef)temp; return (CFNumberRef)temp;
else else
...@@ -83,7 +83,7 @@ template<> ...@@ -83,7 +83,7 @@ template<>
CFDictionaryRef getArrayItemAsRef(CFArrayRef array, CFIndex idx) CFDictionaryRef getArrayItemAsRef(CFArrayRef array, CFIndex idx)
{ {
CFTypeRef temp = CFArrayGetValueAtIndex(array, idx); CFTypeRef temp = CFArrayGetValueAtIndex(array, idx);
if(temp && CFGetTypeID(temp) == CFDictionaryGetTypeID()) if(temp && CFGetTypeID(temp) == CFDictionaryGetTypeID())
return (CFDictionaryRef)temp; return (CFDictionaryRef)temp;
else else
...@@ -94,7 +94,7 @@ CFDictionaryRef getArrayItemAsRef(CFArrayRef array, CFIndex idx) ...@@ -94,7 +94,7 @@ CFDictionaryRef getArrayItemAsRef(CFArrayRef array, CFIndex idx)
int getInt32(CFNumberRef ref) int getInt32(CFNumberRef ref)
{ {
int r = 0; int r = 0;
if (r) if (r)
CFNumberGetValue(ref, kCFNumberIntType, &r); CFNumberGetValue(ref, kCFNumberIntType, &r);
return r; return r;
} }
...@@ -115,16 +115,16 @@ void MacHIDManager::initialize() ...@@ -115,16 +115,16 @@ void MacHIDManager::initialize()
//Make the search more specific by adding usage flags //Make the search more specific by adding usage flags
int usage = kHIDUsage_GD_Joystick; int usage = kHIDUsage_GD_Joystick;
int page = kHIDPage_GenericDesktop; int page = kHIDPage_GenericDesktop;
io_iterator_t iterator = lookUpDevices(usage, page); io_iterator_t iterator = lookUpDevices(usage, page);
if(iterator) if(iterator)
iterateAndOpenDevices(iterator); iterateAndOpenDevices(iterator);
//Doesn't support multiple usage flags, iterate twice //Doesn't support multiple usage flags, iterate twice
usage = kHIDUsage_GD_GamePad; usage = kHIDUsage_GD_GamePad;
iterator = lookUpDevices(usage, page); iterator = lookUpDevices(usage, page);
if(iterator) if(iterator)
iterateAndOpenDevices(iterator); iterateAndOpenDevices(iterator);
} }
...@@ -135,20 +135,20 @@ io_iterator_t MacHIDManager::lookUpDevices(int usage, int page) ...@@ -135,20 +135,20 @@ io_iterator_t MacHIDManager::lookUpDevices(int usage, int page)
CFMutableDictionaryRef deviceLookupMap = IOServiceMatching(kIOHIDDeviceKey); CFMutableDictionaryRef deviceLookupMap = IOServiceMatching(kIOHIDDeviceKey);
if(!deviceLookupMap) if(!deviceLookupMap)
OIS_EXCEPT(E_General, "Could not setup HID device search parameters"); OIS_EXCEPT(E_General, "Could not setup HID device search parameters");
CFNumberRef usageRef = CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &usage); CFNumberRef usageRef = CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &usage);
CFNumberRef pageRef = CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &page); CFNumberRef pageRef = CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &page);
CFDictionarySetValue(deviceLookupMap, CFSTR(kIOHIDPrimaryUsageKey), usageRef); CFDictionarySetValue(deviceLookupMap, CFSTR(kIOHIDPrimaryUsageKey), usageRef);
CFDictionarySetValue(deviceLookupMap, CFSTR(kIOHIDPrimaryUsagePageKey), pageRef); CFDictionarySetValue(deviceLookupMap, CFSTR(kIOHIDPrimaryUsagePageKey), pageRef);
//IOServiceGetMatchingServices consumes the map so we do not have to release it ourself //IOServiceGetMatchingServices consumes the map so we do not have to release it ourself
io_iterator_t iterator = 0; io_iterator_t iterator = 0;
IOReturn result = IOServiceGetMatchingServices(kIOMasterPortDefault, deviceLookupMap, &iterator); IOReturn result = IOServiceGetMatchingServices(kIOMasterPortDefault, deviceLookupMap, &iterator);
CFRelease(usageRef); CFRelease(usageRef);
CFRelease(pageRef); CFRelease(pageRef);
if(result == kIOReturnSuccess) if(result == kIOReturnSuccess)
{ {
return iterator; return iterator;
...@@ -172,28 +172,28 @@ void MacHIDManager::iterateAndOpenDevices(io_iterator_t iterator) ...@@ -172,28 +172,28 @@ void MacHIDManager::iterateAndOpenDevices(io_iterator_t iterator)
{ {
//Go through device to find all needed info //Go through device to find all needed info
HidInfo* hid = enumerateDeviceProperties(propertyMap); HidInfo* hid = enumerateDeviceProperties(propertyMap);
if(hid) if(hid)
{ {
//todo - we need to hold an open interface so we do not have to enumerate again later //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 //should be able to watch for device removals also
// Testing opening / closing interface // Testing opening / closing interface
IOCFPlugInInterface **pluginInterface = NULL; IOCFPlugInInterface **pluginInterface = NULL;
SInt32 score = 0; SInt32 score = 0;
if (IOCreatePlugInInterfaceForService(hidDevice, kIOHIDDeviceUserClientTypeID, kIOCFPlugInInterfaceID, &pluginInterface, &score) == kIOReturnSuccess) if (IOCreatePlugInInterfaceForService(hidDevice, kIOHIDDeviceUserClientTypeID, kIOCFPlugInInterfaceID, &pluginInterface, &score) == kIOReturnSuccess)
{ {
IOHIDDeviceInterface **interface; IOHIDDeviceInterface **interface;
HRESULT pluginResult = (*pluginInterface)->QueryInterface(pluginInterface, CFUUIDGetUUIDBytes(kIOHIDDeviceInterfaceID), (void **)&(interface)); HRESULT pluginResult = (*pluginInterface)->QueryInterface(pluginInterface, CFUUIDGetUUIDBytes(kIOHIDDeviceInterfaceID), (void **)&(interface));
if(pluginResult != S_OK) if(pluginResult != S_OK)
OIS_EXCEPT(E_General, "Not able to create plugin interface"); OIS_EXCEPT(E_General, "Not able to create plugin interface");
IODestroyPlugInInterface(pluginInterface); IODestroyPlugInInterface(pluginInterface);
hid->interface = interface; hid->interface = interface;
//Check for duplicates - some devices have multiple usage //Check for duplicates - some devices have multiple usage
if(std::find(mDeviceList.begin(), mDeviceList.end(), hid) == mDeviceList.end()) if(std::find(mDeviceList.begin(), mDeviceList.end(), hid) == mDeviceList.end())
mDeviceList.push_back(hid); mDeviceList.push_back(hid);
...@@ -201,7 +201,7 @@ void MacHIDManager::iterateAndOpenDevices(io_iterator_t iterator) ...@@ -201,7 +201,7 @@ void MacHIDManager::iterateAndOpenDevices(io_iterator_t iterator)
} }
} }
} }
IOObjectRelease(iterator); IOObjectRelease(iterator);
} }
...@@ -209,25 +209,25 @@ void MacHIDManager::iterateAndOpenDevices(io_iterator_t iterator) ...@@ -209,25 +209,25 @@ void MacHIDManager::iterateAndOpenDevices(io_iterator_t iterator)
HidInfo* MacHIDManager::enumerateDeviceProperties(CFMutableDictionaryRef propertyMap) HidInfo* MacHIDManager::enumerateDeviceProperties(CFMutableDictionaryRef propertyMap)
{ {
HidInfo* info = new HidInfo(); HidInfo* info = new HidInfo();
info->type = OISJoyStick; info->type = OISJoyStick;
CFStringRef str = getDictionaryItemAsRef<CFStringRef>(propertyMap, kIOHIDManufacturerKey); CFStringRef str = getDictionaryItemAsRef<CFStringRef>(propertyMap, kIOHIDManufacturerKey);
if (str) if (str)
info->vendor = CFStringGetCStringPtr(str, CFStringGetSystemEncoding()); info->vendor = CFStringGetCStringPtr(str, CFStringGetSystemEncoding());
str = getDictionaryItemAsRef<CFStringRef>(propertyMap, kIOHIDProductKey); str = getDictionaryItemAsRef<CFStringRef>(propertyMap, kIOHIDProductKey);
if (str) if (str)
info->productKey = CFStringGetCStringPtr(str, CFStringGetSystemEncoding()); info->productKey = CFStringGetCStringPtr(str, CFStringGetSystemEncoding());
info->combinedKey = info->vendor + " " + info->productKey; info->combinedKey = info->vendor + " " + info->productKey;
//Go through all items in this device (i.e. buttons, hats, sticks, axes, etc) //Go through all items in this device (i.e. buttons, hats, sticks, axes, etc)
CFArrayRef array = getDictionaryItemAsRef<CFArrayRef>(propertyMap, kIOHIDElementKey); CFArrayRef array = getDictionaryItemAsRef<CFArrayRef>(propertyMap, kIOHIDElementKey);
if (array) if (array)
for (int i = 0; i < CFArrayGetCount(array); i++) for (int i = 0; i < CFArrayGetCount(array); i++)
parseDeviceProperties(getArrayItemAsRef<CFDictionaryRef>(array, i)); parseDeviceProperties(getArrayItemAsRef<CFDictionaryRef>(array, i));
return info; return info;
} }
...@@ -236,7 +236,7 @@ void MacHIDManager::parseDeviceProperties(CFDictionaryRef properties) ...@@ -236,7 +236,7 @@ void MacHIDManager::parseDeviceProperties(CFDictionaryRef properties)
{ {
if(!properties) if(!properties)
return; return;
CFArrayRef array = getDictionaryItemAsRef<CFArrayRef>(properties, kIOHIDElementKey); CFArrayRef array = getDictionaryItemAsRef<CFArrayRef>(properties, kIOHIDElementKey);
if (array) if (array)
{ {
...@@ -245,7 +245,7 @@ void MacHIDManager::parseDeviceProperties(CFDictionaryRef properties) ...@@ -245,7 +245,7 @@ void MacHIDManager::parseDeviceProperties(CFDictionaryRef properties)
CFDictionaryRef element = getArrayItemAsRef<CFDictionaryRef>(array, i); CFDictionaryRef element = getArrayItemAsRef<CFDictionaryRef>(array, i);
if (element) if (element)
{ {
if(getInt32(getDictionaryItemAsRef<CFNumberRef>(element, kIOHIDElementTypeKey)) == kIOHIDElementTypeCollection) if(getInt32(getDictionaryItemAsRef<CFNumberRef>(element, kIOHIDElementTypeKey)) == kIOHIDElementTypeCollection)
{ //Check if we need to recurse further intoi another collection { //Check if we need to recurse further intoi another collection
if(getInt32(getDictionaryItemAsRef<CFNumberRef>(element, kIOHIDElementUsagePageKey)) == kHIDPage_GenericDesktop) if(getInt32(getDictionaryItemAsRef<CFNumberRef>(element, kIOHIDElementUsagePageKey)) == kHIDPage_GenericDesktop)
parseDeviceProperties(element); parseDeviceProperties(element);
...@@ -294,7 +294,7 @@ void MacHIDManager::parseDevicePropertiesGroup(CFDictionaryRef properties) ...@@ -294,7 +294,7 @@ void MacHIDManager::parseDevicePropertiesGroup(CFDictionaryRef properties)
{ {
if(!properties) if(!properties)
return; return;
CFArrayRef array = getDictionaryItemAsRef<CFArrayRef>(properties, kIOHIDElementKey); CFArrayRef array = getDictionaryItemAsRef<CFArrayRef>(properties, kIOHIDElementKey);
if(array) if(array)
{ {
...@@ -344,7 +344,7 @@ DeviceList MacHIDManager::freeDeviceList() ...@@ -344,7 +344,7 @@ DeviceList MacHIDManager::freeDeviceList()
if((*it)->inUse == false) if((*it)->inUse == false)
ret.insert(std::make_pair((*it)->type, (*it)->combinedKey)); ret.insert(std::make_pair((*it)->type, (*it)->combinedKey));
} }
return ret; return ret;
} }
...@@ -353,13 +353,13 @@ int MacHIDManager::totalDevices(Type iType) ...@@ -353,13 +353,13 @@ int MacHIDManager::totalDevices(Type iType)
{ {
int ret = 0; int ret = 0;
HidInfoList::iterator it = mDeviceList.begin(), end = mDeviceList.end(); HidInfoList::iterator it = mDeviceList.begin(), end = mDeviceList.end();
for(; it != end; ++it) for(; it != end; ++it)
{ {
if((*it)->type == iType) if((*it)->type == iType)
ret++; ret++;
} }
return ret; return ret;
} }
...@@ -368,13 +368,13 @@ int MacHIDManager::freeDevices(Type iType) ...@@ -368,13 +368,13 @@ int MacHIDManager::freeDevices(Type iType)
{ {
int ret = 0; int ret = 0;
HidInfoList::iterator it = mDeviceList.begin(), end = mDeviceList.end(); HidInfoList::iterator it = mDeviceList.begin(), end = mDeviceList.end();
for(; it != end; ++it) for(; it != end; ++it)
{ {
if((*it)->inUse == false && (*it)->type == iType) if((*it)->inUse == false && (*it)->type == iType)
ret++; ret++;
} }
return ret; return ret;
} }
...@@ -382,22 +382,22 @@ int MacHIDManager::freeDevices(Type iType) ...@@ -382,22 +382,22 @@ int MacHIDManager::freeDevices(Type iType)
bool MacHIDManager::vendorExist(Type iType, const std::string & vendor) bool MacHIDManager::vendorExist(Type iType, const std::string & vendor)
{ {
HidInfoList::iterator it = mDeviceList.begin(), end = mDeviceList.end(); HidInfoList::iterator it = mDeviceList.begin(), end = mDeviceList.end();
for(; it != end; ++it) for(; it != end; ++it)
{ {
if((*it)->type == iType && (*it)->combinedKey == vendor) if((*it)->type == iType && (*it)->combinedKey == vendor)
return true; return true;
} }
return false; return false;
} }
//--------------------------------------------------------------------------------// //--------------------------------------------------------------------------------//
Object* MacHIDManager::createObject(InputManager* creator, Type iType, bool bufferMode, Object* MacHIDManager::createObject(InputManager* creator, Type iType, bool bufferMode,
const std::string & vendor) const std::string & vendor)
{ {
Object *obj = 0; Object *obj = 0;
HidInfoList::iterator it = mDeviceList.begin(), end = mDeviceList.end(); HidInfoList::iterator it = mDeviceList.begin(), end = mDeviceList.end();
for(; it != end; ++it) for(; it != end; ++it)
{ {
...@@ -409,7 +409,7 @@ Object* MacHIDManager::createObject(InputManager* creator, Type iType, bool buff ...@@ -409,7 +409,7 @@ Object* MacHIDManager::createObject(InputManager* creator, Type iType, bool buff
int totalDevs = totalDevices(iType); int totalDevs = totalDevices(iType);
int freeDevs = freeDevices(iType); int freeDevs = freeDevices(iType);
int devID = totalDevs - freeDevs; int devID = totalDevs - freeDevs;
obj = new MacJoyStick((*it)->combinedKey, bufferMode, *it, creator, devID); obj = new MacJoyStick((*it)->combinedKey, bufferMode, *it, creator, devID);
(*it)->inUse = true; (*it)->inUse = true;
return obj; return obj;
...@@ -421,7 +421,7 @@ Object* MacHIDManager::createObject(InputManager* creator, Type iType, bool buff ...@@ -421,7 +421,7 @@ Object* MacHIDManager::createObject(InputManager* creator, Type iType, bool buff
} }
} }
} }
return obj; return obj;
} }
......
/* /*
The zlib/libpng License The zlib/libpng License
Copyright (c) 2006 Chris Snyder Copyright (c) 2006 Chris Snyder
This software is provided 'as-is', without any express or implied warranty. In no event will This software is provided 'as-is', without any express or implied warranty. In no event will
the authors be held liable for any damages arising from the use of this software. the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose, including commercial Permission is granted to anyone to use this software for any purpose, including commercial
applications, and to alter it and redistribute it freely, subject to the following applications, and to alter it and redistribute it freely, subject to the following
restrictions: restrictions:
1. The origin of this software must not be misrepresented; you must not claim that 1. The origin of this software must not be misrepresented; you must not claim that
you wrote the original software. If you use this software in a product, you wrote the original software. If you use this software in a product,
an acknowledgment in the product documentation would be appreciated but is an acknowledgment in the product documentation would be appreciated but is
not required. not required.
2. Altered source versions must be plainly marked as such, and must not be 2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software. misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
*/ */
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
#include <Carbon/Carbon.h> #include <Carbon/Carbon.h>
using namespace OIS; using namespace OIS;
//-------------------------------------------------------------------// //-------------------------------------------------------------------//
OSStatus KeyDownWrapper( EventHandlerCallRef nextHandler, OSStatus KeyDownWrapper( EventHandlerCallRef nextHandler,
EventRef theEvent, EventRef theEvent,
...@@ -38,7 +38,7 @@ OSStatus KeyDownWrapper( EventHandlerCallRef nextHandler, ...@@ -38,7 +38,7 @@ OSStatus KeyDownWrapper( EventHandlerCallRef nextHandler,
// TODO find a better way. This cast isn't very safe // TODO find a better way. This cast isn't very safe
if (callClass != NULL) { if (callClass != NULL) {
((MacKeyboard*)callClass)->_keyDownCallback( theEvent ); ((MacKeyboard*)callClass)->_keyDownCallback( theEvent );
// propagate the event down the chain // propagate the event down the chain
return CallNextEventHandler( nextHandler, theEvent ); return CallNextEventHandler( nextHandler, theEvent );
} }
...@@ -56,7 +56,7 @@ OSStatus KeyUpWrapper( EventHandlerCallRef nextHandler, ...@@ -56,7 +56,7 @@ OSStatus KeyUpWrapper( EventHandlerCallRef nextHandler,
{ {
if (callClass != NULL) { if (callClass != NULL) {
((MacKeyboard*)callClass)->_keyUpCallback( theEvent ); ((MacKeyboard*)callClass)->_keyUpCallback( theEvent );
// propagate the event down the chain // propagate the event down the chain
return CallNextEventHandler( nextHandler, theEvent ); return CallNextEventHandler( nextHandler, theEvent );
} }
...@@ -74,10 +74,10 @@ OSStatus KeyModWrapper( EventHandlerCallRef nextHandler, ...@@ -74,10 +74,10 @@ OSStatus KeyModWrapper( EventHandlerCallRef nextHandler,
{ {
if (callClass != NULL) { if (callClass != NULL) {
((MacKeyboard*)callClass)->_modChangeCallback( theEvent ); ((MacKeyboard*)callClass)->_modChangeCallback( theEvent );
// propagate the event down the chain // propagate the event down the chain
return CallNextEventHandler( nextHandler, theEvent ); return CallNextEventHandler( nextHandler, theEvent );
} }
else { else {
OIS_EXCEPT(E_General, "KeyModWrapper >> Being called by something other than our event handler!"); OIS_EXCEPT(E_General, "KeyModWrapper >> Being called by something other than our event handler!");
...@@ -93,10 +93,10 @@ OSStatus MouseMoveWrapper( EventHandlerCallRef nextHandler, ...@@ -93,10 +93,10 @@ OSStatus MouseMoveWrapper( EventHandlerCallRef nextHandler,
{ {
if (callClass != NULL) { if (callClass != NULL) {
((MacMouse*)callClass)->_mouseMoveCallback( theEvent ); ((MacMouse*)callClass)->_mouseMoveCallback( theEvent );
// propagate the event down the chain // propagate the event down the chain
return CallNextEventHandler( nextHandler, theEvent ); return CallNextEventHandler( nextHandler, theEvent );
} }
else { else {
OIS_EXCEPT(E_General, "MouseMoveWrapper >> Being called by something other than our event handler!"); OIS_EXCEPT(E_General, "MouseMoveWrapper >> Being called by something other than our event handler!");
...@@ -112,10 +112,10 @@ OSStatus MouseScrollWrapper( EventHandlerCallRef nextHandler, ...@@ -112,10 +112,10 @@ OSStatus MouseScrollWrapper( EventHandlerCallRef nextHandler,
{ {
if (callClass != NULL) { if (callClass != NULL) {
((MacMouse*)callClass)->_mouseScrollCallback( theEvent ); ((MacMouse*)callClass)->_mouseScrollCallback( theEvent );
// propagate the event down the chain // propagate the event down the chain
return CallNextEventHandler( nextHandler, theEvent ); return CallNextEventHandler( nextHandler, theEvent );
} }
else { else {
OIS_EXCEPT(E_General, "MouseScrollWrapper >> Being called by something other than our event handler!"); OIS_EXCEPT(E_General, "MouseScrollWrapper >> Being called by something other than our event handler!");
...@@ -131,10 +131,10 @@ OSStatus MouseButtonWrapper( EventHandlerCallRef nextHandler, ...@@ -131,10 +131,10 @@ OSStatus MouseButtonWrapper( EventHandlerCallRef nextHandler,
{ {
if (callClass != NULL) { if (callClass != NULL) {
((MacMouse*)callClass)->_mouseButtonCallback( theEvent ); ((MacMouse*)callClass)->_mouseButtonCallback( theEvent );
// propagate the event down the chain // propagate the event down the chain
return CallNextEventHandler( nextHandler, theEvent ); return CallNextEventHandler( nextHandler, theEvent );
} }
else { else {
OIS_EXCEPT(E_General, "MouseButtonWrapper >> Being called by something other than our event handler!"); OIS_EXCEPT(E_General, "MouseButtonWrapper >> Being called by something other than our event handler!");
...@@ -151,7 +151,7 @@ OSStatus MouseWrapper( EventHandlerCallRef nextHandler, EventRef theEvent, void* ...@@ -151,7 +151,7 @@ OSStatus MouseWrapper( EventHandlerCallRef nextHandler, EventRef theEvent, void*
((MacMouse*)callClass)->_mouseCallback( theEvent ); ((MacMouse*)callClass)->_mouseCallback( theEvent );
// propagate the event down the chain // propagate the event down the chain
return CallNextEventHandler( nextHandler, theEvent ); return CallNextEventHandler( nextHandler, theEvent );
} }
else else
OIS_EXCEPT(E_General, "MouseWrapper >> Being called by something other than our event handler!"); OIS_EXCEPT(E_General, "MouseWrapper >> Being called by something other than our event handler!");
......
/* /*
The zlib/libpng License The zlib/libpng License
Copyright (c) 2006 Chris Snyder Copyright (c) 2006 Chris Snyder
This software is provided 'as-is', without any express or implied warranty. In no event will This software is provided 'as-is', without any express or implied warranty. In no event will
the authors be held liable for any damages arising from the use of this software. the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose, including commercial Permission is granted to anyone to use this software for any purpose, including commercial
applications, and to alter it and redistribute it freely, subject to the following applications, and to alter it and redistribute it freely, subject to the following
restrictions: restrictions:
1. The origin of this software must not be misrepresented; you must not claim that 1. The origin of this software must not be misrepresented; you must not claim that
you wrote the original software. If you use this software in a product, you wrote the original software. If you use this software in a product,
an acknowledgment in the product documentation would be appreciated but is an acknowledgment in the product documentation would be appreciated but is
not required. not required.
2. Altered source versions must be plainly marked as such, and must not be 2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software. misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
*/ */
#include "mac/MacInputManager.h" #include "mac/MacInputManager.h"
...@@ -60,10 +60,10 @@ MacInputManager::~MacInputManager() ...@@ -60,10 +60,10 @@ MacInputManager::~MacInputManager()
void MacInputManager::_initialize( ParamList &paramList ) void MacInputManager::_initialize( ParamList &paramList )
{ {
_parseConfigSettings( paramList ); _parseConfigSettings( paramList );
//Enumerate all devices attached //Enumerate all devices attached
_enumerateDevices(); _enumerateDevices();
mHIDManager->initialize(); mHIDManager->initialize();
} }
...@@ -102,10 +102,10 @@ void MacInputManager::_parseConfigSettings( ParamList &paramList ) ...@@ -102,10 +102,10 @@ void MacInputManager::_parseConfigSettings( ParamList &paramList )
mEventTargetRef = GetApplicationEventTarget(); mEventTargetRef = GetApplicationEventTarget();
} }
} }
if(mEventTargetRef == NULL) if(mEventTargetRef == NULL)
OIS_EXCEPT( E_General, "MacInputManager::_parseConfigSettings >> Unable to find a window or event target" ); OIS_EXCEPT( E_General, "MacInputManager::_parseConfigSettings >> Unable to find a window or event target" );
// Keyboard // Keyboard
if(paramList.find("MacAutoRepeatOn") != paramList.end()) if(paramList.find("MacAutoRepeatOn") != paramList.end())
{ {
...@@ -167,14 +167,14 @@ bool MacInputManager::vendorExist(Type iType, const std::string & vendor) ...@@ -167,14 +167,14 @@ bool MacInputManager::vendorExist(Type iType, const std::string & vendor)
} }
//--------------------------------------------------------------------------------// //--------------------------------------------------------------------------------//
Object* MacInputManager::createObject(InputManager* creator, Type iType, bool bufferMode, Object* MacInputManager::createObject(InputManager* creator, Type iType, bool bufferMode,
const std::string & vendor) const std::string & vendor)
{ {
Object *obj = 0; Object *obj = 0;
switch(iType) switch(iType)
{ {
case OISKeyboard: case OISKeyboard:
{ {
if( keyboardUsed == false ) if( keyboardUsed == false )
obj = new MacKeyboard(this, bufferMode, mUseRepeat); obj = new MacKeyboard(this, bufferMode, mUseRepeat);
......
/* /*
The zlib/libpng License The zlib/libpng License
Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com) Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
This software is provided 'as-is', without any express or implied warranty. In no event will This software is provided 'as-is', without any express or implied warranty. In no event will
the authors be held liable for any damages arising from the use of this software. the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose, including commercial Permission is granted to anyone to use this software for any purpose, including commercial
applications, and to alter it and redistribute it freely, subject to the following applications, and to alter it and redistribute it freely, subject to the following
restrictions: restrictions:
1. The origin of this software must not be misrepresented; you must not claim that 1. The origin of this software must not be misrepresented; you must not claim that
you wrote the original software. If you use this software in a product, you wrote the original software. If you use this software in a product,
an acknowledgment in the product documentation would be appreciated but is an acknowledgment in the product documentation would be appreciated but is
not required. not required.
2. Altered source versions must be plainly marked as such, and must not be 2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software. misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
*/ */
...@@ -32,24 +32,24 @@ ...@@ -32,24 +32,24 @@
using namespace OIS; using namespace OIS;
//--------------------------------------------------------------------------------------------------// //--------------------------------------------------------------------------------------------------//
MacJoyStick::MacJoyStick(const std::string &vendor, bool buffered, HidInfo* info, InputManager* creator, int devID) : MacJoyStick::MacJoyStick(const std::string &vendor, bool buffered, HidInfo* info, InputManager* creator, int devID) :
JoyStick(vendor, buffered, devID, creator), mInfo(info) JoyStick(vendor, buffered, devID, creator), mInfo(info)
{ {
} }
//--------------------------------------------------------------------------------------------------// //--------------------------------------------------------------------------------------------------//
MacJoyStick::~MacJoyStick() MacJoyStick::~MacJoyStick()
{ {
//TODO: check if the queue has been started first? //TODO: check if the queue has been started first?
//(*mQueue)->stop(mQueue); //(*mQueue)->stop(mQueue);
(*mQueue)->dispose(mQueue); (*mQueue)->dispose(mQueue);
(*mQueue)->Release(mQueue); (*mQueue)->Release(mQueue);
//TODO: check if the interface has been opened first? //TODO: check if the interface has been opened first?
(*mInfo->interface)->close(mInfo->interface); (*mInfo->interface)->close(mInfo->interface);
(*mInfo->interface)->Release(mInfo->interface); (*mInfo->interface)->Release(mInfo->interface);
} }
//--------------------------------------------------------------------------------------------------// //--------------------------------------------------------------------------------------------------//
...@@ -57,21 +57,21 @@ void MacJoyStick::_initialize() ...@@ -57,21 +57,21 @@ void MacJoyStick::_initialize()
{ {
assert(mInfo && "Given HidInfo invalid"); assert(mInfo && "Given HidInfo invalid");
assert(mInfo->interface && "Joystick interface invalid"); assert(mInfo->interface && "Joystick interface invalid");
//TODO: Is this necessary? //TODO: Is this necessary?
//Clear old state //Clear old state
mState.mAxes.clear(); mState.mAxes.clear();
if ((*mInfo->interface)->open(mInfo->interface, 0) != KERN_SUCCESS) if ((*mInfo->interface)->open(mInfo->interface, 0) != KERN_SUCCESS)
OIS_EXCEPT(E_General, "MacJoyStick::_initialize() >> Could not initialize joy device!"); OIS_EXCEPT(E_General, "MacJoyStick::_initialize() >> Could not initialize joy device!");
mState.clear(); mState.clear();
_enumerateCookies(); _enumerateCookies();
mState.mButtons.resize(mInfo->numButtons); mState.mButtons.resize(mInfo->numButtons);
mState.mAxes.resize(mInfo->numAxes); mState.mAxes.resize(mInfo->numAxes);
mQueue = _createQueue(); mQueue = _createQueue();
} }
...@@ -91,11 +91,11 @@ private: ...@@ -91,11 +91,11 @@ private:
void MacJoyStick::capture() void MacJoyStick::capture()
{ {
assert(mQueue && "Queue must be initialized before calling MacJoyStick::capture()"); assert(mQueue && "Queue must be initialized before calling MacJoyStick::capture()");
AbsoluteTime zeroTime = {0,0}; AbsoluteTime zeroTime = {0,0};
IOHIDEventStruct event; IOHIDEventStruct event;
IOReturn result = (*mQueue)->getNextEvent(mQueue, &event, zeroTime, 0); IOReturn result = (*mQueue)->getNextEvent(mQueue, &event, zeroTime, 0);
while(result == kIOReturnSuccess) while(result == kIOReturnSuccess)
{ {
switch(event.type) switch(event.type)
...@@ -105,7 +105,7 @@ void MacJoyStick::capture() ...@@ -105,7 +105,7 @@ void MacJoyStick::capture()
std::vector<IOHIDElementCookie>::iterator buttonIt = std::find(mCookies.buttonCookies.begin(), mCookies.buttonCookies.end(), event.elementCookie); std::vector<IOHIDElementCookie>::iterator buttonIt = std::find(mCookies.buttonCookies.begin(), mCookies.buttonCookies.end(), event.elementCookie);
int button = std::distance(mCookies.buttonCookies.begin(), buttonIt); int button = std::distance(mCookies.buttonCookies.begin(), buttonIt);
mState.mButtons[button] = (event.value == 1); mState.mButtons[button] = (event.value == 1);
if(mBuffered && mListener) if(mBuffered && mListener)
{ {
if(event.value == 0) if(event.value == 0)
...@@ -120,16 +120,16 @@ void MacJoyStick::capture() ...@@ -120,16 +120,16 @@ void MacJoyStick::capture()
case kIOHIDElementTypeInput_Axis: case kIOHIDElementTypeInput_Axis:
std::map<IOHIDElementCookie, AxisInfo>::iterator axisIt = std::find_if(mCookies.axisCookies.begin(), mCookies.axisCookies.end(), FindAxisCookie(event.elementCookie)); 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); int axis = std::distance(mCookies.axisCookies.begin(), axisIt);
//Copied from LinuxJoyStickEvents.cpp, line 149 //Copied from LinuxJoyStickEvents.cpp, line 149
const AxisInfo& axisInfo = axisIt->second; const AxisInfo& axisInfo = axisIt->second;
float proportion = (float) (event.value - axisInfo.max) / (float) (axisInfo.min - axisInfo.max); float proportion = (float) (event.value - axisInfo.max) / (float) (axisInfo.min - axisInfo.max);
mState.mAxes[axis].abs = -JoyStick::MIN_AXIS - (JoyStick::MAX_AXIS * 2 * proportion); mState.mAxes[axis].abs = -JoyStick::MIN_AXIS - (JoyStick::MAX_AXIS * 2 * proportion);
if(mBuffered && mListener) mListener->axisMoved(JoyStickEvent(this, mState), axis); if(mBuffered && mListener) mListener->axisMoved(JoyStickEvent(this, mState), axis);
break; break;
} }
result = (*mQueue)->getNextEvent(mQueue, &event, zeroTime, 0); result = (*mQueue)->getNextEvent(mQueue, &event, zeroTime, 0);
} }
} }
...@@ -145,7 +145,7 @@ Interface* MacJoyStick::queryInterface(Interface::IType type) ...@@ -145,7 +145,7 @@ Interface* MacJoyStick::queryInterface(Interface::IType type)
{ {
//Thought about using covariant return type here.. however, //Thought about using covariant return type here.. however,
//some devices may allow LED light changing, or other interface stuff //some devices may allow LED light changing, or other interface stuff
//f( ff_device && type == Interface::ForceFeedback ) //f( ff_device && type == Interface::ForceFeedback )
//return ff_device; //return ff_device;
//else //else
...@@ -157,51 +157,51 @@ void MacJoyStick::_enumerateCookies() ...@@ -157,51 +157,51 @@ void MacJoyStick::_enumerateCookies()
{ {
assert(mInfo && "Given HidInfo invalid"); assert(mInfo && "Given HidInfo invalid");
assert(mInfo->interface && "Joystick interface invalid"); assert(mInfo->interface && "Joystick interface invalid");
CFTypeRef object; CFTypeRef object;
long number; long number;
IOHIDElementCookie cookie; IOHIDElementCookie cookie;
long usage; long usage;
long usagePage; long usagePage;
int min; int min;
int max; int max;
CFDictionaryRef element; CFDictionaryRef element;
// Copy all elements, since we're grabbing most of the elements // Copy all elements, since we're grabbing most of the elements
// for this device anyway, and thus, it's faster to iterate them // for this device anyway, and thus, it's faster to iterate them
// ourselves. When grabbing only one or two elements, a matching // ourselves. When grabbing only one or two elements, a matching
// dictionary should be passed in here instead of NULL. // dictionary should be passed in here instead of NULL.
CFArrayRef elements; CFArrayRef elements;
IOReturn success = reinterpret_cast<IOHIDDeviceInterface122*>(*mInfo->interface)->copyMatchingElements(mInfo->interface, NULL, &elements); IOReturn success = reinterpret_cast<IOHIDDeviceInterface122*>(*mInfo->interface)->copyMatchingElements(mInfo->interface, NULL, &elements);
if (success == kIOReturnSuccess) if (success == kIOReturnSuccess)
{ {
const CFIndex numOfElements = CFArrayGetCount(elements); const CFIndex numOfElements = CFArrayGetCount(elements);
for (CFIndex i = 0; i < numOfElements; ++i) for (CFIndex i = 0; i < numOfElements; ++i)
{ {
element = static_cast<CFDictionaryRef>(CFArrayGetValueAtIndex(elements, i)); element = static_cast<CFDictionaryRef>(CFArrayGetValueAtIndex(elements, i));
//Get cookie //Get cookie
object = (CFDictionaryGetValue(element, object = (CFDictionaryGetValue(element,
CFSTR(kIOHIDElementCookieKey))); CFSTR(kIOHIDElementCookieKey)));
if (object == 0 || CFGetTypeID(object) != CFNumberGetTypeID()) if (object == 0 || CFGetTypeID(object) != CFNumberGetTypeID())
continue; continue;
if(!CFNumberGetValue((CFNumberRef) object, kCFNumberLongType, if(!CFNumberGetValue((CFNumberRef) object, kCFNumberLongType,
&number)) &number))
continue; continue;
cookie = (IOHIDElementCookie) number; cookie = (IOHIDElementCookie) number;
//Get usage //Get usage
object = CFDictionaryGetValue(element, object = CFDictionaryGetValue(element,
CFSTR(kIOHIDElementUsageKey)); CFSTR(kIOHIDElementUsageKey));
if (object == 0 || CFGetTypeID(object) != CFNumberGetTypeID()) if (object == 0 || CFGetTypeID(object) != CFNumberGetTypeID())
continue; continue;
if (!CFNumberGetValue((CFNumberRef) object, kCFNumberLongType, if (!CFNumberGetValue((CFNumberRef) object, kCFNumberLongType,
&number)) &number))
continue; continue;
usage = number; usage = number;
//Get min //Get min
object = CFDictionaryGetValue(element, object = CFDictionaryGetValue(element,
CFSTR(kIOHIDElementMinKey)); // kIOHIDElementMinKey or kIOHIDElementScaledMinKey?, no idea ... CFSTR(kIOHIDElementMinKey)); // kIOHIDElementMinKey or kIOHIDElementScaledMinKey?, no idea ...
...@@ -211,7 +211,7 @@ void MacJoyStick::_enumerateCookies() ...@@ -211,7 +211,7 @@ void MacJoyStick::_enumerateCookies()
&number)) &number))
continue; continue;
min = number; min = number;
//Get max //Get max
object = CFDictionaryGetValue(element, object = CFDictionaryGetValue(element,
CFSTR(kIOHIDElementMaxKey)); // kIOHIDElementMaxKey or kIOHIDElementScaledMaxKey?, no idea ... CFSTR(kIOHIDElementMaxKey)); // kIOHIDElementMaxKey or kIOHIDElementScaledMaxKey?, no idea ...
...@@ -220,19 +220,19 @@ void MacJoyStick::_enumerateCookies() ...@@ -220,19 +220,19 @@ void MacJoyStick::_enumerateCookies()
if (!CFNumberGetValue((CFNumberRef) object, kCFNumberIntType, if (!CFNumberGetValue((CFNumberRef) object, kCFNumberIntType,
&number)) &number))
continue; continue;
max = number; max = number;
//Get usage page //Get usage page
object = CFDictionaryGetValue(element, object = CFDictionaryGetValue(element,
CFSTR(kIOHIDElementUsagePageKey)); CFSTR(kIOHIDElementUsagePageKey));
if (object == 0 || CFGetTypeID(object) != CFNumberGetTypeID()) if (object == 0 || CFGetTypeID(object) != CFNumberGetTypeID())
continue; continue;
if (!CFNumberGetValue((CFNumberRef) object, kCFNumberLongType, if (!CFNumberGetValue((CFNumberRef) object, kCFNumberLongType,
&number)) &number))
continue; continue;
usagePage = number; usagePage = number;
switch(usagePage) switch(usagePage)
{ {
...@@ -260,50 +260,50 @@ void MacJoyStick::_enumerateCookies() ...@@ -260,50 +260,50 @@ void MacJoyStick::_enumerateCookies()
case kHIDPage_Button: case kHIDPage_Button:
mCookies.buttonCookies.push_back(cookie); mCookies.buttonCookies.push_back(cookie);
break; break;
} }
} }
mInfo->numButtons = mCookies.buttonCookies.size(); mInfo->numButtons = mCookies.buttonCookies.size();
mInfo->numAxes = mCookies.axisCookies.size(); mInfo->numAxes = mCookies.axisCookies.size();
}
else
{
OIS_EXCEPT(E_General, "JoyStick elements could not be copied: copyMatchingElements failed with error: " + success);
} }
else
{
OIS_EXCEPT(E_General, "JoyStick elements could not be copied: copyMatchingElements failed with error: " + success);
}
} }
//--------------------------------------------------------------------------------------------------// //--------------------------------------------------------------------------------------------------//
IOHIDQueueInterface** MacJoyStick::_createQueue(unsigned int depth) IOHIDQueueInterface** MacJoyStick::_createQueue(unsigned int depth)
{ {
assert(mInfo && "Given HidInfo invalid"); assert(mInfo && "Given HidInfo invalid");
assert(mInfo->interface && "Joystick interface invalid"); assert(mInfo->interface && "Joystick interface invalid");
IOHIDQueueInterface** queue = (*mInfo->interface)->allocQueue(mInfo->interface); IOHIDQueueInterface** queue = (*mInfo->interface)->allocQueue(mInfo->interface);
if (queue) if (queue)
{ {
//create the queue //create the queue
IOReturn result = (*queue)->create(queue, 0, depth); IOReturn result = (*queue)->create(queue, 0, depth);
if(result == kIOReturnSuccess) if(result == kIOReturnSuccess)
{ {
//add elements to the queue //add elements to the queue
std::map<IOHIDElementCookie, AxisInfo>::iterator axisIt = mCookies.axisCookies.begin(); std::map<IOHIDElementCookie, AxisInfo>::iterator axisIt = mCookies.axisCookies.begin();
for(; axisIt != mCookies.axisCookies.end(); ++axisIt) for(; axisIt != mCookies.axisCookies.end(); ++axisIt)
{ {
result = (*queue)->addElement(queue, axisIt->first, 0); result = (*queue)->addElement(queue, axisIt->first, 0);
} }
std::vector<IOHIDElementCookie>::iterator buttonIt = mCookies.buttonCookies.begin(); std::vector<IOHIDElementCookie>::iterator buttonIt = mCookies.buttonCookies.begin();
for(; buttonIt != mCookies.buttonCookies.end(); ++buttonIt) for(; buttonIt != mCookies.buttonCookies.end(); ++buttonIt)
{ {
result = (*queue)->addElement(queue, (*buttonIt), 0); result = (*queue)->addElement(queue, (*buttonIt), 0);
} }
//start data delivery to queue //start data delivery to queue
result = (*queue)->start(queue); result = (*queue)->start(queue);
if(result == kIOReturnSuccess) if(result == kIOReturnSuccess)
{ {
return queue; return queue;
......
/* /*
The zlib/libpng License The zlib/libpng License
Copyright (c) 2006 Chris Snyder Copyright (c) 2006 Chris Snyder
This software is provided 'as-is', without any express or implied warranty. In no event will This software is provided 'as-is', without any express or implied warranty. In no event will
the authors be held liable for any damages arising from the use of this software. the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose, including commercial Permission is granted to anyone to use this software for any purpose, including commercial
applications, and to alter it and redistribute it freely, subject to the following applications, and to alter it and redistribute it freely, subject to the following
restrictions: restrictions:
1. The origin of this software must not be misrepresented; you must not claim that 1. The origin of this software must not be misrepresented; you must not claim that
you wrote the original software. If you use this software in a product, you wrote the original software. If you use this software in a product,
an acknowledgment in the product documentation would be appreciated but is an acknowledgment in the product documentation would be appreciated but is
not required. not required.
2. Altered source versions must be plainly marked as such, and must not be 2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software. misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
*/ */
...@@ -51,14 +51,14 @@ MacKeyboard::MacKeyboard( InputManager* creator, bool buffered, bool repeat ) ...@@ -51,14 +51,14 @@ MacKeyboard::MacKeyboard( InputManager* creator, bool buffered, bool repeat )
keyDownEventRef = NULL; keyDownEventRef = NULL;
keyUpEventRef = NULL; keyUpEventRef = NULL;
keyModEventRef = NULL; keyModEventRef = NULL;
useRepeat = repeat; useRepeat = repeat;
// Get a so-called "Univeral procedure pointer" for our callback // Get a so-called "Univeral procedure pointer" for our callback
keyDownUPP = NewEventHandlerUPP( KeyDownWrapper ); keyDownUPP = NewEventHandlerUPP( KeyDownWrapper );
keyUpUPP = NewEventHandlerUPP( KeyUpWrapper ); keyUpUPP = NewEventHandlerUPP( KeyUpWrapper );
keyModUPP = NewEventHandlerUPP( KeyModWrapper ); keyModUPP = NewEventHandlerUPP( KeyModWrapper );
// populate the conversion map // populate the conversion map
populateKeyConversion(); populateKeyConversion();
...@@ -72,13 +72,13 @@ MacKeyboard::~MacKeyboard() ...@@ -72,13 +72,13 @@ MacKeyboard::~MacKeyboard()
// after it is deleted // after it is deleted
if (keyDownEventRef != NULL) if (keyDownEventRef != NULL)
RemoveEventHandler(keyDownEventRef); RemoveEventHandler(keyDownEventRef);
if (keyUpEventRef != NULL) if (keyUpEventRef != NULL)
RemoveEventHandler(keyUpEventRef); RemoveEventHandler(keyUpEventRef);
if (keyModEventRef != NULL) if (keyModEventRef != NULL)
RemoveEventHandler(keyModEventRef); RemoveEventHandler(keyModEventRef);
// dispose of our UPPs // dispose of our UPPs
DisposeEventHandlerUPP(keyDownUPP); DisposeEventHandlerUPP(keyDownUPP);
DisposeEventHandlerUPP(keyUpUPP); DisposeEventHandlerUPP(keyUpUPP);
...@@ -96,17 +96,17 @@ void MacKeyboard::_initialize() ...@@ -96,17 +96,17 @@ void MacKeyboard::_initialize()
memset( &KeyBuffer, 0, 256 ); memset( &KeyBuffer, 0, 256 );
mModifiers = 0; mModifiers = 0;
prevModMask = 0; prevModMask = 0;
// just in case this gets called after the first time.. better safe // just in case this gets called after the first time.. better safe
if (keyDownEventRef != NULL) if (keyDownEventRef != NULL)
RemoveEventHandler(keyDownEventRef); RemoveEventHandler(keyDownEventRef);
if (keyUpEventRef != NULL) if (keyUpEventRef != NULL)
RemoveEventHandler(keyUpEventRef); RemoveEventHandler(keyUpEventRef);
if (keyModEventRef != NULL) if (keyModEventRef != NULL)
RemoveEventHandler(keyModEventRef); RemoveEventHandler(keyModEventRef);
keyDownEventRef = NULL; keyDownEventRef = NULL;
keyUpEventRef = NULL; keyUpEventRef = NULL;
keyModEventRef = NULL; keyModEventRef = NULL;
...@@ -117,7 +117,7 @@ void MacKeyboard::_initialize() ...@@ -117,7 +117,7 @@ void MacKeyboard::_initialize()
status = InstallEventHandler( event, keyDownUPP, 2, DownSpec, this, &keyDownEventRef ); status = InstallEventHandler( event, keyDownUPP, 2, DownSpec, this, &keyDownEventRef );
else else
status = InstallEventHandler( event, keyDownUPP, 1, DownSpec, this, &keyDownEventRef ); status = InstallEventHandler( event, keyDownUPP, 1, DownSpec, this, &keyDownEventRef );
if (status != noErr) if (status != noErr)
OIS_EXCEPT( E_General, "MacKeyboard::_initialize >> Error loading KeyDown event handler" ); OIS_EXCEPT( E_General, "MacKeyboard::_initialize >> Error loading KeyDown event handler" );
...@@ -141,23 +141,23 @@ void MacKeyboard::capture() ...@@ -141,23 +141,23 @@ void MacKeyboard::capture()
// if not buffered just return, we update the unbuffered automatically // if not buffered just return, we update the unbuffered automatically
if ( !mBuffered || !mListener ) if ( !mBuffered || !mListener )
return; return;
//If the mListener returns false, that means that we are probably deleted... //If the mListener returns false, that means that we are probably deleted...
//send no more events and just leave as the this pointer is invalid now... //send no more events and just leave as the this pointer is invalid now...
bool ret = true; bool ret = true;
// run through our event stack // run through our event stack
eventStack::iterator cur_it; eventStack::iterator cur_it;
for (cur_it = pendingEvents.begin(); cur_it != pendingEvents.end(); cur_it++) for (cur_it = pendingEvents.begin(); cur_it != pendingEvents.end(); cur_it++)
{ {
if ( (*cur_it).Type == MAC_KEYDOWN || (*cur_it).Type == MAC_KEYREPEAT) if ( (*cur_it).Type == MAC_KEYDOWN || (*cur_it).Type == MAC_KEYREPEAT)
mListener->keyPressed( (*cur_it).Event ); mListener->keyPressed( (*cur_it).Event );
else if ( (*cur_it).Type == MAC_KEYUP ) else if ( (*cur_it).Type == MAC_KEYUP )
mListener->keyReleased( (*cur_it).Event ); mListener->keyReleased( (*cur_it).Event );
} }
pendingEvents.clear(); pendingEvents.clear();
} }
...@@ -166,7 +166,7 @@ void MacKeyboard::capture() ...@@ -166,7 +166,7 @@ void MacKeyboard::capture()
std::string& MacKeyboard::getAsString( KeyCode key ) std::string& MacKeyboard::getAsString( KeyCode key )
{ {
getString = ""; getString = "";
return getString; return getString;
} }
...@@ -180,24 +180,24 @@ void MacKeyboard::setBuffered( bool buffered ) ...@@ -180,24 +180,24 @@ void MacKeyboard::setBuffered( bool buffered )
//-------------------------------------------------------------------// //-------------------------------------------------------------------//
void MacKeyboard::_keyDownCallback( EventRef theEvent ) void MacKeyboard::_keyDownCallback( EventRef theEvent )
{ {
UInt32 virtualKey; UInt32 virtualKey;
OSStatus status; OSStatus status;
unsigned int time = (unsigned int)GetEventTime(theEvent); unsigned int time = (unsigned int)GetEventTime(theEvent);
status = GetEventParameter(theEvent, status = GetEventParameter(theEvent,
'kcod', // get it in virtual keycode 'kcod', // get it in virtual keycode
typeUInt32, NULL, // desired return type typeUInt32, NULL, // desired return type
sizeof(UInt32), NULL, // bufsize sizeof(UInt32), NULL, // bufsize
&virtualKey ); &virtualKey );
KeyCode kc = keyConversion[virtualKey]; KeyCode kc = keyConversion[virtualKey];
// record what kind of text we should pass the KeyEvent // record what kind of text we should pass the KeyEvent
UniChar text[10]; UniChar text[10];
char macChar; char macChar;
// TODO clean this up // TODO clean this up
if (mTextMode == Unicode) if (mTextMode == Unicode)
{ {
...@@ -207,11 +207,11 @@ void MacKeyboard::_keyDownCallback( EventRef theEvent ) ...@@ -207,11 +207,11 @@ void MacKeyboard::_keyDownCallback( EventRef theEvent )
//status = GetEventParameter( theEvent, 'kuni', typeUnicodeText, NULL, sizeof(UniChar)*10, NULL, &text ); //status = GetEventParameter( theEvent, 'kuni', typeUnicodeText, NULL, sizeof(UniChar)*10, NULL, &text );
status = GetEventParameter( theEvent, 'kuni', typeUnicodeText, NULL, sizeof(UniChar) * 10, &stringsize, &text ); status = GetEventParameter( theEvent, 'kuni', typeUnicodeText, NULL, sizeof(UniChar) * 10, &stringsize, &text );
std::cout << "String length: " << stringsize << std::endl; std::cout << "String length: " << stringsize << std::endl;
//wstring unitext; //wstring unitext;
//for (int i=0;i<10;i++) unitext += (wchar_t)text[i]; //for (int i=0;i<10;i++) unitext += (wchar_t)text[i];
//wcout << "Unicode out: " << unitext << endl; //wcout << "Unicode out: " << unitext << endl;
if(stringsize > 0) if(stringsize > 0)
{ {
// for each unicode char, send an event // for each unicode char, send an event
...@@ -221,10 +221,10 @@ void MacKeyboard::_keyDownCallback( EventRef theEvent ) ...@@ -221,10 +221,10 @@ void MacKeyboard::_keyDownCallback( EventRef theEvent )
injectEvent( kc, time, MAC_KEYDOWN, (unsigned int)text[i] ); injectEvent( kc, time, MAC_KEYDOWN, (unsigned int)text[i] );
} }
} }
} }
else if (mTextMode == Ascii) else if (mTextMode == Ascii)
{ {
status = GetEventParameter( theEvent, 'kchr', typeChar, NULL, sizeof(char), NULL, &macChar ); status = GetEventParameter( theEvent, 'kchr', typeChar, NULL, sizeof(char), NULL, &macChar );
injectEvent( kc, time, MAC_KEYDOWN, (unsigned int)macChar ); injectEvent( kc, time, MAC_KEYDOWN, (unsigned int)macChar );
} }
...@@ -238,34 +238,34 @@ void MacKeyboard::_keyDownCallback( EventRef theEvent ) ...@@ -238,34 +238,34 @@ void MacKeyboard::_keyDownCallback( EventRef theEvent )
void MacKeyboard::_keyUpCallback( EventRef theEvent ) void MacKeyboard::_keyUpCallback( EventRef theEvent )
{ {
UInt32 virtualKey; UInt32 virtualKey;
OSStatus status; OSStatus status;
status = GetEventParameter( theEvent, kEventParamKeyCode, typeUInt32, status = GetEventParameter( theEvent, kEventParamKeyCode, typeUInt32,
NULL, sizeof(UInt32), NULL, &virtualKey ); NULL, sizeof(UInt32), NULL, &virtualKey );
KeyCode kc = keyConversion[virtualKey]; KeyCode kc = keyConversion[virtualKey];
injectEvent( kc, (int)GetEventTime(theEvent), MAC_KEYUP ); injectEvent( kc, (int)GetEventTime(theEvent), MAC_KEYUP );
} }
//-------------------------------------------------------------------// //-------------------------------------------------------------------//
void MacKeyboard::_modChangeCallback( EventRef theEvent ) void MacKeyboard::_modChangeCallback( EventRef theEvent )
{ {
UInt32 mods; UInt32 mods;
OSStatus status; OSStatus status;
status = GetEventParameter( theEvent, kEventParamKeyModifiers, status = GetEventParameter( theEvent, kEventParamKeyModifiers,
typeUInt32, NULL, sizeof(UInt32), NULL, &mods ); typeUInt32, NULL, sizeof(UInt32), NULL, &mods );
// find the changed bit // find the changed bit
UInt32 change = prevModMask ^ mods; UInt32 change = prevModMask ^ mods;
MacEventType newstate = ((change & prevModMask) > 0) ? MAC_KEYUP : MAC_KEYDOWN; MacEventType newstate = ((change & prevModMask) > 0) ? MAC_KEYUP : MAC_KEYDOWN;
unsigned int time = (int)GetEventTime( theEvent ); unsigned int time = (int)GetEventTime( theEvent );
//cout << "preMask: " << hex << prevModMask << endl; //cout << "preMask: " << hex << prevModMask << endl;
//cout << "ModMask: " << hex << mods << endl; //cout << "ModMask: " << hex << mods << endl;
//cout << "Change: " << hex << (change & prevModMask) << endl << endl; //cout << "Change: " << hex << (change & prevModMask) << endl << endl;
// TODO test modifiers on a full keyboard to check if different mask for left/right // TODO test modifiers on a full keyboard to check if different mask for left/right
switch (change) switch (change)
{ {
...@@ -274,37 +274,37 @@ void MacKeyboard::_modChangeCallback( EventRef theEvent ) ...@@ -274,37 +274,37 @@ void MacKeyboard::_modChangeCallback( EventRef theEvent )
injectEvent( KC_LSHIFT, time, newstate ); injectEvent( KC_LSHIFT, time, newstate );
//injectEvent( KC_RSHIFT, time, newstate ); //injectEvent( KC_RSHIFT, time, newstate );
break; break;
case (optionKey): // option (alt) case (optionKey): // option (alt)
mModifiers &= (newstate == MAC_KEYDOWN) ? Alt : -Alt; mModifiers &= (newstate == MAC_KEYDOWN) ? Alt : -Alt;
//injectEvent( KC_RMENU, time, newstate ); //injectEvent( KC_RMENU, time, newstate );
injectEvent( KC_LMENU, time, newstate ); injectEvent( KC_LMENU, time, newstate );
break; break;
case (controlKey): // Ctrl case (controlKey): // Ctrl
mModifiers += (newstate == MAC_KEYDOWN) ? Ctrl : -Ctrl; mModifiers += (newstate == MAC_KEYDOWN) ? Ctrl : -Ctrl;
//injectEvent( KC_RCONTROL, time, newstate ); //injectEvent( KC_RCONTROL, time, newstate );
injectEvent( KC_LCONTROL, time, newstate ); injectEvent( KC_LCONTROL, time, newstate );
break; break;
case (cmdKey): // apple case (cmdKey): // apple
//injectEvent( KC_RWIN, time, newstate ); //injectEvent( KC_RWIN, time, newstate );
injectEvent( KC_LWIN, time, newstate ); injectEvent( KC_LWIN, time, newstate );
break; break;
case (kEventKeyModifierFnMask): // fn key case (kEventKeyModifierFnMask): // fn key
injectEvent( KC_APPS, time, newstate ); injectEvent( KC_APPS, time, newstate );
break; break;
case (kEventKeyModifierNumLockMask): // numlock case (kEventKeyModifierNumLockMask): // numlock
injectEvent( KC_NUMLOCK, time, newstate ); injectEvent( KC_NUMLOCK, time, newstate );
break; break;
case (alphaLock): // caps lock case (alphaLock): // caps lock
injectEvent( KC_CAPITAL, time, newstate ); injectEvent( KC_CAPITAL, time, newstate );
break; break;
} }
prevModMask = mods; prevModMask = mods;
} }
...@@ -313,7 +313,7 @@ void MacKeyboard::injectEvent( KeyCode kc, unsigned int time, MacEventType type, ...@@ -313,7 +313,7 @@ void MacKeyboard::injectEvent( KeyCode kc, unsigned int time, MacEventType type,
{ {
// set to 1 if this is either a keydown or repeat // set to 1 if this is either a keydown or repeat
KeyBuffer[kc] = ( type == MAC_KEYUP ) ? 0 : 1; KeyBuffer[kc] = ( type == MAC_KEYUP ) ? 0 : 1;
if ( mBuffered && mListener ) if ( mBuffered && mListener )
pendingEvents.push_back( MacKeyStackEvent( KeyEvent(this, kc, txt), type) ); pendingEvents.push_back( MacKeyStackEvent( KeyEvent(this, kc, txt), type) );
} }
...@@ -331,7 +331,7 @@ void MacKeyboard::copyKeyStates( char keys[256] ) const ...@@ -331,7 +331,7 @@ void MacKeyboard::copyKeyStates( char keys[256] ) const
void MacKeyboard::populateKeyConversion() void MacKeyboard::populateKeyConversion()
{ {
// TODO finish the key mapping // TODO finish the key mapping
// Virtual Key Map to KeyCode // Virtual Key Map to KeyCode
keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x12, KC_1)); keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x12, KC_1));
keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x13, KC_2)); keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x13, KC_2));
...@@ -343,31 +343,31 @@ void MacKeyboard::populateKeyConversion() ...@@ -343,31 +343,31 @@ void MacKeyboard::populateKeyConversion()
keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x1C, KC_8)); keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x1C, KC_8));
keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x19, KC_9)); keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x19, KC_9));
keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x1D, KC_0)); keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x1D, KC_0));
keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x33, KC_BACK)); // might be wrong keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x33, KC_BACK)); // might be wrong
keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x1B, KC_MINUS)); keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x1B, KC_MINUS));
keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x18, KC_EQUALS)); keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x18, KC_EQUALS));
keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x31, KC_SPACE)); keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x31, KC_SPACE));
keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x2B, KC_COMMA)); keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x2B, KC_COMMA));
keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x2F, KC_PERIOD)); keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x2F, KC_PERIOD));
keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x2A, KC_BACKSLASH)); keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x2A, KC_BACKSLASH));
keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x2C, KC_SLASH)); keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x2C, KC_SLASH));
keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x21, KC_LBRACKET)); keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x21, KC_LBRACKET));
keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x1E, KC_RBRACKET)); keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x1E, KC_RBRACKET));
keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x35, KC_ESCAPE)); keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x35, KC_ESCAPE));
keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x39, KC_CAPITAL)); keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x39, KC_CAPITAL));
keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x30, KC_TAB)); keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x30, KC_TAB));
keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x24, KC_RETURN)); // double check return/enter keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x24, KC_RETURN)); // double check return/enter
//keyConversion.insert(VirtualtoOIS_KeyMap::value_type(XK_colon, KC_COLON)); // no colon? //keyConversion.insert(VirtualtoOIS_KeyMap::value_type(XK_colon, KC_COLON)); // no colon?
keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x29, KC_SEMICOLON)); keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x29, KC_SEMICOLON));
keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x27, KC_APOSTROPHE)); keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x27, KC_APOSTROPHE));
keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x32, KC_GRAVE)); keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x32, KC_GRAVE));
keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x0B, KC_B)); keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x0B, KC_B));
keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x00, KC_A)); keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x00, KC_A));
keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x08, KC_C)); keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x08, KC_C));
...@@ -394,7 +394,7 @@ void MacKeyboard::populateKeyConversion() ...@@ -394,7 +394,7 @@ void MacKeyboard::populateKeyConversion()
keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x07, KC_X)); keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x07, KC_X));
keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x10, KC_Y)); keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x10, KC_Y));
keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x06, KC_Z)); keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x06, KC_Z));
keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x7A, KC_F1)); keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x7A, KC_F1));
keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x78, KC_F2)); keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x78, KC_F2));
keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x63, KC_F3)); keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x63, KC_F3));
...@@ -410,7 +410,7 @@ void MacKeyboard::populateKeyConversion() ...@@ -410,7 +410,7 @@ void MacKeyboard::populateKeyConversion()
keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x69, KC_F13)); keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x69, KC_F13));
keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x6B, KC_F14)); keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x6B, KC_F14));
keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x71, KC_F15)); keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x71, KC_F15));
//Keypad //Keypad
keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x52, KC_NUMPAD0)); keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x52, KC_NUMPAD0));
keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x53, KC_NUMPAD1)); keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x53, KC_NUMPAD1));
...@@ -429,7 +429,7 @@ void MacKeyboard::populateKeyConversion() ...@@ -429,7 +429,7 @@ void MacKeyboard::populateKeyConversion()
keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x4B, KC_DIVIDE)); keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x4B, KC_DIVIDE));
keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x43, KC_MULTIPLY)); keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x43, KC_MULTIPLY));
keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x4C, KC_NUMPADENTER)); keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x4C, KC_NUMPADENTER));
//Keypad with numlock off //Keypad with numlock off
//keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x73, KC_NUMPAD7)); // not sure of these //keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x73, KC_NUMPAD7)); // not sure of these
//keyConversion.insert(VirtualtoOIS_KeyMap::value_type(XK_KP_Up, KC_NUMPAD8)); // check on a non-laptop //keyConversion.insert(VirtualtoOIS_KeyMap::value_type(XK_KP_Up, KC_NUMPAD8)); // check on a non-laptop
...@@ -442,22 +442,22 @@ void MacKeyboard::populateKeyConversion() ...@@ -442,22 +442,22 @@ void MacKeyboard::populateKeyConversion()
//keyConversion.insert(VirtualtoOIS_KeyMap::value_type(XK_KP_Page_Down, KC_NUMPAD3)); //keyConversion.insert(VirtualtoOIS_KeyMap::value_type(XK_KP_Page_Down, KC_NUMPAD3));
//keyConversion.insert(VirtualtoOIS_KeyMap::value_type(XK_KP_Insert, KC_NUMPAD0)); //keyConversion.insert(VirtualtoOIS_KeyMap::value_type(XK_KP_Insert, KC_NUMPAD0));
//keyConversion.insert(VirtualtoOIS_KeyMap::value_type(XK_KP_Delete, KC_DECIMAL)); //keyConversion.insert(VirtualtoOIS_KeyMap::value_type(XK_KP_Delete, KC_DECIMAL));
keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x7E, KC_UP)); keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x7E, KC_UP));
keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x7D, KC_DOWN)); keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x7D, KC_DOWN));
keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x7B, KC_LEFT)); keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x7B, KC_LEFT));
keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x7C, KC_RIGHT)); keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x7C, KC_RIGHT));
keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x74, KC_PGUP)); keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x74, KC_PGUP));
keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x79, KC_PGDOWN)); keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x79, KC_PGDOWN));
keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x73, KC_HOME)); keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x73, KC_HOME));
keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x77, KC_END)); keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x77, KC_END));
//keyConversion.insert(VirtualtoOIS_KeyMap::value_type(XK_Print, KC_SYSRQ)); // ?? //keyConversion.insert(VirtualtoOIS_KeyMap::value_type(XK_Print, KC_SYSRQ)); // ??
//keyConversion.insert(VirtualtoOIS_KeyMap::value_type(XK_Scroll_Lock, KC_SCROLL)); // ?? //keyConversion.insert(VirtualtoOIS_KeyMap::value_type(XK_Scroll_Lock, KC_SCROLL)); // ??
//keyConversion.insert(VirtualtoOIS_KeyMap::value_type(XK_Pause, KC_PAUSE)); // ?? //keyConversion.insert(VirtualtoOIS_KeyMap::value_type(XK_Pause, KC_PAUSE)); // ??
//keyConversion.insert(VirtualtoOIS_KeyMap::value_type(XK_Insert, KC_INSERT)); // ?? //keyConversion.insert(VirtualtoOIS_KeyMap::value_type(XK_Insert, KC_INSERT)); // ??
keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x75, KC_DELETE)); // del under help key? keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x75, KC_DELETE)); // del under help key?
} }
......
...@@ -18,7 +18,7 @@ const EventTypeSpec mouseEvents[] = { ...@@ -18,7 +18,7 @@ const EventTypeSpec mouseEvents[] = {
{ kEventClassMouse, kEventMouseUp }, { kEventClassMouse, kEventMouseUp },
{ kEventClassMouse, kEventMouseMoved }, { kEventClassMouse, kEventMouseMoved },
{ kEventClassMouse, kEventMouseDragged }, { kEventClassMouse, kEventMouseDragged },
{ kEventClassMouse, kEventMouseWheelMoved } { kEventClassMouse, kEventMouseWheelMoved }
}; };
const EventTypeSpec WinFocusAcquired [] = {{kEventClassApplication, kEventAppDeactivated}}; const EventTypeSpec WinFocusAcquired [] = {{kEventClassApplication, kEventAppDeactivated}};
...@@ -44,10 +44,10 @@ MacMouse::~MacMouse() ...@@ -44,10 +44,10 @@ MacMouse::~MacMouse()
if(mWindowFocusHandler != NULL) if(mWindowFocusHandler != NULL)
RemoveEventHandler(mWindowFocusHandler); RemoveEventHandler(mWindowFocusHandler);
DisposeEventHandlerUPP(mouseUPP); DisposeEventHandlerUPP(mouseUPP);
DisposeEventHandlerUPP(mWindowFocusListener); DisposeEventHandlerUPP(mWindowFocusListener);
// Restore Mouse // Restore Mouse
CGAssociateMouseAndMouseCursorPosition(TRUE); CGAssociateMouseAndMouseCursorPosition(TRUE);
CGDisplayShowCursor(kCGDirectMainDisplay); CGDisplayShowCursor(kCGDirectMainDisplay);
...@@ -60,32 +60,32 @@ void MacMouse::_initialize() ...@@ -60,32 +60,32 @@ void MacMouse::_initialize()
mState.clear(); mState.clear();
mTempState.clear(); mTempState.clear();
mMouseWarped = false; mMouseWarped = false;
// Hide OS Mouse // Hide OS Mouse
CGDisplayHideCursor(kCGDirectMainDisplay); CGDisplayHideCursor(kCGDirectMainDisplay);
MacInputManager* im = static_cast<MacInputManager*>(mCreator); MacInputManager* im = static_cast<MacInputManager*>(mCreator);
WindowRef win = im->_getWindow(); WindowRef win = im->_getWindow();
if(win) if(win)
{ {
Rect clipRect = {0.0f, 0.0f, 0.0f, 0.0f}; Rect clipRect = {0.0f, 0.0f, 0.0f, 0.0f};
GetWindowBounds(win, kWindowContentRgn, &clipRect); GetWindowBounds(win, kWindowContentRgn, &clipRect);
CGPoint warpPoint; CGPoint warpPoint;
warpPoint.x = ((clipRect.right - clipRect.left) / 2) + clipRect.left; warpPoint.x = ((clipRect.right - clipRect.left) / 2) + clipRect.left;
warpPoint.y = ((clipRect.bottom - clipRect.top) / 2) + clipRect.top; warpPoint.y = ((clipRect.bottom - clipRect.top) / 2) + clipRect.top;
CGDisplayMoveCursorToPoint(kCGDirectMainDisplay, warpPoint); //Place at display origin CGDisplayMoveCursorToPoint(kCGDirectMainDisplay, warpPoint); //Place at display origin
mMouseWarped = true; mMouseWarped = true;
} }
//Now that mouse is warped, start listening for events //Now that mouse is warped, start listening for events
EventTargetRef event = ((MacInputManager*)mCreator)->_getEventTarget(); EventTargetRef event = ((MacInputManager*)mCreator)->_getEventTarget();
if(mouseEventRef != NULL) if(mouseEventRef != NULL)
RemoveEventHandler(mouseEventRef); RemoveEventHandler(mouseEventRef);
if(mWindowFocusHandler != NULL) if(mWindowFocusHandler != NULL)
RemoveEventHandler(mWindowFocusHandler); RemoveEventHandler(mWindowFocusHandler);
...@@ -95,7 +95,7 @@ void MacMouse::_initialize() ...@@ -95,7 +95,7 @@ void MacMouse::_initialize()
OIS_EXCEPT( E_General, "MacMouse::_initialize >> Error loading Mouse event handler" ); OIS_EXCEPT( E_General, "MacMouse::_initialize >> Error loading Mouse event handler" );
if(InstallEventHandler(event, mWindowFocusListener, GetEventTypeCount(WinFocusAcquired), WinFocusAcquired, this, &mWindowFocusHandler) != noErr) if(InstallEventHandler(event, mWindowFocusListener, GetEventTypeCount(WinFocusAcquired), WinFocusAcquired, this, &mWindowFocusHandler) != noErr)
OIS_EXCEPT( E_General, "MacMouse::_initialize >> Error loading Mouse event handler" ); OIS_EXCEPT( E_General, "MacMouse::_initialize >> Error loading Mouse event handler" );
//Lock OS Mouse movement //Lock OS Mouse movement
mNeedsToRegainFocus = false; mNeedsToRegainFocus = false;
...@@ -129,7 +129,7 @@ void MacMouse::capture() ...@@ -129,7 +129,7 @@ void MacMouse::capture()
mState.X.rel = 0; mState.X.rel = 0;
mState.Y.rel = 0; mState.Y.rel = 0;
mState.Z.rel = 0; mState.Z.rel = 0;
if(mTempState.X.rel || mTempState.Y.rel || mTempState.Z.rel) if(mTempState.X.rel || mTempState.Y.rel || mTempState.Z.rel)
{ {
//printf("%i %i %i\n\n", mTempState.X.rel, mTempState.Y.rel, mTempState.Z.rel); //printf("%i %i %i\n\n", mTempState.X.rel, mTempState.Y.rel, mTempState.Z.rel);
...@@ -138,11 +138,11 @@ void MacMouse::capture() ...@@ -138,11 +138,11 @@ void MacMouse::capture()
mState.X.rel = mTempState.X.rel; mState.X.rel = mTempState.X.rel;
mState.Y.rel = mTempState.Y.rel; mState.Y.rel = mTempState.Y.rel;
mState.Z.rel = mTempState.Z.rel; mState.Z.rel = mTempState.Z.rel;
//Update absolute position //Update absolute position
mState.X.abs += mTempState.X.rel; mState.X.abs += mTempState.X.rel;
mState.Y.abs += mTempState.Y.rel; mState.Y.abs += mTempState.Y.rel;
if(mState.X.abs > mState.width) if(mState.X.abs > mState.width)
mState.X.abs = mState.width; mState.X.abs = mState.width;
else if(mState.X.abs < 0) else if(mState.X.abs < 0)
...@@ -152,9 +152,9 @@ void MacMouse::capture() ...@@ -152,9 +152,9 @@ void MacMouse::capture()
mState.Y.abs = mState.height; mState.Y.abs = mState.height;
else if(mState.Y.abs < 0) else if(mState.Y.abs < 0)
mState.Y.abs = 0; mState.Y.abs = 0;
mState.Z.abs += mTempState.Z.rel; mState.Z.abs += mTempState.Z.rel;
//Fire off event //Fire off event
if(mListener && mBuffered) if(mListener && mBuffered)
mListener->mouseMoved(MouseEvent(this, mState)); mListener->mouseMoved(MouseEvent(this, mState));
...@@ -176,7 +176,7 @@ void MacMouse::_mouseCallback( EventRef theEvent ) ...@@ -176,7 +176,7 @@ void MacMouse::_mouseCallback( EventRef theEvent )
//HIPoint location = {0.0f, 0.0f}; //HIPoint location = {0.0f, 0.0f};
HIPoint delta = {0.0f, 0.0f}; HIPoint delta = {0.0f, 0.0f};
//Rect clipRect = {0.0f, 0.0f, 0.0f, 0.0f}; //Rect clipRect = {0.0f, 0.0f, 0.0f, 0.0f};
if(mNeedsToRegainFocus) if(mNeedsToRegainFocus)
break; break;
...@@ -184,15 +184,15 @@ void MacMouse::_mouseCallback( EventRef theEvent ) ...@@ -184,15 +184,15 @@ void MacMouse::_mouseCallback( EventRef theEvent )
// TODO: Look into HIViewNewTrackingArea // TODO: Look into HIViewNewTrackingArea
//GetEventParameter(theEvent, kEventParamMouseLocation, typeHIPoint, NULL, sizeof(HIPoint), NULL, &location); //GetEventParameter(theEvent, kEventParamMouseLocation, typeHIPoint, NULL, sizeof(HIPoint), NULL, &location);
GetEventParameter(theEvent, kEventParamMouseDelta, typeHIPoint, NULL, sizeof(HIPoint), NULL, &delta); GetEventParameter(theEvent, kEventParamMouseDelta, typeHIPoint, NULL, sizeof(HIPoint), NULL, &delta);
// Mouse X and Y are the position on the screen, // Mouse X and Y are the position on the screen,
// startng from top-left at 0,0 caps at full monitor resolution // startng from top-left at 0,0 caps at full monitor resolution
// If we have a window we need to return adjusted coordinates // If we have a window we need to return adjusted coordinates
// If not, just use raw coordinates - only do this if showing OS mouse // If not, just use raw coordinates - only do this if showing OS mouse
//MacInputManager* im = static_cast<MacInputManager*>(mCreator); //MacInputManager* im = static_cast<MacInputManager*>(mCreator);
//WindowRef win = im->_getWindow(); //WindowRef win = im->_getWindow();
//if(win != NULL) //if(win != NULL)
//{ //{
// GetWindowBounds(win, kWindowContentRgn, &clipRect); // GetWindowBounds(win, kWindowContentRgn, &clipRect);
...@@ -202,7 +202,7 @@ void MacMouse::_mouseCallback( EventRef theEvent ) ...@@ -202,7 +202,7 @@ void MacMouse::_mouseCallback( EventRef theEvent )
// clipRect.right = mState.width; // clipRect.right = mState.width;
// clipRect.bottom = mState.height; // clipRect.bottom = mState.height;
//} //}
// clip the mouse, absolute positioning // clip the mouse, absolute positioning
//if (location.x <= clipRect.left) //if (location.x <= clipRect.left)
// mState.X.abs = 0; // mState.X.abs = 0;
...@@ -210,21 +210,21 @@ void MacMouse::_mouseCallback( EventRef theEvent ) ...@@ -210,21 +210,21 @@ void MacMouse::_mouseCallback( EventRef theEvent )
// mState.X.abs = clipRect.right - clipRect.left; // mState.X.abs = clipRect.right - clipRect.left;
//else //else
// mState.X.abs = location.x - clipRect.left; // mState.X.abs = location.x - clipRect.left;
//if (location.y <= clipRect.top) //if (location.y <= clipRect.top)
// mState.Y.abs = 0; // mState.Y.abs = 0;
//else if(location.y >= clipRect.bottom) //else if(location.y >= clipRect.bottom)
// mState.Y.abs = clipRect.bottom - clipRect.top; // mState.Y.abs = clipRect.bottom - clipRect.top;
//else //else
// mState.Y.abs = location.y - clipRect.top; // mState.Y.abs = location.y - clipRect.top;
// relative positioning // relative positioning
if(!mMouseWarped) if(!mMouseWarped)
{ {
mTempState.X.rel += delta.x; mTempState.X.rel += delta.x;
mTempState.Y.rel += delta.y; mTempState.Y.rel += delta.y;
} }
mMouseWarped = false; mMouseWarped = false;
break; break;
...@@ -234,21 +234,21 @@ void MacMouse::_mouseCallback( EventRef theEvent ) ...@@ -234,21 +234,21 @@ void MacMouse::_mouseCallback( EventRef theEvent )
EventMouseButton button = 0; EventMouseButton button = 0;
int mouseButton = 3; int mouseButton = 3;
UInt32 modifiers = 0; UInt32 modifiers = 0;
if(mNeedsToRegainFocus) if(mNeedsToRegainFocus)
break; break;
// Capture parameters // Capture parameters
GetEventParameter(theEvent, kEventParamMouseButton, typeMouseButton, NULL, sizeof(EventMouseButton), NULL, &button); GetEventParameter(theEvent, kEventParamMouseButton, typeMouseButton, NULL, sizeof(EventMouseButton), NULL, &button);
GetEventParameter(theEvent, kEventParamKeyModifiers, typeUInt32, NULL, sizeof(UInt32), NULL, &modifiers); GetEventParameter(theEvent, kEventParamKeyModifiers, typeUInt32, NULL, sizeof(UInt32), NULL, &modifiers);
if((button == kEventMouseButtonTertiary) || ((button == kEventMouseButtonPrimary) && (modifiers & optionKey))) if((button == kEventMouseButtonTertiary) || ((button == kEventMouseButtonPrimary) && (modifiers & optionKey)))
{ {
mouseButton = 2; mouseButton = 2;
mState.buttons |= 1 << mouseButton; mState.buttons |= 1 << mouseButton;
} }
else if((button == kEventMouseButtonSecondary) || ((button == kEventMouseButtonPrimary) && (modifiers & controlKey))) else if((button == kEventMouseButtonSecondary) || ((button == kEventMouseButtonPrimary) && (modifiers & controlKey)))
{ {
mouseButton = 1; mouseButton = 1;
mState.buttons |= 1 << mouseButton; mState.buttons |= 1 << mouseButton;
} }
...@@ -268,48 +268,48 @@ void MacMouse::_mouseCallback( EventRef theEvent ) ...@@ -268,48 +268,48 @@ void MacMouse::_mouseCallback( EventRef theEvent )
EventMouseButton button = 0; EventMouseButton button = 0;
int mouseButton = 3; int mouseButton = 3;
UInt32 modifiers = 0; UInt32 modifiers = 0;
if(mNeedsToRegainFocus) if(mNeedsToRegainFocus)
{ {
mNeedsToRegainFocus = false; mNeedsToRegainFocus = false;
CGAssociateMouseAndMouseCursorPosition(false); CGAssociateMouseAndMouseCursorPosition(false);
MacInputManager* im = static_cast<MacInputManager*>(mCreator); MacInputManager* im = static_cast<MacInputManager*>(mCreator);
WindowRef win = im->_getWindow(); WindowRef win = im->_getWindow();
if(win) if(win)
{ {
Rect clipRect = {0.0f, 0.0f, 0.0f, 0.0f}; Rect clipRect = {0.0f, 0.0f, 0.0f, 0.0f};
GetWindowBounds(win, kWindowContentRgn, &clipRect); GetWindowBounds(win, kWindowContentRgn, &clipRect);
CGPoint warpPoint; CGPoint warpPoint;
warpPoint.x = ((clipRect.right - clipRect.left) / 2) + clipRect.left; warpPoint.x = ((clipRect.right - clipRect.left) / 2) + clipRect.left;
warpPoint.y = ((clipRect.bottom - clipRect.top) / 2) + clipRect.top; warpPoint.y = ((clipRect.bottom - clipRect.top) / 2) + clipRect.top;
CGDisplayMoveCursorToPoint(kCGDirectMainDisplay, warpPoint); //Place at display origin CGDisplayMoveCursorToPoint(kCGDirectMainDisplay, warpPoint); //Place at display origin
CGDisplayHideCursor(kCGDirectMainDisplay); CGDisplayHideCursor(kCGDirectMainDisplay);
mMouseWarped = true; mMouseWarped = true;
} }
//Once we regain focus, we do not really know what state all the buttons are in - for now, set to not pressed. todo, check current status //Once we regain focus, we do not really know what state all the buttons are in - for now, set to not pressed. todo, check current status
//compare against old status, and send off any needed events //compare against old status, and send off any needed events
mState.buttons = 0; mState.buttons = 0;
break; break;
} }
// Capture parameters // Capture parameters
GetEventParameter(theEvent, kEventParamMouseButton, typeMouseButton, NULL, sizeof(EventMouseButton), NULL, &button); GetEventParameter(theEvent, kEventParamMouseButton, typeMouseButton, NULL, sizeof(EventMouseButton), NULL, &button);
GetEventParameter(theEvent, kEventParamKeyModifiers, typeUInt32, NULL, sizeof(UInt32), NULL, &modifiers); GetEventParameter(theEvent, kEventParamKeyModifiers, typeUInt32, NULL, sizeof(UInt32), NULL, &modifiers);
if ((button == kEventMouseButtonTertiary) || ((button == kEventMouseButtonPrimary) && (modifiers & optionKey))) if ((button == kEventMouseButtonTertiary) || ((button == kEventMouseButtonPrimary) && (modifiers & optionKey)))
{ {
mouseButton = 2; mouseButton = 2;
mState.buttons &= ~(1 << mouseButton); mState.buttons &= ~(1 << mouseButton);
} }
else if ((button == kEventMouseButtonSecondary) || ((button == kEventMouseButtonPrimary) && (modifiers & controlKey))) else if ((button == kEventMouseButtonSecondary) || ((button == kEventMouseButtonPrimary) && (modifiers & controlKey)))
{ {
mouseButton = 1; mouseButton = 1;
mState.buttons &= ~(1 << mouseButton); mState.buttons &= ~(1 << mouseButton);
} }
...@@ -327,12 +327,12 @@ void MacMouse::_mouseCallback( EventRef theEvent ) ...@@ -327,12 +327,12 @@ void MacMouse::_mouseCallback( EventRef theEvent )
case kEventMouseWheelMoved: case kEventMouseWheelMoved:
{ {
SInt32 wheelDelta = 0; SInt32 wheelDelta = 0;
EventMouseWheelAxis wheelAxis = 0; EventMouseWheelAxis wheelAxis = 0;
// Capture parameters // Capture parameters
GetEventParameter(theEvent, kEventParamMouseWheelAxis, typeMouseWheelAxis, NULL, sizeof(EventMouseWheelAxis), NULL, &wheelAxis); GetEventParameter(theEvent, kEventParamMouseWheelAxis, typeMouseWheelAxis, NULL, sizeof(EventMouseWheelAxis), NULL, &wheelAxis);
GetEventParameter(theEvent, kEventParamMouseWheelDelta, typeSInt32, NULL, sizeof(SInt32), NULL, &wheelDelta); GetEventParameter(theEvent, kEventParamMouseWheelDelta, typeSInt32, NULL, sizeof(SInt32), NULL, &wheelDelta);
// If the Y axis of the wheel changed, then update the Z // If the Y axis of the wheel changed, then update the Z
// Does OIS care about the X wheel axis? // Does OIS care about the X wheel axis?
if(wheelAxis == kEventMouseWheelAxisY) if(wheelAxis == kEventMouseWheelAxisY)
...@@ -342,5 +342,5 @@ void MacMouse::_mouseCallback( EventRef theEvent ) ...@@ -342,5 +342,5 @@ void MacMouse::_mouseCallback( EventRef theEvent )
} }
default: default:
break; break;
} }
} }
...@@ -72,10 +72,10 @@ short Win32ForceFeedback::getFFAxesNumber() ...@@ -72,10 +72,10 @@ short Win32ForceFeedback::getFFAxesNumber()
//--------------------------------------------------------------// //--------------------------------------------------------------//
unsigned short Win32ForceFeedback::getFFMemoryLoad() unsigned short Win32ForceFeedback::getFFMemoryLoad()
{ {
DIPROPDWORD dipdw; // DIPROPDWORD contains a DIPROPHEADER structure. DIPROPDWORD dipdw; // DIPROPDWORD contains a DIPROPHEADER structure.
dipdw.diph.dwSize = sizeof(DIPROPDWORD); dipdw.diph.dwSize = sizeof(DIPROPDWORD);
dipdw.diph.dwHeaderSize = sizeof(DIPROPHEADER); dipdw.diph.dwHeaderSize = sizeof(DIPROPHEADER);
dipdw.diph.dwObj = 0; // device property dipdw.diph.dwObj = 0; // device property
dipdw.diph.dwHow = DIPH_DEVICE; dipdw.diph.dwHow = DIPH_DEVICE;
dipdw.dwData = 0; // In case of any error. dipdw.dwData = 0; // In case of any error.
...@@ -155,7 +155,7 @@ void Win32ForceFeedback::setMasterGain( float level ) ...@@ -155,7 +155,7 @@ void Win32ForceFeedback::setMasterGain( float level )
DIPropGain.dwData = gain_level; DIPropGain.dwData = gain_level;
#if (OIS_WIN32_JOYFF_DEBUG > 0) #if (OIS_WIN32_JOYFF_DEBUG > 0)
cout << "Win32ForceFeedback("<< mJoyStick << ") : Setting master gain to " cout << "Win32ForceFeedback("<< mJoyStick << ") : Setting master gain to "
<< level << " => " << DIPropGain.dwData << endl; << level << " => " << DIPropGain.dwData << endl;
#endif #endif
...@@ -178,7 +178,7 @@ void Win32ForceFeedback::setAutoCenterMode( bool auto_on ) ...@@ -178,7 +178,7 @@ void Win32ForceFeedback::setAutoCenterMode( bool auto_on )
DIPropAutoCenter.dwData = (auto_on ? DIPROPAUTOCENTER_ON : DIPROPAUTOCENTER_OFF); DIPropAutoCenter.dwData = (auto_on ? DIPROPAUTOCENTER_ON : DIPROPAUTOCENTER_OFF);
#if (OIS_WIN32_JOYFF_DEBUG > 0) #if (OIS_WIN32_JOYFF_DEBUG > 0)
cout << "Win32ForceFeedback("<< mJoyStick << ") : Setting auto-center mode to " cout << "Win32ForceFeedback("<< mJoyStick << ") : Setting auto-center mode to "
<< auto_on << " => " << DIPropAutoCenter.dwData << endl; << auto_on << " => " << DIPropAutoCenter.dwData << endl;
#endif #endif
...@@ -328,9 +328,9 @@ void Win32ForceFeedback::_setCommonProperties( ...@@ -328,9 +328,9 @@ void Win32ForceFeedback::_setCommonProperties(
#if (OIS_WIN32_JOYFF_DEBUG > 1) #if (OIS_WIN32_JOYFF_DEBUG > 1)
cout << " Trigger :" << endl cout << " Trigger :" << endl
<< " Button : " << effect->trigger_button << " Button : " << effect->trigger_button
<< " => " << diEffect->dwTriggerButton << endl << " => " << diEffect->dwTriggerButton << endl
<< " Interval : " << effect->trigger_interval << " Interval : " << effect->trigger_interval
<< " => " << diEffect->dwTriggerRepeatInterval << endl; << " => " << diEffect->dwTriggerRepeatInterval << endl;
#endif #endif
...@@ -364,9 +364,9 @@ void Win32ForceFeedback::_setCommonProperties( ...@@ -364,9 +364,9 @@ void Win32ForceFeedback::_setCommonProperties(
{ {
cout << " Enveloppe :" << endl cout << " Enveloppe :" << endl
<< " AttackLen : " << envelope->attackLength << " AttackLen : " << envelope->attackLength
<< " => " << diEnvelope->dwAttackTime << endl << " => " << diEnvelope->dwAttackTime << endl
<< " AttackLvl : " << envelope->attackLevel << " AttackLvl : " << envelope->attackLevel
<< " => " << diEnvelope->dwAttackLevel << endl << " => " << diEnvelope->dwAttackLevel << endl
<< " FadeLen : " << envelope->fadeLength << " FadeLen : " << envelope->fadeLength
<< " => " << diEnvelope->dwFadeTime << endl << " => " << diEnvelope->dwFadeTime << endl
<< " FadeLvl : " << envelope->fadeLevel << " FadeLvl : " << envelope->fadeLevel
...@@ -380,9 +380,9 @@ void Win32ForceFeedback::_setCommonProperties( ...@@ -380,9 +380,9 @@ void Win32ForceFeedback::_setCommonProperties(
#if (OIS_WIN32_JOYFF_DEBUG > 1) #if (OIS_WIN32_JOYFF_DEBUG > 1)
cout << " Replay :" << endl cout << " Replay :" << endl
<< " Length : " << effect->replay_length << " Length : " << effect->replay_length
<< " => " << diEffect->dwDuration << endl << " => " << diEffect->dwDuration << endl
<< " Delay : " << effect->replay_delay << " Delay : " << effect->replay_delay
<< " => " << diEffect->dwStartDelay << endl; << " => " << diEffect->dwStartDelay << endl;
#endif #endif
...@@ -491,7 +491,7 @@ void Win32ForceFeedback::_addEffectSupport( LPCDIEFFECTINFO pdei ) ...@@ -491,7 +491,7 @@ void Win32ForceFeedback::_addEffectSupport( LPCDIEFFECTINFO pdei )
default: default:
eForce = Effect::UnknownForce; eForce = Effect::UnknownForce;
#if defined (_DEBUG) #if defined (_DEBUG)
cout << "Win32ForceFeedback: DirectInput8 Effect type support not implemented: " cout << "Win32ForceFeedback: DirectInput8 Effect type support not implemented: "
<< "DIEFT_GETTYPE="<< (int)DIEFT_GETTYPE(pdei->dwEffType) << endl; << "DIEFT_GETTYPE="<< (int)DIEFT_GETTYPE(pdei->dwEffType) << endl;
#endif #endif
return; return;
......
...@@ -6,16 +6,16 @@ Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com) ...@@ -6,16 +6,16 @@ Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
This software is provided 'as-is', without any express or implied warranty. In no event will This software is provided 'as-is', without any express or implied warranty. In no event will
the authors be held liable for any damages arising from the use of this software. the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose, including commercial Permission is granted to anyone to use this software for any purpose, including commercial
applications, and to alter it and redistribute it freely, subject to the following applications, and to alter it and redistribute it freely, subject to the following
restrictions: restrictions:
1. The origin of this software must not be misrepresented; you must not claim that 1. The origin of this software must not be misrepresented; you must not claim that
you wrote the original software. If you use this software in a product, you wrote the original software. If you use this software in a product,
an acknowledgment in the product documentation would be appreciated but is an acknowledgment in the product documentation would be appreciated but is
not required. not required.
2. Altered source versions must be plainly marked as such, and must not be 2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software. misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
...@@ -64,7 +64,7 @@ void Win32InputManager::_initialize( ParamList &paramList ) ...@@ -64,7 +64,7 @@ void Win32InputManager::_initialize( ParamList &paramList )
//First of all, get the Windows Handle and Instance //First of all, get the Windows Handle and Instance
ParamList::iterator i = paramList.find("WINDOW"); ParamList::iterator i = paramList.find("WINDOW");
if( i == paramList.end() ) if( i == paramList.end() )
OIS_EXCEPT( E_InvalidParam, "Win32InputManager::Win32InputManager >> No HWND found!" ); OIS_EXCEPT( E_InvalidParam, "Win32InputManager::Win32InputManager >> No HWND found!" );
// Get number as 64 bit and then convert. Handles the case of 32 or 64 bit HWND // Get number as 64 bit and then convert. Handles the case of 32 or 64 bit HWND
...@@ -78,7 +78,7 @@ void Win32InputManager::_initialize( ParamList &paramList ) ...@@ -78,7 +78,7 @@ void Win32InputManager::_initialize( ParamList &paramList )
//Create the device //Create the device
hr = DirectInput8Create( hInst, DIRECTINPUT_VERSION, IID_IDirectInput8, (VOID**)&mDirectInput, NULL ); hr = DirectInput8Create( hInst, DIRECTINPUT_VERSION, IID_IDirectInput8, (VOID**)&mDirectInput, NULL );
if (FAILED(hr)) if (FAILED(hr))
OIS_EXCEPT( E_General, "Win32InputManager::Win32InputManager >> Not able to init DirectX8 Input!"); OIS_EXCEPT( E_General, "Win32InputManager::Win32InputManager >> Not able to init DirectX8 Input!");
//Ok, now we have DirectInput, parse whatever extra settings were sent to us //Ok, now we have DirectInput, parse whatever extra settings were sent to us
...@@ -101,7 +101,7 @@ void Win32InputManager::_parseConfigSettings( ParamList &paramList ) ...@@ -101,7 +101,7 @@ void Win32InputManager::_parseConfigSettings( ParamList &paramList )
//Check for pairs: ie. ("w32_keyboard","DISCL_NOWINKEY")("w32_keyboard","DISCL_FOREGROUND") //Check for pairs: ie. ("w32_keyboard","DISCL_NOWINKEY")("w32_keyboard","DISCL_FOREGROUND")
ParamList::iterator i = paramList.begin(), e = paramList.end(); ParamList::iterator i = paramList.begin(), e = paramList.end();
for( ; i != e; ++i ) for( ; i != e; ++i )
{ {
if( i->first == "w32_keyboard" ) if( i->first == "w32_keyboard" )
kbSettings |= temp[i->second]; kbSettings |= temp[i->second];
...@@ -122,7 +122,7 @@ void Win32InputManager::_enumerateDevices() ...@@ -122,7 +122,7 @@ void Win32InputManager::_enumerateDevices()
mDirectInput->EnumDevices(NULL, _DIEnumDevCallback, this, DIEDFL_ATTACHEDONLY); mDirectInput->EnumDevices(NULL, _DIEnumDevCallback, this, DIEDFL_ATTACHEDONLY);
#ifdef OIS_WIN32_XINPUT_SUPPORT #ifdef OIS_WIN32_XINPUT_SUPPORT
//let's check how many possible XInput devices we may have (max 4)... //let's check how many possible XInput devices we may have (max 4)...
for(int i = 0; i < 3; ++i) for(int i = 0; i < 3; ++i)
{ {
XINPUT_STATE state; XINPUT_STATE state;
...@@ -156,7 +156,7 @@ BOOL CALLBACK Win32InputManager::_DIEnumDevCallback(LPCDIDEVICEINSTANCE lpddi, L ...@@ -156,7 +156,7 @@ BOOL CALLBACK Win32InputManager::_DIEnumDevCallback(LPCDIDEVICEINSTANCE lpddi, L
jsInfo.devId = _this_->joySticks; jsInfo.devId = _this_->joySticks;
_this_->joySticks++; _this_->joySticks++;
_this_->unusedJoyStickList.push_back( jsInfo ); _this_->unusedJoyStickList.push_back( jsInfo );
} }
...@@ -234,7 +234,7 @@ Object* Win32InputManager::createObject(InputManager* creator, Type iType, bool ...@@ -234,7 +234,7 @@ Object* Win32InputManager::createObject(InputManager* creator, Type iType, bool
switch(iType) switch(iType)
{ {
case OISKeyboard: case OISKeyboard:
{ {
if( keyboardUsed == false ) if( keyboardUsed == false )
obj = new Win32Keyboard(this, mDirectInput, bufferMode, kbSettings); obj = new Win32Keyboard(this, mDirectInput, bufferMode, kbSettings);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment