[Example] Controller #4
paladin-t
started this conversation in
Libs And Tips
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
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