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

Vibration doesn't work for some controllers #14634

Closed
toby3d opened this issue Dec 13, 2017 · 38 comments
Closed

Vibration doesn't work for some controllers #14634

toby3d opened this issue Dec 13, 2017 · 38 comments

Comments

@toby3d
Copy link
Contributor

toby3d commented Dec 13, 2017


Bugsquad note: This issue has been confirmed several times already. No need to confirm it further.


Operating system or device, Godot version, GPU Model and driver (if graphics related): 1c0007b commit from master branch, Linux Mint Mate 18.2 x86_64
Issue description: (for example) Input.start_joy_vibration(0, 0.5, 1, 5) don't do anything. Tested with connected PS, XBox and Steam Constrollers.

Bugsquad edit (keywords for easier searching): vibrate, gamepad, joystick

@groud groud added this to the 3.0 milestone Dec 13, 2017
@vnen
Copy link
Member

vnen commented Dec 13, 2017

Works for me on Windows 10, with an Xbox 360 controller. Might be Linux only.

@toby3d
Copy link
Contributor Author

toby3d commented Dec 13, 2017

The controllers are successfully connected, the control works without unnecessary movements. Vibration works on Steam, but not in Godot.

@akien-mga
Copy link
Member

akien-mga commented Dec 13, 2017

Tested on Mageia 6 x86_64 (Linux) with the same commit and my two controllers work fine:

  • Cheap CSL Computer PC / PS3 controller, seen in the joypads demo as "GreenAsia Inc. USB Joystick"
  • Steam Controller, emulating Xbox mode via SC Controller

@brainsick
Copy link
Contributor

Ubuntu 17.10 x86_64
Microsoft X-Box One Pad
Godot 2.1.4 (Steam) and Godot 3.0 Beta 1
Joypads Demo - Start Vibration
... works for me

@toby3d
Copy link
Contributor Author

toby3d commented Dec 14, 2017

Hm... I try check demo project little later, maybe I just use method not right.

@toby3d
Copy link
Contributor Author

toby3d commented Dec 14, 2017

Okay, only Steam Controller via SC Controller app works with vibration. Others - worked and finded by godot app, but vibration doesn't work.

@akien-mga
Copy link
Member

We have now entered release freeze for Godot 3.0 and want to focus only on release critical issues for that milestone. Therefore, we're moving this issue to the 3.1 milestone, though a fix may be made available for a 3.0.x maintenance release after it has been tested in the master branch during 3.1 development. If you consider that this issue is critical enough to warrant blocking the 3.0 release until fixed, please comment so that we can assess it more in-depth.

@akien-mga akien-mga changed the title Vibration doesn't work? Vibration doesn't work for some controllers on Linux Jan 5, 2018
@akien-mga akien-mga modified the milestones: 3.0, 3.1 Jan 5, 2018
@akien-mga
Copy link
Member

We need more information on what exact controller models and setup do not work, as so far nobody could reproduce those issues.

@akien-mga akien-mga removed this from the 3.1 milestone Jan 19, 2019
@ghost
Copy link

ghost commented Oct 4, 2019

I am here to bring an exact setup for my controller. I am using MacOS Mojave 10.14.6 with a Dualshock PS4 Controller I bought at Walmart.

The controller vibrates when told to by Steam (Identify Controller Feature). The model number of the controller is CUH-2CT2U. It is an official Sony controller.

Using the System Information app on my Mac, I found this info (Bluetooth).

PS4 Controller:
  Address:	90-89-5F-B8-64-E5
  Major Type:	Peripheral
  Minor Type:	Peripheral
  Services:	Wireless Controller
  Paired:	Yes
  Configured:	Yes
  Connected:	Yes
  Manufacturer:	Unknown (0x7, 0x00)
  Firmware Version:	0x0100
  Vendor ID:	0x054C
  Product ID:	0x09CC
  Class of Device:	0x05 0x02 0x2508
  AFH:	On
  AFH Map:	F0F719000370807D
  RSSI:	-42
  Role:	Master
  Connection Mode:	Active Mode
  Interval:	0 ms
  Host Connectable:	No
  EDR Supported:	Yes
  eSCO Supported:	Yes
  SSP Supported:	Yes

