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

Direction pad buttons not working #3229

Closed
ghost opened this issue Dec 1, 2021 · 9 comments
Closed

Direction pad buttons not working #3229

ghost opened this issue Dec 1, 2021 · 9 comments
Labels
A-Input Player input via keyboard, mouse, gamepad, and more C-Bug An unexpected or incorrect behavior S-Needs-Investigation This issue requires detective work to figure out what's going wrong

Comments

@ghost
Copy link

ghost commented Dec 1, 2021

Bevy version

bab4ee962d88a5576d7f045d22129e8d20645f14

Operating system & version

Host: Arch Linux
Guest Debian 10 (rust:buster docker image)

What you did

Here is a (sort of)-minimal repro:

struct Buttons {
  jump: GamepadButtonType,
  shoot: GamepadButtonType,
  up: GamepadButtonType,
  down: GamepadButtonType,
  left: GamepadButtonType,
  right: GamepadButtonType,
}

impl Default for Buttons {
  fn default() -> Self {
    Self {
      jump: GamepadButtonType::South,
      shoot: GamepadButtonType::West,
      up: GamepadButtonType::DPadUp,
      down: GamepadButtonType::DPadDown,
      left: GamepadButtonType::DPadLeft,
      right: GamepadButtonType::DPadRight,
    }
  }
}

fn input_system(
  button_inputs: Res<Input<GamepadButton>>,
  buttons: Res<Buttons>
) {
  let just_pressed = |button_type| {
    button_inputs.just_pressed(GamepadButton(Gamepad(0), button_type))
  };

  if just_pressed(buttons.jump) {
    println!("jump");
  }

  if just_pressed(buttons.shoot) {
    println!("shoot");
  }

  if just_pressed(buttons.up) {
    println!("up");
  } else if just_pressed(buttons.down) {
    println!("down");
  }

  if just_pressed(buttons.left) {
    println!("left");
  } else if just_pressed(buttons.right) {
    println!("right");
  }
}

With this code in place, I can press A/X on my gamepad and see jump/shoot print to the console, respectively. However, I see nothing print when pressing any of the directional buttons.

What you expected to happen

When I press a button, the corresponding println! should execute.

What actually happened

Nothing happens.

Additional information

The controller in question is rock solid, and works on any steam games and/or emulators.

@ghost ghost added C-Bug An unexpected or incorrect behavior S-Needs-Triage This issue needs to be labelled labels Dec 1, 2021
@ghost
Copy link
Author

ghost commented Dec 1, 2021

Okay. I've just noticed that there is a GamepadAxisType::{DPadX, DPadY}, and these seem to work. I'm genuinely curious why GamepadButtonType::{DPadLeft, DPadRight, DPadUp, DPadDown} exist if they are also (only?) available on the GamepadAxisType enum?

This seems counter-intuitive to me. Most APIs treat the directional pad buttons as at least buttons, a few supporting an analog API (axis here) in addition to this.

Is this intended behavior, or a bug? If intended then API documentation would help, and removing the buttons from the GamepadButtonType would be great.

@alice-i-cecile
Copy link
Member

alice-i-cecile commented Dec 1, 2021

Okay. I've just noticed that there is a GamepadAxisType::{DPadX, DPadY}, and these seem to work. I'm genuinely curious why GamepadButtonType::{DPadLeft, DPadRight, DPadUp, DPadDown} exist if they are also (only?) available on the GamepadAxisType enum?

The difference is that the buttons return a binary output, while the axes will return a float showing intensity :)

The DPad buttons are working for me on Windows 10 with an XBox controller: which gamepad are you using?

Could you test the gamepad on a different tool to verify that it's our (or more likely, gilrs's) issue? Perhaps https://gamepad-tester.com/ ? I would also test our upstream examples: https://github.com/Arvamer/gilrs/tree/master/gilrs/examples

@ghost
Copy link
Author

ghost commented Dec 2, 2021

