godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
88k stars 19.9k forks source link

Vibration not working with Google Stadia controller #94265

Open frankhuurman opened 1 month ago

frankhuurman commented 1 month ago

Tested versions

v4.2.2.stable.official [15073afe3]

System information

Godot v4.2.2.stable - Ubuntu 22.04.4 LTS 22.04 - Wayland - Vulkan (Forward+) - integrated AMD Unknown (RADV RENOIR) () - AMD Ryzen 7 4800U with Radeon Graphics (16 Threads)

Issue description

When trying to use Input.start_joy_vibration() to trigger vibrations/rumble for my (bluetooth connected) Google Stadia controller it doesn't seem to do anything.

I've tried different values but I couldn't get any vibrations working, the controller works just fine for all other input. In my MRP I've linked the vibration call to a button but it doesn't work either when used in other functions like _physics_process().

Steps to reproduce

Minimal reproduction project (MRP)

extends  Node2D

func _input(_event):
    if Input.is_action_pressed("ui_menu"):
        Input.start_joy_vibration(0, 1, 1, 100)
Calinou commented 1 month ago

Can you test https://github.com/godotengine/godot/pull/87925 and see if it resolves the issue?

frankhuurman commented 1 month ago

I'd love to but unfortunately the artifacts have expired in that commit, can't download them anymore :( image

Calinou commented 1 month ago

I'd love to but unfortunately the artifacts have expired in that commit, can't download them anymore :(

You can still build the PR from source as described in the page I linked.

frankhuurman commented 1 month ago

Never built a game engine from source before but it was pretty easy, took about 11 minutes and launched on first try (v4.3.beta.custom_build).

Made a 2D node, added one of my controller input buttons(A button) to the input map, added a script to 2D node, checked for that mapped button in the _input function and it does trigger my print statement when I press it but vibration/rumble isn't working.

I checked the joypad ID with Input.get_connected_joypads() and it only showed this one as [0] so I used that one.

I tried different settings:

Input.start_joy_vibration(0, 0.5, 1, 1)
Input.start_joy_vibration(0, 0.5, 1, 500)
Input.start_joy_vibration(0, 0.5, 1, 10)
Input.start_joy_vibration(0, 0, 1, 10)
Input.start_joy_vibration(0, 0.5, 1, 50)

But nothing seems to make it vibrate.

Just for completeness sake, script that I used where 'pressed!' is printed to the console on button press:

func _input(event: InputEvent) -> void:
    if Input.is_action_just_pressed("ui_test"):
        print("pressed!")
        Input.start_joy_vibration(0, 0.5, 1, 500)

After this I hooked up my wired Xbox 360 controller and if I press the A button it immediately vibrates.


Off-topic: Also found some different behaviour between both controllers I did not ever notice before. The Stadia controller prints "pressed!" only one time each button press, the Xbox 360 wired controller prints it 2 or 3 times each button press. Seems like there's a difference in the input speed/latency but that might be something that's not known to me and is common knowledge.

I looked into it and apparently it has to do with me using the Input class directly instead of the triggered InputEvent.

So with this code snippet:

func _input(event: InputEvent) -> void:
    if event.is_action_pressed("ui_test"):
        print("pressed event!")
    if Input.is_action_pressed("ui_test"):
        print("pressed!")

I get this output when I press the A button 1 time on the Xbox controller:

pressed event!
pressed!
pressed!
pressed!

And this output on the Stadia controller:

pressed event!
pressed!

So at least I learned something useful from this joypad rumble debug session.