@ghost
Copy link

ghost commented Dec 29, 2019

@akien-mga

Not getting vibration from PS4 controllers on Windows builds. Checked and still present in 318c693.

I have had this issue for as long as I have been using Godot. Reluctant to report, since it seems like there are no longer active contributors for this area of the engine.

So the following line does nothing for me, but will work if I use an emulator to emulate an XBox controller.

Input.start_joy_vibration(0, 1.0, 1.0, 1.0)

My details are:

Win10 64-bit
Joypad - Sony DualShock 4
GUID - 4c05cc09000000000000504944564944

@Calinou Calinou changed the title Vibration doesn't work for some controllers on Linux Vibration doesn't work for some controllers Dec 29, 2019
@follower
Copy link
Contributor

Note that--on Windows--vibration relies on the XInput API which the official docs describe as "allows applications to receive input from the Xbox Controller for Windows"--i.e. at least officially, it's not a generic controller API.

I notice that SDL haptic support includes XInput & DirectX Input support on Windows, so adding additional controller support via DirectX may be possible.

Related issue: #30256

Related links:

@Lunatoid
Copy link
Contributor

At least for Windows, controllers need to be emulated as an XInput device. I tested with my DualShock 4 controller on Windows 10 and it didn't work, however when I used DS4Windows, which turns your DS4 into an emulated Xbox controller, it did work.

DS4Windows seems to use the ViGEmBus driver for it's emulation, perhaps that could be a place to look.

@wingeisoftware
Copy link

For the record, I just ran into a "Vibration not working issue". My controller was plugged via a (cheap) usb hub, and that was the issue. I soon as i connected my gamepad directly to the computer it worked. I guess the hub did not deliver enough power for the vibration motors.

@djrain
Copy link

djrain commented Jul 24, 2021

Vibration is not working for me using Xbox Series X controller, on macOS Big Sur over bluetooth.
The vibration works using this website https://gamepad-tester.com/ but not in Godot (3.3.2 stable)

@brettchalupa
Copy link
Contributor

Is this issue up for grabs still? I'm interested in taking on trying to fix it. I've got a PS4 controller, Switch controller, and an Xbox One controller with access to Linux, macOS, and Windows. I'd be happy to dig into this and get it as cross-platform and cross-controller as possible.

@Rubonnek
Copy link
Member

@brettchalupa It's up for grabs. I don't think anyone else is working on this.

@brettchalupa
Copy link
Contributor

brettchalupa commented Feb 17, 2023

I've been doing some testing on Ubuntu, Steam Deck, and macOS today with a little test app to detect controllers and rumble them. Here are my findings so far with Godot v4.0.rc2.official [d2699dc].

  • I couldn't get any controller to rumble on macOS 12.6 on an M1 MacBook Pro. I tested the Xbox One, DualShock 4, and Nintendo Switch Pro controllers.
  • On Linux (Pop!_OS 22.04 LTS), the Xbox One controller rumbled. I couldn't connected my DualShock 4 or Nintendo Switch Pro controllers. I'd like to try those some more, as maybe Bluetooth was just being funky.
  • The Xbox One controller rumbled on SteamOS. But surprisingly the Steam Deck's internal haptics didn't rumble even though it appeared as a controller. I have that functionality turned on and working in the config. Didn't work in desktop nor game modes of the OS.

I haven't booted up Windows and tested that yet, but I am assuming Xbox (aka Xinput) works there.

My next steps are:

  • explore why controllers aren't rumbling on macOS
  • further test out DualShock 4 controller on Linux and Windows, investigate findings
  • look into why Steam Deck's haptics don't just work
  • test rumble on web

If anyone else is interested in lending a hand with testing or investigating, let me know! It'd be much appreciated.

@HaSa1002
Copy link
Contributor

On Windows, you'll find only XInput to be working. All other controllers need directinput that is not implemented. Switch Pro controllers only work using Steam Input when connected via cable. Bluetooth seems to be working though. I dunno what they do to make that work (Windows only reads information spam). SDL has some info how to trigger vibrations on DualShock and DualSense as well as an example how to use the adaptive triggers. Maybe you'll find some pointers there.

@brettchalupa
Copy link
Contributor

@HaSa1002 Thanks, that's some helpful guidance and direction. 👍

@brettchalupa
Copy link
Contributor

brettchalupa commented Feb 17, 2023

Let me know if I'm being too noisy here, but I thought I'd share some findings from the world of macOS rumble.

I tested some Unity games that I know have rumble support and none of them worked on macOS. So I dug into Apple's haptics API and can confirm it rumbles DS4 and XInput controllers with this sample game they provided. So at the very baseline, we know that with Swift and Apple's SDK, you can rumble a DS4 and Xbox One controller on macOS 12.6.

Then I thought, okay, let's see if SDL2 can rumble controllers on macOS. I wrote a little SDL2 CLI tester and tested some controllers. The controllers using XInput rumbled, awesome! And a controller that emulates Switch Pro Controller rumbled too, just a bit weakly. DS4/MFi and DirectInput controllers didn't rumble though, and SDL reports them as not supporting rumble.

So what does this mean? Well, it should at least be possible to get XInput controllers rumbling on macOS in Godot by referencing SDL's implementation. That's my initial goal, that way XInput controllers work on macOS, Windows, and Linux.

From there, outstanding questions are:

  • How do we get DS4 (and maybe Dual Sense?) controllers working with rumble (and maybe the triggers too)? This seems like an interesting resource: https://github.com/JibbSmart/JoyShockLibrary
  • Test on controller rumble on mobile
  • Further explore different controller APIs and rumble support for all of them on as many platforms as possible (Switch Pro Controllers, DirectInput, etc.)

But I think XInput on modern macOS probably seems like a fine starting place for now for making this a bit better.

All right, time to dig into the Godot source. 😸

@Calinou
Copy link
Member

Calinou commented Feb 17, 2023

How do we get DS4 (and maybe Dual Sense?) controllers working with rumble (and maybe the triggers too)? This seems like an interesting resource: JibbSmart/JoyShockLibrary

See discussion on godotengine/godot-proposals#2829. JoyShockLibrary is in maintenance mode and may not remain maintained in the long term, but we don't want to adopt the entirety of SDL for binary size reasons (among other concerns). Copy-pasting code from relevant libraries is fine still.

@brettchalupa
Copy link
Contributor

brettchalupa commented Feb 19, 2023

I’ve continued my research and testing to better understand what’s possible and what is and isn’t working. Here are some more findings:

  • Windows:
    • XInput rumbles without issue in Godot on Windows.
    • DualShock 4 does not, as others have reported. SDL2 does with a special hint. So it should be possible to add to Godot. DS4Windows and Steam Input seem like potentially viable alternatives for immediate needs. I tested Steam Input with DS4 and confirmed rumbles work in a Godot game. A lot of people have DS4 controllers so I want to dig into this working on Windows without a need for Steam or DS4Windows.
  • MacOS:
    • Steam Input has no effect on rumble on XInput or DS4 in a Godot game running through it from my testing. But Steam can rumble everything when identifying controllers. Steam certainly has some advanced rumble integration from what I can tell. I wonder if any of it is open source…
    • Edit: DS4 does work in SDL2 on MacOS when using the SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_PS4_RUMBLE, "1"); hint, so that's promising!
  • Linux:
    • Did more testing and XInput, Switch, and DualShock 4 are all rumbling for me without issue on Ubuntu 22.04. Yay.
    • My Steam Deck appears to be having issues with all haptics and rumble, so I am going to try to fix that and then will do more Godot rumble testing on the Deck. Connected DS4, XInput, and Switch controllers rumble fine.
  • Web
    • Only Chrome (and thus Edge) supports rumble from testing on Mac, Linux, and Windows via the JS console. The API is pretty simple.
    • Firefox has an API for this but it didn’t work on any OS from my testing. Maybe one day in the future.
    • Godot web exports don’t rumble in Chrome. Seems possible though. It’s not a stable, standard API, so maybe risky to add? Would like to experiment with this more.

In summary: rumble for XInput on MacOS and DualShock 4 on Windows are my highest priorities.

Need to test Deck, iOS, and Android more. Chrome web may be possible. It’s unclear how possible DS4 on MacOS will be, needs more experimentation. I don’t have a Dual Sense controller yet, but I’d like to eventually test and support that too.