Okay. I've just noticed that there is a GamepadAxisType::{DPadX, DPadY}, and these seem to work. I'm genuinely curious why GamepadButtonType::{DPadLeft, DPadRight, DPadUp, DPadDown} exist if they are also (only?) available on the GamepadAxisType enum?

The difference is that the buttons return a binary output, while the axes will return a float showing intensity :)

But digital pads are .. digital 😅

The DPad buttons are working for me on Windows 10 with an XBox controller: which gamepad are you using?

XBOX One S Wireless

Could you test the gamepad on a different tool to verify that it's our (or more likely, gilrs's) issue? Perhaps https://gamepad-tester.com/ ? I would also test our upstream examples: https://github.com/Arvamer/gilrs/tree/master/gilrs/examples

Tried gamepad tester and everything was nice and flickery there. I can try gilrs examples maybe this weekend.

@alice-i-cecile alice-i-cecile added A-Input Player input via keyboard, mouse, gamepad, and more S-Needs-Investigation This issue requires detective work to figure out what's going wrong and removed S-Needs-Triage This issue needs to be labelled labels Dec 2, 2021
@bjorn3
Copy link
Contributor

bjorn3 commented Dec 2, 2021

Tried gamepad tester and everything was nice and flickery there.

How does it report the d-pad? Can you show a screenshot while pressing one or more of the d-pad buttons?

@ghost
Copy link
Author

ghost commented Dec 3, 2021

Tried gamepad tester and everything was nice and flickery there.

How does it report the d-pad? Can you show a screenshot while pressing one or more of the d-pad buttons?

Hopefully this table will suffice, as it'll cover all of the buttons.

Button Axis 6 Axis 7
- 0 0
Up 0 -1
Down 0 1
Left -1 0
Right 1 0

For an "at rest" reference, here's an image from the gamepad tester:

image

It might also be worth mentioning that this particular setup is using the standard USB kernel module not the custom bluetooth ones like xpadneo. I have the controller plugged in directly via USB cable.

@bjorn3
Copy link
Contributor

bjorn3 commented Dec 3, 2021

It reports the d-pad as two axis and not as four d-pad buttons. This matches how bevy responds.

@ghost
Copy link
Author

ghost commented Dec 4, 2021

It reports the d-pad as two axis and not as four d-pad buttons. This matches how bevy responds.

Noted. I wonder why this controller behaves differently than the one that @alice-i-cecile has.. Also this will prevent me from having simple just_pressed checks for digital pad :(

I guess it's a known issue though. I'm okay with closing this as it doesn't appear to be a problem with bevy and/or gilrs. Hopefully anyone googling for this in the future stumbles on this issue.

@ghost
Copy link
Author

ghost commented Dec 4, 2021

Since I just found this, I'm going to add it here.

Recognized devices always have digital pad mapped as axes on Linux if using the xpad module, which is the default configuration. This can be confirmed by running systool -vm xpad.

To reiterate, even if you set the parameter the module outright ignores it for recognized devices. This is my configuration and I still have digital pad as axes instead of buttons.

$ systool -vm xpad
Module = "xpad"

  Attributes:
    coresize            = "45056"
    initsize            = "0"
    initstate           = "live"
    refcnt              = "0"
    srcversion          = "487C2C241DADE10B46F23B8"
    taint               = ""
    uevent              = <store method only>

  Parameters:
    auto_poweroff       = "Y"
    dpad_to_buttons     = "Y"
    sticks_to_null      = "N"
    triggers_to_buttons = "N"

  Sections:

Cheers.

@zicklag
Copy link
Member

zicklag commented Jul 5, 2022

It's possible that #5220 may fix this and detect the DPad as buttons like you were expecting @adam-becker. If you want, you could try it out and see if it will pick up your DPad as buttons after the change.

bors bot pushed a commit that referenced this issue 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.
inodentry pushed a commit to IyesGames/bevy that referenced this issue 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 issue 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 issue 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 S-Needs-Investigation This issue requires detective work to figure out what's going wrong
Projects
None yet
Development

No branches or pull requests

3 participants