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
Laptop touchpads are seen as gamepads #59250
Comments
For completeness, I also tested on v3.4.4-rc2 and v3.5-beta2 and both behave as expected. |
I didn't bisect, but I have a hunch that #57612 might be the culprit. It hasn't been cherry-picked for |
I cannot reproduce this issue on my laptop (I have an ELAN1401:00 touchpad). So I'm not able to troubleshoot or confirm that #57612 is the culprit. |
I've created PR #59412 to increase the restriction on devices that are detected as gamepads that should fix this issue. |
Solved by #59412. Thank you for your help. |
The issue won't be fixed in |
For anyone else running into this issue, you can work around the issue by including this in any
This obviously shouldn't be in production code. And it's also not cognizant of the fact that you might have both a joypad and a touchpad connected. |
Looking forward to the merge! I see the suggested workaround above, and I don't quite understand it. I am in the process of figuring out how to get local multiplayer to work, and am adding a player instance to the scene for each connected gamepad. So my current workaround looks something like this:
At least that's the relevant bit. Hope this helps someone, or that someone comments on why not to do this. Though ultimately, I don't intend to leave the number of players to be determined by how many devices are connected. |
This can be seen in Input Map in project settings in beta14 Since "Listening for input" is focused when adding new key to an action, it will immediately detect moving the mouse as Joypad Axis 0,1 or 2 |
I can confirm this on 4.0.beta16 (Linux) while I was working on godotengine/godot-demo-projects#830, but with a different kind of device. This is not limited to laptop touchpads. Here, it was occurring with a motherboard LED controller: The issue is also present on 3.5.1: I'm using Fedora 37 and don't have OpenRGB installed. |
#59412 is one of the proposed fixes and has been waiting nearly a year |
As making the touchpad not usable as a input device is difficult and would make using certain controllers impossible, can we not simply have a way to stop the input system from registering a certain device? |
We could have a project setting with a list of device IDs that shouldn't be registered as controllers (plus an environment variable to append to this list), but this will require manual maintenance. We could ship a list of known problematic "not-a-controller" IDs by default too. |
I'm running into this problem with Godot 4.1.1 and none of the existing solutions worked to filtering out the joystick events being generated by the trackpad on my Framework laptop with Ubuntu 22.04. However, I've noticed that Input.is_joy_known() returns false for these trackpads and not real joysticks, and so a workaround in my _input event handler that seems to be working for me is this:
|
Have you tried using my builds? Ive patched a fix into them. |
This comment was marked as off-topic.
This comment was marked as off-topic.
See #59412 (comment). The PR needs to be revised significantly (or even remade from scratch) before it can be merged. |
You can use this script I made before the PR is ready.
Tested on Godot v4.2.stable.mono.flathub only.
Not sure if you should use this in production. But it can at least help you for now, if you use a laptop for development. Tweak the list of words if needed. You might also want to remove the logging line or uncomment the debug line. Just add this script as an auto-load in your project settings. The node will just connect to the signal at startup, then self-delete. The callback needs to stay because even a touchpad device may take a few frames to be recognized (e.g. in Flatpak). When the device is disabled, it'll also send input events once to reset all SDL axes and buttons to 0. Gist: TouchpadIsNotJoypad.gd Previous simpler version using RegEx (outdated, was for v4.1.3):It's very simple and self-explanatory. Tweak the regex if needed (it's definitely not exhaustive nor well-tested). # Public domain, as per The Unlicense. NO WARRANTY. See https://unlicense.org
extends Node
## Solves a [url=https://github.com/godotengine/godot/issues/59250]bug[/url] where touchpad devices
## can be detected as a joypad.
##
## This script should be autoloaded in the project settings.
## This is merely a workaround, not for use in production code.
func _ready() -> void:
int(Input.joy_connection_changed.connect(Callable(get_script(), joy_check.get_method())))
queue_free()
## Pattern of joypad names to disable.
static var pattern := RegEx.create_from_string('\\b(?i:(?:touch|track|click)pad|mouse|pen)\\b')
## Validates a joypad connection. Called for every joypad device connected.
## Device names matching the pattern will be disabled (remapped to an empty mapping).
static func joy_check(device_id: int, connected: bool) -> void:
if not connected:
return
var device_name := Input.get_joy_name(device_id)
# Uncomment the line below to debug problematic devices:
# print('Connected device ', device_id, ': ', device_name)
if not pattern.search(device_name):
return
# Device should be ignored.
var guid := Input.get_joy_guid(device_id)
var mapping := guid + ',' + device_name.replace(',', '') # not mapping any axes or buttons
# Replace with empty mapping on this guid. Should ignore all joypad input from this device.
Input.add_joy_mapping(mapping, true)
prints('Ignoring joypad device:', mapping) # you can comment out or remove this line
|
I've updated the code above to fix an issue. The change is because even the touchpad device may take a few frames to appear (e.g. on Flatpak version of Godot), so now the check will run for every device connection instead of assuming the list of devices is ready at startup. Also, devices like drawing tablets can be connected at any time. I've also updated the regex to match "mouse" and "pen" words as well. Note that this isn't exhaustive. I don't know if words like "pencil", "tablet", "stylus", etc. should be included. Tweak as needed. EDIT: I've updated the script (on the gist link now) to use a list of banned words instead of RegEx. It should now work even if you compiled Godot with the regex module disabled. See #59412 (comment) . |
I've updated the code in the gist again to fix another issue. Please update if you're using the code (it's for v4.2 now, but should be trivial to port back by removing |
This comment was marked as off-topic.
This comment was marked as off-topic.
See the linked PR, but otherwise please don't bump things without information, if someone has an update they would have added it here :) |
Godot version
4.0-alpha4
System information
Linux - Manjaro 21.2.5
Issue description
In Godot 4.0-alpha4, my laptop's touchpads are seen as gamepads. When no actual controllers are attached to my laptop, functions and signals such as
Input.get_connected_joypads()
andInput.joy_connection_changed.connect
see two existing devices. When I add real controllers, they are assigned device ids from 2 and up. In contrast, this is not the case in Godot 3.4.3.Godot 3 output at start
[blank]
Godot 3 output when I connect a Xbox 360
0 Xbox 360 Controller
Godot 4 output at start
0 SYNA8008:00 06CB:CE58 Touchpad
1 ELAN901C:00 04F3:2C29
Godot 4 output when I connect a Xbox 360
2 Xbox 360 Controller
Note that if the Xbox controller is connected when I launch the "game", it is seen with device id = 0.
A tool such as gamepad-tool yields the same results as Godot 3 (no additional devices detected).
Steps to reproduce
Create an empty project with a single Node2D and the following script attached
Minimal reproduction project
No response
The text was updated successfully, but these errors were encountered: