eek! a mouse! (or the start of one on Mac?)

This commit is contained in:
AJ Kelly
2011-02-23 18:19:54 -06:00
parent b8d79c1904
commit 070cccb307
@@ -6,6 +6,7 @@
#include "InputFilter.h" #include "InputFilter.h"
#include "archutils/Darwin/DarwinThreadHelpers.h" #include "archutils/Darwin/DarwinThreadHelpers.h"
#include "archutils/Darwin/KeyboardDevice.h" #include "archutils/Darwin/KeyboardDevice.h"
//#include "archutils/Darwin/MouseDevice.h"
#include "archutils/Darwin/JoystickDevice.h" #include "archutils/Darwin/JoystickDevice.h"
#include "archutils/Darwin/PumpDevice.h" #include "archutils/Darwin/PumpDevice.h"
@@ -63,8 +64,8 @@ int InputHandler_MacOSX_HID::Run( void *data )
} }
// Add an observer for the start of the run loop // Add an observer for the start of the run loop
{ {
/* The function copies the information out of the structure, so the memory pointed /* The function copies the information out of the structure, so the memory
* to by context does not need to persist beyond the function call. */ * pointed to by context does not need to persist beyond the function call. */
CFRunLoopObserverContext context = { 0, &This->m_Sem, NULL, NULL, NULL }; CFRunLoopObserverContext context = { 0, &This->m_Sem, NULL, NULL, NULL };
CFRunLoopObserverRef o = CFRunLoopObserverCreate( kCFAllocatorDefault, kCFRunLoopEntry, CFRunLoopObserverRef o = CFRunLoopObserverCreate( kCFAllocatorDefault, kCFRunLoopEntry,
false, 0, RunLoopStarted, &context); false, 0, RunLoopStarted, &context);
@@ -72,11 +73,13 @@ int InputHandler_MacOSX_HID::Run( void *data )
} }
/* Add a source for ending the run loop. This serves two purposes: /* Add a source for ending the run loop. This serves two purposes:
* 1. it provides a way to terminate the run loop when IH_MacOSX_HID exists, and * 1. it provides a way to terminate the run loop when IH_MacOSX_HID exists,
* 2. it ensures that CFRunLoopRun() doesn't return immediately if there are no other sources. */ * and 2. it ensures that CFRunLoopRun() doesn't return immediately if
* there are no other sources. */
{ {
/* Being a little tricky here, the perform callback takes a void* and returns nothing. /* Being a little tricky here, the perform callback takes a void* and
* CFRunLoopStop takes a CFRunLoopRef (a pointer) so cast the function and pass the loop ref. */ * returns nothing. CFRunLoopStop takes a CFRunLoopRef (a pointer) so
* cast the function and pass the loop ref. */
void *info = This->m_LoopRef; void *info = This->m_LoopRef;
void (*perform)(void *) = (void (*)(void *))CFRunLoopStop; void (*perform)(void *) = (void (*)(void *))CFRunLoopStop;
// { version, info, retain, release, copyDescription, equal, hash, schedule, cancel, perform } // { version, info, retain, release, copyDescription, equal, hash, schedule, cancel, perform }
@@ -170,6 +173,10 @@ static HIDDevice *MakeDevice( InputDevice id )
{ {
if( id == DEVICE_KEYBOARD ) if( id == DEVICE_KEYBOARD )
return new KeyboardDevice; return new KeyboardDevice;
/*
if( id == DEVICE_MOUSE )
return new MouseDevice;
*/
if( IsJoystick(id) ) if( IsJoystick(id) )
return new JoystickDevice; return new JoystickDevice;
if( IsPump(id) ) if( IsPump(id) )
@@ -216,8 +223,11 @@ void InputHandler_MacOSX_HID::AddDevices( int usagePage, int usage, InputDevice
enum_add( id, num ); enum_add( id, num );
m_vDevices.push_back( dev ); m_vDevices.push_back( dev );
ret = IOServiceAddInterestNotification( m_NotifyPort, device, kIOGeneralInterest, ret = IOServiceAddInterestNotification(
InputHandler_MacOSX_HID::DeviceChanged, this, &i ); m_NotifyPort, device, kIOGeneralInterest,
InputHandler_MacOSX_HID::DeviceChanged,
this, &i
);
if( ret == KERN_SUCCESS ) if( ret == KERN_SUCCESS )
m_vIters.push_back( i ); m_vIters.push_back( i );
@@ -237,6 +247,10 @@ InputHandler_MacOSX_HID::InputHandler_MacOSX_HID() : m_Sem( "Input thread starte
// Add devices. // Add devices.
LOG->Trace( "Finding keyboards" ); LOG->Trace( "Finding keyboards" );
AddDevices( kHIDPage_GenericDesktop, kHIDUsage_GD_Keyboard, id ); AddDevices( kHIDPage_GenericDesktop, kHIDUsage_GD_Keyboard, id );
/*
LOG->Trace( "Finding mice" );
AddDevices( kHIDPage_GenericDesktop, kHIDUsage_GD_Mouse, id );
*/
LOG->Trace( "Finding joysticks" ); LOG->Trace( "Finding joysticks" );
id = DEVICE_JOY1; id = DEVICE_JOY1;
AddDevices( kHIDPage_GenericDesktop, kHIDUsage_GD_Joystick, id ); AddDevices( kHIDPage_GenericDesktop, kHIDUsage_GD_Joystick, id );
@@ -457,7 +471,6 @@ wchar_t InputHandler_MacOSX_HID::DeviceButtonToChar( DeviceButton button, bool b
return InputHandler::DeviceButtonToChar( button, bUseCurrentKeyModifiers ); return InputHandler::DeviceButtonToChar( button, bUseCurrentKeyModifiers );
} }
/* /*
* (c) 2005, 2006 Steve Checkoway * (c) 2005, 2006 Steve Checkoway
* All rights reserved. * All rights reserved.