]> gitweb.factorcode.org Git - factor.git/blobdiff - basis/game/input/dinput/dinput.factor
factor: trim using lists
[factor.git] / basis / game / input / dinput / dinput.factor
old mode 100755 (executable)
new mode 100644 (file)
index ff8e475..a600e6c
@@ -1,13 +1,11 @@
 USING: accessors alien alien.c-types alien.data alien.strings
-arrays assocs byte-arrays combinators combinators.short-circuit
-continuations game.input game.input.dinput.keys-array
-io.encodings.utf16n kernel locals math
-math.bitwise math.rectangles namespaces parser sequences shuffle
-specialized-arrays ui.backend.windows vectors windows.com
-windows.directx.dinput windows.directx.dinput.constants
-windows.kernel32 windows.messages windows.ole32 windows.errors
-windows.user32 classes.struct ;
-FROM: namespaces => change-global ;
+arrays assocs byte-arrays classes.struct combinators
+combinators.short-circuit game.input
+game.input.dinput.keys-array kernel math math.bitwise
+math.rectangles namespaces sequences specialized-arrays
+ui.backend.windows vectors windows.com windows.directx.dinput
+windows.directx.dinput.constants windows.errors windows.kernel32
+windows.messages windows.ole32 windows.user32 ;
 SPECIALIZED-ARRAY: DIDEVICEOBJECTDATA
 IN: game.input.dinput
 
@@ -42,7 +40,7 @@ SYMBOLS: +dinput+ +keyboard-device+ +keyboard-state+
     get-global IDirectInputDevice8W::SetDataFormat check-ole32-error ; inline
 
 : <buffer-size-diprop> ( size -- DIPROPDWORD )
-    DIPROPDWORD <struct> [
+    DIPROPDWORD new [
         diph>>
         DIPROPDWORD heap-size  >>dwSize
         DIPROPHEADER heap-size >>dwHeaderSize
@@ -78,11 +76,11 @@ SYMBOLS: +dinput+ +keyboard-device+ +keyboard-state+
     MOUSE-BUFFER-SIZE DIDEVICEOBJECTDATA <c-array> +mouse-buffer+ set-global ;
 
 : device-info ( device -- DIDEVICEIMAGEINFOW )
-    DIDEVICEINSTANCEW <struct>
+    DIDEVICEINSTANCEW new
         DIDEVICEINSTANCEW heap-size >>dwSize
     [ IDirectInputDevice8W::GetDeviceInfo check-ole32-error ] keep ; inline
 : device-caps ( device -- DIDEVCAPS )
-    DIDEVCAPS <struct>
+    DIDEVCAPS new
         DIDEVCAPS heap-size >>dwSize
     [ IDirectInputDevice8W::GetCapabilities check-ole32-error ] keep ; inline
 
@@ -159,7 +157,7 @@ SYMBOLS: +dinput+ +keyboard-device+ +keyboard-state+
 
 : find-and-remove-detached-devices ( -- )
     +controller-devices+ get-global keys
-    [ device-attached? not ] filter
+    [ device-attached? ] reject
     [ remove-controller ] each ;
 
 : ?device-interface ( dbt-broadcast-hdr -- ? )
@@ -177,7 +175,7 @@ SYMBOLS: +dinput+ +keyboard-device+ +keyboard-state+
     <alien> DEV_BROADCAST_HDR memory>struct ;
 
 : handle-wm-devicechange ( hWnd uMsg wParam lParam -- )
-    [ 2drop ] 2dip swap {
+    2nipd swap {
         { [ dup DBT_DEVICEARRIVAL = ]         [ drop <DEV_BROADCAST_HDR> device-arrived ] }
         { [ dup DBT_DEVICEREMOVECOMPLETE = ]  [ drop <DEV_BROADCAST_HDR> device-removed ] }
         [ 2drop ]
@@ -191,7 +189,7 @@ TUPLE: window-rect < rect window-loc ;
     { 0 0 } >>dim ;
 
 : (device-notification-filter) ( -- DEV_BROADCAST_DEVICEW )
-    DEV_BROADCAST_DEVICEW <struct>
+    DEV_BROADCAST_DEVICEW new
         DEV_BROADCAST_DEVICEW heap-size >>dbcc_size
         DBT_DEVTYP_DEVICEINTERFACE >>dbcc_devicetype ;
 
@@ -316,7 +314,7 @@ CONSTANT: pov-values
     } case ;
 
 : fill-mouse-state ( buffer count -- state )
-    iota [ +mouse-state+ get-global ] 2dip swap [ nth (fill-mouse-state) ] curry each ;
+    <iota> [ +mouse-state+ get-global ] 2dip swap [ nth (fill-mouse-state) ] curry each ;
 
 : get-device-state ( device DIJOYSTATE2 -- )
     [ dup IDirectInputDevice8W::Poll check-ole32-error ] dip
@@ -324,7 +322,7 @@ CONSTANT: pov-values
     IDirectInputDevice8W::GetDeviceState check-ole32-error ;
 
 : (read-controller) ( handle template -- state )
-    swap [ DIJOYSTATE2 <struct> [ get-device-state ] keep ]
+    swap [ DIJOYSTATE2 new [ get-device-state ] keep ]
     [ fill-controller-state ] [ drop f ] with-acquisition ;
 
 M: dinput-game-input-backend read-controller