fraca7 / dsremap

Input remapping for the Dual Shock 4
MIT License
16 stars 2 forks source link

Upgrade LUFA to modern alternative? #2

Open bsperryn opened 3 years ago

bsperryn commented 3 years ago

Hello, unfortunately LUFA only supports older AVR boards.

How about something like https://github.com/NicoHood/HID or https://github.com/hathach/tinyusb so that it would be compatible with modern boards?

fraca7 commented 3 years ago

My first prototypes used the HID library but it quickly became clear it doesn't allow the kind of low-level USB access I need to trick the PS4. I'll take a look at tinyusb.

bsperryn commented 3 years ago

I'll also keep digging around and see whether I can find any other alternatives.

bsperryn commented 3 years ago

I can't seem to find anything else, please let me know if there is anything I can do to help.

bsperryn commented 3 years ago

https://github.com/arduino/ArduinoCore-samd/blob/master/cores/arduino/USB/USBAPI.h#L67

This is low level enough? I believe the Nico/HID library is using this under the hood for the Samd boards and something similar for the other boards.

fraca7 commented 3 years ago

It is, but it's also badly designed and next to impossible to extend or use in "advanced" situations. LUFA on the other hand enables the user to do pretty much anything with its callback-based API. I'm hoping tinyusb follows the same philosophy.

bsperryn commented 3 years ago

Could you tell me what functionality is missing in the USBAPI that's needed for your library?

I've been having a problem getting TinyUsb to work with my board.

In combination with the HID library I'm thinking of recreating the LUFA interface, but using the Arduino USBAPI under the hood. That way your code wouldn't need any dramatic changes.

Could you tell which which LUFA functionality this library is using and in which files so that I can recreate the LUFA interface?

fraca7 commented 3 years ago

I use basically all of the low-level device (not host) USB APIs. At first I tried using the Arduino built-in USB code but it didn't have some of the core functionality I needed, so I doubt you can do that. It would probably be simpler to implement a driver for your board directly in LUFA (http://www.fourwalledcubicle.com/files/LUFA/Doc/210130/html/_page__writing_board_drivers.html) or maybe add support for your board in the Arduino LUFA project (https://github.com/Palatis/Arduino-Lufa) wouldn't it ?

bsperryn commented 3 years ago

Yes, you're probably right. It does seem fairly daunting to me since I've never done anything like that before, but I guess that's probably what needs to be done!