-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
[SDL2] Adding input and FFB support for Logitech G29(PS3) on hidapi #11591
base: SDL2
Are you sure you want to change the base?
Conversation
Can you retarget this PR for SDL3? |
|
I don't know whether or not this will be accepted into SDL2 branch, but One issue is SDL_hidapihaptic_lg4ff.c does libc function calls sprintf, |
@sezero Thank you so much for the patch, can I ask for a version with As for whether this will be accepted or not, I'm unsure, and there seems to be a sentiment to use |
There you go: 0001.patch.txt Note that the abs() and llabs() issue is still there. (SDL_abs() is the worst thing added to SDL api...) |
Implementing a hardware driver inside SDL is something I would never expect. I'd say it's a bad idea but who knows, maybe I'm old fashioned. I would have thought porting the driver would be a better idea but maybe it's not possible. |
Hey @berarma , thanks for looking at and commenting on this! Please also see #11598 (comment) , as the author of new-lg4ff, you can decide whether code ported from your driver can be part of SDL or not
On open platforms like FreeBSD, I'd agree, someone well versed in FreeBSD development should be able to develop/port drivers to FreeBSD evdev, yielding a better performing driver, even when a userspace driver might be "good enough" On other platforms however, it's not always possible On Android, how the kernel is compiled is up to device manufacturers (and they orphan their kernels way way too often), the Paddleboat API does not have any feedback support beyond vibration motors, there's sure no HAL implemented for more complicated evdev FFB; However it is possible to get raw usb access On Apple operating systems, they introduced SDL's various hidapi controller implementations can be used in these situations |
Yeah, we'll need official permission from @berarma to relicense code based on their work under the Zlib license for SDL. |
My work is based on the Linux lg4ff module. I added code to implement more effects other than the constant effect and some tweaking features. I'm not sure I'm in a position to decide this. |
Then I believe yet another person to ping would be @mungewell, going by the header of hid-lg4ff.c |
Current implementation does not include SDL_Haptic integration for force feedback Supported devices: G29, G27, G25, DFGT, DFP Features: Joystick button, hat and axis input 5 level rev light control on SDL_JoystickSetLED raw hid command sending on SDL_JoystickSendEffect all command sending are based on https://github.com/berarma/new-lg4ff tested on G29 in various compat modes shifter input is not tested because I don't have one
effect rendering is ported from https://github.com/berarma/new-lg4ff
If a SDL_Joystick internal lookup manages to define a joystick type that is not game controller, it should stay as a joystick
- add new files to Makefile.os2 and Makefile.w32 - fix negative return check from SDL_hid_read() - fix SDL_HIDAPI_HapticDestroyEffect() as it returns void - fix C89 build issues - change an sprintf() call to SDL_snprintf() - fix a -Wuninitialized warning - add casts Sint32 and float casts to avoid warnings - add missing newlines to new files
Happy holiday seasons!
Attaching email exchange with @mungewell , @MadCatX and @slouken here, once again thank you so much @mungewell @MadCatX for being so forth coming with the license conversion: Permission to port hid-lg4ff to SDL2_3.mbox.txt
@berarma Your effect rendering code still brings enhancement to the driver, and I'd love to be able to include them in this port. To do so, I'd still need your explicit permission |
Here is a minor clean-up patch. (Possibly applies to the SDL3 version too.) Pick from it as you like.
|
I give permission to re-licence my code in new-lg4ff under the Zlib license. |
- make _abs,_llabs, get_time_ms, effect_is_periodic, effect_is_condition helpers static inline. - rename _abs and _llabs to abs32 and abs64 to avoid analyzers complain about reserved names. - make the drivers[] array static. - NULL terminate the drivers[] array to avoid an empty array in case if SDL_HAPTIC_HIDAPI_LG4FF isn't configured. - minor formatting clean-ups here and there. - remove #endif comments about SDL_JOYSTICK_HIDAPI for readability. those #if / #endif blocks are short enough already.
Thanks for the patch!
Thank you! |
Hi @Kethen, it sounds like you have permission from the authors to use this code. Great job! Can you please note that on the SDL3 PR and link to the relevant comments in this pull request? We're getting close to 3.2.0 release, so I'll bump your SDL3 PR to the 3.4.0 milestone where it is likely to be accepted. |
I see that our names don't appear in the headings of the files where our code is used, only above the corresponding functions. Is that correct? |
@Kethen, the convention is to add copyright holders to the license at the top, e.g. SDL/src/camera/pipewire/SDL_camera_pipewire.c Lines 3 to 4 in 23410de
|
Hello @slouken, currently ported functions are annotated this way SDL/src/haptic/hidapi/SDL_hidapihaptic_lg4ff.c Lines 1140 to 1148 in 54f4837
What would be appropriate to add to the header of files in this PR (and the SDL3 PR) containing ported code? |
Maybe you can ask the contributors how they would like to be credited? |
This is what I expected. In my very basic understanding of copyright law, in the current form, it looks as if we had transferred copyrights. Sincerely, I don't know how important this might be, but is there any issue in following the convention? |
No, no issue at all. |
@slouken In that case, copyrights of authors of ported code are now added to license headers |
Description
These changes enable the Logitech G29 wheel to run on hidapi with both SDL_Joystick and SDL_Haptic interfaces.
While it is already possible to use the wheel on Linux in WINE + SDL2 thanks to the in-tree evdev driver as well as new-lg4ff, these set of changes allow the G29 to be used with WINE under MacOS and FreeBSD
These wheels should also be supported, but I can only test them from G29's compat modes: G27, G25, DFGT, DFP, DFEX
Haptic and led support are ported from https://github.com/berarma/new-lg4ff so giving @berarma a ping here
Companion test program for testing SDL_Joystick input events, changing wheel compat mode and testing SDL_Haptic calls
https://github.com/Kethen/sdl_lg4ff_util/
Help wanted for this pull request
Help wanted for future pull requests
Existing Issue(s)
#6540