diff --git a/stepmania/src/arch/InputHandler/InputHandler_Carbon.cpp b/stepmania/src/arch/InputHandler/InputHandler_Carbon.cpp index 0db9e26d49..9ed353248e 100644 --- a/stepmania/src/arch/InputHandler/InputHandler_Carbon.cpp +++ b/stepmania/src/arch/InputHandler/InputHandler_Carbon.cpp @@ -464,36 +464,6 @@ void InputHandler_Carbon::QueueCallBack( void *target, int result, void *refcon, } } -OSStatus InputHandler_Carbon::EventHandler( EventHandlerCallRef callRef, EventRef event, void *data ) -{ - InputHandler_Carbon *This = (InputHandler_Carbon *)data; - UInt32 kind = GetEventKind(event); - UInt32 keyCode; - char charCode; - - GetEventParameter( event, kEventParamKeyCode, typeUInt32, NULL, sizeof(keyCode), NULL, &keyCode ); - GetEventParameter( event, kEventParamKeyMacCharCodes, typeChar, NULL, sizeof(charCode), NULL, &charCode ); - - const char *type; - - switch( kind ) - { - case kEventRawKeyDown: - type = "down"; - break; - case kEventRawKeyRepeat: - type = "repeat"; - break; - case kEventRawKeyUp: - type = "up"; - default: - type = "unknown"; - } - - LOG->Trace( "(0) %u %c: %s\n", unsigned(keyCode), charCode, type ); - return 0; -} - static void RunLoopStarted( CFRunLoopObserverRef o, CFRunLoopActivity a, void *sem ) { CFRelease(o); // we don't need this any longer @@ -530,23 +500,10 @@ InputHandler_Carbon::~InputHandler_Carbon() delete *i; if( mMasterPort ) mach_port_deallocate( mach_task_self(), mMasterPort ); - RemoveEventHandler( mEventHandlerRef ); - DisposeEventHandlerUPP( mEventHandlerUPP ); } InputHandler_Carbon::InputHandler_Carbon() : mSem("Input thread started") { - // Install a Carbon Event handler - mEventHandlerUPP = NewEventHandlerUPP( EventHandler ); - EventTypeSpec typeList[] = { - { kEventClassKeyboard, kEventRawKeyDown }, - { kEventClassKeyboard, kEventRawKeyRepeat }, - { kEventClassKeyboard, kEventRawKeyUp } }; - - - if( InstallEventHandler(GetApplicationEventTarget(), mEventHandlerUPP, 3, typeList, this, &mEventHandlerRef) ) - LOG->Warn("Failed to install the Event Handler."); - // Get a Mach port to initiate communication with I/O Kit. mach_port_t masterPort; diff --git a/stepmania/src/arch/InputHandler/InputHandler_Carbon.h b/stepmania/src/arch/InputHandler/InputHandler_Carbon.h index 61e2206157..546436fa49 100644 --- a/stepmania/src/arch/InputHandler/InputHandler_Carbon.h +++ b/stepmania/src/arch/InputHandler/InputHandler_Carbon.h @@ -3,15 +3,7 @@ #include #include "InputHandler.h" - -// Avoid pulling the header in here -typedef struct OpaqueEventHandlerCallRef *EventHandlerCallRef; -typedef struct OpaqueEventRef *EventRef; -typedef struct OpaqueEventHandlerRef *EventHandlerRef; -typedef struct OpaqueEventTargetRef *EventTargetRef; -typedef long int OSStatus; -typedef OSStatus (*EventHandlerProcPtr) ( EventHandlerCallRef, EventRef, void * ); -typedef EventHandlerProcPtr EventHandlerUPP; +#include "RageThreads.h" class JoystickDevice; @@ -20,8 +12,11 @@ class InputHandler_Carbon : public InputHandler private: int mMasterPort; std::vector mDevices; - EventHandlerUPP mEventHandlerUPP; - EventHandlerRef mEventHandlerRef; + RageThread mInputThread; + RageSemaphore mSem; + void *mLoopRef; + + static int Run(void *data); public: InputHandler_Carbon(); @@ -31,7 +26,6 @@ public: vector& vDescriptionsOut ); static void QueueCallBack( void *target, int result, void *refcon, void *sender ); - static OSStatus EventHandler( EventHandlerCallRef callRef, EventRef event, void *data ); }; #define USE_INPUT_HANDLER_CARBON