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

[Merged by Bors] - Improve Gamepad DPad Button Detection #5220

Closed
wants to merge 1 commit into from

Conversation

zicklag
Copy link
Member

@zicklag zicklag commented Jul 5, 2022

Objective

Solution

  • Enables the axis_dpad_to_button filter in gilrs which will use it's remote mapping information to see if there are hats mapped to dpads for that remote model. I don't really understand the logic it uses exactly, but it is usually enabled by default in gilrs and I believe it probably leads to more intuitive mapping compared to the current situation of dpad buttons being mapped to an axis.
  • Removes the GamepadAxisType::DPadX and GamepadAxisType::DPadY enum variants to avoid user confusion. Those variants should never be emitted anyway, for all supported remotes.

Changelog

Changed

  • Removed GamepadAxisType::DPadX and GamepadAxisType::DPadY in favor of using GamepadButtonType::DPad[Up/Down/Left/Right] instead.

Migration Guide

If your game reads gamepad events or queries the axis state of GamePadAxisType::DPadX or GamePadAxisType::DPadY, then you must migrate your code to check whether or not the GamepadButtonType::DPadUp, GamepadButtonType::DPadDown, etc. buttons were pressed instead.

@alice-i-cecile alice-i-cecile added C-Bug An unexpected or incorrect behavior A-Input Player input via keyboard, mouse, gamepad, and more labels Jul 5, 2022
Copy link
Member

@alice-i-cecile alice-i-cecile left a comment

Choose a reason for hiding this comment

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

This is much more reasonable behavior, and I really like the improved consistency.

I think this means we need to remove the DPad axis variants on GamepadAxisType then? It seems like this will cause all dpad presses to be treated as button presses rather than axis events.

This is also good, because then there's exactly one way to handle dpad events.

@zicklag
Copy link
Member Author

zicklag commented Jul 5, 2022

I think this means we need to remove the DPad axis variants on GamepadAxisType then?

That's a really good question. We might still need them there? I'm not positive.

As far as I can tell from the gilrs source code, the filter that does the axis-to-button conversion for the dpad uses its database of controller models to try see if that database says that some axis is in fact a dpad, but if there were a remote that wasn't in that database, or if the remote already has a dpad, then it might report a dpad as an axis instead.

The gilrs docs say:

This filter will do nothing if gamepad has dpad buttons (to prevent double events for same element) and if standard NativeEvCode for dpads is used by some other buttons. It will always try to map if SDL mappings contains mappings for all four hats.

So it sounds like there could still be scenarios where a DPad axis might be reported, and that the event conversion is best-effort.

@alice-i-cecile
Copy link
Member

Hmm. I would personally be in favor of just removing the enum variants proactively and seeing what sort of bug reports we get. Those docs seem like they should be doing basically what we want. If we're still getting problems for users we can try manual deduplication, either in bevy or upstream.

If you / reviewers disagree, please at least leave a warning note on those variants, and point users to the corresponding buttons.

@zicklag
Copy link
Member Author

zicklag commented Jul 5, 2022

OK, I'm good with that. If we get a bug report about the buttons not being detected, I think the solution will be to add a mapping to the controller database here and then update gilrs to use it, and that seems like a reasonable workflow.

I pushed an update.

Copy link
Member

@alice-i-cecile alice-i-cecile left a comment

Choose a reason for hiding this comment

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

Changes LGTM now :) Make sure to remember to update your PR description!

@alice-i-cecile alice-i-cecile added the M-Needs-Migration-Guide A breaking change to Bevy's public API that needs to be noted in a migration guide label Jul 5, 2022
Enable the `axis_dpad_to_button` gilrs filter to map hats to dpad
buttons on supported remotes.
@alice-i-cecile
Copy link
Member

@Shatur I'd like to hear your opinion on this.

Copy link
Contributor

@Shatur Shatur left a comment

Choose a reason for hiding this comment

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

I think that the change is make sense.

Looks like Godot doesn't have DPadX or DPadY either: https://docs.godotengine.org/ru/stable/classes/class_%40globalscope.html#enum-globalscope-joysticklist

@alice-i-cecile alice-i-cecile added the S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it label Jul 6, 2022
@odecay
Copy link

odecay commented Jul 7, 2022

I don't have experience with gilrs but I personally find using Dpad buttons as independent direction inputs as opposed to mapping them as axes highly preferable. 👍

@alice-i-cecile
Copy link
Member

bors r+

bors bot pushed a commit that referenced this pull request Jul 11, 2022
# Objective

- Enable the `axis_dpad_to_button` gilrs filter to map hats to dpad buttons on supported remotes.
- Fixes Leafwing-Studios/leafwing-input-manager#149
- Might have fixed the confusion related to #3229

## Solution

- Enables the `axis_dpad_to_button` filter in `gilrs` which will use it's remote mapping information to see if there are hats mapped to dpads for that remote model. I don't really understand the logic it uses exactly, but it is usually enabled by default in gilrs and I believe it probably leads to more intuitive mapping compared to the current situation of dpad buttons being mapped to an axis.
- Removes the `GamepadAxisType::DPadX` and `GamepadAxisType::DPadY` enum variants to avoid user confusion. Those variants should never be emitted anyway, for all supported remotes.

