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 )
: 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>
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 } ;