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

Fix joypad demo for Godot 4.x #943

Merged
merged 8 commits into from
Apr 13, 2024

Conversation

noidexe
Copy link
Contributor

@noidexe noidexe commented Aug 23, 2023

This fixes a number of issues preventing to use the remap feature:

  • The gamepad images with the button layout were not visible
  • Gamepad input was not being detected while the remap window was focused
  • Some porting issues where .pressed appeared where .button_pressed was meant
  • The wrong buttons being highlighted when remapping triggers
  • The remap window was accepting events from all gamepads rather than only the one being remapped, which could be an issue if another connected controller has analog drift of is accidentally pressed for whatever reason.

Input detection only works with native subwindows. I couldn't get it to work when using embedded subwindows. The subwindow seems to stop event propagation even with handle_input_locally disabled. You can workaround it by clicking outside the remap window before pressing a button but it should get a proper fix
Checking the Godot source code it seems to be by design. Subwindows will always handle input when focused. Managed to fix it by connecting to Window.window_input

If embedded windows are used, and RemapWizard/Mapping is focused, it
seems to be marking gamepad input as handled so it never reaches
remap_wizard.gd::_input in the parent node.
Disabling "handle input locally" in
RemapWizard/Mapping doesn't seem to have any effect.

Switching to native windows seems to fix the issue, but this will not
work for HTML5 platforms
@Calinou Calinou added the bug label Aug 23, 2023
@Calinou
Copy link
Member

Calinou commented Aug 23, 2023

Tested locally. On 4.1.1, when you first start the demo with a controller connected, it's possible to see pressed buttons/axes but the UI appears grayed out (and the controller name doesn't appear):

image

You need to change the SpinBox value back and forth for the UI to look correct:

image

@noidexe
Copy link
Contributor Author

noidexe commented Aug 23, 2023

Tested locally. On 4.1.1, when you first start the demo with a controller connected, it's possible to see pressed buttons/axes but the UI appears grayed out (and the controller name doesn't appear):

I cannot reproduce that, at least on windows and with a couple of xinput and dinput gamepads. I don't have a PS5 one.

Can you add _on_joy_connection_changed(joypad, true) to the for loop in joypads.gd::_ready ? Maybe that'll fix it.

@Calinou
Copy link
Member

Calinou commented Aug 24, 2023

I've just tested this again (all testing was done on Linux). It looks like it works as-is on 4.2.dev godotengine/godot@6758a7f8c but not on 4.1.1.stable (which also prints lots of threading warnings).

I guess we can assume this to be an engine bug and merge the demo update anyway.

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.

Thank you for this! Tested, works great. I pushed a few small tweaks to the UI layout and code style.

@aaronfranke aaronfranke changed the title Fix joypad demo Fix joypad demo for Godot 4.x Apr 13, 2024
@aaronfranke aaronfranke merged commit 01db4a6 into godotengine:master Apr 13, 2024
1 check passed
@aaronfranke aaronfranke added this to the 4.2 milestone Apr 13, 2024
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.

3 participants