From ae5f5553e6329aca915b361b5ccfdf5dc0387f94 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Fri, 15 May 2009 15:26:41 -0500 Subject: [PATCH] move IOHIDManagerSetDeviceMatching call after IOHIDManagerOpen. this prevents IOHIDManagerOpen from failing if it would match an exclusive-opened device --- basis/game-input/iokit/iokit.factor | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/basis/game-input/iokit/iokit.factor b/basis/game-input/iokit/iokit.factor index 32440e92b2..68ecaecc29 100755 --- a/basis/game-input/iokit/iokit.factor +++ b/basis/game-input/iokit/iokit.factor @@ -12,10 +12,11 @@ SYMBOLS: +hid-manager+ +keyboard-state+ +mouse-state+ +controller-states+ ; iokit-game-input-backend game-input-backend set-global -: hid-manager-matching ( matching-seq -- alien ) - f 0 IOHIDManagerCreate - [ swap >plist IOHIDManagerSetDeviceMatchingMultiple ] - keep ; +: make-hid-manager ( -- alien ) + f 0 IOHIDManagerCreate ; + +: set-hid-manager-matching ( alien matching-seq -- ) + >plist IOHIDManagerSetDeviceMatchingMultiple ; : devices-from-hid-manager ( manager -- vector ) [ @@ -85,9 +86,6 @@ CONSTANT: hat-switch-matching-hash : ?hat-switch ( device -- ? ) hat-switch-matching-hash ?axis ; -: hid-manager-matching-game-devices ( -- alien ) - game-devices-matching-seq hid-manager-matching ; - : device-property ( device key -- value ) IOHIDDeviceGetProperty [ plist> ] [ f ] if* ; : element-property ( element key -- value ) @@ -288,12 +286,13 @@ M: iokit-game-input-backend reset-mouse 256 +keyboard-state+ set-global ; M: iokit-game-input-backend (open-game-input) - hid-manager-matching-game-devices { + make-hid-manager { [ initialize-variables ] [ device-matched-callback f IOHIDManagerRegisterDeviceMatchingCallback ] [ device-removed-callback f IOHIDManagerRegisterDeviceRemovalCallback ] [ device-input-callback f IOHIDManagerRegisterInputValueCallback ] [ 0 IOHIDManagerOpen mach-error ] + [ game-devices-matching-seq set-hid-manager-matching ] [ CFRunLoopGetMain CFRunLoopDefaultMode IOHIDManagerScheduleWithRunLoop