Added Windows gamepad support #579
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Gamepad support for Hazel
This pull request contains the basic implementation of a gamepad input system. It only supports regular gamepads, so it isn't possible to connect a guitar hero controller for example.
Why?
Having an interface for gamepad input will be useful if Hazel ever gets ported to console. It's also very important for an engine to support gamepad input, as it is one of the most popular input methods in the industry.
How does it work?
Additional functions have been added to the input class to poll button state, trigger state, joystick state and vibration state.
Some additional enum values have been added to map ABXY buttons to the Dualshock's square, cross, rectangle and triangle button.
The input system handles deadzone values as well.
You may also notice that there is three new functions in the input class: Init, SetEventCallback and Update.
Init is used to initialise input polling libraries (XInput on Windows for example)
SetEventCallback is used so that the input system can send GamepadConnected and GamepadDisconnected events.
Update is used to actually update the state of the gamepads.
Example code
What you might ask
Because GLFW doesn't support gamepad vibration.
No, because gamepad connection and disconnection should be handled as notifications : not just a plain old boolean state
LOL as if Hazel was cross-platform KEKW (on a serious note, when Hazel will be able to build on both Mac and Linux, I'll add
the necessary backends for Apple's GameController framework and Linux joystick file descriptor)
What could be added