Skip to content
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

Add a page about gamepad/controller support in Godot #4620

Merged
merged 1 commit into from
Feb 13, 2021

Conversation

Calinou
Copy link
Member

@Calinou Calinou commented Feb 3, 2021

This is a first pass at documenting controller support in Godot. Feel free to suggest additional things to document.

@aaronfranke I know that you worked on getting input actions on multiple directions for 3.2.4, and I remember this being useful to implement proper deadzone calculations for 2D top-down movement. Could you explain this a little? I don't really know how to document it, but it would be good to have the documentation page explain how to handle dead zones properly in this situation.

@aaronfranke
Copy link
Member

This article is missing information about the most important part: What code should people use? It only mentions that the code paths are the same between keyboard input and controller input, but not what those code paths are.

  • For joysticks and WASD etc when you have two axes, want both axes to behave as one input, and for input to be in the form of a Vector2 such as for movement or looking, starting with Godot 4.0, Input.get_vector should be used.

  • For other types of axis input, such as if you want to handle joystick axes individually, or you have a device where an axis is by itself (such as the throttle on a flight stick), starting with Godot 4.0, Input.get_axis should be used.

  • For other types of analog input, such as if you are handling a trigger, or only care about one direction on a joystick, or want to handle one direction at a time, starting with Godot 3.1, Input.get_action_strength should be used.

  • For binary input, if you only want a true or false value, or if the input is inherently binary such as mouse buttons, controller face buttons/start/select/joystick clicks/bumpers, and keyboard keys (except for keys handled as vectors/axes), in pretty much any Godot version, Input.is_action_pressed should be used.

@aaronfranke aaronfranke force-pushed the add-gamepad-page branch 3 times, most recently from 65ababd to 04514d9 Compare February 8, 2021 05:41
Copy link
Member

@aaronfranke aaronfranke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me now. I made a few fixes and tweaks and added C# example code, let me know what you think @Calinou.

by opening a pull request on the linked repository.

There are many ways to create mappings. One option is to use the mapping wizard
in the `official Joypads demo <https://godotengine.org/asset-library/asset/140>`__.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: This is technically not true just yet, but godotengine/godot-demo-projects#575 was merged, so this sentence will be true the next time I make a release of the demos on the Godot Asset Library.

@Calinou
Copy link
Member Author

Calinou commented Feb 8, 2021

@aaronfranke Changes look good to me 🙂

@Calinou Calinou merged commit 53c1af7 into godotengine:master Feb 13, 2021
@Calinou Calinou deleted the add-gamepad-page branch February 13, 2021 01:11
var velocity = Input.get_vector("move_left", "move_right", "move_forward", "move_back")

# The line above is a shorter form of:
var velocity = Vector2(Input.get_action_strength("move_right") - Input.get_action_strength("move_left"),
Copy link
Member

@groud groud Feb 14, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is false in fact. One of the advantages of the using get_vector over this is the handling of the deadzone.
With this solution the deazone end up square instead of circular.

I'm ok with mentionning that they are similar but it's false to say they are equivalent.

Copy link
Member Author

@Calinou Calinou Feb 14, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR opened: #4651

@akien-mga
Copy link
Member

Cherry-picked for 3.3.

akien-mga pushed a commit that referenced this pull request Jun 2, 2021
akien-mga pushed a commit that referenced this pull request Jun 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants