ESP32-BLE-Gamepad icon indicating copy to clipboard operation
ESP32-BLE-Gamepad copied to clipboard

Is it possible to implement force feedback?

Open David1r20 opened this issue 2 years ago • 15 comments

Is there a possibility to get ffb?

David1r20 avatar May 03 '22 14:05 David1r20

Hi

Was asked a couple of years ago

https://github.com/lemmingDev/ESP32-BLE-Gamepad/issues/12

Out of my area of expertise

If someone wants to take a crack at it and create a pull request, it would be greatly appreciated.

lemmingDev avatar May 05 '22 09:05 lemmingDev

Sorry for my poor english. with ffb do you mean a simple vibrator motor?, i found an app for android that test the gamepad and the vibration, can you catch this command and implement it to the library? or this is the complicated part?

Narsku avatar May 22 '22 23:05 Narsku

Sorry. I have no idea how to get it working...

lemmingDev avatar May 23 '22 06:05 lemmingDev

Force feedback or haptic is possible, but not yet quite standard, at least not in my very basic research.

There are a few options:

  1. make your own interface for your project ie: BLE serial - https://www.hackster.io/chuartdo/ble-haptic-dual-joystick-controller-31c2c2
  2. emulate one of the other vendors haptic system XBox/PSX controller (not sure the legal status) -
  3. setup the correct HID and output fields with callbacks, like CapsLock LED - https://github.com/tloimu/adapt-ffb-joy/tree/wiki
  4. Possible part of 3 - Extend support for FFB in SDL2 - https://github.com/libsdl-org/SDL/tree/main/src/joystick/hidapi

3 and 4 are something in my spare time I am trying to understand and added, but it's slow going and just a little over my current skill level.

Hope this might help somebody else just start their progress.

LeeNX avatar May 23 '22 11:05 LeeNX

Ok!, I'm gonna try to work on it

Narsku avatar May 23 '22 12:05 Narsku

That would be great. Let me know if you make any progress

lemmingDev avatar May 27 '22 06:05 lemmingDev

Let me jump into this issue because I'm also interested in it.

@Narsku https://github.com/lemmingDev/ESP32-BLE-Gamepad/issues/99#issuecomment-1134022276

i found an app for android that test the gamepad and the vibration, can you catch this command and implement it to the library? or this is the complicated part?

Which app did you try? I also want to try the app.

kotobuki avatar Jun 25 '22 23:06 kotobuki

Seems some of the info needed is here https://www.usb.org/sites/default/files/pid1_01_0.pdf

lemmingDev avatar Sep 20 '22 20:09 lemmingDev

And here's an Arduino Leonado joystick library with force feedback https://github.com/YukMingLaw/ArduinoJoystickWithFFBLibrary

lemmingDev avatar Sep 20 '22 20:09 lemmingDev

I have been reading through the ArduinoJoystickWithFFBLibrary repo and came across https://github.com/YukMingLaw/ArduinoJoystickWithFFBLibrary/issues/30#issuecomment-870345902 where extending the HID PID seems to get FFB working in Linux, so I was thinking of extending ESP32-BLE-Gamepad PID to include the changes for test - https://github.com/YukMingLaw/ArduinoJoystickWithFFBLibrary/blob/master/src/FFBDescriptor.h

but after about a 1/3 of the way through, worried about any typos or other problems, hoping there might be a quicker or even better way to do this, for just a test? @lemmingDev you have an idea? Need to take into account, Report IDs (not got to the point to test yet)- Was thinking about just making a Report IDs and offset from the init base.

My fork and branch in it's current state - https://github.com/LeeNX/ESP32-BLE-Gamepad/commits/leet-ffb-pid

Also thinking, if we going to use this code, we should possible ask or inform https://github.com/YukMingLaw that we doing this? Just good citizenship ... I will reach out, if nobody else beats me too it.

LeeNX avatar Nov 19 '22 08:11 LeeNX

Hi @LeeNX

Have you had any luck getting the FFB to work? I was looking at using ESP32-S2 and convert the ArduinoJoystickWithFFBLibrary to work with the esp32, but if this works that's even better.

Thanks

MatthewReed303 avatar Dec 01 '22 20:12 MatthewReed303

@MatthewReed303 still in progress, have not made much headway since my last post. Not much feedback either, so I am not sure if anybody else would find this useful. I am still keen and interested and will come back to this. Just need to find the time and motivation. Have some free time coming up in two weeks, so I think I will be able to get to at least testing PID with OSX and Linux (Raspberry Pi) with SDL 2/3.

Been hacking at a simple console testing program, to test some of my ideas. Was very interested in seeing very much different feature reporting back on Linux vs OSX. On Linux, if I set SDL hint that my BLE devices is PS4 controller, not much changes, but on OSX, when hinted as PS4 controller, the serial number from BLE is reported back differently. SDL feature (bug) that I was not expecting. I don't even remember why I did think of even trying this.

I hope there is more interest, which would be motivating for me.

LeeNX avatar Dec 02 '22 08:12 LeeNX

Does this library have a callback for messages received from the PC? I'm trying to do some latency measurements and my idea was to send FFB messages to the controller and respond back with a button press thus having the full round-trip latency.

tapir avatar Dec 24 '22 18:12 tapir

I'm using the [Fino](https://github.com/jmriego/Fino] library which based on the YukMingLaw to create an Arduino FFB Yoke for FlightSim. I'm thinking about to make a new design of the yoke to make it smaller and may be use an ESP32 processor to bring my project to a next level (Bluetooth, faster, wifi).

Is there any progress of implementation of FFB? You would make may people very happy for implement, especially the Flightsim and RacinSim Guys!

gagagu avatar Jul 11 '23 13:07 gagagu

Xinput fork of library here that does rumble https://github.com/Mystfit/ESP32-BLE-CompositeHID

No progress on force feedback

lemmingDev avatar Feb 24 '24 04:02 lemmingDev