]> gitweb.factorcode.org Git - factor.git/blobdiff - basis/game/input/xinput/xinput.factor
use radix literals
[factor.git] / basis / game / input / xinput / xinput.factor
index 568deb3750ff669d8c86170c14caa946f193afa7..034c9490856eac081447b71fe47117900a41f106 100644 (file)
@@ -30,7 +30,7 @@ MACRO: map-index-compose ( seq quot -- seq )
       XINPUT_GAMEPAD_B
       XINPUT_GAMEPAD_X
       XINPUT_GAMEPAD_Y }
-      [ [ bitand ] dip swap 0 = [ 2drop ] [ 1.0 -rot swap set-nth ] if ]
+      [ [ bitand ] dip swap 0 = [ 2drop ] [ [ 1.0 ] 2dip swap set-nth ] if ]
       map-index-compose 2cleave ;
 
  : >pov ( byte -- symbol )
@@ -56,14 +56,14 @@ MACRO: map-index-compose ( seq quot -- seq )
 : fill-controller-state ( XINPUT_STATE -- controller-state )
     Gamepad>> controller-state new dup rot
     {
-        [ wButtons>> HEX: f bitand >pov swap (>>pov) ]
-        [ wButtons>> fill-buttons swap (>>buttons) ]
-        [ sThumbLX>> >axis swap (>>x) ]
-        [ sThumbLY>> >axis swap (>>y) ]
-        [ sThumbRX>> >axis swap (>>rx) ]
-        [ sThumbRY>> >axis swap (>>ry) ]
-        [ bLeftTrigger>> >trigger swap (>>z) ]
-        [ bRightTrigger>> >trigger swap (>>rz) ]
+        [ wButtons>> 0xf bitand >pov swap pov<< ]
+        [ wButtons>> fill-buttons swap buttons<< ]
+        [ sThumbLX>> >axis swap x<< ]
+        [ sThumbLY>> >axis swap y<< ]
+        [ sThumbRX>> >axis swap rx<< ]
+        [ sThumbRY>> >axis swap ry<< ]
+        [ bLeftTrigger>> >trigger swap z<< ]
+        [ bRightTrigger>> >trigger swap rz<< ]
     } 2cleave ;
 PRIVATE>
 
@@ -84,13 +84,13 @@ M: xinput-game-input-backend (close-game-input)
     FALSE XInputEnable ;
 
 M: xinput-game-input-backend (reset-game-input)
-    global [
+    [
         {
             +dinput+ +keyboard-device+ +keyboard-state+
             +controller-devices+ +controller-guids+
             +device-change-window+ +device-change-handle+
         } [ off ] each
-    ] bind ;
+    ] with-global ;
 
 M: xinput-game-input-backend get-controllers
     { 0 1 2 3 } ;