---

## Changelog

### Changed

- Removed `GamepadAxisType::DPadX` and `GamepadAxisType::DPadY` in favor of using `GamepadButtonType::DPad[Up/Down/Left/Right]` instead.

## Migration Guide

If your game reads gamepad events or queries the axis state of `GamePadAxisType::DPadX` or `GamePadAxisType::DPadY`, then you must migrate your code to check whether or not the `GamepadButtonType::DPadUp`, `GamepadButtonType::DPadDown`, etc. buttons were pressed instead.
@bors bors bot changed the title Improve Gamepad DPad Button Detection [Merged by Bors] - Improve Gamepad DPad Button Detection Jul 11, 2022
@bors bors bot closed this Jul 11, 2022
inodentry pushed a commit to IyesGames/bevy that referenced this pull request Aug 8, 2022
# Objective

- Enable the `axis_dpad_to_button` gilrs filter to map hats to dpad buttons on supported remotes.
- Fixes Leafwing-Studios/leafwing-input-manager#149
- Might have fixed the confusion related to bevyengine#3229

## Solution

- Enables the `axis_dpad_to_button` filter in `gilrs` which will use it's remote mapping information to see if there are hats mapped to dpads for that remote model. I don't really understand the logic it uses exactly, but it is usually enabled by default in gilrs and I believe it probably leads to more intuitive mapping compared to the current situation of dpad buttons being mapped to an axis.
- Removes the `GamepadAxisType::DPadX` and `GamepadAxisType::DPadY` enum variants to avoid user confusion. Those variants should never be emitted anyway, for all supported remotes.

---

## Changelog

### Changed

- Removed `GamepadAxisType::DPadX` and `GamepadAxisType::DPadY` in favor of using `GamepadButtonType::DPad[Up/Down/Left/Right]` instead.

## Migration Guide

If your game reads gamepad events or queries the axis state of `GamePadAxisType::DPadX` or `GamePadAxisType::DPadY`, then you must migrate your code to check whether or not the `GamepadButtonType::DPadUp`, `GamepadButtonType::DPadDown`, etc. buttons were pressed instead.
james7132 pushed a commit to james7132/bevy that referenced this pull request Oct 28, 2022
# Objective

- Enable the `axis_dpad_to_button` gilrs filter to map hats to dpad buttons on supported remotes.
- Fixes Leafwing-Studios/leafwing-input-manager#149
- Might have fixed the confusion related to bevyengine#3229

## Solution

- Enables the `axis_dpad_to_button` filter in `gilrs` which will use it's remote mapping information to see if there are hats mapped to dpads for that remote model. I don't really understand the logic it uses exactly, but it is usually enabled by default in gilrs and I believe it probably leads to more intuitive mapping compared to the current situation of dpad buttons being mapped to an axis.
- Removes the `GamepadAxisType::DPadX` and `GamepadAxisType::DPadY` enum variants to avoid user confusion. Those variants should never be emitted anyway, for all supported remotes.

---

## Changelog

### Changed

- Removed `GamepadAxisType::DPadX` and `GamepadAxisType::DPadY` in favor of using `GamepadButtonType::DPad[Up/Down/Left/Right]` instead.

## Migration Guide

If your game reads gamepad events or queries the axis state of `GamePadAxisType::DPadX` or `GamePadAxisType::DPadY`, then you must migrate your code to check whether or not the `GamepadButtonType::DPadUp`, `GamepadButtonType::DPadDown`, etc. buttons were pressed instead.
ItsDoot pushed a commit to ItsDoot/bevy that referenced this pull request Feb 1, 2023
# Objective

- Enable the `axis_dpad_to_button` gilrs filter to map hats to dpad buttons on supported remotes.
- Fixes Leafwing-Studios/leafwing-input-manager#149
- Might have fixed the confusion related to bevyengine#3229

## Solution

- Enables the `axis_dpad_to_button` filter in `gilrs` which will use it's remote mapping information to see if there are hats mapped to dpads for that remote model. I don't really understand the logic it uses exactly, but it is usually enabled by default in gilrs and I believe it probably leads to more intuitive mapping compared to the current situation of dpad buttons being mapped to an axis.
- Removes the `GamepadAxisType::DPadX` and `GamepadAxisType::DPadY` enum variants to avoid user confusion. Those variants should never be emitted anyway, for all supported remotes.

---

## Changelog

### Changed

- Removed `GamepadAxisType::DPadX` and `GamepadAxisType::DPadY` in favor of using `GamepadButtonType::DPad[Up/Down/Left/Right]` instead.

## Migration Guide

If your game reads gamepad events or queries the axis state of `GamePadAxisType::DPadX` or `GamePadAxisType::DPadY`, then you must migrate your code to check whether or not the `GamepadButtonType::DPadUp`, `GamepadButtonType::DPadDown`, etc. buttons were pressed instead.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Input Player input via keyboard, mouse, gamepad, and more C-Bug An unexpected or incorrect behavior M-Needs-Migration-Guide A breaking change to Bevy's public API that needs to be noted in a migration guide S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DPad Buttons Presses Not Detected
4 participants