A lot of what I’ve shared is just confirming the issues reported above, but it helps me to test the issues and have a couple control groups to test against like the SDL tester and a Unity game I know rumbles. I have a pretty good grasp on what’s possible and what to do next. Will try to report back in the coming days and hopefully have a PR.

@brettchalupa
Copy link
Contributor

brettchalupa commented Feb 20, 2023

I've been digging into the Godot MacOS joypad vibration code and have some options for the path forward. Feedback and guidance would be much appreciated!

Current Godot MacOS Joypad Vibration Implementation

Right now the Godot Joypad implementation on MacOS uses Apple's ForceFeedback API. See the headers and vibration code. The ForceFeedback API has been supported in MacOS since 10.2, released back in 2003. It's not clear to me what devices this rumbles, but we do know it doesn't work for modern game controllers.

Godot also uses the MacOS IOKit API for interfacing with joypads.

MacOS Controller Paths Forward

Here are the options I see:

  1. Use the MacOS GameController system framework — this is Apple's robust controller API for interacting with modern controllers in all sorts of ways, including vibration/haptics. This is what Godot's iOS Joypad implementation uses.
    • Compatibility: iOS 7.0+, iPadOS 7.0+, macOS 10.9+, Mac Catalyst 13.0+, tvOS 9.0+
    • Would be implemented in Obj-C++, like iOS Joypad
    • Pros:
      • Will work with Xbox One, PS4, etc. controllers.
      • System API
      • Similar and/or shared implementation with Godot's iOS Joypad
      • It will be straightforward to get vibration working on iOS as a follow up
    • Cons:
      • Would require a re-implementation of the current MacOS joypad implementation, can't just add in a rumble support.
      • Might mean dropping support for MacOS joypad support for prior operating systems prior to macOS 10.9 (2013 release), unless there's a desire to maintain the current joypad implementation for those older operating system versions.
  2. Use the HIDAPI library — HIDAPI is a liberally licensed Human Interface Device (HID) library for interfacing with a variety of controllers. This is used by SDL, and it seems to work quite well for wide compatibility.
    • Pros:
      • Mature, stable library that's been widely used
      • Could help enable more than XInput rumble on Windows?
    • Cons:
      • Pulling in an entire library. Would Godot just use it for MacOS or for everything?
      • Requires a re-implementation without any reference within Godot

My Thoughts

I am honestly not sure... HIDAPI seems like it could unlock DualShock 4 rumble on Windows but would require a lot of work. More than I am likely capable of taking on. Going with the Apple GameController framework seems approachable because of Godot's iOS joypad implementation I can reference. It's also appealing to use a system API that can be shared across Apple platforms.

Next Steps

I'm not an expert in this domain. I'm just a person who wants my controller to rumble and am willing to do the work to help make that happen. 😂 I may be missing an option for a path forward.

Are any contributors/maintainers able to give me some guidance on how to proceed with this work or conversation? The scope of the decision seems too big for me to just make and start hacking away at the implementation without guidance/feedback.

@Calinou
Copy link
Member

Calinou commented Feb 20, 2023

Might mean dropping support for MacOS joypad support for prior operating systems prior to macOS 10.9 (2013 release), unless there's a desire to maintain the current joypad implementation for those older operating system versions.

Godot 4 requires macOS 10.12 or later, so that's fine.

@brettchalupa
Copy link
Contributor

Given I haven't gotten much feedback on my comment above, I'll plan on proceeding with the proposed option 1, Use the MacOS GameController system framework for getting MacOS vibration working. After sitting with this and learning more Godot over the past month, I think it's a good long-term solution.

Once that's done, I'd like to explore vibration on iOS, Android, Chrome web, and DualShock 4 on Windows after that. Help/support with DS4 on Windows would be welcome, as it's quite a different implementation than what exists.

Just to set expectations, it may be a few weeks/months before I have time to do this. But it's on my radar and important to me as I develop primarily on MacOS and want to add and test rumble in my games.

@27thLiz
Copy link
Contributor

27thLiz commented Apr 11, 2023

that should be fine, provided you can keep compatibility with the existing gamepad mappings

@brettchalupa
Copy link
Contributor

