Skip to content

Commit 354895d

Browse files
authored
Add Flydigi VADER 4 Pro HIDAPI support (#12874)
1 parent 8d9a4fe commit 354895d

File tree

14 files changed

+461
-2
lines changed

14 files changed

+461
-2
lines changed

VisualC-GDK/SDL/SDL.vcxproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -713,6 +713,7 @@
713713
<ClCompile Include="..\..\src\joystick\gdk\SDL_gameinputjoystick.cpp" />
714714
<ClCompile Include="..\..\src\joystick\hidapi\SDL_hidapijoystick.c" />
715715
<ClCompile Include="..\..\src\joystick\hidapi\SDL_hidapi_8bitdo.c" />
716+
<ClCompile Include="..\..\src\joystick\hidapi\SDL_hidapi_flydigi.c" />
716717
<ClCompile Include="..\..\src\joystick\hidapi\SDL_hidapi_combined.c" />
717718
<ClCompile Include="..\..\src\joystick\hidapi\SDL_hidapi_gamecube.c" />
718719
<ClCompile Include="..\..\src\joystick\hidapi\SDL_hidapi_gip.c" />

VisualC-GDK/SDL/SDL.vcxproj.filters

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
<ClCompile Include="..\..\src\joystick\gdk\SDL_gameinputjoystick.cpp" />
6565
<ClCompile Include="..\..\src\joystick\hidapi\SDL_hidapijoystick.c" />
6666
<ClCompile Include="..\..\src\joystick\hidapi\SDL_hidapi_8bitdo.c" />
67+
<ClCompile Include="..\..\src\joystick\hidapi\SDL_hidapi_flydigi.c" />
6768
<ClCompile Include="..\..\src\joystick\hidapi\SDL_hidapi_combined.c" />
6869
<ClCompile Include="..\..\src\joystick\hidapi\SDL_hidapi_gamecube.c" />
6970
<ClCompile Include="..\..\src\joystick\hidapi\SDL_hidapi_gip.c" />

VisualC/SDL/SDL.vcxproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -603,6 +603,7 @@
603603
</ClCompile>
604604
<ClCompile Include="..\..\src\joystick\hidapi\SDL_hidapijoystick.c" />
605605
<ClCompile Include="..\..\src\joystick\hidapi\SDL_hidapi_8bitdo.c" />
606+
<ClCompile Include="..\..\src\joystick\hidapi\SDL_hidapi_flydigi.c" />
606607
<ClCompile Include="..\..\src\joystick\hidapi\SDL_hidapi_combined.c" />
607608
<ClCompile Include="..\..\src\joystick\hidapi\SDL_hidapi_gamecube.c" />
608609
<ClCompile Include="..\..\src\joystick\hidapi\SDL_hidapi_gip.c" />

VisualC/SDL/SDL.vcxproj.filters

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1185,6 +1185,9 @@
11851185
<ClCompile Include="..\..\src\joystick\hidapi\SDL_hidapi_8bitdo.c">
11861186
<Filter>joystick\hidapi</Filter>
11871187
</ClCompile>
1188+
<ClCompile Include="..\..\src\joystick\hidapi\SDL_hidapi_flydigi.c">
1189+
<Filter>joystick\hidapi</Filter>
1190+
</ClCompile>
11881191
<ClCompile Include="..\..\src\joystick\hidapi\SDL_hidapi_combined.c">
11891192
<Filter>joystick\hidapi</Filter>
11901193
</ClCompile>

Xcode/SDL/SDL.xcodeproj/project.pbxproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,7 @@
389389
F338A1182D1B37D8007CDFDF /* SDL_tray.m in Sources */ = {isa = PBXBuildFile; fileRef = F338A1172D1B37D8007CDFDF /* SDL_tray.m */; };
390390
F338A11A2D1B37E4007CDFDF /* SDL_tray.c in Sources */ = {isa = PBXBuildFile; fileRef = F338A1192D1B37E4007CDFDF /* SDL_tray.c */; };
391391
F3395BA82D9A5971007246C8 /* SDL_hidapi_8bitdo.c in Sources */ = {isa = PBXBuildFile; fileRef = F3395BA72D9A5971007246C8 /* SDL_hidapi_8bitdo.c */; };
392+
F3395BA82D9A5971007246C9 /* SDL_hidapi_flydigi.c in Sources */ = {isa = PBXBuildFile; fileRef = F3395BA72D9A5971007246C9 /* SDL_hidapi_flydigi.c */; };
392393
F34400342D40217A003F26D7 /* LICENSE.txt in Resources */ = {isa = PBXBuildFile; fileRef = F373DA182D388A1E002158FA /* LICENSE.txt */; };
393394
F34400362D40217A003F26D7 /* README.md in Resources */ = {isa = PBXBuildFile; fileRef = F373DA192D388A1E002158FA /* README.md */; };
394395
F344003D2D4022E1003F26D7 /* INSTALL.md in Resources */ = {isa = PBXBuildFile; fileRef = F344003C2D4022E1003F26D7 /* INSTALL.md */; };
@@ -949,6 +950,7 @@
949950
F338A1172D1B37D8007CDFDF /* SDL_tray.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SDL_tray.m; sourceTree = "<group>"; };
950951
F338A1192D1B37E4007CDFDF /* SDL_tray.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = SDL_tray.c; sourceTree = "<group>"; };
951952
F3395BA72D9A5971007246C8 /* SDL_hidapi_8bitdo.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = SDL_hidapi_8bitdo.c; sourceTree = "<group>"; };
953+
F3395BA72D9A5971007246C9 /* SDL_hidapi_flydigi.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = SDL_hidapi_flydigi.c; sourceTree = "<group>"; };
952954
F344003C2D4022E1003F26D7 /* INSTALL.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = INSTALL.md; sourceTree = "<group>"; };
953955
F362B9152B3349E200D30B94 /* controller_list.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = controller_list.h; sourceTree = "<group>"; };
954956
F362B9162B3349E200D30B94 /* SDL_gamepad_c.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_gamepad_c.h; sourceTree = "<group>"; };
@@ -1928,6 +1930,7 @@
19281930
isa = PBXGroup;
19291931
children = (
19301932
F3395BA72D9A5971007246C8 /* SDL_hidapi_8bitdo.c */,
1933+
F3395BA72D9A5971007246C9 /* SDL_hidapi_flydigi.c */,
19311934
F32305FE28939F6400E66D30 /* SDL_hidapi_combined.c */,
19321935
A7D8A7C923E2513E00DCD162 /* SDL_hidapi_gamecube.c */,
19331936
F3B6B8092DC3EA54004954FD /* SDL_hidapi_gip.c */,

include/SDL3/SDL_hints.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1746,6 +1746,18 @@ extern "C" {
17461746
*/
17471747
#define SDL_HINT_JOYSTICK_HIDAPI_8BITDO "SDL_JOYSTICK_HIDAPI_8BITDO"
17481748

1749+
/**
1750+
* A variable controlling whether the HIDAPI driver for Flydigi controllers
1751+
* should be used.
1752+
*
1753+
* This variable can be set to the following values:
1754+
*
1755+
* "0" - HIDAPI driver is not used. "1" - HIDAPI driver is used.
1756+
*
1757+
* The default is the value of SDL_HINT_JOYSTICK_HIDAPI
1758+
*/
1759+
#define SDL_HINT_JOYSTICK_HIDAPI_FLYDIGI "SDL_JOYSTICK_HIDAPI_FLYDIGI"
1760+
17491761
/**
17501762
* A variable controlling whether the HIDAPI driver for Nintendo Switch
17511763
* controllers should be used.

src/hidapi/SDL_hidapi.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1109,6 +1109,11 @@ bool SDL_HIDAPI_ShouldIgnoreDevice(int bus, Uint16 vendor_id, Uint16 product_id,
11091109
(usage == USB_USAGE_GENERIC_KEYBOARD || usage == USB_USAGE_GENERIC_MOUSE)) {
11101110
return true;
11111111
}
1112+
} else if (vendor_id == USB_VENDOR_FLYDIGI && product_id == USB_PRODUCT_FLYDIGI_VADER4_PRO) {
1113+
if (usage_page == USB_USAGEPAGE_VENDOR_FLYDIGI) {
1114+
return false;
1115+
}
1116+
return true;
11121117
} else if (usage_page == USB_USAGEPAGE_GENERIC_DESKTOP &&
11131118
(usage == USB_USAGE_GENERIC_JOYSTICK || usage == USB_USAGE_GENERIC_GAMEPAD || usage == USB_USAGE_GENERIC_MULTIAXISCONTROLLER)) {
11141119
// This is a controller

src/joystick/SDL_gamepad.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -829,7 +829,9 @@ static GamepadMapping_t *SDL_CreateMappingForHIDAPIGamepad(SDL_GUID guid)
829829
}
830830
} else if (SDL_IsJoystickHoriSteamController(vendor, product)) {
831831
/* The Wireless HORIPad for Steam has QAM, Steam, Capsense L/R Sticks, 2 rear buttons, and 2 misc buttons */
832-
SDL_strlcat(mapping_string, "paddle1:b13,paddle2:b12,paddle3:b15,paddle4:b14,misc2:b11,misc3:b16,misc4:b17,", sizeof(mapping_string));
832+
SDL_strlcat(mapping_string, "paddle1:b13,paddle2:b12,paddle3:b15,paddle4:b14,misc2:b11,misc3:b16,misc4:b17", sizeof(mapping_string));
833+
} else if (SDL_IsJoystickFlydigiController(vendor, product)) {
834+
SDL_strlcat(mapping_string, "paddle1:b11,paddle2:b12,paddle3:b13,paddle4:b14,misc1:b15,misc2:b16,misc3:b17", sizeof(mapping_string));
833835
} else if (vendor == USB_VENDOR_8BITDO && product == USB_PRODUCT_8BITDO_ULTIMATE2_WIRELESS) {
834836
SDL_strlcat(mapping_string, "paddle1:b12,paddle2:b11,paddle3:b14,paddle4:b13,", sizeof(mapping_string));
835837
} else {

src/joystick/SDL_joystick.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3175,6 +3175,11 @@ bool SDL_IsJoystickHoriSteamController(Uint16 vendor_id, Uint16 product_id)
31753175
return vendor_id == USB_VENDOR_HORI && (product_id == USB_PRODUCT_HORI_STEAM_CONTROLLER || product_id == USB_PRODUCT_HORI_STEAM_CONTROLLER_BT);
31763176
}
31773177

3178+
bool SDL_IsJoystickFlydigiController(Uint16 vendor_id, Uint16 product_id)
3179+
{
3180+
return vendor_id == USB_VENDOR_FLYDIGI && (product_id == USB_PRODUCT_FLYDIGI_VADER4_PRO);
3181+
}
3182+
31783183
bool SDL_IsJoystickSteamDeck(Uint16 vendor_id, Uint16 product_id)
31793184
{
31803185
EControllerType eType = GuessControllerType(vendor_id, product_id);

src/joystick/SDL_joystick_c.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,9 @@ extern bool SDL_IsJoystickSteamController(Uint16 vendor_id, Uint16 product_id);
135135
// Function to return whether a joystick is a HORI Steam controller
136136
extern bool SDL_IsJoystickHoriSteamController(Uint16 vendor_id, Uint16 product_id);
137137

138+
// Function to return whether a joystick is a Flydigi controller
139+
extern bool SDL_IsJoystickFlydigiController(Uint16 vendor_id, Uint16 product_id);
140+
138141
// Function to return whether a joystick is a Steam Deck
139142
extern bool SDL_IsJoystickSteamDeck(Uint16 vendor_id, Uint16 product_id);
140143

0 commit comments

Comments
 (0)