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

PS4 controller connected makes a unusable duplicate index on Linux #50273

Open
vladimir-sama opened this issue Jul 8, 2021 · 8 comments
Open

Comments

@vladimir-sama
Copy link

Godot version

3.3.2.stable.official

System information

Garuda Linux, 5.12.12-zen1-1-zen, KDE Dragonized, PS4 Controller

Issue description

So I started a new project, then added a joystick detector

var _unused

func _ready():
	_unused = Input.connect('joy_connection_changed', self, '_joy_changed')
	print(Input.get_connected_joypads())
	print()

func _joy_changed(device : int, connected: int):
	if connected:
		Input.start_joy_vibration(device, 0.50, 0.00, 0.30)
		print(device)
		print(Input.get_joy_guid(device))
		print()

I have 2 PS4 controllers connected by cable to a usb 3.0 hub, to a usb 3.0, output:

[]

0
030000004c050000c405000011810000

1
030000004c050000c405000011810000

2
030000004c050000c405000011810000

3
030000004c050000c405000011810000

I connected both controllers one after the other, and there is duplicate indexes? and if I connect them before starting the project:

[0, 1, 2, 3]

I also tried using the duplicate index as player input, did not work.

Steps to reproduce

extends Node2D

func _ready():
	Input.connect('joy_connection_changed', self, '_joy_changed')
	print(Input.get_connected_joypads())
	print()

func _joy_changed(device : int, connected: int):
	print(device)
	if connected: print(Input.get_joy_guid(device))

Nodes are:

Control
ViewportContainer
Viewport
Node2D (code)

Minimal reproduction project

No response

@akien-mga
Copy link
Member

CC @madmiraal

If you connect only one of the controllers directly, do you confirm that it still registers as both device 0 and 1? And does unplugging it unregister both devices 0 and 1?

When a single controller is plugged in, do you have both /dev/input/js0 and /dev/input/js1 defined?

@akien-mga akien-mga changed the title Controller connected makes a unusable duplicate index PS4 controller connected makes a unusable duplicate index on Linux Jul 8, 2021
@vladimir-sama
Copy link
Author

If you connect only one of the controllers directly, do you confirm that it still registers as both device 0 and 1? And does unplugging it unregister both devices 0 and 1?

Yes, when I connect the controller there is an instant when there is only one index, but the second index apears afterwards, when disconnected, the second index is last to desappear

When a single controller is plugged in, do you have both /dev/input/js0 and /dev/input/js1 defined?

No, if you mean the input settings, only the connected controllers are shown

@madmiraal
Copy link
Contributor

Related to if not a duplicate of #41933.

@akien-mga
Copy link
Member

Related to if not a duplicate of #41933.

Seems to be the case indeed. I closed the other one as this one has more details.

@JyKin
Copy link

JyKin commented Oct 14, 2022

Hello,
I've seen this issue after having what I think is the same problem on a game made with Godot.
It seems things are not clear for people involved here so let me explain.
On Linux (as hinted in the issue #41933 closed as duplicate), controller with motion controls, like DS3, DS4, Dualsense or Switch Pro Controller (I own the last 3 and tested the last 2), appears as 2 different devices (thus two different /dev/input/eventxx and two different /dev/input/jsxx). One is the classic controller, the other is the motion input.
Most of the time, the first is the controller, the second the motion. But they can be reversed (it happened to me mostly when plugging a controller while a godot game was running).

Now, of course, the question is how to consider the motion controls device as not a joystick ? Well, it happened that the commit 8fe2ecf, found on themaster branch, fixes the problem. On the dev version, and thus the future version 4 of Godot, only device that have buttons AND analog axis are considered proper controller. Since motion control input device only have axis, they are rejected. There is also the commit b966ca6 that make Nintendo Joycon considered as proper controller, because they only have one thumbstick.

I tested the first commit by cherry-picking it on to of the tag 3.5.1-stable to check and it works the way I expect. I don't know how you want to deal with update of version 3 of Godot but at least, I want to say that this problem is fixed on master branch.

@Calinou
Copy link
Member

Calinou commented Oct 14, 2022

Feel free to open a pull request against the 3.x branch to cherry-pick this 🙂

@JyKin
Copy link

JyKin commented Oct 14, 2022

Ok, I made one picking both commits at #67414
I hope that's the way, I'm not used to github. I am more of a plain git user ^^'

@vaartis
Copy link
Contributor

vaartis commented May 13, 2023

For some reason in 4.0.2 the DualSense (PS5) gamepad is now detected as device 1, and its touchpad as device 0, no matter what I do. Just rechecked it in 4.0-beta17 and there it's the other way around, which seems more correct to me.

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

No branches or pull requests

7 participants