Sorry for such silence here on this issue. I sadly no longer have a macOS machine due to a job change and am not able to really dig into the issue of getting rumble working on modern macOS. I hope that my findings that I shared above at least help someone pick this up with a little bit of context and info. Consider this issue unassigned and free to pick up for anyone who is interested in attempting to fix it. 👍

@Kryptyk1
Copy link

#14634 #30256
Controller Vibration Not Working Using Either Setup:

Input.start_joy_vibration(1, 1.0, 1.0, 1.0)
Input.start_joy_vibration(0, 1.0, 1.0, 1.0)

On Godot v4.0.3.stable.official [5222a99]

With These Specs:
OS Name Microsoft Windows 10 Home
Version 10.0.19045 Build 19045
Other OS Description Not Available
OS Manufacturer Microsoft Corporation
System Name #######
System Manufacturer LENOVO
System Model 81FB
System Type x64-based PC
System SKU LENOVO_MT_81FB_BU_idea_FM_ideapad 330S-15ARR
Processor AMD Ryzen 3 2200U with Radeon Vega Mobile Gfx, 2500 Mhz, 2 Core(s), 4 Logical Processor(s)
BIOS Version/Date LENOVO 7WCN38WW, 4/11/2019
SMBIOS Version 3.1
Embedded Controller Version 1.38
BIOS Mode UEFI
BaseBoard Manufacturer LENOVO
BaseBoard Product LNVNB161216
BaseBoard Version SDK0J40700WIN
Platform Role Mobile
Secure Boot State On
PCR7 Configuration Elevation Required to View
Windows Directory C:\WINDOWS
System Directory C:\WINDOWS\system32
Boot Device \Device\HarddiskVolume1
Locale United States
Hardware Abstraction Layer Version = "10.0.19041.2728"
User Name #######
Time Zone #######
Installed Physical Memory (RAM) 8.00 GB
Total Physical Memory 6.89 GB
Available Physical Memory 2.06 GB
Total Virtual Memory 13.8 GB
Available Virtual Memory 7.03 GB
Page File Space 6.89 GB
Page File C:\pagefile.sys
Kernel DMA Protection Off
Virtualization-based security Not enabled
Device Encryption Support Elevation Required to View
Hyper-V - VM Monitor Mode Extensions Yes
Hyper-V - Second Level Address Translation Extensions Yes
Hyper-V - Virtualization Enabled in Firmware Yes
Hyper-V - Data Execution Protection Yes

(Some Irrelevant personal info omitted)

With This PS4 Controller Model:
MODEL CUH-ZCT2E

This was tested in Debug mode not in a build of the game.

p.s Sorry if I formatted/ referenced issues etc wrongly I am new to github.

@JezerM
Copy link
Contributor

JezerM commented Aug 17, 2023

Hi, I just noticed that vibration doesn't work for controllers in macOS a few days ago, so I tried to fix it. I would appreciate if someone interested could test it.

And thanks to @brettchalupa for the initial guide on how controllers work in Godot and how this issue could be addressed.

JezerM added a commit to JezerM/godot that referenced this issue Oct 8, 2023
This implementation complies with Godot's documentation regarding
start_joy_vibration.

Relates to godotengine#14634 and fixes it for macOS.
@coelhucas
Copy link

Tested on MacOS with Xbox Series S gamepad, dualshock 4 and joycons, none working (as of version 4.1.3).

@Alex2782
Copy link
Contributor

@coelhucas There is already PR, I was able to test my Bluetooth XBox controller on Macos.
#80709

@JezerM
Copy link
Contributor

JezerM commented Feb 20, 2024

For macOS, this is already fixed in the master branch~

@akien-mga
Copy link
Member

After #80709, I think we can close this old issue.

If anyone still experiences non-working vibration with some controllers on some platforms in 4.3 or later, please open a dedicated issue for that controller / platform combination so it can be assessed.

@Yurinka
Copy link

Yurinka commented Jul 7, 2024

The issue continues happening in v4.2.2.stable.official when running it (reproduced it in the editor, using Windows 10):

-Xbox compatible gamepads rumble properly
-DualShock4 (connected via USB) doesn't rumble
-DualSense (connected via USB) doesn't rumble
-Switch Pro controller doesn't rumble

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