Skip to content

Commit 00f3a82

Browse files
endriftslouken
authored andcommitted
Joystick: Add new GIP driver to replace old Xbox One wired driver
This new driver is based on official documentation released by Microsoft in September, though it still lacks several important features, notably the Security handshake for wireless dongles and audio support. It is, however, more reliable and extensible than the old driver.
1 parent 48dfc03 commit 00f3a82

File tree

12 files changed

+2471
-0
lines changed

12 files changed

+2471
-0
lines changed

VisualC-GDK/SDL/SDL.vcxproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -715,6 +715,7 @@
715715
<ClCompile Include="..\..\src\joystick\hidapi\SDL_hidapi_8bitdo.c" />
716716
<ClCompile Include="..\..\src\joystick\hidapi\SDL_hidapi_combined.c" />
717717
<ClCompile Include="..\..\src\joystick\hidapi\SDL_hidapi_gamecube.c" />
718+
<ClCompile Include="..\..\src\joystick\hidapi\SDL_hidapi_gip.c" />
718719
<ClCompile Include="..\..\src\joystick\hidapi\SDL_hidapi_luna.c" />
719720
<ClCompile Include="..\..\src\joystick\hidapi\SDL_hidapi_ps3.c" />
720721
<ClCompile Include="..\..\src\joystick\hidapi\SDL_hidapi_ps4.c" />

VisualC-GDK/SDL/SDL.vcxproj.filters

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
<ClCompile Include="..\..\src\joystick\hidapi\SDL_hidapi_8bitdo.c" />
6767
<ClCompile Include="..\..\src\joystick\hidapi\SDL_hidapi_combined.c" />
6868
<ClCompile Include="..\..\src\joystick\hidapi\SDL_hidapi_gamecube.c" />
69+
<ClCompile Include="..\..\src\joystick\hidapi\SDL_hidapi_gip.c" />
6970
<ClCompile Include="..\..\src\joystick\hidapi\SDL_hidapi_luna.c" />
7071
<ClCompile Include="..\..\src\joystick\hidapi\SDL_hidapi_ps3.c" />
7172
<ClCompile Include="..\..\src\joystick\hidapi\SDL_hidapi_ps4.c" />

VisualC/SDL/SDL.vcxproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -605,6 +605,7 @@
605605
<ClCompile Include="..\..\src\joystick\hidapi\SDL_hidapi_8bitdo.c" />
606606
<ClCompile Include="..\..\src\joystick\hidapi\SDL_hidapi_combined.c" />
607607
<ClCompile Include="..\..\src\joystick\hidapi\SDL_hidapi_gamecube.c" />
608+
<ClCompile Include="..\..\src\joystick\hidapi\SDL_hidapi_gip.c" />
608609
<ClCompile Include="..\..\src\joystick\hidapi\SDL_hidapi_luna.c" />
609610
<ClCompile Include="..\..\src\joystick\hidapi\SDL_hidapi_ps3.c" />
610611
<ClCompile Include="..\..\src\joystick\hidapi\SDL_hidapi_ps4.c" />

VisualC/SDL/SDL.vcxproj.filters

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1191,6 +1191,9 @@
11911191
<ClCompile Include="..\..\src\joystick\hidapi\SDL_hidapi_gamecube.c">
11921192
<Filter>joystick\hidapi</Filter>
11931193
</ClCompile>
1194+
<ClCompile Include="..\..\src\joystick\hidapi\SDL_hidapi_gip.c">
1195+
<Filter>joystick\hidapi</Filter>
1196+
</ClCompile>
11941197
<ClCompile Include="..\..\src\joystick\hidapi\SDL_hidapi_luna.c">
11951198
<Filter>joystick\hidapi</Filter>
11961199
</ClCompile>

