Skip to content

Commit 35c0377

Browse files
authored
[SDL3] Adding input and FFB support for Logitech G29(PS3) on hidapi (#11598)
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
1 parent d66483d commit 35c0377

17 files changed

+2887
-18
lines changed

Android.mk

+1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ LOCAL_SRC_FILES := \
4242
$(wildcard $(LOCAL_PATH)/src/haptic/*.c) \
4343
$(wildcard $(LOCAL_PATH)/src/haptic/android/*.c) \
4444
$(wildcard $(LOCAL_PATH)/src/haptic/dummy/*.c) \
45+
$(wildcard $(LOCAL_PATH)/src/haptic/hidapi/*.c) \
4546
$(wildcard $(LOCAL_PATH)/src/hidapi/*.c) \
4647
$(wildcard $(LOCAL_PATH)/src/hidapi/android/*.cpp) \
4748
$(wildcard $(LOCAL_PATH)/src/joystick/*.c) \

VisualC-GDK/SDL/SDL.vcxproj

+5
Original file line numberDiff line numberDiff line change
@@ -454,8 +454,10 @@
454454
<ClInclude Include="..\..\src\io\SDL_sysasyncio.h" />
455455
<ClInclude Include="..\..\src\haptic\SDL_haptic_c.h" />
456456
<ClInclude Include="..\..\src\haptic\SDL_syshaptic.h" />
457+
<ClInclude Include="..\..\src\haptic\SDL_hidapihaptic.h" />
457458
<ClInclude Include="..\..\src\haptic\windows\SDL_dinputhaptic_c.h" />
458459
<ClInclude Include="..\..\src\haptic\windows\SDL_windowshaptic_c.h" />
460+
<ClInclude Include="..\..\src\haptic\hidapi\SDL_hidapihaptic_c.h" />
459461
<ClInclude Include="..\..\src\hidapi\hidapi\hidapi.h" />
460462
<ClInclude Include="..\..\src\hidapi\SDL_hidapi_c.h" />
461463
<ClInclude Include="..\..\src\joystick\controller_type.h" />
@@ -703,6 +705,8 @@
703705
<LanguageStandard Condition="'$(Configuration)|$(Platform)'=='Release|Gaming.Xbox.Scarlett.x64'">stdcpp17</LanguageStandard>
704706
<LanguageStandard Condition="'$(Configuration)|$(Platform)'=='Release|Gaming.Xbox.XboxOne.x64'">stdcpp17</LanguageStandard>
705707
</ClCompile>
708+
<ClCompile Include="..\..\src\haptic\hidapi\SDL_hidapihaptic.c" />
709+
<ClCompile Include="..\..\src\haptic\hidapi\SDL_hidapihaptic_lg4ff.c" />
706710
<ClCompile Include="..\..\src\hidapi\SDL_hidapi.c" />
707711
<ClCompile Include="..\..\src\joystick\controller_type.c" />
708712
<ClCompile Include="..\..\src\joystick\dummy\SDL_sysjoystick.c" />
@@ -725,6 +729,7 @@
725729
<ClCompile Include="..\..\src\joystick\hidapi\SDL_hidapi_xbox360.c" />
726730
<ClCompile Include="..\..\src\joystick\hidapi\SDL_hidapi_xbox360w.c" />
727731
<ClCompile Include="..\..\src\joystick\hidapi\SDL_hidapi_xboxone.c" />
732+
<ClCompile Include="..\..\src\joystick\hidapi\SDL_hidapi_lg4ff.c" />
728733
<ClCompile Include="..\..\src\joystick\SDL_gamepad.c" />
729734
<ClCompile Include="..\..\src\joystick\SDL_joystick.c" />
730735
<ClCompile Include="..\..\src\joystick\SDL_steam_virtual_gamepad.c" />

VisualC-GDK/SDL/SDL.vcxproj.filters

+5
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@
5656
<ClCompile Include="..\..\src\haptic\SDL_haptic.c" />
5757
<ClCompile Include="..\..\src\haptic\windows\SDL_dinputhaptic.c" />
5858
<ClCompile Include="..\..\src\haptic\windows\SDL_windowshaptic.c" />
59+
<ClCompile Include="..\..\src\haptic\hidapi\SDL_hidapihaptic.c" />
60+
<ClCompile Include="..\..\src\haptic\hidapi\SDL_hidapihaptic_lg4ff.c" />
5961
<ClCompile Include="..\..\src\hidapi\SDL_hidapi.c" />
6062
<ClCompile Include="..\..\src\joystick\controller_type.c" />
6163
<ClCompile Include="..\..\src\joystick\dummy\SDL_sysjoystick.c" />
@@ -78,6 +80,7 @@
7880
<ClCompile Include="..\..\src\joystick\hidapi\SDL_hidapi_xbox360.c" />
7981
<ClCompile Include="..\..\src\joystick\hidapi\SDL_hidapi_xbox360w.c" />
8082
<ClCompile Include="..\..\src\joystick\hidapi\SDL_hidapi_xboxone.c" />
83+
<ClCompile Include="..\..\src\joystick\hidapi\SDL_hidapi_lg4ff.c" />
8184
<ClCompile Include="..\..\src\joystick\SDL_gamepad.c" />
8285
<ClCompile Include="..\..\src\joystick\SDL_joystick.c" />
8386
<ClCompile Include="..\..\src\joystick\SDL_steam_virtual_gamepad.c" />
@@ -343,8 +346,10 @@
343346
<ClInclude Include="..\..\src\gpu\SDL_sysgpu.h" />
344347
<ClInclude Include="..\..\src\haptic\SDL_haptic_c.h" />
345348
<ClInclude Include="..\..\src\haptic\SDL_syshaptic.h" />
349+
<ClInclude Include="..\..\src\haptic\SDL_hidapihaptic.h" />
346350
<ClInclude Include="..\..\src\haptic\windows\SDL_dinputhaptic_c.h" />
347351
<ClInclude Include="..\..\src\haptic\windows\SDL_windowshaptic_c.h" />
352+
<ClInclude Include="..\..\src\haptic\hidapi\SDL_hidapihaptic_c.h" />
348353
<ClInclude Include="..\..\src\hidapi\hidapi\hidapi.h" />
349354
<ClInclude Include="..\..\src\hidapi\SDL_hidapi_c.h" />
350355
<ClInclude Include="..\..\src\joystick\controller_type.h" />

VisualC/SDL/SDL.vcxproj

+5
Original file line numberDiff line numberDiff line change
@@ -367,8 +367,10 @@
367367
<ClInclude Include="..\..\src\io\SDL_sysasyncio.h" />
368368
<ClInclude Include="..\..\src\haptic\SDL_haptic_c.h" />
369369
<ClInclude Include="..\..\src\haptic\SDL_syshaptic.h" />
370+
<ClInclude Include="..\..\src\haptic\SDL_hidapihaptic.h" />
370371
<ClInclude Include="..\..\src\haptic\windows\SDL_dinputhaptic_c.h" />
371372
<ClInclude Include="..\..\src\haptic\windows\SDL_windowshaptic_c.h" />
373+
<ClInclude Include="..\..\src\haptic\hidapi\SDL_hidapihaptic_c.h" />
372374
<ClInclude Include="..\..\src\hidapi\hidapi\hidapi.h" />
373375
<ClInclude Include="..\..\src\hidapi\SDL_hidapi_c.h" />
374376
<ClInclude Include="..\..\src\joystick\controller_type.h" />
@@ -573,6 +575,8 @@
573575
<ClCompile Include="..\..\src\haptic\SDL_haptic.c" />
574576
<ClCompile Include="..\..\src\haptic\windows\SDL_dinputhaptic.c" />
575577
<ClCompile Include="..\..\src\haptic\windows\SDL_windowshaptic.c" />
578+
<ClCompile Include="..\..\src\haptic\hidapi\SDL_hidapihaptic.c" />
579+
<ClCompile Include="..\..\src\haptic\hidapi\SDL_hidapihaptic_lg4ff.c" />
576580
<ClCompile Include="..\..\src\hidapi\SDL_hidapi.c" />
577581
<ClCompile Include="..\..\src\joystick\controller_type.c" />
578582
<ClCompile Include="..\..\src\joystick\dummy\SDL_sysjoystick.c" />
@@ -595,6 +599,7 @@
595599
<ClCompile Include="..\..\src\joystick\hidapi\SDL_hidapi_xbox360.c" />
596600
<ClCompile Include="..\..\src\joystick\hidapi\SDL_hidapi_xbox360w.c" />
597601
<ClCompile Include="..\..\src\joystick\hidapi\SDL_hidapi_xboxone.c" />
602+
<ClCompile Include="..\..\src\joystick\hidapi\SDL_hidapi_lg4ff.c" />
598603
<ClCompile Include="..\..\src\joystick\SDL_gamepad.c" />
599604
<ClCompile Include="..\..\src\joystick\SDL_joystick.c" />
600605
<ClCompile Include="..\..\src\joystick\SDL_steam_virtual_gamepad.c" />

VisualC/SDL/SDL.vcxproj.filters

+18
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@
8282
<Filter Include="haptic\windows">
8383
<UniqueIdentifier>{ebc2fca3-3c26-45e3-815e-3e0581d5e226}</UniqueIdentifier>
8484
</Filter>
85+
<Filter Include="haptic\hidapi">
86+
<UniqueIdentifier>{06DB01C0-65B5-4DE7-8ADC-C0B0CA3A1E69}</UniqueIdentifier>
87+
</Filter>
8588
<Filter Include="haptic\dummy">
8689
<UniqueIdentifier>{47c445a2-7014-4e15-9660-7c89a27dddcf}</UniqueIdentifier>
8790
</Filter>
@@ -564,6 +567,9 @@
564567
<ClInclude Include="..\..\src\haptic\SDL_syshaptic.h">
565568
<Filter>haptic</Filter>
566569
</ClInclude>
570+
<ClInclude Include="..\..\src\haptic\SDL_hidapihaptic.h">
571+
<Filter>haptic</Filter>
572+
</ClInclude>
567573
<ClInclude Include="..\..\src\haptic\SDL_haptic_c.h">
568574
<Filter>haptic</Filter>
569575
</ClInclude>
@@ -621,6 +627,9 @@
621627
<ClInclude Include="..\..\src\haptic\windows\SDL_windowshaptic_c.h">
622628
<Filter>haptic\windows</Filter>
623629
</ClInclude>
630+
<ClInclude Include="..\..\src\haptic\hidapi\SDL_hidapihaptic_c.h">
631+
<Filter>haptic\hidapi</Filter>
632+
</ClInclude>
624633
<ClInclude Include="..\..\src\joystick\hidapi\SDL_hidapijoystick_c.h">
625634
<Filter>joystick\hidapi</Filter>
626635
</ClInclude>
@@ -1163,6 +1172,12 @@
11631172
<ClCompile Include="..\..\src\haptic\windows\SDL_windowshaptic.c">
11641173
<Filter>haptic\windows</Filter>
11651174
</ClCompile>
1175+
<ClCompile Include="..\..\src\haptic\hidapi\SDL_hidapihaptic.c">
1176+
<Filter>haptic\hidapi</Filter>
1177+
</ClCompile>
1178+
<ClCompile Include="..\..\src\haptic\hidapi\SDL_hidapihaptic_lg4ff.c">
1179+
<Filter>haptic\hidapi</Filter>
1180+
</ClCompile>
11661181
<ClCompile Include="..\..\src\haptic\dummy\SDL_syshaptic.c">
11671182
<Filter>haptic\dummy</Filter>
11681183
</ClCompile>
@@ -1223,6 +1238,9 @@
12231238
<ClCompile Include="..\..\src\joystick\hidapi\SDL_hidapi_xboxone.c">
12241239
<Filter>joystick\hidapi</Filter>
12251240
</ClCompile>
1241+
<ClCompile Include="..\..\src\joystick\hidapi\SDL_hidapi_lg4ff.c">
1242+
<Filter>joystick\hidapi</Filter>
1243+
</ClCompile>
12261244
<ClCompile Include="..\..\src\joystick\hidapi\SDL_hidapijoystick.c">
12271245
<Filter>joystick\hidapi</Filter>
12281246
</ClCompile>

Xcode/SDL/SDL.xcodeproj/project.pbxproj

+24
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,10 @@
7171
63134A262A7902FD0021E9A6 /* SDL_pen.c in Sources */ = {isa = PBXBuildFile; fileRef = 63134A242A7902FD0021E9A6 /* SDL_pen.c */; };
7272
75E0915A241EA924004729E1 /* SDL_virtualjoystick.c in Sources */ = {isa = PBXBuildFile; fileRef = 75E09158241EA924004729E1 /* SDL_virtualjoystick.c */; };
7373
75E09163241EA924004729E1 /* SDL_virtualjoystick_c.h in Headers */ = {isa = PBXBuildFile; fileRef = 75E09159241EA924004729E1 /* SDL_virtualjoystick_c.h */; };
74+
89E5801E2D03602200DAF6D3 /* SDL_hidapi_lg4ff.c in Sources */ = {isa = PBXBuildFile; fileRef = 89E5801D2D03602200DAF6D3 /* SDL_hidapi_lg4ff.c */; };
75+
89E580232D03606400DAF6D3 /* SDL_hidapihaptic.c in Sources */ = {isa = PBXBuildFile; fileRef = 89E5801F2D03606400DAF6D3 /* SDL_hidapihaptic.c */; };
76+
89E580242D03606400DAF6D3 /* SDL_hidapihaptic_lg4ff.c in Sources */ = {isa = PBXBuildFile; fileRef = 89E580212D03606400DAF6D3 /* SDL_hidapihaptic_lg4ff.c */; };
77+
89E580252D03606400DAF6D3 /* SDL_hidapihaptic_c.h in Headers */ = {isa = PBXBuildFile; fileRef = 89E580202D03606400DAF6D3 /* SDL_hidapihaptic_c.h */; };
7478
9846B07C287A9020000C35C8 /* SDL_hidapi_shield.c in Sources */ = {isa = PBXBuildFile; fileRef = 9846B07B287A9020000C35C8 /* SDL_hidapi_shield.c */; };
7579
A1626A3E2617006A003F1973 /* SDL_triangle.c in Sources */ = {isa = PBXBuildFile; fileRef = A1626A3D2617006A003F1973 /* SDL_triangle.c */; };
7680
A1626A522617008D003F1973 /* SDL_triangle.h in Headers */ = {isa = PBXBuildFile; fileRef = A1626A512617008C003F1973 /* SDL_triangle.h */; };
@@ -608,6 +612,10 @@
608612
63134A242A7902FD0021E9A6 /* SDL_pen.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_pen.c; sourceTree = "<group>"; };
609613
75E09158241EA924004729E1 /* SDL_virtualjoystick.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_virtualjoystick.c; sourceTree = "<group>"; };
610614
75E09159241EA924004729E1 /* SDL_virtualjoystick_c.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_virtualjoystick_c.h; sourceTree = "<group>"; };
615+
89E5801D2D03602200DAF6D3 /* SDL_hidapi_lg4ff.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = SDL_hidapi_lg4ff.c; sourceTree = "<group>"; };
616+
89E5801F2D03606400DAF6D3 /* SDL_hidapihaptic.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = SDL_hidapihaptic.c; sourceTree = "<group>"; };
617+
89E580202D03606400DAF6D3 /* SDL_hidapihaptic_c.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SDL_hidapihaptic_c.h; sourceTree = "<group>"; };
618+
89E580212D03606400DAF6D3 /* SDL_hidapihaptic_lg4ff.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = SDL_hidapihaptic_lg4ff.c; sourceTree = "<group>"; };
611619
9846B07B287A9020000C35C8 /* SDL_hidapi_shield.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_hidapi_shield.c; sourceTree = "<group>"; };
612620
A1626A3D2617006A003F1973 /* SDL_triangle.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_triangle.c; sourceTree = "<group>"; };
613621
A1626A512617008C003F1973 /* SDL_triangle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_triangle.h; sourceTree = "<group>"; };
@@ -1477,6 +1485,16 @@
14771485
path = virtual;
14781486
sourceTree = "<group>";
14791487
};
1488+
89E580222D03606400DAF6D3 /* hidapi */ = {
1489+
isa = PBXGroup;
1490+
children = (
1491+
89E5801F2D03606400DAF6D3 /* SDL_hidapihaptic.c */,
1492+
89E580202D03606400DAF6D3 /* SDL_hidapihaptic_c.h */,
1493+
89E580212D03606400DAF6D3 /* SDL_hidapihaptic_lg4ff.c */,
1494+
);
1495+
path = hidapi;
1496+
sourceTree = "<group>";
1497+
};
14801498
A75FDAA423E2790500529352 /* ios */ = {
14811499
isa = PBXGroup;
14821500
children = (
@@ -1535,6 +1553,7 @@
15351553
A7D8A5C223E2513D00DCD162 /* haptic */ = {
15361554
isa = PBXGroup;
15371555
children = (
1556+
89E580222D03606400DAF6D3 /* hidapi */,
15381557
A7D8A5CD23E2513D00DCD162 /* darwin */,
15391558
A7D8A5C323E2513D00DCD162 /* dummy */,
15401559
A7D8A5C623E2513D00DCD162 /* SDL_haptic_c.h */,
@@ -1904,6 +1923,7 @@
19041923
A7D8A7BE23E2513E00DCD162 /* hidapi */ = {
19051924
isa = PBXGroup;
19061925
children = (
1926+
89E5801D2D03602200DAF6D3 /* SDL_hidapi_lg4ff.c */,
19071927
F32305FE28939F6400E66D30 /* SDL_hidapi_combined.c */,
19081928
A7D8A7C923E2513E00DCD162 /* SDL_hidapi_gamecube.c */,
19091929
F3F07D59269640160074468B /* SDL_hidapi_luna.c */,
@@ -2617,6 +2637,7 @@
26172637
F37E18642BAA40670098C111 /* SDL_time_c.h in Headers */,
26182638
F31013C82C24E98200FBE946 /* SDL_keymap_c.h in Headers */,
26192639
63134A252A7902FD0021E9A6 /* SDL_pen_c.h in Headers */,
2640+
89E580252D03606400DAF6D3 /* SDL_hidapihaptic_c.h in Headers */,
26202641
F36C34312C0F876500991150 /* SDL_offscreenvulkan.h in Headers */,
26212642
A7D8B2C023E2514200DCD162 /* SDL_pixels_c.h in Headers */,
26222643
F37E18622BAA40090098C111 /* SDL_sysfilesystem.h in Headers */,
@@ -2905,6 +2926,8 @@
29052926
A7D8BBDD23E2574800DCD162 /* SDL_uikitmodes.m in Sources */,
29062927
A7D8BA3723E2514400DCD162 /* SDL_d3dmath.c in Sources */,
29072928
F3A9AE9C2C8A13C100AAC390 /* SDL_pipeline_gpu.c in Sources */,
2929+
89E580232D03606400DAF6D3 /* SDL_hidapihaptic.c in Sources */,
2930+
89E580242D03606400DAF6D3 /* SDL_hidapihaptic_lg4ff.c in Sources */,
29082931
75E0915A241EA924004729E1 /* SDL_virtualjoystick.c in Sources */,
29092932
F338A11A2D1B37E4007CDFDF /* SDL_tray.c in Sources */,
29102933
A7D8ABEB23E2514100DCD162 /* SDL_nullvideo.c in Sources */,
@@ -2966,6 +2989,7 @@
29662989
A7D8B76423E2514300DCD162 /* SDL_mixer.c in Sources */,
29672990
A7D8BB5723E2514500DCD162 /* SDL_events.c in Sources */,
29682991
A7D8ADE623E2514100DCD162 /* SDL_blit_0.c in Sources */,
2992+
89E5801E2D03602200DAF6D3 /* SDL_hidapi_lg4ff.c in Sources */,
29692993
A7D8B8A823E2514400DCD162 /* SDL_diskaudio.c in Sources */,
29702994
56A2373329F9C113003CCA5F /* SDL_sysrwlock.c in Sources */,
29712995
F3A9AE9A2C8A13C100AAC390 /* SDL_shaders_gpu.c in Sources */,

cmake/sdlchecks.cmake

+1
Original file line numberDiff line numberDiff line change
@@ -1136,6 +1136,7 @@ macro(CheckHIDAPI)
11361136
set(HAVE_SDL_JOYSTICK TRUE)
11371137
set(HAVE_HIDAPI_JOYSTICK TRUE)
11381138
sdl_glob_sources("${SDL3_SOURCE_DIR}/src/joystick/hidapi/*.c")
1139+
sdl_glob_sources("${SDL3_SOURCE_DIR}/src/haptic/hidapi/*.c")
11391140
endif()
11401141
else()
11411142
set(SDL_HIDAPI_DISABLED 1)

include/SDL3/SDL_hints.h

+13
Original file line numberDiff line numberDiff line change
@@ -1721,6 +1721,19 @@ extern "C" {
17211721
*/
17221722
#define SDL_HINT_JOYSTICK_HIDAPI_STEAM_HORI "SDL_JOYSTICK_HIDAPI_STEAM_HORI"
17231723

1724+
/**
1725+
* A variable controlling whether the HIDAPI driver for some Logitech wheels
1726+
* should be used.
1727+
*
1728+
* This variable can be set to the following values:
1729+
*
1730+
* - "0": HIDAPI driver is not used
1731+
* - "1": HIDAPI driver is used
1732+
*
1733+
* The default is the value of SDL_HINT_JOYSTICK_HIDAPI
1734+
*/
1735+
#define SDL_HINT_JOYSTICK_HIDAPI_LG4FF "SDL_JOYSTICK_HIDAPI_LG4FF"
1736+
17241737
/**
17251738
* A variable controlling whether the HIDAPI driver for Nintendo Switch
17261739
* controllers should be used.

0 commit comments

Comments
 (0)