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
Improve gamepad support #17
Merged
openclonk-mirror
merged 17 commits into
openclonk:master
from
lluchs:sdl-gamecontroller
Mar 21, 2016
Merged
Improve gamepad support #17
openclonk-mirror
merged 17 commits into
openclonk:master
from
lluchs:sdl-gamecontroller
Mar 21, 2016
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
With the SDL_GameController interface, buttons and axes have actual names we can refer to. This also allows for advanced mappings using both sticks (this probably needs script changes) as well as the triggers.
Analog moved events are only sent once per control frame.
SDL usage is masked with HAVE_SDL checks so it should work without SDL, but SDL has to be linked when it's available.
To keep compatibility with scripts which expect only binary buttons, this adds a third parameter to the function which enables the new functionality. Bonus /script to test the controller stick x axis: Schedule(GetCursor(), "Message(\"%d / %d\", GetPlayerControlState(0, CON_Left, true), GetPlayerControlState(0, CON_Right, true))", 10, 100000000) Note that the values will be inconsistent if multiple analog sticks are bound to the same control, as values from one stick will overwrite those from the other one. This can happen even if you move only one stick.
It is now possible to control all GUI menus using the left stick or the dpad, along with the A and B buttons on the controller. This also doubles the button emulation dead zone to make navigating the menus with the stick easier.
This also removes the controller id from the control definitions, instead defaulting to 0. This doesn't change anything for now as we only had definitions for controller 0 anyways.
- GamePadControl::AnyButtonDown - GamePadOpener::SetGamePad
New script functions: - PlayRumble(int plr, int strength, int length) - StopRumble(int plr)
The icons currently only show Xbox 360 controller labeling. The icon set also includes icons for PlayStation controllers, so we could extend this in the future.
We want one gamepad key mapping to work with multiple gamepads, so including the id there doesn't make sense. Additionally, the gamepad id may change during the game (controller hot-plugging).
The available gamepads are distributed automatically among players. This also implements controller hot-plugging: It is possible to start a game without a controller and plug it in later, and to reconnect a controller after plugging it out.
lluchs
force-pushed
the
sdl-gamecontroller
branch
from
February 23, 2016 16:08
876c31f
to
8811356
Compare
This affected all platforms other than SDL.
@ckanibal made building on Windows work now, so this is ready for merging now. |
openclonk-mirror
pushed a commit
that referenced
this pull request
Mar 21, 2016
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
See the corresponding topic in the forums.
I don't have Windows, so somebody should probably try to compile this there before merging.