Xcode/SDL/SDL.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,7 @@
438438
F3B439532C935C2C00792030 /* SDL_posixprocess.c in Sources */ = {isa = PBXBuildFile; fileRef = F3B439522C935C2C00792030 /* SDL_posixprocess.c */; };
439439
F3B439562C937DAB00792030 /* SDL_process.c in Sources */ = {isa = PBXBuildFile; fileRef = F3B439542C937DAB00792030 /* SDL_process.c */; };
440440
F3B439572C937DAB00792030 /* SDL_sysprocess.h in Headers */ = {isa = PBXBuildFile; fileRef = F3B439552C937DAB00792030 /* SDL_sysprocess.h */; };
441+
F3B6B80A2DC3EA54004954FD /* SDL_hidapi_gip.c in Sources */ = {isa = PBXBuildFile; fileRef = F3B6B8092DC3EA54004954FD /* SDL_hidapi_gip.c */; };
441442
F3C1BD752D1F1A3000846529 /* SDL_tray_utils.c in Sources */ = {isa = PBXBuildFile; fileRef = F3C1BD742D1F1A3000846529 /* SDL_tray_utils.c */; };
442443
F3C1BD762D1F1A3000846529 /* SDL_tray_utils.h in Headers */ = {isa = PBXBuildFile; fileRef = F3C1BD732D1F1A3000846529 /* SDL_tray_utils.h */; };
443444
F3C2CB222C5DDDB2004D7998 /* SDL_categories_c.h in Headers */ = {isa = PBXBuildFile; fileRef = F3C2CB202C5DDDB2004D7998 /* SDL_categories_c.h */; };
@@ -1012,6 +1013,7 @@
10121013
F3B439522C935C2C00792030 /* SDL_posixprocess.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_posixprocess.c; sourceTree = "<group>"; };
10131014
F3B439542C937DAB00792030 /* SDL_process.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_process.c; sourceTree = "<group>"; };
10141015
F3B439552C937DAB00792030 /* SDL_sysprocess.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_sysprocess.h; sourceTree = "<group>"; };
1016+
F3B6B8092DC3EA54004954FD /* SDL_hidapi_gip.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = SDL_hidapi_gip.c; sourceTree = "<group>"; };
10151017
F3C1BD732D1F1A3000846529 /* SDL_tray_utils.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SDL_tray_utils.h; sourceTree = "<group>"; };
10161018
F3C1BD742D1F1A3000846529 /* SDL_tray_utils.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = SDL_tray_utils.c; sourceTree = "<group>"; };
10171019
F3C2CB202C5DDDB2004D7998 /* SDL_categories_c.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_categories_c.h; sourceTree = "<group>"; };
@@ -1928,6 +1930,7 @@
19281930
F3395BA72D9A5971007246C8 /* SDL_hidapi_8bitdo.c */,
19291931
F32305FE28939F6400E66D30 /* SDL_hidapi_combined.c */,
19301932
A7D8A7C923E2513E00DCD162 /* SDL_hidapi_gamecube.c */,
1933+
F3B6B8092DC3EA54004954FD /* SDL_hidapi_gip.c */,
19311934
89E5801D2D03602200DAF6D3 /* SDL_hidapi_lg4ff.c */,
19321935
F3F07D59269640160074468B /* SDL_hidapi_luna.c */,
19331936
F3FD042C2C9B755700824C4C /* SDL_hidapi_nintendo.h */,
@@ -3056,6 +3059,7 @@
30563059
A7D8BA5B23E2514400DCD162 /* SDL_shaders_gles2.c in Sources */,
30573060
A7D8B14023E2514200DCD162 /* SDL_blit_1.c in Sources */,
30583061
A7D8BBDB23E2574800DCD162 /* SDL_uikitmetalview.m in Sources */,
3062+
F3B6B80A2DC3EA54004954FD /* SDL_hidapi_gip.c in Sources */,
30593063
A7D8BB1523E2514500DCD162 /* SDL_mouse.c in Sources */,
30603064
F395C19C2569C68F00942BFF /* SDL_iokitjoystick.c in Sources */,
30613065
A7D8B4B223E2514300DCD162 /* SDL_sysjoystick.c in Sources */,

android-project/app/src/main/java/org/libsdl/app/HIDDeviceManager.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,9 +288,13 @@ private boolean isXboxOneController(UsbDevice usbDevice, UsbInterface usbInterfa
288288
0x1532, // Razer Wildcat
289289
0x20d6, // PowerA
290290
0x24c6, // PowerA
291+
0x294b, // Snakebyte
291292
0x2dc8, // 8BitDo
292293
0x2e24, // Hyperkin
294+
0x2e95, // SCUF
295+
0x3285, // Nacon
293296
0x3537, // GameSir
297+
0x366c, // ByoWave
294298
};
295299

296300
if (usbInterface.getId() == 0 &&

include/SDL3/SDL_hints.h

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1949,6 +1949,41 @@ extern "C" {
19491949
*/
19501950
#define SDL_HINT_JOYSTICK_HIDAPI_XBOX_ONE_HOME_LED "SDL_JOYSTICK_HIDAPI_XBOX_ONE_HOME_LED"
19511951

1952+
/**
1953+
* A variable controlling whether the new HIDAPI driver for wired Xbox One
1954+
* (GIP) controllers should be used.
1955+
*
1956+
* The variable can be set to the following values:
1957+
*
1958+
* - "0": HIDAPI driver is not used.
1959+
* - "1": HIDAPI driver is used.
1960+
*
1961+
* The default is the value of SDL_HINT_JOYSTICK_HIDAPI_XBOX_ONE.
1962+
*
1963+
* This hint should be set before initializing joysticks and gamepads.
1964+
*
1965+
* \since This hint is available since SDL 3.4.0.
1966+
*/
1967+
#define SDL_HINT_JOYSTICK_HIDAPI_GIP "SDL_JOYSTICK_HIDAPI_GIP"
1968+
1969+
/**
1970+
* A variable controlling whether the new HIDAPI driver for wired Xbox One
1971+
* (GIP) controllers should reset the controller if it can't get the
1972+
* metadata from the controller.
1973+
*
1974+
* The variable can be set to the following values:
1975+
*
1976+
* - "0": Assume this is a generic controller.
1977+
* - "1": Reset the controller to get metadata.
1978+
*
1979+
* By default the controller is not reset.
1980+
*
1981+
* This hint should be set before initializing joysticks and gamepads.
1982+
*
1983+
* \since This hint is available since SDL 3.4.0.
1984+
*/
1985+
#define SDL_HINT_JOYSTICK_HIDAPI_GIP_RESET_FOR_METADATA "SDL_JOYSTICK_HIDAPI_GIP_RESET_FOR_METADATA"
1986+
19521987
/**
19531988
* A variable controlling whether IOKit should be used for controller
19541989
* handling.

src/hidapi/libusb/hid.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -879,9 +879,13 @@ static int is_xboxone(unsigned short vendor_id, const struct libusb_interface_de
879879
0x1532, /* Razer Wildcat */
880880
0x20d6, /* PowerA */
881881
0x24c6, /* PowerA */
882+
0x294b, /* Snakebyte */
882883
0x2dc8, /* 8BitDo */
883884
0x2e24, /* Hyperkin */
885+
0x2e95, /* SCUF */
886+
0x3285, /* Nacon */
884887
0x3537, /* GameSir */
888+
0x366c, /* ByoWave */
885889
};
886890

887891
if (intf_desc->bInterfaceNumber == 0 &&

0 commit comments

Comments
 (0)