game-input doesnt need a backend, now loads dinput or iokit directly

db4
Doug Coleman 2008-12-16 01:33:51 -06:00
parent 7597f38a08
commit 7538928754
14 changed files with 18 additions and 41 deletions

View File

@ -1,21 +0,0 @@
USING: eval multiline system combinators ;
IN: game-input.backend
STRING: set-backend-for-macosx
USING: namespaces parser game-input.backend.iokit ;
<< "game-input" (use+) >>
iokit-game-input-backend game-input-backend set-global
;
STRING: set-backend-for-windows
USING: namespaces parser game-input.backend.dinput ;
<< "game-input" (use+) >>
dinput-game-input-backend game-input-backend set-global
;
{
{ [ os macosx? ] [ set-backend-for-macosx eval ] }
{ [ os windows? ] [ set-backend-for-windows eval ] }
{ [ t ] [ ] }
} cond

View File

@ -1 +0,0 @@
Joe Groff

View File

@ -1 +0,0 @@
Platform-specific backends for game-input

View File

@ -1 +0,0 @@
games

View File

@ -1,16 +1,16 @@
USING: windows.dinput windows.dinput.constants parser symbols USING: windows.dinput windows.dinput.constants parser symbols
alien.c-types windows.ole32 namespaces assocs kernel arrays alien.c-types windows.ole32 namespaces assocs kernel arrays
vectors windows.kernel32 windows.com windows.dinput shuffle vectors windows.kernel32 windows.com windows.dinput shuffle
windows.user32 windows.messages sequences combinators windows.user32 windows.messages sequences combinators locals
math.geometry.rect ui.windows accessors math windows alien math.geometry.rect ui.windows accessors math windows alien
alien.strings io.encodings.utf16 io.encodings.utf16n alien.strings io.encodings.utf16 io.encodings.utf16n
continuations byte-arrays locals continuations byte-arrays game-input.dinput.keys-array ;
game-input.backend.dinput.keys-array ; IN: game-input.dinput
<< "game-input" (use+) >>
IN: game-input.backend.dinput
SINGLETON: dinput-game-input-backend SINGLETON: dinput-game-input-backend
dinput-game-input-backend game-input-backend set-global
SYMBOLS: +dinput+ +keyboard-device+ +keyboard-state+ SYMBOLS: +dinput+ +keyboard-device+ +keyboard-state+
+controller-devices+ +controller-guids+ +controller-devices+ +controller-guids+
+device-change-window+ +device-change-handle+ ; +device-change-window+ +device-change-handle+ ;

View File

@ -1,6 +1,6 @@
USING: sequences sequences.private math alien.c-types USING: sequences sequences.private math alien.c-types
accessors ; accessors ;
IN: game-input.backend.dinput.keys-array IN: game-input.dinput.keys-array
TUPLE: keys-array underlying ; TUPLE: keys-array underlying ;
C: <keys-array> keys-array C: <keys-array> keys-array

View File

@ -1,5 +1,6 @@
USING: arrays accessors continuations kernel symbols USING: arrays accessors continuations kernel symbols system
combinators.lib sequences namespaces init vocabs ; combinators.lib sequences namespaces init vocabs vocabs.loader
combinators ;
IN: game-input IN: game-input
SYMBOLS: game-input-backend game-input-opened ; SYMBOLS: game-input-backend game-input-opened ;
@ -19,10 +20,6 @@ M: f (reset-game-input) ;
game-input-opened off game-input-opened off
(reset-game-input) ; (reset-game-input) ;
: load-game-input-backend ( -- )
game-input-backend get
[ "game-input.backend" load-vocab drop ] unless ;
[ reset-game-input ] "game-input" add-init-hook [ reset-game-input ] "game-input" add-init-hook
PRIVATE> PRIVATE>
@ -76,5 +73,8 @@ M: keyboard-state clone
HOOK: read-keyboard game-input-backend ( -- keyboard-state ) HOOK: read-keyboard game-input-backend ( -- keyboard-state )
load-game-input-backend {
{ [ os windows? ] [ "game-input.dinput" require ] }
{ [ os macosx? ] [ "game-input.iokit" require ] }
{ [ t ] [ ] }
} cond

View File

@ -3,12 +3,13 @@ kernel cocoa.enumeration destructors math.parser cocoa.application
sequences locals combinators.short-circuit threads sequences locals combinators.short-circuit threads
symbols namespaces assocs vectors arrays combinators symbols namespaces assocs vectors arrays combinators
core-foundation.run-loop accessors sequences.private core-foundation.run-loop accessors sequences.private
alien.c-types math parser ; alien.c-types math parser game-input ;
<< "game-input" (use+) >> IN: game-input.iokit
IN: game-input.backend.iokit
SINGLETON: iokit-game-input-backend SINGLETON: iokit-game-input-backend
iokit-game-input-backend game-input-backend set-global
: hid-manager-matching ( matching-seq -- alien ) : hid-manager-matching ( matching-seq -- alien )
f 0 IOHIDManagerCreate f 0 IOHIDManagerCreate
[ swap >plist IOHIDManagerSetDeviceMatchingMultiple ] [ swap >plist IOHIDManagerSetDeviceMatchingMultiple ]