-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added Windows gamepad support #579
base: master
Are you sure you want to change the base?
Conversation
Nice. I wasn't aware that glfw doesn't support gamepad vibration |
Have you implemented this for mac and linux already? |
Already adressed in the QNA:
|
Any specific reason for moving the EventCallbackFn? |
I think the OP chose to move it so it was easier to use: |
Correct. It's just so that the input system can also access the EventCallbackFn type. No reason not to move it for clarity. |
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