move IOHIDManagerSetDeviceMatching call after IOHIDManagerOpen. this prevents IOHIDManagerOpen from failing if it would match an exclusive-opened device

db4
Joe Groff 2009-05-15 15:26:41 -05:00
parent 5a1452b72c
commit ae5f5553e6
1 changed files with 7 additions and 8 deletions

View File

@ -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 )
<NSString> IOHIDDeviceGetProperty [ plist> ] [ f ] if* ;
: element-property ( element key -- value )
@ -288,12 +286,13 @@ M: iokit-game-input-backend reset-mouse
256 <bit-array> +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