wulf7 / iichid

Generic HID layer for FreeBSD. Including I2C and USB backends.
BSD 2-Clause "Simplified" License
45 stars 6 forks source link

Full featured driver for PlayStation4 DualShock4 controller on IICHID? #33

Open cederom opened 4 years ago

cederom commented 4 years ago

Hello world :-)

I have this nice PS4 controller that can work over USB and Bluetooth. It works over USB at this point on FreeBSD with using HID but not all features are supported (accelerometer, touch pad, etc, does not work).

Is it possible to extend this HID driver with additional features using this IICHID project?

How this can be achieved?

Any hints appreciated :-)

Tomek

wulf7 commented 4 years ago

Is it possible to extend this HID driver with additional features using this IICHID project?

Certainly, yes.

How this can be achieved?

As I do not own such a device, someone else should write support for it.

Any hints appreciated :-)

If you are going to create this driver, the first thing you should do is to find out if report descriptor located in this device is valid or no and then write a good one if "no". Than you should find out which events are expected by userland software to handle input. And than you should create HID->evdev (or something else) convertor on base of iichid. xb360gp.c is a good example of such a convertor.

cederom commented 4 years ago

Thank you @wulf7 for all of the hints!

I have last one question. Are "descriptors" those funny HEX tables that are kinf of mask what device can do? Do you have a nice reference to read about those descriptos? I downloaded once the HID specification but the implementation was still a bit unclear. From what I saw in the sources of Linux and FreeBSD HID device drivers some parts were similar and some differer probably that was the source of different capabilities availability?

Btw. if I could order such controller for you would you have time to write/extend such driver since you already have all experience and what would be the cost? I mostly care about accelerometer that is built into the controller and I would like to use that data to drive camera in VR environment (fun project).. having a trackpad data would be nice too but optional.

wulf7 commented 4 years ago

I have last one question. Are "descriptors" those funny HEX tables that are kinf of mask what device can do?

Yes, they are.

Do you have a nice reference to read about those descriptos? I downloaded once the HID specification but the implementation was still a bit unclear.

The HID specs and source code of parsers are the best docs, but there are some small easy to use tools to make life better. See e.g:

  1. https://eleccelerator.com/usbdescreqparser/ - it could decrypt HID report given in HEX format
  2. sudo usbhidctl -al -f /dev/hidraw* where hidraw* can be obtained from dmesg ouput. It can dump decoded data in real-time, not only decrypt report descriptor.

You can use latter utility to check if DualShock2 controller contains good descriptor or not. Just run it and try to push all buttons one by one, touch trackpad area e.t.c. and see if dumped data matches your doings or not. If it does, you do not need to craft custom descriptor. Built-in one can be used.

I mostly care about accelerometer that is built into the controller and I would like to use that data to drive camera in VR environment (fun project).. having a trackpad data would be nice too but optional.

Do you have any tools to process accelerometer data? If you do and this software can not process raw hid data but supports some other simple protocol like evdev, than you can send me such a device to write a driver.

cederom commented 4 years ago

Thanks for the hints @wulf7! You rox! I will try the usbhidctl :-)

I base my work on PS4 DualShock4 controller demo that was written for Blender up to 2.79. DS4/PS4 controller support was there in Blender ready to use. It does not use evdev, I guess its more USB HID. But.. it was working on Blender Game Engine that was removed in 2.80. Still Blender 2.79 can build and work on FreeBSD. Its a bit mess right now, but that could be quite nice inexpensive easy to buy controller with all available digital, analog, IMU, and even trackpad inputs :-)

https://www.sharecg.com/v/81050/related/5/3D-Model/Blender-Game-Engine-PS4-Controller-Python-Script

I am working right now on a different projects so its not high priority stuff.. but if you have some time and will to play with this kind of controller I can transfer lets say $100 via paypal so you can get it locally and see how it works with iichid? :-)

wulf7 commented 4 years ago

PS4 DualShock4 ... Blender . Really you have intrigued me a lot :-). Unfortunatelly, I can't just visit nearest store due to COVID-19, Could you say which one game controller should be chosen? https://www.mvideo.ru/playstation-4327/ps4-aksessuary-4334/f/category=geimpady-dlya-ps4-7667 can give you an idea what can be bought in Moscow just now. Do not try to pay for it as payment can be blocked by anti-fraud system. Just point me to the proper device. Unfortunately, all the sites about russian online trade are in russian.

cederom commented 4 years ago

Any original PS4 controller will have the same standard features and functions. All of them just seem to have different painting :-) Just do not buy any "clone" or "replacement" as they would be totally different device inside :-) How about eBay or Amazon and international shipping? We use couriers and inpost-automats deliveries a lot now in Poland :-) Thanks!! :-)

wulf7 commented 4 years ago

I have ordered this one: https://www.mvideo.ru/products/geimpad-dlya-konsoli-ps4-playstation-4-dualshock-4-v2-black-cuh-zct2e-40065372 I am almost sure that it is not genuine Sony but compatible one.

How about eBay or Amazon and international shipping?

Do not forget that local shipping takes one day while international takes up to the month Moscow is twice bigger than New-York so usually you can buy virtually anything you want locally.

wulf7 commented 4 years ago

Initial support is added, but there are lot things to do left,

cederom commented 4 years ago

Thank You @wulf7 YOU ROX! =)

arrowd commented 3 years ago

I've got a PS5 controller. Is this PR related to its support?

wulf7 commented 3 years ago

Although PS5 controller is looking pretty much like a slightly modified PS4 clone, it is better to open new issue.