This commit is contained in:
Steve Checkoway
2005-12-19 01:32:36 +00:00
parent 4b31547f78
commit a8d0b5c9f9
@@ -36,7 +36,8 @@ static inline Boolean IntValue( const void *o, int *n )
return CFNumberGetValue( CFNumberRef(o), kCFNumberIntType, n ); return CFNumberGetValue( CFNumberRef(o), kCFNumberIntType, n );
} }
/* This is just awful, these aren't objects, treating them as such leads /*
* This is just awful, these aren't objects, treating them as such leads
* to: (*object)->function(object [, argument]...) * to: (*object)->function(object [, argument]...)
* Instead, do: CALL(object, function [, argument]...) * Instead, do: CALL(object, function [, argument]...)
*/ */
@@ -198,8 +199,8 @@ bool Device::Open( io_object_t device )
// open the interface // open the interface
if( (ret = CALL(mInterface, open, 0)) != kIOReturnSuccess ) if( (ret = CALL(mInterface, open, 0)) != kIOReturnSuccess )
{ {
PrintIOErr(ret, "Failed to open the interface."); PrintIOErr( ret, "Failed to open the interface." );
CALL(mInterface, Release); CALL( mInterface, Release );
mInterface = NULL; mInterface = NULL;
return false; return false;
} }
@@ -214,8 +215,8 @@ bool Device::Open( io_object_t device )
if( (ret = CALL(mQueue, create, 0, 32)) != kIOReturnSuccess ) if( (ret = CALL(mQueue, create, 0, 32)) != kIOReturnSuccess )
{ {
PrintIOErr(ret, "Failed to create the queue."); PrintIOErr( ret, "Failed to create the queue." );
CALL(mQueue, Release); CALL( mQueue, Release );
mQueue = NULL; mQueue = NULL;
return false; return false;
} }
@@ -695,17 +696,17 @@ void InputHandler_Carbon::QueueCallBack( void *target, int result, void *refcon,
static void RunLoopStarted( CFRunLoopObserverRef o, CFRunLoopActivity a, void *sem ) static void RunLoopStarted( CFRunLoopObserverRef o, CFRunLoopActivity a, void *sem )
{ {
CFRelease(o); // we don't need this any longer CFRelease( o ); // we don't need this any longer
((RageSemaphore *)sem)->Post(); ((RageSemaphore *)sem)->Post();
} }
int InputHandler_Carbon::Run(void *data) int InputHandler_Carbon::Run( void *data )
{ {
InputHandler_Carbon *This = (InputHandler_Carbon *)data; InputHandler_Carbon *This = (InputHandler_Carbon *)data;
CFRunLoopRef loopRef = CFRunLoopGetCurrent(); CFRunLoopRef loopRef = CFRunLoopGetCurrent();
int n = 0; int n = 0;
CFRetain(loopRef); CFRetain( loopRef );
FOREACH( Device *, This->mDevices, i ) FOREACH( Device *, This->mDevices, i )
(*i)->StartQueue( loopRef, InputHandler_Carbon::QueueCallBack, This, n++ ); (*i)->StartQueue( loopRef, InputHandler_Carbon::QueueCallBack, This, n++ );
This->mLoopRef = loopRef; This->mLoopRef = loopRef;
@@ -770,7 +771,7 @@ static io_iterator_t GetDeviceIterator( mach_port_t mp, int usagePage, int usage
return iter; return iter;
} }
InputHandler_Carbon::InputHandler_Carbon() : mMasterPort(0), mSem("Input thread started") InputHandler_Carbon::InputHandler_Carbon() : mMasterPort( 0 ), mSem( "Input thread started" )
{ {
// Get a Mach port to initiate communication with I/O Kit. // Get a Mach port to initiate communication with I/O Kit.
mach_port_t masterPort; mach_port_t masterPort;
@@ -785,7 +786,7 @@ InputHandler_Carbon::InputHandler_Carbon() : mMasterPort(0), mSem("Input thread
mMasterPort = masterPort; mMasterPort = masterPort;
// Find the joysticks // Find the joysticks
io_iterator_t iter = GetDeviceIterator(masterPort, kHIDPage_GenericDesktop, kHIDUsage_GD_Joystick ); io_iterator_t iter = GetDeviceIterator( masterPort, kHIDPage_GenericDesktop, kHIDUsage_GD_Joystick );
if( iter ) if( iter )
{ {
@@ -833,16 +834,16 @@ InputHandler_Carbon::InputHandler_Carbon() : mMasterPort(0), mSem("Input thread
IOObjectRelease( iter ); IOObjectRelease( iter );
} }
mInputThread.SetName( "InputThread" ); mInputThread.SetName( "Input thread" );
mInputThread.Create(InputHandler_Carbon::Run, this); mInputThread.Create( InputHandler_Carbon::Run, this );
// Wait for the run loop to start before returning. // Wait for the run loop to start before returning.
mSem.Wait(); mSem.Wait();
} }
void InputHandler_Carbon::GetDevicesAndDescriptions( vector<InputDevice>& dev, vector<CString>& desc ) void InputHandler_Carbon::GetDevicesAndDescriptions( vector<InputDevice>& dev, vector<CString>& desc )
{ {
dev.push_back(DEVICE_KEYBOARD); dev.push_back( DEVICE_KEYBOARD );
desc.push_back("Keyboard"); desc.push_back( "Keyboard" );
FOREACH_CONST( Device *, mDevices, i ) FOREACH_CONST( Device *, mDevices, i )
{ {