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