You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Background: the gamepad API supports virtual gamepads (could be binded to actual hardware) with 6 buttons for each player (Left/Right/Up/Down, A/B).
What's new in this post: furthermore the btn(...) and btnp(...) functions also support retrieving from connected game controllers directly, with full buttons and axes support.
Pass negative index to the two functions to retrieve from a controller hardware. Eg.
btn(Controller.A, -1): gets whether the A button of the 1st connected controller is being pressed
btnp(Controller.B, -1): gets whether the B button of the 1st connected controller is released from pressing
btn(Controller.A, -2): gets whether the A button of the 2nd connected controller is being pressed
btn(Controller.AxisLeftX, -2): gets the offset value of the Left X-axis of the 2nd connected controller
This feature is not yet documented, because I suppose the API could be more intuitive and improved but I haven't decided how to. So if you'd like to take an early try, consider importing and using the following wrapper instead.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Background: the gamepad API supports virtual gamepads (could be binded to actual hardware) with 6 buttons for each player (Left/Right/Up/Down, A/B).
What's new in this post: furthermore the
btn(...)
andbtnp(...)
functions also support retrieving from connected game controllers directly, with full buttons and axes support.The key/axis constants are:
Pass negative index to the two functions to retrieve from a controller hardware. Eg.
btn(Controller.A, -1)
: gets whether the A button of the 1st connected controller is being pressedbtnp(Controller.B, -1)
: gets whether the B button of the 1st connected controller is released from pressingbtn(Controller.A, -2)
: gets whether the A button of the 2nd connected controller is being pressedbtn(Controller.AxisLeftX, -2)
: gets the offset value of the Left X-axis of the 2nd connected controllerThis feature is not yet documented, because I suppose the API could be more intuitive and improved but I haven't decided how to. So if you'd like to take an early try, consider importing and using the following wrapper instead.
example controller.zip
Wrapper usage:
Beta Was this translation helpful? Give feedback.
All reactions