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: add some deadzone for joypad motion detection #3

Merged
merged 5 commits into from
Apr 27, 2024

Conversation

raganw
Copy link
Contributor

@raganw raganw commented Oct 15, 2023

Prior to this change, if there was both a keyboard and joypad connected and the user was using the keyboard, but there was some stick drift with the joypad, input detection would bounce between keyboard and joypad.

This change adds a minimum axis_value that a InputEventJoypadMotion must have before detecting the input type as a joypad.

Ideally, it seems like this deadzone should be configurable, but I'm new to Godot and its plugin architecture and couldn't quite figure out how best to surface that as customizable.

@Pennycook
Copy link
Owner

Thanks for working on this. I didn't see this behavior with my controllers, so I didn't realize this could be a problem.

Ideally, it seems like this deadzone should be configurable, but I'm new to Godot and its plugin architecture and couldn't quite figure out how best to surface that as customizable.

I'm not sure what the best way to do this is, either. For now, what I'd recommend is declaring a new variable in InputPromptManager, similar to what I did for preferred_icons:

## The preferred icons to be used by [ActionPrompt], [JoypadButtonPrompt] and [JoypadMotionPrompt]
## nodes. When set to a specific value, all nodes with "Automatic" icons will be overridden to use
## the specified value.
var preferred_icons := InputPrompt.Icons.AUTOMATIC:
set(value):
preferred_icons = value
if preferred_icons == null or preferred_icons == InputPrompt.Icons.AUTOMATIC:
icons = InputPrompt.Icons.XBOX
else:
icons = value
emit_signal("icons_changed")

If there was something like a device_detection_deadzone variable, then there would at least be an easy way to modify this value through code.

@Pennycook
Copy link
Owner

I've been looking at this a bit more recently, and discovered two things of interest:

  1. Godot uses a deadzone value of 0.5 by default (see here)
  1. It is possible to add custom entries into the ProjectSettings

I still need to figure out exactly how to do this, but ProjectSettings seems like the right place to expose an InputPrompt-specific deadzone value.

raganw and others added 2 commits April 20, 2024 14:21
Prior to this change, if there was both a keyboard and joypad connected
and the user was using the keyboard, but there was some stick drift with
the joypad, input detection would bounce between keyboard and joypad.

This change adds a minimum axis_value that a InputEventJoypadMotion must
have before being detecting the input type as a joypad.
@Pennycook
Copy link
Owner

@raganw: I think I got this working with ProjectSettings, so the value is configurable without touching any of the plugin code. See below:

image

I tested this on my Steam Deck (which, it turns out, has a small amount of stick drift!) and things seem to work. But I'd appreciate it if you could take a look and confirm that everything is working as expected before I merge it in.

@Pennycook Pennycook closed this Apr 21, 2024
@Pennycook Pennycook reopened this Apr 21, 2024
@raganw
Copy link
Contributor Author

raganw commented Apr 26, 2024

@Pennycook - Thanks for shepherding this change. I confirmed that this works with the project I was working on and it looks good. I merged in main so if you're good with it, :shipit:

@Pennycook Pennycook merged commit cc4f414 into Pennycook:main Apr 27, 2024
1 check passed
@Pennycook
Copy link
Owner

You're very welcome. Thank you for identifying the issue, providing the fix, and for helping out with testing.

It's merged! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants