Added HIDAPI joystick drivers for more consistent support for Xbox, PS4 and Nintendo Switch Pro controller support across platforms.

Added SDL_GameControllerRumble() and SDL_JoystickRumble() for simple force feedback outside of the SDL haptics API
This commit is contained in:
Sam Lantinga
2018-08-09 16:00:17 -07:00
parent ba90412cda
commit d2042e1ed4
53 changed files with 6827 additions and 1367 deletions
+18 -1
View File
@@ -31,7 +31,7 @@ LOCAL_SRC_FILES := \
$(wildcard $(LOCAL_PATH)/src/haptic/android/*.c) \ $(wildcard $(LOCAL_PATH)/src/haptic/android/*.c) \
$(wildcard $(LOCAL_PATH)/src/joystick/*.c) \ $(wildcard $(LOCAL_PATH)/src/joystick/*.c) \
$(wildcard $(LOCAL_PATH)/src/joystick/android/*.c) \ $(wildcard $(LOCAL_PATH)/src/joystick/android/*.c) \
$(LOCAL_PATH)/src/joystick/steam/SDL_steamcontroller.c \ $(wildcard $(LOCAL_PATH)/src/joystick/hidapi/*.c) \
$(wildcard $(LOCAL_PATH)/src/loadso/dlopen/*.c) \ $(wildcard $(LOCAL_PATH)/src/loadso/dlopen/*.c) \
$(wildcard $(LOCAL_PATH)/src/power/*.c) \ $(wildcard $(LOCAL_PATH)/src/power/*.c) \
$(wildcard $(LOCAL_PATH)/src/power/android/*.c) \ $(wildcard $(LOCAL_PATH)/src/power/android/*.c) \
@@ -48,6 +48,8 @@ LOCAL_SRC_FILES := \
$(wildcard $(LOCAL_PATH)/src/video/yuv2rgb/*.c) \ $(wildcard $(LOCAL_PATH)/src/video/yuv2rgb/*.c) \
$(wildcard $(LOCAL_PATH)/src/test/*.c)) $(wildcard $(LOCAL_PATH)/src/test/*.c))
LOCAL_SHARED_LIBRARIES := hidapi
LOCAL_CFLAGS += -DGL_GLEXT_PROTOTYPES LOCAL_CFLAGS += -DGL_GLEXT_PROTOTYPES
LOCAL_LDLIBS := -ldl -lGLESv1_CM -lGLESv2 -llog -landroid LOCAL_LDLIBS := -ldl -lGLESv1_CM -lGLESv2 -llog -landroid
@@ -88,4 +90,19 @@ LOCAL_MODULE_FILENAME := libSDL2main
include $(BUILD_STATIC_LIBRARY) include $(BUILD_STATIC_LIBRARY)
###########################
#
# hidapi library
#
###########################
include $(CLEAR_VARS)
LOCAL_CPPFLAGS += -std=c++11
LOCAL_SRC_FILES := $(LOCAL_PATH)/src/hidapi/android/hid.cpp
LOCAL_MODULE := libhidapi
LOCAL_LDLIBS := -llog
include $(BUILD_SHARED_LIBRARY)
+24 -4
View File
@@ -80,6 +80,18 @@
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|x64'" /> <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|x64'" />
<LibraryPath Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">C:\Program Files %28x86%29\Microsoft DirectX SDK %28June 2010%29\Lib\x86;$(LibraryPath)</LibraryPath> <LibraryPath Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">C:\Program Files %28x86%29\Microsoft DirectX SDK %28June 2010%29\Lib\x86;$(LibraryPath)</LibraryPath>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<IncludePath>D:\dev\steam\rel\streaming_client\SDL\src\hidapi\hidapi;$(IncludePath)</IncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<IncludePath>D:\dev\steam\rel\streaming_client\SDL\src\hidapi\hidapi;$(IncludePath)</IncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<IncludePath>D:\dev\steam\rel\streaming_client\SDL\src\hidapi\hidapi;$(IncludePath)</IncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<IncludePath>D:\dev\steam\rel\streaming_client\SDL\src\hidapi\hidapi;$(IncludePath)</IncludePath>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<PreBuildEvent> <PreBuildEvent>
<Command> <Command>
@@ -109,7 +121,7 @@
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ResourceCompile> </ResourceCompile>
<Link> <Link>
<AdditionalDependencies>winmm.lib;imm32.lib;version.lib;%(AdditionalDependencies)</AdditionalDependencies> <AdditionalDependencies>setupapi.lib;winmm.lib;imm32.lib;version.lib;%(AdditionalDependencies)</AdditionalDependencies>
<IgnoreAllDefaultLibraries>true</IgnoreAllDefaultLibraries> <IgnoreAllDefaultLibraries>true</IgnoreAllDefaultLibraries>
<GenerateDebugInformation>true</GenerateDebugInformation> <GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Windows</SubSystem> <SubSystem>Windows</SubSystem>
@@ -140,7 +152,7 @@
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ResourceCompile> </ResourceCompile>
<Link> <Link>
<AdditionalDependencies>winmm.lib;imm32.lib;version.lib;%(AdditionalDependencies)</AdditionalDependencies> <AdditionalDependencies>setupapi.lib;winmm.lib;imm32.lib;version.lib;%(AdditionalDependencies)</AdditionalDependencies>
<IgnoreAllDefaultLibraries>true</IgnoreAllDefaultLibraries> <IgnoreAllDefaultLibraries>true</IgnoreAllDefaultLibraries>
<GenerateDebugInformation>true</GenerateDebugInformation> <GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Windows</SubSystem> <SubSystem>Windows</SubSystem>
@@ -174,7 +186,7 @@
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ResourceCompile> </ResourceCompile>
<Link> <Link>
<AdditionalDependencies>winmm.lib;imm32.lib;version.lib;%(AdditionalDependencies)</AdditionalDependencies> <AdditionalDependencies>setupapi.lib;winmm.lib;imm32.lib;version.lib;%(AdditionalDependencies)</AdditionalDependencies>
<IgnoreAllDefaultLibraries>true</IgnoreAllDefaultLibraries> <IgnoreAllDefaultLibraries>true</IgnoreAllDefaultLibraries>
<GenerateDebugInformation>true</GenerateDebugInformation> <GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Windows</SubSystem> <SubSystem>Windows</SubSystem>
@@ -206,7 +218,7 @@
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ResourceCompile> </ResourceCompile>
<Link> <Link>
<AdditionalDependencies>winmm.lib;imm32.lib;version.lib;%(AdditionalDependencies)</AdditionalDependencies> <AdditionalDependencies>setupapi.lib;winmm.lib;imm32.lib;version.lib;%(AdditionalDependencies)</AdditionalDependencies>
<IgnoreAllDefaultLibraries>true</IgnoreAllDefaultLibraries> <IgnoreAllDefaultLibraries>true</IgnoreAllDefaultLibraries>
<GenerateDebugInformation>true</GenerateDebugInformation> <GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Windows</SubSystem> <SubSystem>Windows</SubSystem>
@@ -318,6 +330,8 @@
<ClInclude Include="..\..\src\haptic\windows\SDL_dinputhaptic_c.h" /> <ClInclude Include="..\..\src\haptic\windows\SDL_dinputhaptic_c.h" />
<ClInclude Include="..\..\src\haptic\windows\SDL_windowshaptic_c.h" /> <ClInclude Include="..\..\src\haptic\windows\SDL_windowshaptic_c.h" />
<ClInclude Include="..\..\src\haptic\windows\SDL_xinputhaptic_c.h" /> <ClInclude Include="..\..\src\haptic\windows\SDL_xinputhaptic_c.h" />
<ClInclude Include="..\..\src\joystick\hidapi\controller_type.h" />
<ClInclude Include="..\..\src\joystick\hidapi\SDL_hidapijoystick_c.h" />
<ClInclude Include="..\..\src\joystick\SDL_joystick_c.h" /> <ClInclude Include="..\..\src\joystick\SDL_joystick_c.h" />
<ClInclude Include="..\..\src\joystick\SDL_sysjoystick.h" /> <ClInclude Include="..\..\src\joystick\SDL_sysjoystick.h" />
<ClInclude Include="..\..\src\joystick\windows\SDL_dinputjoystick_c.h" /> <ClInclude Include="..\..\src\joystick\windows\SDL_dinputjoystick_c.h" />
@@ -411,6 +425,12 @@
<ClCompile Include="..\..\src\haptic\windows\SDL_dinputhaptic.c" /> <ClCompile Include="..\..\src\haptic\windows\SDL_dinputhaptic.c" />
<ClCompile Include="..\..\src\haptic\windows\SDL_windowshaptic.c" /> <ClCompile Include="..\..\src\haptic\windows\SDL_windowshaptic.c" />
<ClCompile Include="..\..\src\haptic\windows\SDL_xinputhaptic.c" /> <ClCompile Include="..\..\src\haptic\windows\SDL_xinputhaptic.c" />
<ClCompile Include="..\..\src\hidapi\windows\hid.c" />
<ClCompile Include="..\..\src\joystick\hidapi\SDL_hidapijoystick.c" />
<ClCompile Include="..\..\src\joystick\hidapi\SDL_hidapi_ps4.c" />
<ClCompile Include="..\..\src\joystick\hidapi\SDL_hidapi_switch.c" />
<ClCompile Include="..\..\src\joystick\hidapi\SDL_hidapi_xbox360.c" />
<ClCompile Include="..\..\src\joystick\hidapi\SDL_hidapi_xboxone.c" />
<ClCompile Include="..\..\src\joystick\SDL_gamecontroller.c" /> <ClCompile Include="..\..\src\joystick\SDL_gamecontroller.c" />
<ClCompile Include="..\..\src\joystick\SDL_joystick.c" /> <ClCompile Include="..\..\src\joystick\SDL_joystick.c" />
<ClCompile Include="..\..\src\joystick\windows\SDL_dinputjoystick.c" /> <ClCompile Include="..\..\src\joystick\windows\SDL_dinputjoystick.c" />
+9 -1
View File
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?> ???<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup> <ItemGroup>
<Filter Include="API Headers"> <Filter Include="API Headers">
@@ -313,6 +313,8 @@
<ClInclude Include="..\..\src\video\yuv2rgb\yuv_rgb.h" /> <ClInclude Include="..\..\src\video\yuv2rgb\yuv_rgb.h" />
<ClInclude Include="..\..\src\render\direct3d11\SDL_shaders_d3d11.h" /> <ClInclude Include="..\..\src\render\direct3d11\SDL_shaders_d3d11.h" />
<ClInclude Include="..\..\src\render\direct3d\SDL_shaders_d3d.h" /> <ClInclude Include="..\..\src\render\direct3d\SDL_shaders_d3d.h" />
<ClInclude Include="..\..\src\joystick\hidapi\controller_type.h" />
<ClInclude Include="..\..\src\joystick\hidapi\SDL_hidapijoystick_c.h" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="..\..\src\libm\e_atan2.c" /> <ClCompile Include="..\..\src\libm\e_atan2.c" />
@@ -454,6 +456,12 @@
<ClCompile Include="..\..\src\video\yuv2rgb\yuv_rgb.c" /> <ClCompile Include="..\..\src\video\yuv2rgb\yuv_rgb.c" />
<ClCompile Include="..\..\src\render\direct3d11\SDL_shaders_d3d11.c" /> <ClCompile Include="..\..\src\render\direct3d11\SDL_shaders_d3d11.c" />
<ClCompile Include="..\..\src\render\direct3d\SDL_shaders_d3d.c" /> <ClCompile Include="..\..\src\render\direct3d\SDL_shaders_d3d.c" />
<ClCompile Include="..\..\src\hidapi\windows\hid.c" />
<ClCompile Include="..\..\src\joystick\hidapi\SDL_hidapi_ps4.c" />
<ClCompile Include="..\..\src\joystick\hidapi\SDL_hidapi_switch.c" />
<ClCompile Include="..\..\src\joystick\hidapi\SDL_hidapi_xbox360.c" />
<ClCompile Include="..\..\src\joystick\hidapi\SDL_hidapi_xboxone.c" />
<ClCompile Include="..\..\src\joystick\hidapi\SDL_hidapijoystick.c" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ResourceCompile Include="..\..\src\main\windows\version.rc" /> <ResourceCompile Include="..\..\src\main\windows\version.rc" />
+69 -19
View File
@@ -110,8 +110,8 @@
56F9D5601DF73BA400C15B5D /* SDL_dataqueue.c in Sources */ = {isa = PBXBuildFile; fileRef = 566726431DF72CF5001DD3DB /* SDL_dataqueue.c */; }; 56F9D5601DF73BA400C15B5D /* SDL_dataqueue.c in Sources */ = {isa = PBXBuildFile; fileRef = 566726431DF72CF5001DD3DB /* SDL_dataqueue.c */; };
93CB792313FC5E5200BD3E05 /* SDL_uikitviewcontroller.h in Headers */ = {isa = PBXBuildFile; fileRef = 93CB792213FC5E5200BD3E05 /* SDL_uikitviewcontroller.h */; }; 93CB792313FC5E5200BD3E05 /* SDL_uikitviewcontroller.h in Headers */ = {isa = PBXBuildFile; fileRef = 93CB792213FC5E5200BD3E05 /* SDL_uikitviewcontroller.h */; };
93CB792613FC5F5300BD3E05 /* SDL_uikitviewcontroller.m in Sources */ = {isa = PBXBuildFile; fileRef = 93CB792513FC5F5300BD3E05 /* SDL_uikitviewcontroller.m */; }; 93CB792613FC5F5300BD3E05 /* SDL_uikitviewcontroller.m in Sources */ = {isa = PBXBuildFile; fileRef = 93CB792513FC5F5300BD3E05 /* SDL_uikitviewcontroller.m */; };
A7A9EEA91F702631002A5589 /* SDL_steamcontroller.c in Sources */ = {isa = PBXBuildFile; fileRef = A7A9EEA71F702631002A5589 /* SDL_steamcontroller.c */; }; A704172E20F7E74800A82227 /* controller_type.h in Headers */ = {isa = PBXBuildFile; fileRef = A704172D20F7E74800A82227 /* controller_type.h */; };
A7A9EEAA1F702631002A5589 /* SDL_steamcontroller.h in Headers */ = {isa = PBXBuildFile; fileRef = A7A9EEA81F702631002A5589 /* SDL_steamcontroller.h */; }; A704172F20F7E76000A82227 /* SDL_gamecontroller.c in Sources */ = {isa = PBXBuildFile; fileRef = AA0AD06116647BBB00CE5896 /* SDL_gamecontroller.c */; };
A7F629241FE06523002F9CC9 /* SDL_uikitmetalview.m in Sources */ = {isa = PBXBuildFile; fileRef = 4D7516F81EE1C28A00820EEA /* SDL_uikitmetalview.m */; }; A7F629241FE06523002F9CC9 /* SDL_uikitmetalview.m in Sources */ = {isa = PBXBuildFile; fileRef = 4D7516F81EE1C28A00820EEA /* SDL_uikitmetalview.m */; };
AA0AD06216647BBB00CE5896 /* SDL_gamecontroller.c in Sources */ = {isa = PBXBuildFile; fileRef = AA0AD06116647BBB00CE5896 /* SDL_gamecontroller.c */; }; AA0AD06216647BBB00CE5896 /* SDL_gamecontroller.c in Sources */ = {isa = PBXBuildFile; fileRef = AA0AD06116647BBB00CE5896 /* SDL_gamecontroller.c */; };
AA0AD06516647BD400CE5896 /* SDL_gamecontroller.h in Headers */ = {isa = PBXBuildFile; fileRef = AA0AD06416647BD400CE5896 /* SDL_gamecontroller.h */; }; AA0AD06516647BD400CE5896 /* SDL_gamecontroller.h in Headers */ = {isa = PBXBuildFile; fileRef = AA0AD06416647BD400CE5896 /* SDL_gamecontroller.h */; };
@@ -194,7 +194,18 @@
AADC5A631FDA10C800960936 /* SDL_shaders_metal_ios.h in Headers */ = {isa = PBXBuildFile; fileRef = AADC5A611FDA10C800960936 /* SDL_shaders_metal_ios.h */; }; AADC5A631FDA10C800960936 /* SDL_shaders_metal_ios.h in Headers */ = {isa = PBXBuildFile; fileRef = AADC5A611FDA10C800960936 /* SDL_shaders_metal_ios.h */; };
AADC5A641FDA10C800960936 /* SDL_render_metal.m in Sources */ = {isa = PBXBuildFile; fileRef = AADC5A621FDA10C800960936 /* SDL_render_metal.m */; }; AADC5A641FDA10C800960936 /* SDL_render_metal.m in Sources */ = {isa = PBXBuildFile; fileRef = AADC5A621FDA10C800960936 /* SDL_render_metal.m */; };
AADC5A651FDA10CB00960936 /* SDL_render_metal.m in Sources */ = {isa = PBXBuildFile; fileRef = AADC5A621FDA10C800960936 /* SDL_render_metal.m */; }; AADC5A651FDA10CB00960936 /* SDL_render_metal.m in Sources */ = {isa = PBXBuildFile; fileRef = AADC5A621FDA10C800960936 /* SDL_render_metal.m */; };
AAE7A4222041CCA90096E65A /* SDL_steamcontroller.c in Sources */ = {isa = PBXBuildFile; fileRef = A7A9EEA71F702631002A5589 /* SDL_steamcontroller.c */; }; F3BDD77620F51C3C004ECBF3 /* hid.mm in Sources */ = {isa = PBXBuildFile; fileRef = F3BDD77520F51C3C004ECBF3 /* hid.mm */; };
F3BDD79220F51CB8004ECBF3 /* SDL_hidapi_xbox360.c in Sources */ = {isa = PBXBuildFile; fileRef = F3BDD78B20F51CB8004ECBF3 /* SDL_hidapi_xbox360.c */; };
F3BDD79320F51CB8004ECBF3 /* SDL_hidapi_xbox360.c in Sources */ = {isa = PBXBuildFile; fileRef = F3BDD78B20F51CB8004ECBF3 /* SDL_hidapi_xbox360.c */; };
F3BDD79420F51CB8004ECBF3 /* SDL_hidapi_switch.c in Sources */ = {isa = PBXBuildFile; fileRef = F3BDD78C20F51CB8004ECBF3 /* SDL_hidapi_switch.c */; };
F3BDD79520F51CB8004ECBF3 /* SDL_hidapi_switch.c in Sources */ = {isa = PBXBuildFile; fileRef = F3BDD78C20F51CB8004ECBF3 /* SDL_hidapi_switch.c */; };
F3BDD79620F51CB8004ECBF3 /* SDL_hidapi_xboxone.c in Sources */ = {isa = PBXBuildFile; fileRef = F3BDD78D20F51CB8004ECBF3 /* SDL_hidapi_xboxone.c */; };
F3BDD79720F51CB8004ECBF3 /* SDL_hidapi_xboxone.c in Sources */ = {isa = PBXBuildFile; fileRef = F3BDD78D20F51CB8004ECBF3 /* SDL_hidapi_xboxone.c */; };
F3BDD79820F51CB8004ECBF3 /* SDL_hidapi_ps4.c in Sources */ = {isa = PBXBuildFile; fileRef = F3BDD78E20F51CB8004ECBF3 /* SDL_hidapi_ps4.c */; };
F3BDD79920F51CB8004ECBF3 /* SDL_hidapi_ps4.c in Sources */ = {isa = PBXBuildFile; fileRef = F3BDD78E20F51CB8004ECBF3 /* SDL_hidapi_ps4.c */; };
F3BDD79B20F51CB8004ECBF3 /* SDL_hidapijoystick_c.h in Headers */ = {isa = PBXBuildFile; fileRef = F3BDD79020F51CB8004ECBF3 /* SDL_hidapijoystick_c.h */; };
F3BDD79C20F51CB8004ECBF3 /* SDL_hidapijoystick.c in Sources */ = {isa = PBXBuildFile; fileRef = F3BDD79120F51CB8004ECBF3 /* SDL_hidapijoystick.c */; };
F3BDD79D20F51CB8004ECBF3 /* SDL_hidapijoystick.c in Sources */ = {isa = PBXBuildFile; fileRef = F3BDD79120F51CB8004ECBF3 /* SDL_hidapijoystick.c */; };
FA1DC2721C62BE65008F99A0 /* SDL_uikitclipboard.h in Headers */ = {isa = PBXBuildFile; fileRef = FA1DC2701C62BE65008F99A0 /* SDL_uikitclipboard.h */; }; FA1DC2721C62BE65008F99A0 /* SDL_uikitclipboard.h in Headers */ = {isa = PBXBuildFile; fileRef = FA1DC2701C62BE65008F99A0 /* SDL_uikitclipboard.h */; };
FA1DC2731C62BE65008F99A0 /* SDL_uikitclipboard.m in Sources */ = {isa = PBXBuildFile; fileRef = FA1DC2711C62BE65008F99A0 /* SDL_uikitclipboard.m */; }; FA1DC2731C62BE65008F99A0 /* SDL_uikitclipboard.m in Sources */ = {isa = PBXBuildFile; fileRef = FA1DC2711C62BE65008F99A0 /* SDL_uikitclipboard.m */; };
FAB5981D1BB5C31500BE72C5 /* SDL_atomic.c in Sources */ = {isa = PBXBuildFile; fileRef = 04FFAB8912E23B8D00BA343D /* SDL_atomic.c */; }; FAB5981D1BB5C31500BE72C5 /* SDL_atomic.c in Sources */ = {isa = PBXBuildFile; fileRef = 04FFAB8912E23B8D00BA343D /* SDL_atomic.c */; };
@@ -223,7 +234,6 @@
FAB5984C1BB5C31600BE72C5 /* SDL_syshaptic.c in Sources */ = {isa = PBXBuildFile; fileRef = 047677B80EA76A31008ABAF1 /* SDL_syshaptic.c */; }; FAB5984C1BB5C31600BE72C5 /* SDL_syshaptic.c in Sources */ = {isa = PBXBuildFile; fileRef = 047677B80EA76A31008ABAF1 /* SDL_syshaptic.c */; };
FAB5984D1BB5C31600BE72C5 /* SDL_haptic.c in Sources */ = {isa = PBXBuildFile; fileRef = 047677B90EA76A31008ABAF1 /* SDL_haptic.c */; }; FAB5984D1BB5C31600BE72C5 /* SDL_haptic.c in Sources */ = {isa = PBXBuildFile; fileRef = 047677B90EA76A31008ABAF1 /* SDL_haptic.c */; };
FAB598501BB5C31600BE72C5 /* SDL_sysjoystick.m in Sources */ = {isa = PBXBuildFile; fileRef = FD689F000E26E5B600F90B21 /* SDL_sysjoystick.m */; }; FAB598501BB5C31600BE72C5 /* SDL_sysjoystick.m in Sources */ = {isa = PBXBuildFile; fileRef = FD689F000E26E5B600F90B21 /* SDL_sysjoystick.m */; };
FAB598511BB5C31600BE72C5 /* SDL_gamecontroller.c in Sources */ = {isa = PBXBuildFile; fileRef = AA0AD06116647BBB00CE5896 /* SDL_gamecontroller.c */; };
FAB598521BB5C31600BE72C5 /* SDL_joystick.c in Sources */ = {isa = PBXBuildFile; fileRef = FD5F9D1E0E0E08B3008E885B /* SDL_joystick.c */; }; FAB598521BB5C31600BE72C5 /* SDL_joystick.c in Sources */ = {isa = PBXBuildFile; fileRef = FD5F9D1E0E0E08B3008E885B /* SDL_joystick.c */; };
FAB598551BB5C31600BE72C5 /* SDL_sysloadso.c in Sources */ = {isa = PBXBuildFile; fileRef = 047AF1B20EA98D6C00811173 /* SDL_sysloadso.c */; }; FAB598551BB5C31600BE72C5 /* SDL_sysloadso.c in Sources */ = {isa = PBXBuildFile; fileRef = 047AF1B20EA98D6C00811173 /* SDL_sysloadso.c */; };
FAB598561BB5C31600BE72C5 /* SDL_sysloadso.c in Sources */ = {isa = PBXBuildFile; fileRef = FD8BD8190E27E25900B52CD5 /* SDL_sysloadso.c */; }; FAB598561BB5C31600BE72C5 /* SDL_sysloadso.c in Sources */ = {isa = PBXBuildFile; fileRef = FD8BD8190E27E25900B52CD5 /* SDL_sysloadso.c */; };
@@ -432,8 +442,7 @@
56ED04E2118A8EFD00A56AA6 /* SDL_syspower.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SDL_syspower.m; path = ../../src/power/uikit/SDL_syspower.m; sourceTree = SOURCE_ROOT; }; 56ED04E2118A8EFD00A56AA6 /* SDL_syspower.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SDL_syspower.m; path = ../../src/power/uikit/SDL_syspower.m; sourceTree = SOURCE_ROOT; };
93CB792213FC5E5200BD3E05 /* SDL_uikitviewcontroller.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_uikitviewcontroller.h; sourceTree = "<group>"; }; 93CB792213FC5E5200BD3E05 /* SDL_uikitviewcontroller.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_uikitviewcontroller.h; sourceTree = "<group>"; };
93CB792513FC5F5300BD3E05 /* SDL_uikitviewcontroller.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDL_uikitviewcontroller.m; sourceTree = "<group>"; }; 93CB792513FC5F5300BD3E05 /* SDL_uikitviewcontroller.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDL_uikitviewcontroller.m; sourceTree = "<group>"; };
A7A9EEA71F702631002A5589 /* SDL_steamcontroller.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_steamcontroller.c; sourceTree = "<group>"; }; A704172D20F7E74800A82227 /* controller_type.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = controller_type.h; sourceTree = "<group>"; };
A7A9EEA81F702631002A5589 /* SDL_steamcontroller.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_steamcontroller.h; sourceTree = "<group>"; };
AA0AD06116647BBB00CE5896 /* SDL_gamecontroller.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_gamecontroller.c; sourceTree = "<group>"; }; AA0AD06116647BBB00CE5896 /* SDL_gamecontroller.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_gamecontroller.c; sourceTree = "<group>"; };
AA0AD06416647BD400CE5896 /* SDL_gamecontroller.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_gamecontroller.h; sourceTree = "<group>"; }; AA0AD06416647BD400CE5896 /* SDL_gamecontroller.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_gamecontroller.h; sourceTree = "<group>"; };
AA0F8494178D5F1A00823F9D /* SDL_systls.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_systls.c; sourceTree = "<group>"; }; AA0F8494178D5F1A00823F9D /* SDL_systls.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_systls.c; sourceTree = "<group>"; };
@@ -510,6 +519,13 @@
AADA5B8E16CCAB7C00107CF7 /* SDL_bits.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_bits.h; sourceTree = "<group>"; }; AADA5B8E16CCAB7C00107CF7 /* SDL_bits.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_bits.h; sourceTree = "<group>"; };
AADC5A611FDA10C800960936 /* SDL_shaders_metal_ios.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_shaders_metal_ios.h; sourceTree = "<group>"; }; AADC5A611FDA10C800960936 /* SDL_shaders_metal_ios.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_shaders_metal_ios.h; sourceTree = "<group>"; };
AADC5A621FDA10C800960936 /* SDL_render_metal.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDL_render_metal.m; sourceTree = "<group>"; }; AADC5A621FDA10C800960936 /* SDL_render_metal.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDL_render_metal.m; sourceTree = "<group>"; };
F3BDD77520F51C3C004ECBF3 /* hid.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = hid.mm; sourceTree = "<group>"; };
F3BDD78B20F51CB8004ECBF3 /* SDL_hidapi_xbox360.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_hidapi_xbox360.c; sourceTree = "<group>"; };
F3BDD78C20F51CB8004ECBF3 /* SDL_hidapi_switch.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_hidapi_switch.c; sourceTree = "<group>"; };
F3BDD78D20F51CB8004ECBF3 /* SDL_hidapi_xboxone.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_hidapi_xboxone.c; sourceTree = "<group>"; };
F3BDD78E20F51CB8004ECBF3 /* SDL_hidapi_ps4.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_hidapi_ps4.c; sourceTree = "<group>"; };
F3BDD79020F51CB8004ECBF3 /* SDL_hidapijoystick_c.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_hidapijoystick_c.h; sourceTree = "<group>"; };
F3BDD79120F51CB8004ECBF3 /* SDL_hidapijoystick.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_hidapijoystick.c; sourceTree = "<group>"; };
FA1DC2701C62BE65008F99A0 /* SDL_uikitclipboard.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_uikitclipboard.h; sourceTree = "<group>"; }; FA1DC2701C62BE65008F99A0 /* SDL_uikitclipboard.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_uikitclipboard.h; sourceTree = "<group>"; };
FA1DC2711C62BE65008F99A0 /* SDL_uikitclipboard.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDL_uikitclipboard.m; sourceTree = "<group>"; }; FA1DC2711C62BE65008F99A0 /* SDL_uikitclipboard.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDL_uikitclipboard.m; sourceTree = "<group>"; };
FAB598141BB5C1B100BE72C5 /* libSDL2.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libSDL2.a; sourceTree = BUILT_PRODUCTS_DIR; }; FAB598141BB5C1B100BE72C5 /* libSDL2.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libSDL2.a; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -778,15 +794,6 @@
name = uikit; name = uikit;
sourceTree = "<group>"; sourceTree = "<group>";
}; };
A7A9EEA61F702607002A5589 /* steam */ = {
isa = PBXGroup;
children = (
A7A9EEA71F702631002A5589 /* SDL_steamcontroller.c */,
A7A9EEA81F702631002A5589 /* SDL_steamcontroller.h */,
);
path = steam;
sourceTree = "<group>";
};
AA13B3521FB8B41700D9FEE6 /* yuv2rgb */ = { AA13B3521FB8B41700D9FEE6 /* yuv2rgb */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
@@ -807,6 +814,36 @@
path = metal; path = metal;
sourceTree = "<group>"; sourceTree = "<group>";
}; };
F35CEA6E20F51B7F003ECE98 /* hidapi */ = {
isa = PBXGroup;
children = (
F3BDD77420F51C18004ECBF3 /* ios */,
);
name = hidapi;
path = ../../src/hidapi;
sourceTree = SOURCE_ROOT;
};
F3BDD77420F51C18004ECBF3 /* ios */ = {
isa = PBXGroup;
children = (
F3BDD77520F51C3C004ECBF3 /* hid.mm */,
);
path = ios;
sourceTree = "<group>";
};
F3BDD78A20F51C8D004ECBF3 /* hidapi */ = {
isa = PBXGroup;
children = (
F3BDD78E20F51CB8004ECBF3 /* SDL_hidapi_ps4.c */,
F3BDD78C20F51CB8004ECBF3 /* SDL_hidapi_switch.c */,
F3BDD78B20F51CB8004ECBF3 /* SDL_hidapi_xbox360.c */,
F3BDD78D20F51CB8004ECBF3 /* SDL_hidapi_xboxone.c */,
F3BDD79020F51CB8004ECBF3 /* SDL_hidapijoystick_c.h */,
F3BDD79120F51CB8004ECBF3 /* SDL_hidapijoystick.c */,
);
path = hidapi;
sourceTree = "<group>";
};
FD3F4A6F0DEA620800C5B771 /* stdlib */ = { FD3F4A6F0DEA620800C5B771 /* stdlib */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
@@ -824,8 +861,9 @@
FD5F9D080E0E08B3008E885B /* joystick */ = { FD5F9D080E0E08B3008E885B /* joystick */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
A7A9EEA61F702607002A5589 /* steam */, F3BDD78A20F51C8D004ECBF3 /* hidapi */,
FD689EFF0E26E5B600F90B21 /* iphoneos */, FD689EFF0E26E5B600F90B21 /* iphoneos */,
A704172D20F7E74800A82227 /* controller_type.h */,
AA0AD06116647BBB00CE5896 /* SDL_gamecontroller.c */, AA0AD06116647BBB00CE5896 /* SDL_gamecontroller.c */,
FD5F9D1E0E0E08B3008E885B /* SDL_joystick.c */, FD5F9D1E0E0E08B3008E885B /* SDL_joystick.c */,
FD5F9D1F0E0E08B3008E885B /* SDL_joystick_c.h */, FD5F9D1F0E0E08B3008E885B /* SDL_joystick_c.h */,
@@ -970,6 +1008,7 @@
FD99B99D0DD52EDC00FB1D6B /* file */, FD99B99D0DD52EDC00FB1D6B /* file */,
56C181E017C44D6900406AE3 /* filesystem */, 56C181E017C44D6900406AE3 /* filesystem */,
047677B60EA769DF008ABAF1 /* haptic */, 047677B60EA769DF008ABAF1 /* haptic */,
F35CEA6E20F51B7F003ECE98 /* hidapi */,
FD5F9D080E0E08B3008E885B /* joystick */, FD5F9D080E0E08B3008E885B /* joystick */,
FD8BD8150E27E25900B52CD5 /* loadso */, FD8BD8150E27E25900B52CD5 /* loadso */,
56ED04DE118A8E9A00A56AA6 /* power */, 56ED04DE118A8E9A00A56AA6 /* power */,
@@ -1213,13 +1252,13 @@
AA13B3591FB8B46400D9FEE6 /* yuv_rgb.h in Headers */, AA13B3591FB8B46400D9FEE6 /* yuv_rgb.h in Headers */,
04F7807712FB751400FC43C0 /* SDL_blendfillrect.h in Headers */, 04F7807712FB751400FC43C0 /* SDL_blendfillrect.h in Headers */,
04F7807912FB751400FC43C0 /* SDL_blendline.h in Headers */, 04F7807912FB751400FC43C0 /* SDL_blendline.h in Headers */,
F3BDD79B20F51CB8004ECBF3 /* SDL_hidapijoystick_c.h in Headers */,
04F7807B12FB751400FC43C0 /* SDL_blendpoint.h in Headers */, 04F7807B12FB751400FC43C0 /* SDL_blendpoint.h in Headers */,
04F7807C12FB751400FC43C0 /* SDL_draw.h in Headers */, 04F7807C12FB751400FC43C0 /* SDL_draw.h in Headers */,
04F7807E12FB751400FC43C0 /* SDL_drawline.h in Headers */, 04F7807E12FB751400FC43C0 /* SDL_drawline.h in Headers */,
AA13B34E1FB8B27800D9FEE6 /* SDL_yuv_c.h in Headers */, AA13B34E1FB8B27800D9FEE6 /* SDL_yuv_c.h in Headers */,
04F7808012FB751400FC43C0 /* SDL_drawpoint.h in Headers */, 04F7808012FB751400FC43C0 /* SDL_drawpoint.h in Headers */,
04F7808412FB753F00FC43C0 /* SDL_nullframebuffer_c.h in Headers */, 04F7808412FB753F00FC43C0 /* SDL_nullframebuffer_c.h in Headers */,
A7A9EEAA1F702631002A5589 /* SDL_steamcontroller.h in Headers */,
0442EC5012FE1C1E004C9285 /* SDL_render_sw_c.h in Headers */, 0442EC5012FE1C1E004C9285 /* SDL_render_sw_c.h in Headers */,
FA1DC2721C62BE65008F99A0 /* SDL_uikitclipboard.h in Headers */, FA1DC2721C62BE65008F99A0 /* SDL_uikitclipboard.h in Headers */,
0402A85A12FE70C600CECEE3 /* SDL_shaders_gles2.h in Headers */, 0402A85A12FE70C600CECEE3 /* SDL_shaders_gles2.h in Headers */,
@@ -1250,6 +1289,7 @@
AA7558AA1595D55500BBD41B /* SDL_joystick.h in Headers */, AA7558AA1595D55500BBD41B /* SDL_joystick.h in Headers */,
AA13B34B1FB8B27800D9FEE6 /* SDL_shape_internals.h in Headers */, AA13B34B1FB8B27800D9FEE6 /* SDL_shape_internals.h in Headers */,
AA7558AB1595D55500BBD41B /* SDL_keyboard.h in Headers */, AA7558AB1595D55500BBD41B /* SDL_keyboard.h in Headers */,
A704172E20F7E74800A82227 /* controller_type.h in Headers */,
AA7558AC1595D55500BBD41B /* SDL_keycode.h in Headers */, AA7558AC1595D55500BBD41B /* SDL_keycode.h in Headers */,
AA7558AD1595D55500BBD41B /* SDL_loadso.h in Headers */, AA7558AD1595D55500BBD41B /* SDL_loadso.h in Headers */,
AA7558AE1595D55500BBD41B /* SDL_log.h in Headers */, AA7558AE1595D55500BBD41B /* SDL_log.h in Headers */,
@@ -1432,6 +1472,7 @@
FAB598251BB5C31500BE72C5 /* SDL_audiocvt.c in Sources */, FAB598251BB5C31500BE72C5 /* SDL_audiocvt.c in Sources */,
FAB598271BB5C31500BE72C5 /* SDL_audiotypecvt.c in Sources */, FAB598271BB5C31500BE72C5 /* SDL_audiotypecvt.c in Sources */,
FAB598281BB5C31500BE72C5 /* SDL_mixer.c in Sources */, FAB598281BB5C31500BE72C5 /* SDL_mixer.c in Sources */,
F3BDD79720F51CB8004ECBF3 /* SDL_hidapi_xboxone.c in Sources */,
FAB5982A1BB5C31500BE72C5 /* SDL_wave.c in Sources */, FAB5982A1BB5C31500BE72C5 /* SDL_wave.c in Sources */,
FAFDF8C61D88D4530083E6F2 /* SDL_uikitclipboard.m in Sources */, FAFDF8C61D88D4530083E6F2 /* SDL_uikitclipboard.m in Sources */,
FAB5982C1BB5C31500BE72C5 /* SDL_cpuinfo.c in Sources */, FAB5982C1BB5C31500BE72C5 /* SDL_cpuinfo.c in Sources */,
@@ -1442,7 +1483,9 @@
A7F629241FE06523002F9CC9 /* SDL_uikitmetalview.m in Sources */, A7F629241FE06523002F9CC9 /* SDL_uikitmetalview.m in Sources */,
FAB5983C1BB5C31500BE72C5 /* SDL_gesture.c in Sources */, FAB5983C1BB5C31500BE72C5 /* SDL_gesture.c in Sources */,
FAB5983E1BB5C31500BE72C5 /* SDL_keyboard.c in Sources */, FAB5983E1BB5C31500BE72C5 /* SDL_keyboard.c in Sources */,
F3BDD79520F51CB8004ECBF3 /* SDL_hidapi_switch.c in Sources */,
FAB598401BB5C31500BE72C5 /* SDL_mouse.c in Sources */, FAB598401BB5C31500BE72C5 /* SDL_mouse.c in Sources */,
A704172F20F7E76000A82227 /* SDL_gamecontroller.c in Sources */,
FAB598421BB5C31500BE72C5 /* SDL_quit.c in Sources */, FAB598421BB5C31500BE72C5 /* SDL_quit.c in Sources */,
FAB598441BB5C31500BE72C5 /* SDL_touch.c in Sources */, FAB598441BB5C31500BE72C5 /* SDL_touch.c in Sources */,
FAB598461BB5C31500BE72C5 /* SDL_windowevents.c in Sources */, FAB598461BB5C31500BE72C5 /* SDL_windowevents.c in Sources */,
@@ -1454,8 +1497,8 @@
AADC5A5F1FDA105600960936 /* SDL_vulkan_utils.c in Sources */, AADC5A5F1FDA105600960936 /* SDL_vulkan_utils.c in Sources */,
AADC5A5E1FDA105300960936 /* SDL_yuv.c in Sources */, AADC5A5E1FDA105300960936 /* SDL_yuv.c in Sources */,
FAB5984D1BB5C31600BE72C5 /* SDL_haptic.c in Sources */, FAB5984D1BB5C31600BE72C5 /* SDL_haptic.c in Sources */,
F3BDD79320F51CB8004ECBF3 /* SDL_hidapi_xbox360.c in Sources */,
FAB598501BB5C31600BE72C5 /* SDL_sysjoystick.m in Sources */, FAB598501BB5C31600BE72C5 /* SDL_sysjoystick.m in Sources */,
FAB598511BB5C31600BE72C5 /* SDL_gamecontroller.c in Sources */,
FAB598521BB5C31600BE72C5 /* SDL_joystick.c in Sources */, FAB598521BB5C31600BE72C5 /* SDL_joystick.c in Sources */,
FAB598551BB5C31600BE72C5 /* SDL_sysloadso.c in Sources */, FAB598551BB5C31600BE72C5 /* SDL_sysloadso.c in Sources */,
AADC5A651FDA10CB00960936 /* SDL_render_metal.m in Sources */, AADC5A651FDA10CB00960936 /* SDL_render_metal.m in Sources */,
@@ -1482,6 +1525,7 @@
FAB598761BB5C31600BE72C5 /* SDL_stdlib.c in Sources */, FAB598761BB5C31600BE72C5 /* SDL_stdlib.c in Sources */,
FAB598771BB5C31600BE72C5 /* SDL_string.c in Sources */, FAB598771BB5C31600BE72C5 /* SDL_string.c in Sources */,
FAB598781BB5C31600BE72C5 /* SDL_syscond.c in Sources */, FAB598781BB5C31600BE72C5 /* SDL_syscond.c in Sources */,
F3BDD79D20F51CB8004ECBF3 /* SDL_hidapijoystick.c in Sources */,
AADC5A601FDA10A400960936 /* SDL_uikitvulkan.m in Sources */, AADC5A601FDA10A400960936 /* SDL_uikitvulkan.m in Sources */,
FAB598791BB5C31600BE72C5 /* SDL_sysmutex.c in Sources */, FAB598791BB5C31600BE72C5 /* SDL_sysmutex.c in Sources */,
FAB5987B1BB5C31600BE72C5 /* SDL_syssem.c in Sources */, FAB5987B1BB5C31600BE72C5 /* SDL_syssem.c in Sources */,
@@ -1492,6 +1536,7 @@
FAB598821BB5C31600BE72C5 /* SDL_systimer.c in Sources */, FAB598821BB5C31600BE72C5 /* SDL_systimer.c in Sources */,
FAB598831BB5C31600BE72C5 /* SDL_timer.c in Sources */, FAB598831BB5C31600BE72C5 /* SDL_timer.c in Sources */,
FAB598871BB5C31600BE72C5 /* SDL_uikitappdelegate.m in Sources */, FAB598871BB5C31600BE72C5 /* SDL_uikitappdelegate.m in Sources */,
F3BDD79920F51CB8004ECBF3 /* SDL_hidapi_ps4.c in Sources */,
FAB598891BB5C31600BE72C5 /* SDL_uikitevents.m in Sources */, FAB598891BB5C31600BE72C5 /* SDL_uikitevents.m in Sources */,
FAB5988B1BB5C31600BE72C5 /* SDL_uikitmessagebox.m in Sources */, FAB5988B1BB5C31600BE72C5 /* SDL_uikitmessagebox.m in Sources */,
FAB5988D1BB5C31600BE72C5 /* SDL_uikitmodes.m in Sources */, FAB5988D1BB5C31600BE72C5 /* SDL_uikitmodes.m in Sources */,
@@ -1535,7 +1580,6 @@
files = ( files = (
FD6526810DE8FCDD002AD96B /* SDL_systimer.c in Sources */, FD6526810DE8FCDD002AD96B /* SDL_systimer.c in Sources */,
FD6526800DE8FCDD002AD96B /* SDL_timer.c in Sources */, FD6526800DE8FCDD002AD96B /* SDL_timer.c in Sources */,
A7A9EEA91F702631002A5589 /* SDL_steamcontroller.c in Sources */,
FD3F4A7B0DEA620800C5B771 /* SDL_string.c in Sources */, FD3F4A7B0DEA620800C5B771 /* SDL_string.c in Sources */,
FD6526660DE8FCDD002AD96B /* SDL_dummyaudio.c in Sources */, FD6526660DE8FCDD002AD96B /* SDL_dummyaudio.c in Sources */,
FD6526670DE8FCDD002AD96B /* SDL_audio.c in Sources */, FD6526670DE8FCDD002AD96B /* SDL_audio.c in Sources */,
@@ -1566,7 +1610,9 @@
FD3F4A760DEA620800C5B771 /* SDL_getenv.c in Sources */, FD3F4A760DEA620800C5B771 /* SDL_getenv.c in Sources */,
FD3F4A770DEA620800C5B771 /* SDL_iconv.c in Sources */, FD3F4A770DEA620800C5B771 /* SDL_iconv.c in Sources */,
FD3F4A780DEA620800C5B771 /* SDL_malloc.c in Sources */, FD3F4A780DEA620800C5B771 /* SDL_malloc.c in Sources */,
F3BDD79220F51CB8004ECBF3 /* SDL_hidapi_xbox360.c in Sources */,
FD3F4A790DEA620800C5B771 /* SDL_qsort.c in Sources */, FD3F4A790DEA620800C5B771 /* SDL_qsort.c in Sources */,
F3BDD79820F51CB8004ECBF3 /* SDL_hidapi_ps4.c in Sources */,
FD3F4A7A0DEA620800C5B771 /* SDL_stdlib.c in Sources */, FD3F4A7A0DEA620800C5B771 /* SDL_stdlib.c in Sources */,
FDA6844D0DF2374E00F98A1A /* SDL_blit.c in Sources */, FDA6844D0DF2374E00F98A1A /* SDL_blit.c in Sources */,
FDA6844F0DF2374E00F98A1A /* SDL_blit_0.c in Sources */, FDA6844F0DF2374E00F98A1A /* SDL_blit_0.c in Sources */,
@@ -1599,11 +1645,13 @@
FD689F270E26E5D900F90B21 /* SDL_uikitopenglview.m in Sources */, FD689F270E26E5D900F90B21 /* SDL_uikitopenglview.m in Sources */,
FD689FCE0E26E9D400F90B21 /* SDL_uikitappdelegate.m in Sources */, FD689FCE0E26E9D400F90B21 /* SDL_uikitappdelegate.m in Sources */,
FD8BD8250E27E25900B52CD5 /* SDL_sysloadso.c in Sources */, FD8BD8250E27E25900B52CD5 /* SDL_sysloadso.c in Sources */,
F3BDD79C20F51CB8004ECBF3 /* SDL_hidapijoystick.c in Sources */,
047677BB0EA76A31008ABAF1 /* SDL_syshaptic.c in Sources */, 047677BB0EA76A31008ABAF1 /* SDL_syshaptic.c in Sources */,
047677BC0EA76A31008ABAF1 /* SDL_haptic.c in Sources */, 047677BC0EA76A31008ABAF1 /* SDL_haptic.c in Sources */,
047AF1B30EA98D6C00811173 /* SDL_sysloadso.c in Sources */, 047AF1B30EA98D6C00811173 /* SDL_sysloadso.c in Sources */,
046387460F0B5B7D0041FD65 /* SDL_fillrect.c in Sources */, 046387460F0B5B7D0041FD65 /* SDL_fillrect.c in Sources */,
04F2AF561104ABD200D6DDF7 /* SDL_assert.c in Sources */, 04F2AF561104ABD200D6DDF7 /* SDL_assert.c in Sources */,
F3BDD79620F51CB8004ECBF3 /* SDL_hidapi_xboxone.c in Sources */,
56ED04E1118A8EE200A56AA6 /* SDL_power.c in Sources */, 56ED04E1118A8EE200A56AA6 /* SDL_power.c in Sources */,
56ED04E3118A8EFD00A56AA6 /* SDL_syspower.m in Sources */, 56ED04E3118A8EFD00A56AA6 /* SDL_syspower.m in Sources */,
006E9889119552DD001DE610 /* SDL_rwopsbundlesupport.m in Sources */, 006E9889119552DD001DE610 /* SDL_rwopsbundlesupport.m in Sources */,
@@ -1629,10 +1677,12 @@
0402A85912FE70C600CECEE3 /* SDL_shaders_gles2.c in Sources */, 0402A85912FE70C600CECEE3 /* SDL_shaders_gles2.c in Sources */,
04BAC09D1300C1290055DE28 /* SDL_log.c in Sources */, 04BAC09D1300C1290055DE28 /* SDL_log.c in Sources */,
56EA86FB13E9EC2B002E47EB /* SDL_coreaudio.m in Sources */, 56EA86FB13E9EC2B002E47EB /* SDL_coreaudio.m in Sources */,
F3BDD79420F51CB8004ECBF3 /* SDL_hidapi_switch.c in Sources */,
93CB792613FC5F5300BD3E05 /* SDL_uikitviewcontroller.m in Sources */, 93CB792613FC5F5300BD3E05 /* SDL_uikitviewcontroller.m in Sources */,
AA628ADB159369E3005138DD /* SDL_rotate.c in Sources */, AA628ADB159369E3005138DD /* SDL_rotate.c in Sources */,
AA126AD51617C5E7005ABC8F /* SDL_uikitmodes.m in Sources */, AA126AD51617C5E7005ABC8F /* SDL_uikitmodes.m in Sources */,
AA704DD7162AA90A0076D1C1 /* SDL_dropevents.c in Sources */, AA704DD7162AA90A0076D1C1 /* SDL_dropevents.c in Sources */,
F3BDD77620F51C3C004ECBF3 /* hid.mm in Sources */,
AABCC3951640643D00AB8930 /* SDL_uikitmessagebox.m in Sources */, AABCC3951640643D00AB8930 /* SDL_uikitmessagebox.m in Sources */,
AA0AD06216647BBB00CE5896 /* SDL_gamecontroller.c in Sources */, AA0AD06216647BBB00CE5896 /* SDL_gamecontroller.c in Sources */,
AA0F8495178D5F1A00823F9D /* SDL_systls.c in Sources */, AA0F8495178D5F1A00823F9D /* SDL_systls.c in Sources */,
+91
View File
@@ -462,6 +462,30 @@
5C2EF6FE1FC9EE65003F5197 /* SDL_egl.c in Sources */ = {isa = PBXBuildFile; fileRef = 5C2EF6F51FC9EE35003F5197 /* SDL_egl.c */; }; 5C2EF6FE1FC9EE65003F5197 /* SDL_egl.c in Sources */ = {isa = PBXBuildFile; fileRef = 5C2EF6F51FC9EE35003F5197 /* SDL_egl.c */; };
5C2EF6FF1FC9EE65003F5197 /* SDL_rect_c.h in Headers */ = {isa = PBXBuildFile; fileRef = 5C2EF6F41FC9EE34003F5197 /* SDL_rect_c.h */; }; 5C2EF6FF1FC9EE65003F5197 /* SDL_rect_c.h in Headers */ = {isa = PBXBuildFile; fileRef = 5C2EF6F41FC9EE34003F5197 /* SDL_rect_c.h */; };
5C2EF7011FC9EF10003F5197 /* SDL_egl.h in Headers */ = {isa = PBXBuildFile; fileRef = 5C2EF7001FC9EF0F003F5197 /* SDL_egl.h */; }; 5C2EF7011FC9EF10003F5197 /* SDL_egl.h in Headers */ = {isa = PBXBuildFile; fileRef = 5C2EF7001FC9EF0F003F5197 /* SDL_egl.h */; };
A704170920F09A9800A82227 /* hid.c in Sources */ = {isa = PBXBuildFile; fileRef = A704170820F09A9800A82227 /* hid.c */; };
A704170A20F09A9800A82227 /* hid.c in Sources */ = {isa = PBXBuildFile; fileRef = A704170820F09A9800A82227 /* hid.c */; };
A704170B20F09A9800A82227 /* hid.c in Sources */ = {isa = PBXBuildFile; fileRef = A704170820F09A9800A82227 /* hid.c */; };
A704171420F09AC900A82227 /* SDL_hidapijoystick.c in Sources */ = {isa = PBXBuildFile; fileRef = A704170D20F09AC800A82227 /* SDL_hidapijoystick.c */; };
A704171520F09AC900A82227 /* SDL_hidapijoystick.c in Sources */ = {isa = PBXBuildFile; fileRef = A704170D20F09AC800A82227 /* SDL_hidapijoystick.c */; };
A704171620F09AC900A82227 /* SDL_hidapijoystick.c in Sources */ = {isa = PBXBuildFile; fileRef = A704170D20F09AC800A82227 /* SDL_hidapijoystick.c */; };
A704171720F09AC900A82227 /* SDL_hidapijoystick_c.h in Headers */ = {isa = PBXBuildFile; fileRef = A704170E20F09AC800A82227 /* SDL_hidapijoystick_c.h */; };
A704171820F09AC900A82227 /* SDL_hidapijoystick_c.h in Headers */ = {isa = PBXBuildFile; fileRef = A704170E20F09AC800A82227 /* SDL_hidapijoystick_c.h */; };
A704171920F09AC900A82227 /* SDL_hidapijoystick_c.h in Headers */ = {isa = PBXBuildFile; fileRef = A704170E20F09AC800A82227 /* SDL_hidapijoystick_c.h */; };
A704171A20F09AC900A82227 /* SDL_hidapi_switch.c in Sources */ = {isa = PBXBuildFile; fileRef = A704170F20F09AC800A82227 /* SDL_hidapi_switch.c */; };
A704171B20F09AC900A82227 /* SDL_hidapi_switch.c in Sources */ = {isa = PBXBuildFile; fileRef = A704170F20F09AC800A82227 /* SDL_hidapi_switch.c */; };
A704171C20F09AC900A82227 /* SDL_hidapi_switch.c in Sources */ = {isa = PBXBuildFile; fileRef = A704170F20F09AC800A82227 /* SDL_hidapi_switch.c */; };
A704171D20F09AC900A82227 /* controller_type.h in Headers */ = {isa = PBXBuildFile; fileRef = A704171020F09AC900A82227 /* controller_type.h */; };
A704171E20F09AC900A82227 /* controller_type.h in Headers */ = {isa = PBXBuildFile; fileRef = A704171020F09AC900A82227 /* controller_type.h */; };
A704171F20F09AC900A82227 /* controller_type.h in Headers */ = {isa = PBXBuildFile; fileRef = A704171020F09AC900A82227 /* controller_type.h */; };
A704172020F09AC900A82227 /* SDL_hidapi_ps4.c in Sources */ = {isa = PBXBuildFile; fileRef = A704171120F09AC900A82227 /* SDL_hidapi_ps4.c */; };
A704172120F09AC900A82227 /* SDL_hidapi_ps4.c in Sources */ = {isa = PBXBuildFile; fileRef = A704171120F09AC900A82227 /* SDL_hidapi_ps4.c */; };
A704172220F09AC900A82227 /* SDL_hidapi_ps4.c in Sources */ = {isa = PBXBuildFile; fileRef = A704171120F09AC900A82227 /* SDL_hidapi_ps4.c */; };
A704172320F09AC900A82227 /* SDL_hidapi_xboxone.c in Sources */ = {isa = PBXBuildFile; fileRef = A704171220F09AC900A82227 /* SDL_hidapi_xboxone.c */; };
A704172420F09AC900A82227 /* SDL_hidapi_xboxone.c in Sources */ = {isa = PBXBuildFile; fileRef = A704171220F09AC900A82227 /* SDL_hidapi_xboxone.c */; };
A704172520F09AC900A82227 /* SDL_hidapi_xboxone.c in Sources */ = {isa = PBXBuildFile; fileRef = A704171220F09AC900A82227 /* SDL_hidapi_xboxone.c */; };
A704172620F09AC900A82227 /* SDL_hidapi_xbox360.c in Sources */ = {isa = PBXBuildFile; fileRef = A704171320F09AC900A82227 /* SDL_hidapi_xbox360.c */; };
A704172720F09AC900A82227 /* SDL_hidapi_xbox360.c in Sources */ = {isa = PBXBuildFile; fileRef = A704171320F09AC900A82227 /* SDL_hidapi_xbox360.c */; };
A704172820F09AC900A82227 /* SDL_hidapi_xbox360.c in Sources */ = {isa = PBXBuildFile; fileRef = A704171320F09AC900A82227 /* SDL_hidapi_xbox360.c */; };
A7381E961D8B69D600B177DD /* CoreAudio.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A7381E951D8B69D600B177DD /* CoreAudio.framework */; }; A7381E961D8B69D600B177DD /* CoreAudio.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A7381E951D8B69D600B177DD /* CoreAudio.framework */; };
A7381E971D8B6A0300B177DD /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A7381E931D8B69C300B177DD /* AudioToolbox.framework */; }; A7381E971D8B6A0300B177DD /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A7381E931D8B69C300B177DD /* AudioToolbox.framework */; };
A77E6EB4167AB0A90010E40B /* SDL_gamecontroller.h in Headers */ = {isa = PBXBuildFile; fileRef = A77E6EB3167AB0A90010E40B /* SDL_gamecontroller.h */; settings = {ATTRIBUTES = (Public, ); }; }; A77E6EB4167AB0A90010E40B /* SDL_gamecontroller.h in Headers */ = {isa = PBXBuildFile; fileRef = A77E6EB3167AB0A90010E40B /* SDL_gamecontroller.h */; settings = {ATTRIBUTES = (Public, ); }; };
@@ -1114,6 +1138,14 @@
5C2EF6F51FC9EE35003F5197 /* SDL_egl.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_egl.c; sourceTree = "<group>"; }; 5C2EF6F51FC9EE35003F5197 /* SDL_egl.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_egl.c; sourceTree = "<group>"; };
5C2EF6F61FC9EE35003F5197 /* SDL_egl_c.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_egl_c.h; sourceTree = "<group>"; }; 5C2EF6F61FC9EE35003F5197 /* SDL_egl_c.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_egl_c.h; sourceTree = "<group>"; };
5C2EF7001FC9EF0F003F5197 /* SDL_egl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_egl.h; sourceTree = "<group>"; }; 5C2EF7001FC9EF0F003F5197 /* SDL_egl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_egl.h; sourceTree = "<group>"; };
A704170820F09A9800A82227 /* hid.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = hid.c; sourceTree = "<group>"; };
A704170D20F09AC800A82227 /* SDL_hidapijoystick.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_hidapijoystick.c; sourceTree = "<group>"; };
A704170E20F09AC800A82227 /* SDL_hidapijoystick_c.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_hidapijoystick_c.h; sourceTree = "<group>"; };
A704170F20F09AC800A82227 /* SDL_hidapi_switch.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_hidapi_switch.c; sourceTree = "<group>"; };
A704171020F09AC900A82227 /* controller_type.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = controller_type.h; sourceTree = "<group>"; };
A704171120F09AC900A82227 /* SDL_hidapi_ps4.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_hidapi_ps4.c; sourceTree = "<group>"; };
A704171220F09AC900A82227 /* SDL_hidapi_xboxone.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_hidapi_xboxone.c; sourceTree = "<group>"; };
A704171320F09AC900A82227 /* SDL_hidapi_xbox360.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_hidapi_xbox360.c; sourceTree = "<group>"; };
A7381E931D8B69C300B177DD /* AudioToolbox.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AudioToolbox.framework; path = System/Library/Frameworks/AudioToolbox.framework; sourceTree = SDKROOT; }; A7381E931D8B69C300B177DD /* AudioToolbox.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AudioToolbox.framework; path = System/Library/Frameworks/AudioToolbox.framework; sourceTree = SDKROOT; };
A7381E951D8B69D600B177DD /* CoreAudio.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreAudio.framework; path = System/Library/Frameworks/CoreAudio.framework; sourceTree = SDKROOT; }; A7381E951D8B69D600B177DD /* CoreAudio.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreAudio.framework; path = System/Library/Frameworks/CoreAudio.framework; sourceTree = SDKROOT; };
A77E6EB3167AB0A90010E40B /* SDL_gamecontroller.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_gamecontroller.h; sourceTree = "<group>"; }; A77E6EB3167AB0A90010E40B /* SDL_gamecontroller.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_gamecontroller.h; sourceTree = "<group>"; };
@@ -1536,6 +1568,7 @@
04BDFDFF12E6671700899322 /* joystick */ = { 04BDFDFF12E6671700899322 /* joystick */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
A704170C20F09AA600A82227 /* hidapi */,
04BDFE0612E6671700899322 /* darwin */, 04BDFE0612E6671700899322 /* darwin */,
04BDFE1612E6671700899322 /* SDL_joystick.c */, 04BDFE1612E6671700899322 /* SDL_joystick.c */,
04BDFE1712E6671700899322 /* SDL_joystick_c.h */, 04BDFE1712E6671700899322 /* SDL_joystick_c.h */,
@@ -1818,6 +1851,7 @@
567E2F1F17C44BBB005F1892 /* filesystem */, 567E2F1F17C44BBB005F1892 /* filesystem */,
04BDFDEC12E6671700899322 /* file */, 04BDFDEC12E6671700899322 /* file */,
04BDFDF112E6671700899322 /* haptic */, 04BDFDF112E6671700899322 /* haptic */,
A73EBCD520F099C10043B449 /* hidapi */,
04BDFDFF12E6671700899322 /* joystick */, 04BDFDFF12E6671700899322 /* joystick */,
04BDFE2F12E6671700899322 /* loadso */, 04BDFE2F12E6671700899322 /* loadso */,
04BDFE4512E6671700899322 /* power */, 04BDFE4512E6671700899322 /* power */,
@@ -1879,6 +1913,37 @@
path = opengles2; path = opengles2;
sourceTree = "<group>"; sourceTree = "<group>";
}; };
A704170720F09A6700A82227 /* mac */ = {
isa = PBXGroup;
children = (
A704170820F09A9800A82227 /* hid.c */,
);
path = mac;
sourceTree = "<group>";
};
A704170C20F09AA600A82227 /* hidapi */ = {
isa = PBXGroup;
children = (
A704171020F09AC900A82227 /* controller_type.h */,
A704171120F09AC900A82227 /* SDL_hidapi_ps4.c */,
A704170F20F09AC800A82227 /* SDL_hidapi_switch.c */,
A704171320F09AC900A82227 /* SDL_hidapi_xbox360.c */,
A704171220F09AC900A82227 /* SDL_hidapi_xboxone.c */,
A704170E20F09AC800A82227 /* SDL_hidapijoystick_c.h */,
A704170D20F09AC800A82227 /* SDL_hidapijoystick.c */,
);
path = hidapi;
sourceTree = "<group>";
};
A73EBCD520F099C10043B449 /* hidapi */ = {
isa = PBXGroup;
children = (
A704170720F09A6700A82227 /* mac */,
);
name = hidapi;
path = ../../src/hidapi;
sourceTree = SOURCE_ROOT;
};
AA9A7F0E1FB0200B00FED37F /* yuv2rgb */ = { AA9A7F0E1FB0200B00FED37F /* yuv2rgb */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
@@ -1993,6 +2058,7 @@
AA7558421595D4D800BBD41B /* SDL_revision.h in Headers */, AA7558421595D4D800BBD41B /* SDL_revision.h in Headers */,
AA7558441595D4D800BBD41B /* SDL_rwops.h in Headers */, AA7558441595D4D800BBD41B /* SDL_rwops.h in Headers */,
AA7558461595D4D800BBD41B /* SDL_scancode.h in Headers */, AA7558461595D4D800BBD41B /* SDL_scancode.h in Headers */,
A704171720F09AC900A82227 /* SDL_hidapijoystick_c.h in Headers */,
AA7558481595D4D800BBD41B /* SDL_shape.h in Headers */, AA7558481595D4D800BBD41B /* SDL_shape.h in Headers */,
AA75584A1595D4D800BBD41B /* SDL_stdinc.h in Headers */, AA75584A1595D4D800BBD41B /* SDL_stdinc.h in Headers */,
AA75584C1595D4D800BBD41B /* SDL_surface.h in Headers */, AA75584C1595D4D800BBD41B /* SDL_surface.h in Headers */,
@@ -2083,6 +2149,7 @@
04BD01F912E6671800899322 /* SDL_x11window.h in Headers */, 04BD01F912E6671800899322 /* SDL_x11window.h in Headers */,
041B2CA612FA0D680087D585 /* SDL_sysrender.h in Headers */, 041B2CA612FA0D680087D585 /* SDL_sysrender.h in Headers */,
AA9A7F161FB0209D00FED37F /* SDL_yuv_c.h in Headers */, AA9A7F161FB0209D00FED37F /* SDL_yuv_c.h in Headers */,
A704171D20F09AC900A82227 /* controller_type.h in Headers */,
04409B9312FA97ED00FB9AA8 /* SDL_yuv_sw_c.h in Headers */, 04409B9312FA97ED00FB9AA8 /* SDL_yuv_sw_c.h in Headers */,
04F7803912FB748500FC43C0 /* SDL_nullframebuffer_c.h in Headers */, 04F7803912FB748500FC43C0 /* SDL_nullframebuffer_c.h in Headers */,
04F7804A12FB74A200FC43C0 /* SDL_blendfillrect.h in Headers */, 04F7804A12FB74A200FC43C0 /* SDL_blendfillrect.h in Headers */,
@@ -2132,6 +2199,7 @@
AA75581F1595D4D800BBD41B /* SDL_joystick.h in Headers */, AA75581F1595D4D800BBD41B /* SDL_joystick.h in Headers */,
AA7558211595D4D800BBD41B /* SDL_keyboard.h in Headers */, AA7558211595D4D800BBD41B /* SDL_keyboard.h in Headers */,
AA7558231595D4D800BBD41B /* SDL_keycode.h in Headers */, AA7558231595D4D800BBD41B /* SDL_keycode.h in Headers */,
A704171E20F09AC900A82227 /* controller_type.h in Headers */,
AA7558251595D4D800BBD41B /* SDL_loadso.h in Headers */, AA7558251595D4D800BBD41B /* SDL_loadso.h in Headers */,
AA7558271595D4D800BBD41B /* SDL_log.h in Headers */, AA7558271595D4D800BBD41B /* SDL_log.h in Headers */,
AA7558291595D4D800BBD41B /* SDL_main.h in Headers */, AA7558291595D4D800BBD41B /* SDL_main.h in Headers */,
@@ -2207,6 +2275,7 @@
04BD02DC12E6671800899322 /* SDL_systhread_c.h in Headers */, 04BD02DC12E6671800899322 /* SDL_systhread_c.h in Headers */,
04BD02E312E6671800899322 /* SDL_systhread.h in Headers */, 04BD02E312E6671800899322 /* SDL_systhread.h in Headers */,
04BD02E512E6671800899322 /* SDL_thread_c.h in Headers */, 04BD02E512E6671800899322 /* SDL_thread_c.h in Headers */,
A704171820F09AC900A82227 /* SDL_hidapijoystick_c.h in Headers */,
04BD02F212E6671800899322 /* SDL_timer_c.h in Headers */, 04BD02F212E6671800899322 /* SDL_timer_c.h in Headers */,
04BD030D12E6671800899322 /* SDL_cocoaclipboard.h in Headers */, 04BD030D12E6671800899322 /* SDL_cocoaclipboard.h in Headers */,
04BD030F12E6671800899322 /* SDL_cocoaevents.h in Headers */, 04BD030F12E6671800899322 /* SDL_cocoaevents.h in Headers */,
@@ -2296,6 +2365,7 @@
DB313FD917554B71006C0E22 /* SDL_joystick.h in Headers */, DB313FD917554B71006C0E22 /* SDL_joystick.h in Headers */,
DB313FDA17554B71006C0E22 /* SDL_keyboard.h in Headers */, DB313FDA17554B71006C0E22 /* SDL_keyboard.h in Headers */,
DB313FDB17554B71006C0E22 /* SDL_keycode.h in Headers */, DB313FDB17554B71006C0E22 /* SDL_keycode.h in Headers */,
A704171F20F09AC900A82227 /* controller_type.h in Headers */,
DB313FDC17554B71006C0E22 /* SDL_loadso.h in Headers */, DB313FDC17554B71006C0E22 /* SDL_loadso.h in Headers */,
DB313FDD17554B71006C0E22 /* SDL_log.h in Headers */, DB313FDD17554B71006C0E22 /* SDL_log.h in Headers */,
DB313FDE17554B71006C0E22 /* SDL_main.h in Headers */, DB313FDE17554B71006C0E22 /* SDL_main.h in Headers */,
@@ -2371,6 +2441,7 @@
DB313F9317554B71006C0E22 /* SDL_systhread_c.h in Headers */, DB313F9317554B71006C0E22 /* SDL_systhread_c.h in Headers */,
DB313F9417554B71006C0E22 /* SDL_systhread.h in Headers */, DB313F9417554B71006C0E22 /* SDL_systhread.h in Headers */,
DB313F9517554B71006C0E22 /* SDL_thread_c.h in Headers */, DB313F9517554B71006C0E22 /* SDL_thread_c.h in Headers */,
A704171920F09AC900A82227 /* SDL_hidapijoystick_c.h in Headers */,
DB313F9617554B71006C0E22 /* SDL_timer_c.h in Headers */, DB313F9617554B71006C0E22 /* SDL_timer_c.h in Headers */,
DB313F9717554B71006C0E22 /* SDL_cocoaclipboard.h in Headers */, DB313F9717554B71006C0E22 /* SDL_cocoaclipboard.h in Headers */,
DB313F9817554B71006C0E22 /* SDL_cocoaevents.h in Headers */, DB313F9817554B71006C0E22 /* SDL_cocoaevents.h in Headers */,
@@ -2602,6 +2673,7 @@
04BD004112E6671800899322 /* SDL_cpuinfo.c in Sources */, 04BD004112E6671800899322 /* SDL_cpuinfo.c in Sources */,
04BD004812E6671800899322 /* SDL_clipboardevents.c in Sources */, 04BD004812E6671800899322 /* SDL_clipboardevents.c in Sources */,
04BD004A12E6671800899322 /* SDL_events.c in Sources */, 04BD004A12E6671800899322 /* SDL_events.c in Sources */,
A704172620F09AC900A82227 /* SDL_hidapi_xbox360.c in Sources */,
04BD004C12E6671800899322 /* SDL_gesture.c in Sources */, 04BD004C12E6671800899322 /* SDL_gesture.c in Sources */,
04BD004E12E6671800899322 /* SDL_keyboard.c in Sources */, 04BD004E12E6671800899322 /* SDL_keyboard.c in Sources */,
04BD005012E6671800899322 /* SDL_mouse.c in Sources */, 04BD005012E6671800899322 /* SDL_mouse.c in Sources */,
@@ -2640,6 +2712,7 @@
04BD00F612E6671800899322 /* SDL_cocoaevents.m in Sources */, 04BD00F612E6671800899322 /* SDL_cocoaevents.m in Sources */,
04BD00F812E6671800899322 /* SDL_cocoakeyboard.m in Sources */, 04BD00F812E6671800899322 /* SDL_cocoakeyboard.m in Sources */,
AA9A7F151FB0209D00FED37F /* SDL_yuv.c in Sources */, AA9A7F151FB0209D00FED37F /* SDL_yuv.c in Sources */,
A704171A20F09AC900A82227 /* SDL_hidapi_switch.c in Sources */,
04BD00FA12E6671800899322 /* SDL_cocoamodes.m in Sources */, 04BD00FA12E6671800899322 /* SDL_cocoamodes.m in Sources */,
4D16644F1EDD6023003DE88E /* SDL_vulkan_utils.c in Sources */, 4D16644F1EDD6023003DE88E /* SDL_vulkan_utils.c in Sources */,
04BD00FC12E6671800899322 /* SDL_cocoamouse.m in Sources */, 04BD00FC12E6671800899322 /* SDL_cocoamouse.m in Sources */,
@@ -2648,6 +2721,7 @@
04BD010212E6671800899322 /* SDL_cocoavideo.m in Sources */, 04BD010212E6671800899322 /* SDL_cocoavideo.m in Sources */,
04BD010412E6671800899322 /* SDL_cocoawindow.m in Sources */, 04BD010412E6671800899322 /* SDL_cocoawindow.m in Sources */,
04BD011712E6671800899322 /* SDL_nullevents.c in Sources */, 04BD011712E6671800899322 /* SDL_nullevents.c in Sources */,
A704172320F09AC900A82227 /* SDL_hidapi_xboxone.c in Sources */,
04BD011B12E6671800899322 /* SDL_nullvideo.c in Sources */, 04BD011B12E6671800899322 /* SDL_nullvideo.c in Sources */,
04BD017512E6671800899322 /* SDL_blit.c in Sources */, 04BD017512E6671800899322 /* SDL_blit.c in Sources */,
04BD017712E6671800899322 /* SDL_blit_0.c in Sources */, 04BD017712E6671800899322 /* SDL_blit_0.c in Sources */,
@@ -2656,6 +2730,8 @@
04BD017912E6671800899322 /* SDL_blit_A.c in Sources */, 04BD017912E6671800899322 /* SDL_blit_A.c in Sources */,
04BD017A12E6671800899322 /* SDL_blit_auto.c in Sources */, 04BD017A12E6671800899322 /* SDL_blit_auto.c in Sources */,
04BD017C12E6671800899322 /* SDL_blit_copy.c in Sources */, 04BD017C12E6671800899322 /* SDL_blit_copy.c in Sources */,
A704172020F09AC900A82227 /* SDL_hidapi_ps4.c in Sources */,
A704170920F09A9800A82227 /* hid.c in Sources */,
04BD017E12E6671800899322 /* SDL_blit_N.c in Sources */, 04BD017E12E6671800899322 /* SDL_blit_N.c in Sources */,
04BD017F12E6671800899322 /* SDL_blit_slow.c in Sources */, 04BD017F12E6671800899322 /* SDL_blit_slow.c in Sources */,
04BD018112E6671800899322 /* SDL_bmp.c in Sources */, 04BD018112E6671800899322 /* SDL_bmp.c in Sources */,
@@ -2664,6 +2740,7 @@
04BD018C12E6671800899322 /* SDL_pixels.c in Sources */, 04BD018C12E6671800899322 /* SDL_pixels.c in Sources */,
04BD018E12E6671800899322 /* SDL_rect.c in Sources */, 04BD018E12E6671800899322 /* SDL_rect.c in Sources */,
04BD019612E6671800899322 /* SDL_RLEaccel.c in Sources */, 04BD019612E6671800899322 /* SDL_RLEaccel.c in Sources */,
A704171420F09AC900A82227 /* SDL_hidapijoystick.c in Sources */,
04BD019812E6671800899322 /* SDL_shape.c in Sources */, 04BD019812E6671800899322 /* SDL_shape.c in Sources */,
04BD019A12E6671800899322 /* SDL_stretch.c in Sources */, 04BD019A12E6671800899322 /* SDL_stretch.c in Sources */,
04BD019B12E6671800899322 /* SDL_surface.c in Sources */, 04BD019B12E6671800899322 /* SDL_surface.c in Sources */,
@@ -2731,6 +2808,7 @@
04BD024812E6671800899322 /* SDL_audiotypecvt.c in Sources */, 04BD024812E6671800899322 /* SDL_audiotypecvt.c in Sources */,
04BD024912E6671800899322 /* SDL_mixer.c in Sources */, 04BD024912E6671800899322 /* SDL_mixer.c in Sources */,
04BD025112E6671800899322 /* SDL_wave.c in Sources */, 04BD025112E6671800899322 /* SDL_wave.c in Sources */,
A704172720F09AC900A82227 /* SDL_hidapi_xbox360.c in Sources */,
04BD025C12E6671800899322 /* SDL_cpuinfo.c in Sources */, 04BD025C12E6671800899322 /* SDL_cpuinfo.c in Sources */,
04BD026312E6671800899322 /* SDL_clipboardevents.c in Sources */, 04BD026312E6671800899322 /* SDL_clipboardevents.c in Sources */,
04BD026512E6671800899322 /* SDL_events.c in Sources */, 04BD026512E6671800899322 /* SDL_events.c in Sources */,
@@ -2769,6 +2847,7 @@
04BD02E412E6671800899322 /* SDL_thread.c in Sources */, 04BD02E412E6671800899322 /* SDL_thread.c in Sources */,
04BD02F112E6671800899322 /* SDL_timer.c in Sources */, 04BD02F112E6671800899322 /* SDL_timer.c in Sources */,
04BD02F312E6671800899322 /* SDL_systimer.c in Sources */, 04BD02F312E6671800899322 /* SDL_systimer.c in Sources */,
A704171B20F09AC900A82227 /* SDL_hidapi_switch.c in Sources */,
04BD030E12E6671800899322 /* SDL_cocoaclipboard.m in Sources */, 04BD030E12E6671800899322 /* SDL_cocoaclipboard.m in Sources */,
04BD031012E6671800899322 /* SDL_cocoaevents.m in Sources */, 04BD031012E6671800899322 /* SDL_cocoaevents.m in Sources */,
04BD031212E6671800899322 /* SDL_cocoakeyboard.m in Sources */, 04BD031212E6671800899322 /* SDL_cocoakeyboard.m in Sources */,
@@ -2777,6 +2856,7 @@
5C2EF6A31FC98B38003F5197 /* SDL_yuv.c in Sources */, 5C2EF6A31FC98B38003F5197 /* SDL_yuv.c in Sources */,
5C2EF6F11FC9D181003F5197 /* SDL_cocoaopengles.m in Sources */, 5C2EF6F11FC9D181003F5197 /* SDL_cocoaopengles.m in Sources */,
04BD031812E6671800899322 /* SDL_cocoaopengl.m in Sources */, 04BD031812E6671800899322 /* SDL_cocoaopengl.m in Sources */,
A704172420F09AC900A82227 /* SDL_hidapi_xboxone.c in Sources */,
04BD031A12E6671800899322 /* SDL_cocoashape.m in Sources */, 04BD031A12E6671800899322 /* SDL_cocoashape.m in Sources */,
04BD031C12E6671800899322 /* SDL_cocoavideo.m in Sources */, 04BD031C12E6671800899322 /* SDL_cocoavideo.m in Sources */,
04BD031E12E6671800899322 /* SDL_cocoawindow.m in Sources */, 04BD031E12E6671800899322 /* SDL_cocoawindow.m in Sources */,
@@ -2785,6 +2865,8 @@
5C2EF6A51FC98B6B003F5197 /* yuv_rgb.c in Sources */, 5C2EF6A51FC98B6B003F5197 /* yuv_rgb.c in Sources */,
04BD038F12E6671800899322 /* SDL_blit.c in Sources */, 04BD038F12E6671800899322 /* SDL_blit.c in Sources */,
04BD039112E6671800899322 /* SDL_blit_0.c in Sources */, 04BD039112E6671800899322 /* SDL_blit_0.c in Sources */,
A704172120F09AC900A82227 /* SDL_hidapi_ps4.c in Sources */,
A704170A20F09A9800A82227 /* hid.c in Sources */,
04BD039212E6671800899322 /* SDL_blit_1.c in Sources */, 04BD039212E6671800899322 /* SDL_blit_1.c in Sources */,
04BD039312E6671800899322 /* SDL_blit_A.c in Sources */, 04BD039312E6671800899322 /* SDL_blit_A.c in Sources */,
04BD039412E6671800899322 /* SDL_blit_auto.c in Sources */, 04BD039412E6671800899322 /* SDL_blit_auto.c in Sources */,
@@ -2793,6 +2875,7 @@
04BD039912E6671800899322 /* SDL_blit_slow.c in Sources */, 04BD039912E6671800899322 /* SDL_blit_slow.c in Sources */,
04BD039B12E6671800899322 /* SDL_bmp.c in Sources */, 04BD039B12E6671800899322 /* SDL_bmp.c in Sources */,
04BD039C12E6671800899322 /* SDL_clipboard.c in Sources */, 04BD039C12E6671800899322 /* SDL_clipboard.c in Sources */,
A704171520F09AC900A82227 /* SDL_hidapijoystick.c in Sources */,
04BD03A112E6671800899322 /* SDL_fillrect.c in Sources */, 04BD03A112E6671800899322 /* SDL_fillrect.c in Sources */,
04BD03A612E6671800899322 /* SDL_pixels.c in Sources */, 04BD03A612E6671800899322 /* SDL_pixels.c in Sources */,
04BD03A812E6671800899322 /* SDL_rect.c in Sources */, 04BD03A812E6671800899322 /* SDL_rect.c in Sources */,
@@ -2860,6 +2943,7 @@
DB31400617554B71006C0E22 /* SDL_audiotypecvt.c in Sources */, DB31400617554B71006C0E22 /* SDL_audiotypecvt.c in Sources */,
DB31400717554B71006C0E22 /* SDL_mixer.c in Sources */, DB31400717554B71006C0E22 /* SDL_mixer.c in Sources */,
DB31400817554B71006C0E22 /* SDL_wave.c in Sources */, DB31400817554B71006C0E22 /* SDL_wave.c in Sources */,
A704172820F09AC900A82227 /* SDL_hidapi_xbox360.c in Sources */,
DB31400917554B71006C0E22 /* SDL_cpuinfo.c in Sources */, DB31400917554B71006C0E22 /* SDL_cpuinfo.c in Sources */,
DB31400A17554B71006C0E22 /* SDL_clipboardevents.c in Sources */, DB31400A17554B71006C0E22 /* SDL_clipboardevents.c in Sources */,
DB31400B17554B71006C0E22 /* SDL_events.c in Sources */, DB31400B17554B71006C0E22 /* SDL_events.c in Sources */,
@@ -2898,6 +2982,7 @@
DB31402B17554B71006C0E22 /* SDL_thread.c in Sources */, DB31402B17554B71006C0E22 /* SDL_thread.c in Sources */,
DB31402C17554B71006C0E22 /* SDL_timer.c in Sources */, DB31402C17554B71006C0E22 /* SDL_timer.c in Sources */,
DB31402D17554B71006C0E22 /* SDL_systimer.c in Sources */, DB31402D17554B71006C0E22 /* SDL_systimer.c in Sources */,
A704171C20F09AC900A82227 /* SDL_hidapi_switch.c in Sources */,
DB31402E17554B71006C0E22 /* SDL_cocoaclipboard.m in Sources */, DB31402E17554B71006C0E22 /* SDL_cocoaclipboard.m in Sources */,
DB31402F17554B71006C0E22 /* SDL_cocoaevents.m in Sources */, DB31402F17554B71006C0E22 /* SDL_cocoaevents.m in Sources */,
DB31403017554B71006C0E22 /* SDL_cocoakeyboard.m in Sources */, DB31403017554B71006C0E22 /* SDL_cocoakeyboard.m in Sources */,
@@ -2906,6 +2991,7 @@
5C2EF6A41FC98B39003F5197 /* SDL_yuv.c in Sources */, 5C2EF6A41FC98B39003F5197 /* SDL_yuv.c in Sources */,
5C2EF6F31FC9D182003F5197 /* SDL_cocoaopengles.m in Sources */, 5C2EF6F31FC9D182003F5197 /* SDL_cocoaopengles.m in Sources */,
DB31403317554B71006C0E22 /* SDL_cocoaopengl.m in Sources */, DB31403317554B71006C0E22 /* SDL_cocoaopengl.m in Sources */,
A704172520F09AC900A82227 /* SDL_hidapi_xboxone.c in Sources */,
DB31403417554B71006C0E22 /* SDL_cocoashape.m in Sources */, DB31403417554B71006C0E22 /* SDL_cocoashape.m in Sources */,
DB31403517554B71006C0E22 /* SDL_cocoavideo.m in Sources */, DB31403517554B71006C0E22 /* SDL_cocoavideo.m in Sources */,
DB31403617554B71006C0E22 /* SDL_cocoawindow.m in Sources */, DB31403617554B71006C0E22 /* SDL_cocoawindow.m in Sources */,
@@ -2914,6 +3000,8 @@
5C2EF6A61FC98B6C003F5197 /* yuv_rgb.c in Sources */, 5C2EF6A61FC98B6C003F5197 /* yuv_rgb.c in Sources */,
DB31403917554B71006C0E22 /* SDL_blit.c in Sources */, DB31403917554B71006C0E22 /* SDL_blit.c in Sources */,
DB31403A17554B71006C0E22 /* SDL_blit_0.c in Sources */, DB31403A17554B71006C0E22 /* SDL_blit_0.c in Sources */,
A704172220F09AC900A82227 /* SDL_hidapi_ps4.c in Sources */,
A704170B20F09A9800A82227 /* hid.c in Sources */,
DB31403B17554B71006C0E22 /* SDL_blit_1.c in Sources */, DB31403B17554B71006C0E22 /* SDL_blit_1.c in Sources */,
DB31403C17554B71006C0E22 /* SDL_blit_A.c in Sources */, DB31403C17554B71006C0E22 /* SDL_blit_A.c in Sources */,
DB31403D17554B71006C0E22 /* SDL_blit_auto.c in Sources */, DB31403D17554B71006C0E22 /* SDL_blit_auto.c in Sources */,
@@ -2922,6 +3010,7 @@
DB31404017554B71006C0E22 /* SDL_blit_slow.c in Sources */, DB31404017554B71006C0E22 /* SDL_blit_slow.c in Sources */,
DB31404117554B71006C0E22 /* SDL_bmp.c in Sources */, DB31404117554B71006C0E22 /* SDL_bmp.c in Sources */,
DB31404217554B71006C0E22 /* SDL_clipboard.c in Sources */, DB31404217554B71006C0E22 /* SDL_clipboard.c in Sources */,
A704171620F09AC900A82227 /* SDL_hidapijoystick.c in Sources */,
DB31404317554B71006C0E22 /* SDL_fillrect.c in Sources */, DB31404317554B71006C0E22 /* SDL_fillrect.c in Sources */,
DB31404417554B71006C0E22 /* SDL_pixels.c in Sources */, DB31404417554B71006C0E22 /* SDL_pixels.c in Sources */,
DB31404517554B71006C0E22 /* SDL_rect.c in Sources */, DB31404517554B71006C0E22 /* SDL_rect.c in Sources */,
@@ -3019,6 +3108,7 @@
/usr/X11R6/include, /usr/X11R6/include,
"$(VULKAN_SDK)/include", "$(VULKAN_SDK)/include",
../../src/video/khronos, ../../src/video/khronos,
../../src/hidapi/hidapi,
); );
MACOSX_DEPLOYMENT_TARGET = 10.6; MACOSX_DEPLOYMENT_TARGET = 10.6;
SDKROOT = macosx; SDKROOT = macosx;
@@ -3114,6 +3204,7 @@
/usr/X11R6/include, /usr/X11R6/include,
"$(VULKAN_SDK)/include", "$(VULKAN_SDK)/include",
../../src/video/khronos, ../../src/video/khronos,
../../src/hidapi/hidapi,
); );
MACOSX_DEPLOYMENT_TARGET = 10.6; MACOSX_DEPLOYMENT_TARGET = 10.6;
ONLY_ACTIVE_ARCH = YES; ONLY_ACTIVE_ARCH = YES;
@@ -0,0 +1,19 @@
package org.libsdl.app;
interface HIDDevice
{
public int getId();
public int getVendorId();
public int getProductId();
public String getSerialNumber();
public int getVersion();
public String getManufacturerName();
public String getProductName();
public boolean open();
public int sendFeatureReport(byte[] report);
public int sendOutputReport(byte[] report);
public boolean getFeatureReport(byte[] report);
public void setFrozen(boolean frozen);
public void close();
public void shutdown();
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,298 @@
package org.libsdl.app;
import android.hardware.usb.*;
import android.os.Build;
import android.util.Log;
import java.util.Arrays;
class HIDDeviceUSB implements HIDDevice {
private static final String TAG = "hidapi";
protected HIDDeviceManager mManager;
protected UsbDevice mDevice;
protected int mInterface;
protected int mDeviceId;
protected UsbDeviceConnection mConnection;
protected UsbEndpoint mInputEndpoint;
protected UsbEndpoint mOutputEndpoint;
protected InputThread mInputThread;
protected boolean mRunning;
protected boolean mFrozen;
public HIDDeviceUSB(HIDDeviceManager manager, UsbDevice usbDevice, int interface_number) {
mManager = manager;
mDevice = usbDevice;
mInterface = interface_number;
mDeviceId = manager.getDeviceIDForIdentifier(getIdentifier());
mRunning = false;
}
public String getIdentifier() {
return String.format("%s/%x/%x", mDevice.getDeviceName(), mDevice.getVendorId(), mDevice.getProductId());
}
@Override
public int getId() {
return mDeviceId;
}
@Override
public int getVendorId() {
return mDevice.getVendorId();
}
@Override
public int getProductId() {
return mDevice.getProductId();
}
@Override
public String getSerialNumber() {
String result = null;
if (Build.VERSION.SDK_INT >= 21) {
result = mDevice.getSerialNumber();
}
if (result == null) {
result = "";
}
return result;
}
@Override
public int getVersion() {
return 0;
}
@Override
public String getManufacturerName() {
String result = null;
if (Build.VERSION.SDK_INT >= 21) {
result = mDevice.getManufacturerName();
}
if (result == null) {
result = String.format("%x", getVendorId());
}
return result;
}
@Override
public String getProductName() {
String result = null;
if (Build.VERSION.SDK_INT >= 21) {
result = mDevice.getProductName();
}
if (result == null) {
result = String.format("%x", getProductId());
}
return result;
}
public UsbDevice getDevice() {
return mDevice;
}
public String getDeviceName() {
return getManufacturerName() + " " + getProductName() + "(0x" + String.format("%x", getVendorId()) + "/0x" + String.format("%x", getProductId()) + ")";
}
@Override
public boolean open() {
mConnection = mManager.getUSBManager().openDevice(mDevice);
if (mConnection == null) {
Log.w(TAG, "Unable to open USB device " + getDeviceName());
return false;
}
// Force claim all interfaces
for (int i = 0; i < mDevice.getInterfaceCount(); i++) {
UsbInterface iface = mDevice.getInterface(i);
if (!mConnection.claimInterface(iface, true)) {
Log.w(TAG, "Failed to claim interfaces on USB device " + getDeviceName());
close();
return false;
}
}
// Find the endpoints
UsbInterface iface = mDevice.getInterface(mInterface);
for (int j = 0; j < iface.getEndpointCount(); j++) {
UsbEndpoint endpt = iface.getEndpoint(j);
switch (endpt.getDirection()) {
case UsbConstants.USB_DIR_IN:
if (mInputEndpoint == null) {
mInputEndpoint = endpt;
}
break;
case UsbConstants.USB_DIR_OUT:
if (mOutputEndpoint == null) {
mOutputEndpoint = endpt;
}
break;
}
}
// Make sure the required endpoints were present
if (mInputEndpoint == null || mOutputEndpoint == null) {
Log.w(TAG, "Missing required endpoint on USB device " + getDeviceName());
close();
return false;
}
// Start listening for input
mRunning = true;
mInputThread = new InputThread();
mInputThread.start();
return true;
}
@Override
public int sendFeatureReport(byte[] report) {
int res = -1;
int offset = 0;
int length = report.length;
boolean skipped_report_id = false;
byte report_number = report[0];
if (report_number == 0x0) {
++offset;
--length;
skipped_report_id = true;
}
res = mConnection.controlTransfer(
UsbConstants.USB_TYPE_CLASS | 0x01 /*RECIPIENT_INTERFACE*/ | UsbConstants.USB_DIR_OUT,
0x09/*HID set_report*/,
(3/*HID feature*/ << 8) | report_number,
0,
report, offset, length,
1000/*timeout millis*/);
if (res < 0) {
Log.w(TAG, "sendFeatureReport() returned " + res + " on device " + getDeviceName());
return -1;
}
if (skipped_report_id) {
++length;
}
return length;
}
@Override
public int sendOutputReport(byte[] report) {
int r = mConnection.bulkTransfer(mOutputEndpoint, report, report.length, 1000);
if (r != report.length) {
Log.w(TAG, "sendOutputReport() returned " + r + " on device " + getDeviceName());
}
return r;
}
@Override
public boolean getFeatureReport(byte[] report) {
int res = -1;
int offset = 0;
int length = report.length;
boolean skipped_report_id = false;
byte report_number = report[0];
if (report_number == 0x0) {
/* Offset the return buffer by 1, so that the report ID
will remain in byte 0. */
++offset;
--length;
skipped_report_id = true;
}
res = mConnection.controlTransfer(
UsbConstants.USB_TYPE_CLASS | 0x01 /*RECIPIENT_INTERFACE*/ | UsbConstants.USB_DIR_IN,
0x01/*HID get_report*/,
(3/*HID feature*/ << 8) | report_number,
0,
report, offset, length,
1000/*timeout millis*/);
if (res < 0) {
Log.w(TAG, "getFeatureReport() returned " + res + " on device " + getDeviceName());
return false;
}
if (skipped_report_id) {
++res;
++length;
}
byte[] data;
if (res == length) {
data = report;
} else {
data = Arrays.copyOfRange(report, 0, res);
}
mManager.HIDDeviceFeatureReport(mDeviceId, data);
return true;
}
@Override
public void close() {
mRunning = false;
if (mInputThread != null) {
while (mInputThread.isAlive()) {
mInputThread.interrupt();
try {
mInputThread.join();
} catch (InterruptedException e) {
// Keep trying until we're done
}
}
mInputThread = null;
}
if (mConnection != null) {
for (int i = 0; i < mDevice.getInterfaceCount(); i++) {
UsbInterface iface = mDevice.getInterface(i);
mConnection.releaseInterface(iface);
}
mConnection.close();
mConnection = null;
}
}
@Override
public void shutdown() {
close();
mManager = null;
}
@Override
public void setFrozen(boolean frozen) {
mFrozen = frozen;
}
protected class InputThread extends Thread {
@Override
public void run() {
int packetSize = mInputEndpoint.getMaxPacketSize();
byte[] packet = new byte[packetSize];
while (mRunning) {
int r = mConnection.bulkTransfer(mInputEndpoint, packet, packetSize, 1000);
if (r < 0) {
// Could be a timeout or an I/O error
}
if (r > 0) {
byte[] data;
if (r == packetSize) {
data = packet;
} else {
data = Arrays.copyOfRange(packet, 0, r);
}
if (!mFrozen) {
mManager.HIDDeviceInputReport(mDeviceId, data);
}
}
}
}
}
}
@@ -80,7 +80,7 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
protected static Hashtable<Integer, Object> mCursors; protected static Hashtable<Integer, Object> mCursors;
protected static int mLastCursorID; protected static int mLastCursorID;
protected static SDLGenericMotionListener_API12 mMotionListener; protected static SDLGenericMotionListener_API12 mMotionListener;
protected static HIDDeviceManager mHIDDeviceManager;
// This is what SDL runs in. It invokes SDL_main(), eventually // This is what SDL runs in. It invokes SDL_main(), eventually
protected static Thread mSDLThread; protected static Thread mSDLThread;
@@ -241,6 +241,8 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
mClipboardHandler = new SDLClipboardHandler_Old(); mClipboardHandler = new SDLClipboardHandler_Old();
} }
mHIDDeviceManager = new HIDDeviceManager(this);
// Set up the surface // Set up the surface
mSurface = new SDLSurface(getApplication()); mSurface = new SDLSurface(getApplication());
@@ -276,6 +278,10 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
return; return;
} }
if (mHIDDeviceManager != null) {
mHIDDeviceManager.setFrozen(true);
}
SDLActivity.handleNativeState(); SDLActivity.handleNativeState();
} }
@@ -290,6 +296,10 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
return; return;
} }
if (mHIDDeviceManager != null) {
mHIDDeviceManager.setFrozen(false);
}
SDLActivity.handleNativeState(); SDLActivity.handleNativeState();
} }
@@ -330,6 +340,11 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
protected void onDestroy() { protected void onDestroy() {
Log.v(TAG, "onDestroy()"); Log.v(TAG, "onDestroy()");
if (mHIDDeviceManager != null) {
mHIDDeviceManager.close();
mHIDDeviceManager = null;
}
if (SDLActivity.mBrokenLibraries) { if (SDLActivity.mBrokenLibraries) {
super.onDestroy(); super.onDestroy();
// Reset everything in case the user re opens the app // Reset everything in case the user re opens the app
@@ -466,10 +481,7 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
/* The native thread has finished */ /* The native thread has finished */
public static void handleNativeExit() { public static void handleNativeExit() {
SDLActivity.mSDLThread = null; SDLActivity.mSDLThread = null;
mSingleton.finish();
// Make sure we currently have a singleton before we try to call it.
if (mSingleton != null)
mSingleton.finish();
} }
Vendored
+109 -12
View File
@@ -868,6 +868,7 @@ enable_pthread_sem
enable_directx enable_directx
enable_wasapi enable_wasapi
enable_sdl_dlopen enable_sdl_dlopen
enable_hidapi
enable_clock_gettime enable_clock_gettime
enable_rpath enable_rpath
enable_render_d3d enable_render_d3d
@@ -1623,6 +1624,8 @@ Optional Features:
--enable-directx use DirectX for Windows audio/video [[default=yes]] --enable-directx use DirectX for Windows audio/video [[default=yes]]
--enable-wasapi use the Windows WASAPI audio driver [[default=yes]] --enable-wasapi use the Windows WASAPI audio driver [[default=yes]]
--enable-sdl-dlopen use dlopen for shared object loading [[default=yes]] --enable-sdl-dlopen use dlopen for shared object loading [[default=yes]]
--enable-hidapi use HIDAPI for low level joystick drivers
[[default=no]]
--enable-clock_gettime use clock_gettime() instead of gettimeofday() on --enable-clock_gettime use clock_gettime() instead of gettimeofday() on
UNIX [[default=yes]] UNIX [[default=yes]]
--enable-rpath use an rpath when linking SDL [[default=yes]] --enable-rpath use an rpath when linking SDL [[default=yes]]
@@ -16773,7 +16776,7 @@ $as_echo "#define HAVE_SA_SIGACTION 1" >>confdefs.h
fi fi
for ac_header in libunwind.h for ac_header in libunwind.h
do : do :
ac_fn_c_check_header_mongrel "$LINENO" "libunwind.h" "ac_cv_header_libunwind_h" "$ac_includes_default" ac_fn_c_check_header_mongrel "$LINENO" "libunwind.h" "ac_cv_header_libunwind_h" "$ac_includes_default"
if test "x$ac_cv_header_libunwind_h" = xyes; then : if test "x$ac_cv_header_libunwind_h" = xyes; then :
@@ -18377,7 +18380,7 @@ fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for PulseAudio $PULSEAUDIO_REQUIRED_VERSION support" >&5 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for PulseAudio $PULSEAUDIO_REQUIRED_VERSION support" >&5
$as_echo_n "checking for PulseAudio $PULSEAUDIO_REQUIRED_VERSION support... " >&6; } $as_echo_n "checking for PulseAudio $PULSEAUDIO_REQUIRED_VERSION support... " >&6; }
if test x$PKG_CONFIG != xno; then if test x$PKG_CONFIG != xno; then
if $PKG_CONFIG --atleast-pkgconfig-version 0.7 && $PKG_CONFIG --atleast-version $PULSEAUDIO_REQUIRED_VERSION libpulse-simple; then if $PKG_CONFIG --atleast-pkgconfig-version 0.7 && $PKG_CONFIG --atleast-version $PULSEAUDIO_REQUIRED_VERSION libpulse-simple; then
PULSEAUDIO_CFLAGS=`$PKG_CONFIG --cflags libpulse-simple` PULSEAUDIO_CFLAGS=`$PKG_CONFIG --cflags libpulse-simple`
PULSEAUDIO_LIBS=`$PKG_CONFIG --libs libpulse-simple` PULSEAUDIO_LIBS=`$PKG_CONFIG --libs libpulse-simple`
audio_pulseaudio=yes audio_pulseaudio=yes
@@ -20463,7 +20466,7 @@ $as_echo_n "checking for XGenericEvent... " >&6; }
cat confdefs.h - <<_ACEOF >conftest.$ac_ext cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */ /* end confdefs.h. */
#include <X11/Xlib.h> #include <X11/Xlib.h>
int int
main () main ()
@@ -20807,13 +20810,13 @@ $as_echo "#define SDL_VIDEO_DRIVER_X11_XINPUT2 1" >>confdefs.h
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for xinput2 multitouch" >&5 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for xinput2 multitouch" >&5
$as_echo_n "checking for xinput2 multitouch... " >&6; } $as_echo_n "checking for xinput2 multitouch... " >&6; }
have_xinput2_multitouch=no have_xinput2_multitouch=no
cat confdefs.h - <<_ACEOF >conftest.$ac_ext cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */ /* end confdefs.h. */
#include <X11/Xlib.h> #include <X11/Xlib.h>
#include <X11/Xproto.h> #include <X11/Xproto.h>
#include <X11/extensions/XInput2.h> #include <X11/extensions/XInput2.h>
int int
main () main ()
@@ -20828,14 +20831,14 @@ XITouchClassInfo *t;
_ACEOF _ACEOF
if ac_fn_c_try_compile "$LINENO"; then : if ac_fn_c_try_compile "$LINENO"; then :
have_xinput2_multitouch=yes have_xinput2_multitouch=yes
$as_echo "#define SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH 1" >>confdefs.h $as_echo "#define SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH 1" >>confdefs.h
SUMMARY_video_x11="${SUMMARY_video_x11} xinput2_multitouch" SUMMARY_video_x11="${SUMMARY_video_x11} xinput2_multitouch"
fi fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_xinput2_multitouch" >&5 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_xinput2_multitouch" >&5
$as_echo "$have_xinput2_multitouch" >&6; } $as_echo "$have_xinput2_multitouch" >&6; }
fi fi
# Check whether --enable-video-x11-xrandr was given. # Check whether --enable-video-x11-xrandr was given.
@@ -23728,6 +23731,93 @@ $as_echo "#define SDL_JOYSTICK_USBHID 1" >>confdefs.h
esac esac
} }
CheckHIDAPI()
{
# The hidraw support doesn't catch Xbox, PS4 and Nintendo controllers,
# so we'll just use libusb when it's available.
#
# Except that libusb requires root permissions to open devices, so that's not generally useful, and we'll disable this by default.
# Check whether --enable-hidapi was given.
if test "${enable_hidapi+set}" = set; then :
enableval=$enable_hidapi;
else
enable_hidapi=no
fi
if test x$enable_joystick = xyes -a x$enable_hidapi = xyes; then
hidapi_support=no
# Extract the first word of "pkg-config", so it can be a program name with args.
set dummy pkg-config; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if ${ac_cv_path_PKG_CONFIG+:} false; then :
$as_echo_n "(cached) " >&6
else
case $PKG_CONFIG in
[\\/]* | ?:[\\/]*)
ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a path.
;;
*)
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
ac_cv_path_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
done
done
IFS=$as_save_IFS
test -z "$ac_cv_path_PKG_CONFIG" && ac_cv_path_PKG_CONFIG="no"
;;
esac
fi
PKG_CONFIG=$ac_cv_path_PKG_CONFIG
if test -n "$PKG_CONFIG"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $PKG_CONFIG" >&5
$as_echo "$PKG_CONFIG" >&6; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi
if test x$PKG_CONFIG != xno; then
LIBUSB_CFLAGS=`$PKG_CONFIG --cflags libusb-1.0`
LIBUSB_LDFLAGS=`$PKG_CONFIG --libs libusb-1.0`
save_CFLAGS="$CFLAGS"
CFLAGS="$save_CFLAGS $LIBUSB_CFLAGS"
ac_fn_c_check_header_mongrel "$LINENO" "libusb.h" "ac_cv_header_libusb_h" "$ac_includes_default"
if test "x$ac_cv_header_libusb_h" = xyes; then :
have_libusb_h=yes
fi
CFLAGS="$save_CFLAGS"
fi
if test x$have_libusb_h = xyes; then
hidapi_support=yes
$as_echo "#define SDL_JOYSTICK_HIDAPI 1" >>confdefs.h
EXTRA_CFLAGS="$EXTRA_CFLAGS -I$srcdir/src/hidapi/hidapi"
SOURCES="$SOURCES $srcdir/src/joystick/hidapi/*.c"
SOURCES="$SOURCES $srcdir/src/hidapi/libusb/hid.c"
EXTRA_CFLAGS="$EXTRA_CFLAGS $LIBUSB_CFLAGS"
EXTRA_LDFLAGS="$EXTRA_LDFLAGS $LIBUSB_LDFLAGS"
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for hidapi support" >&5
$as_echo_n "checking for hidapi support... " >&6; }
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $hidapi_support" >&5
$as_echo "$hidapi_support" >&6; }
fi
}
CheckClockGettime() CheckClockGettime()
{ {
# Check whether --enable-clock_gettime was given. # Check whether --enable-clock_gettime was given.
@@ -23939,6 +24029,7 @@ case "$host" in
esac esac
CheckTslib CheckTslib
CheckUSBHID CheckUSBHID
CheckHIDAPI
CheckPTHREAD CheckPTHREAD
CheckClockGettime CheckClockGettime
CheckLinuxVersion CheckLinuxVersion
@@ -24514,7 +24605,13 @@ $as_echo "#define SDL_AUDIO_DRIVER_COREAUDIO 1" >>confdefs.h
$as_echo "#define SDL_JOYSTICK_IOKIT 1" >>confdefs.h $as_echo "#define SDL_JOYSTICK_IOKIT 1" >>confdefs.h
$as_echo "#define SDL_JOYSTICK_HIDAPI 1" >>confdefs.h
SOURCES="$SOURCES $srcdir/src/joystick/darwin/*.c" SOURCES="$SOURCES $srcdir/src/joystick/darwin/*.c"
SOURCES="$SOURCES $srcdir/src/joystick/hidapi/*.c"
SOURCES="$SOURCES $srcdir/src/hidapi/mac/hid.c"
EXTRA_CFLAGS="$EXTRA_CFLAGS -I$srcdir/src/hidapi/hidapi"
have_joystick=yes have_joystick=yes
fi fi
# Set up files for the haptic library # Set up files for the haptic library
+55 -15
View File
@@ -285,7 +285,7 @@ if test x$enable_libc = xyes; then
AC_CHECK_MEMBER(struct sigaction.sa_sigaction,[AC_DEFINE([HAVE_SA_SIGACTION], 1, [ ])], ,[#include <signal.h>]) AC_CHECK_MEMBER(struct sigaction.sa_sigaction,[AC_DEFINE([HAVE_SA_SIGACTION], 1, [ ])], ,[#include <signal.h>])
dnl Check for additional non-standard headers dnl Check for additional non-standard headers
AC_CHECK_HEADERS(libunwind.h) AC_CHECK_HEADERS(libunwind.h)
fi fi
@@ -963,7 +963,7 @@ AC_HELP_STRING([--enable-pulseaudio], [use PulseAudio [[default=yes]]]),
AC_PATH_PROG(PKG_CONFIG, pkg-config, no) AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
AC_MSG_CHECKING(for PulseAudio $PULSEAUDIO_REQUIRED_VERSION support) AC_MSG_CHECKING(for PulseAudio $PULSEAUDIO_REQUIRED_VERSION support)
if test x$PKG_CONFIG != xno; then if test x$PKG_CONFIG != xno; then
if $PKG_CONFIG --atleast-pkgconfig-version 0.7 && $PKG_CONFIG --atleast-version $PULSEAUDIO_REQUIRED_VERSION libpulse-simple; then if $PKG_CONFIG --atleast-pkgconfig-version 0.7 && $PKG_CONFIG --atleast-version $PULSEAUDIO_REQUIRED_VERSION libpulse-simple; then
PULSEAUDIO_CFLAGS=`$PKG_CONFIG --cflags libpulse-simple` PULSEAUDIO_CFLAGS=`$PKG_CONFIG --cflags libpulse-simple`
PULSEAUDIO_LIBS=`$PKG_CONFIG --libs libpulse-simple` PULSEAUDIO_LIBS=`$PKG_CONFIG --libs libpulse-simple`
audio_pulseaudio=yes audio_pulseaudio=yes
@@ -1748,7 +1748,7 @@ AC_HELP_STRING([--enable-x11-shared], [dynamically load X11 support [[default=ma
AC_MSG_CHECKING([for XGenericEvent]) AC_MSG_CHECKING([for XGenericEvent])
have_XGenericEvent=no have_XGenericEvent=no
AC_TRY_COMPILE([ AC_TRY_COMPILE([
#include <X11/Xlib.h> #include <X11/Xlib.h>
],[ ],[
Display *display; Display *display;
XEvent event; XEvent event;
@@ -1862,20 +1862,20 @@ AC_HELP_STRING([--enable-video-x11-xinput], [enable X11 XInput extension for man
SUMMARY_video_x11="${SUMMARY_video_x11} xinput2" SUMMARY_video_x11="${SUMMARY_video_x11} xinput2"
AC_DEFINE(SDL_VIDEO_DRIVER_X11_XINPUT2, 1, [ ]) AC_DEFINE(SDL_VIDEO_DRIVER_X11_XINPUT2, 1, [ ])
AC_MSG_CHECKING(for xinput2 multitouch) AC_MSG_CHECKING(for xinput2 multitouch)
have_xinput2_multitouch=no have_xinput2_multitouch=no
AC_TRY_COMPILE([ AC_TRY_COMPILE([
#include <X11/Xlib.h> #include <X11/Xlib.h>
#include <X11/Xproto.h> #include <X11/Xproto.h>
#include <X11/extensions/XInput2.h> #include <X11/extensions/XInput2.h>
],[ ],[
int event_type = XI_TouchBegin; int event_type = XI_TouchBegin;
XITouchClassInfo *t; XITouchClassInfo *t;
],[ ],[
have_xinput2_multitouch=yes have_xinput2_multitouch=yes
AC_DEFINE([SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH], 1, []) AC_DEFINE([SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH], 1, [])
SUMMARY_video_x11="${SUMMARY_video_x11} xinput2_multitouch" SUMMARY_video_x11="${SUMMARY_video_x11} xinput2_multitouch"
]) ])
AC_MSG_RESULT($have_xinput2_multitouch) AC_MSG_RESULT($have_xinput2_multitouch)
fi fi
AC_ARG_ENABLE(video-x11-xrandr, AC_ARG_ENABLE(video-x11-xrandr,
AC_HELP_STRING([--enable-video-x11-xrandr], [enable X11 Xrandr extension for fullscreen [[default=yes]]]), AC_HELP_STRING([--enable-video-x11-xrandr], [enable X11 Xrandr extension for fullscreen [[default=yes]]]),
@@ -3265,6 +3265,41 @@ CheckUSBHID()
esac esac
} }
dnl Check for HIDAPI joystick drivers
CheckHIDAPI()
{
# The hidraw support doesn't catch Xbox, PS4 and Nintendo controllers,
# so we'll just use libusb when it's available.
#
# Except that libusb requires root permissions to open devices, so that's not generally useful, and we'll disable this by default.
AC_ARG_ENABLE(hidapi,
AC_HELP_STRING([--enable-hidapi], [use HIDAPI for low level joystick drivers [[default=no]]]),
, enable_hidapi=no)
if test x$enable_joystick = xyes -a x$enable_hidapi = xyes; then
hidapi_support=no
AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
if test x$PKG_CONFIG != xno; then
LIBUSB_CFLAGS=`$PKG_CONFIG --cflags libusb-1.0`
LIBUSB_LDFLAGS=`$PKG_CONFIG --libs libusb-1.0`
save_CFLAGS="$CFLAGS"
CFLAGS="$save_CFLAGS $LIBUSB_CFLAGS"
AC_CHECK_HEADER(libusb.h, have_libusb_h=yes)
CFLAGS="$save_CFLAGS"
fi
if test x$have_libusb_h = xyes; then
hidapi_support=yes
AC_DEFINE(SDL_JOYSTICK_HIDAPI, 1, [ ])
EXTRA_CFLAGS="$EXTRA_CFLAGS -I$srcdir/src/hidapi/hidapi"
SOURCES="$SOURCES $srcdir/src/joystick/hidapi/*.c"
SOURCES="$SOURCES $srcdir/src/hidapi/libusb/hid.c"
EXTRA_CFLAGS="$EXTRA_CFLAGS $LIBUSB_CFLAGS"
EXTRA_LDFLAGS="$EXTRA_LDFLAGS $LIBUSB_LDFLAGS"
fi
AC_MSG_CHECKING(for hidapi support)
AC_MSG_RESULT($hidapi_support)
fi
}
dnl Check for clock_gettime() dnl Check for clock_gettime()
CheckClockGettime() CheckClockGettime()
{ {
@@ -3386,6 +3421,7 @@ case "$host" in
esac esac
CheckTslib CheckTslib
CheckUSBHID CheckUSBHID
CheckHIDAPI
CheckPTHREAD CheckPTHREAD
CheckClockGettime CheckClockGettime
CheckLinuxVersion CheckLinuxVersion
@@ -3811,7 +3847,11 @@ AC_HELP_STRING([--enable-render-d3d], [enable the Direct3D render driver [[defau
# Set up files for the joystick library # Set up files for the joystick library
if test x$enable_joystick = xyes; then if test x$enable_joystick = xyes; then
AC_DEFINE(SDL_JOYSTICK_IOKIT, 1, [ ]) AC_DEFINE(SDL_JOYSTICK_IOKIT, 1, [ ])
AC_DEFINE(SDL_JOYSTICK_HIDAPI, 1, [ ])
SOURCES="$SOURCES $srcdir/src/joystick/darwin/*.c" SOURCES="$SOURCES $srcdir/src/joystick/darwin/*.c"
SOURCES="$SOURCES $srcdir/src/joystick/hidapi/*.c"
SOURCES="$SOURCES $srcdir/src/hidapi/mac/hid.c"
EXTRA_CFLAGS="$EXTRA_CFLAGS -I$srcdir/src/hidapi/hidapi"
have_joystick=yes have_joystick=yes
fi fi
# Set up files for the haptic library # Set up files for the haptic library
+1
View File
@@ -279,6 +279,7 @@
#undef SDL_JOYSTICK_WINMM #undef SDL_JOYSTICK_WINMM
#undef SDL_JOYSTICK_USBHID #undef SDL_JOYSTICK_USBHID
#undef SDL_JOYSTICK_USBHID_MACHINE_JOYSTICK_H #undef SDL_JOYSTICK_USBHID_MACHINE_JOYSTICK_H
#undef SDL_JOYSTICK_HIDAPI
#undef SDL_JOYSTICK_EMSCRIPTEN #undef SDL_JOYSTICK_EMSCRIPTEN
#undef SDL_HAPTIC_DUMMY #undef SDL_HAPTIC_DUMMY
#undef SDL_HAPTIC_ANDROID #undef SDL_HAPTIC_ANDROID
+1
View File
@@ -134,6 +134,7 @@
/* Enable various input drivers */ /* Enable various input drivers */
#define SDL_JOYSTICK_ANDROID 1 #define SDL_JOYSTICK_ANDROID 1
#define SDL_JOYSTICK_HIDAPI 1
#define SDL_HAPTIC_ANDROID 1 #define SDL_HAPTIC_ANDROID 1
/* Enable various shared object loading systems */ /* Enable various shared object loading systems */
+1
View File
@@ -137,6 +137,7 @@
/* Enable MFi joystick support */ /* Enable MFi joystick support */
#define SDL_JOYSTICK_MFI 1 #define SDL_JOYSTICK_MFI 1
#define SDL_JOYSTICK_HIDAPI 1
/* Enable Unix style SO loading */ /* Enable Unix style SO loading */
#define SDL_LOADSO_DLOPEN 1 #define SDL_LOADSO_DLOPEN 1
+1
View File
@@ -137,6 +137,7 @@
/* Enable various input drivers */ /* Enable various input drivers */
#define SDL_JOYSTICK_IOKIT 1 #define SDL_JOYSTICK_IOKIT 1
#define SDL_JOYSTICK_HIDAPI 1
#define SDL_HAPTIC_IOKIT 1 #define SDL_HAPTIC_IOKIT 1
/* Enable various shared object loading systems */ /* Enable various shared object loading systems */
+1
View File
@@ -190,6 +190,7 @@ typedef unsigned int uintptr_t;
/* Enable various input drivers */ /* Enable various input drivers */
#define SDL_JOYSTICK_DINPUT 1 #define SDL_JOYSTICK_DINPUT 1
#define SDL_JOYSTICK_XINPUT 1 #define SDL_JOYSTICK_XINPUT 1
#define SDL_JOYSTICK_HIDAPI 1
#define SDL_HAPTIC_DINPUT 1 #define SDL_HAPTIC_DINPUT 1
#define SDL_HAPTIC_XINPUT 1 #define SDL_HAPTIC_XINPUT 1
+13
View File
@@ -353,6 +353,19 @@ SDL_GameControllerGetBindForButton(SDL_GameController *gamecontroller,
extern DECLSPEC Uint8 SDLCALL SDL_GameControllerGetButton(SDL_GameController *gamecontroller, extern DECLSPEC Uint8 SDLCALL SDL_GameControllerGetButton(SDL_GameController *gamecontroller,
SDL_GameControllerButton button); SDL_GameControllerButton button);
/**
* Trigger a rumble effect
* Each call to this function cancels any previous rumble effect, and calling it with 0 intensity stops any rumbling.
*
* \param gamecontroller The controller to vibrate
* \param low_frequency_rumble The intensity of the low frequency (left) rumble motor, from 0 to 0xFFFF
* \param high_frequency_rumble The intensity of the high frequency (right) rumble motor, from 0 to 0xFFFF
* \param duration_ms The duration of the rumble effect, in milliseconds
*
* \return 0, or -1 if rumble isn't supported on this joystick
*/
extern DECLSPEC int SDLCALL SDL_GameControllerRumble(SDL_GameController *gamecontroller, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble, Uint32 duration_ms);
/** /**
* Close a controller previously opened with SDL_GameControllerOpen(). * Close a controller previously opened with SDL_GameControllerOpen().
*/ */
+3 -3
View File
@@ -656,8 +656,8 @@ typedef struct SDL_HapticRamp
* This struct is exclusively for the ::SDL_HAPTIC_LEFTRIGHT effect. * This struct is exclusively for the ::SDL_HAPTIC_LEFTRIGHT effect.
* *
* The Left/Right effect is used to explicitly control the large and small * The Left/Right effect is used to explicitly control the large and small
* motors, commonly found in modern game controllers. One motor is high * motors, commonly found in modern game controllers. The small (right) motor
* frequency, the other is low frequency. * is high frequency, and the large (left) motor is low frequency.
* *
* \sa SDL_HAPTIC_LEFTRIGHT * \sa SDL_HAPTIC_LEFTRIGHT
* \sa SDL_HapticEffect * \sa SDL_HapticEffect
@@ -668,7 +668,7 @@ typedef struct SDL_HapticLeftRight
Uint16 type; /**< ::SDL_HAPTIC_LEFTRIGHT */ Uint16 type; /**< ::SDL_HAPTIC_LEFTRIGHT */
/* Replay */ /* Replay */
Uint32 length; /**< Duration of the effect. */ Uint32 length; /**< Duration of the effect in milliseconds. */
/* Rumble */ /* Rumble */
Uint16 large_magnitude; /**< Control of the large controller motor. */ Uint16 large_magnitude; /**< Control of the large controller motor. */
+78
View File
@@ -465,6 +465,84 @@ extern "C" {
*/ */
#define SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS "SDL_JOYSTICK_ALLOW_BACKGROUND_EVENTS" #define SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS "SDL_JOYSTICK_ALLOW_BACKGROUND_EVENTS"
/**
* \brief A variable controlling whether the HIDAPI joystick drivers should be used.
*
* This variable can be set to the following values:
* "0" - HIDAPI drivers are not used
* "1" - HIDAPI drivers are used (the default)
*
* This variable is the default for all drivers, but can be overridden by the hints for specific drivers below.
*/
#define SDL_HINT_JOYSTICK_HIDAPI "SDL_JOYSTICK_HIDAPI"
/**
* \brief A variable controlling whether the HIDAPI driver for PS4 controllers should be used.
*
* This variable can be set to the following values:
* "0" - HIDAPI driver is not used
* "1" - HIDAPI driver is used
*
* The default is the value of SDL_HINT_JOYSTICK_HIDAPI
*/
#define SDL_HINT_JOYSTICK_HIDAPI_PS4 "SDL_JOYSTICK_HIDAPI_PS4"
/**
* \brief A variable controlling whether the HIDAPI driver for Steam Controllers should be used.
*
* This variable can be set to the following values:
* "0" - HIDAPI driver is not used
* "1" - HIDAPI driver is used
*
* The default is the value of SDL_HINT_JOYSTICK_HIDAPI
*/
#define SDL_HINT_JOYSTICK_HIDAPI_STEAM "SDL_JOYSTICK_HIDAPI_STEAM"
/**
* \brief A variable controlling whether the HIDAPI driver for Nintendo Switch controllers should be used.
*
* This variable can be set to the following values:
* "0" - HIDAPI driver is not used
* "1" - HIDAPI driver is used
*
* The default is the value of SDL_HINT_JOYSTICK_HIDAPI
*/
#define SDL_HINT_JOYSTICK_HIDAPI_SWITCH "SDL_JOYSTICK_HIDAPI_SWITCH"
/**
* \brief A variable controlling whether the HIDAPI driver for XBox 360 controllers should be used.
*
* This variable can be set to the following values:
* "0" - HIDAPI driver is not used
* "1" - HIDAPI driver is used
*
* The default is the value of SDL_HINT_JOYSTICK_HIDAPI
*/
#define SDL_HINT_JOYSTICK_HIDAPI_XBOX360 "SDL_JOYSTICK_HIDAPI_XBOX360"
/**
* \brief A variable controlling whether the HIDAPI driver for XBox One controllers should be used.
*
* This variable can be set to the following values:
* "0" - HIDAPI driver is not used
* "1" - HIDAPI driver is used
*
* The default is the value of SDL_HINT_JOYSTICK_HIDAPI
*/
#define SDL_HINT_JOYSTICK_HIDAPI_XBOXONE "SDL_JOYSTICK_HIDAPI_XBOXONE"
/**
* \brief A variable that controls whether Steam Controllers should be exposed using the SDL joystick and game controller APIs
*
* The variable can be set to the following values:
* "0" - Do not scan for Steam Controllers
* "1" - Scan for Steam Controllers (the default)
*
* The default value is "1". This hint must be set before initializing the joystick subsystem.
*/
#define SDL_HINT_ENABLE_STEAM_CONTROLLERS "SDL_ENABLE_STEAM_CONTROLLERS"
/** /**
* \brief If set to "0" then never set the top most bit on a SDL Window, even if the video mode expects it. * \brief If set to "0" then never set the top most bit on a SDL Window, even if the video mode expects it.
* This is a debugging aid for developers and not expected to be used by end users. The default is "1" * This is a debugging aid for developers and not expected to be used by end users. The default is "1"
+17 -4
View File
@@ -97,10 +97,10 @@ typedef enum
typedef enum typedef enum
{ {
SDL_JOYSTICK_POWER_UNKNOWN = -1, SDL_JOYSTICK_POWER_UNKNOWN = -1,
SDL_JOYSTICK_POWER_EMPTY, SDL_JOYSTICK_POWER_EMPTY, /* <= 5% */
SDL_JOYSTICK_POWER_LOW, SDL_JOYSTICK_POWER_LOW, /* <= 20% */
SDL_JOYSTICK_POWER_MEDIUM, SDL_JOYSTICK_POWER_MEDIUM, /* <= 70% */
SDL_JOYSTICK_POWER_FULL, SDL_JOYSTICK_POWER_FULL, /* <= 100% */
SDL_JOYSTICK_POWER_WIRED, SDL_JOYSTICK_POWER_WIRED,
SDL_JOYSTICK_POWER_MAX SDL_JOYSTICK_POWER_MAX
} SDL_JoystickPowerLevel; } SDL_JoystickPowerLevel;
@@ -361,6 +361,19 @@ extern DECLSPEC int SDLCALL SDL_JoystickGetBall(SDL_Joystick * joystick,
extern DECLSPEC Uint8 SDLCALL SDL_JoystickGetButton(SDL_Joystick * joystick, extern DECLSPEC Uint8 SDLCALL SDL_JoystickGetButton(SDL_Joystick * joystick,
int button); int button);
/**
* Trigger a rumble effect
* Each call to this function cancels any previous rumble effect, and calling it with 0 intensity stops any rumbling.
*
* \param joystick The joystick to vibrate
* \param low_frequency_rumble The intensity of the low frequency (left) rumble motor, from 0 to 0xFFFF
* \param high_frequency_rumble The intensity of the high frequency (right) rumble motor, from 0 to 0xFFFF
* \param duration_ms The duration of the rumble effect, in milliseconds
*
* \return 0, or -1 if rumble isn't supported on this joystick
*/
extern DECLSPEC int SDLCALL SDL_JoystickRumble(SDL_Joystick * joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble, Uint32 duration_ms);
/** /**
* Close a joystick previously opened with SDL_JoystickOpen(). * Close a joystick previously opened with SDL_JoystickOpen().
*/ */
+1
View File
@@ -450,6 +450,7 @@ extern DECLSPEC void *SDLCALL SDL_memcpy(SDL_OUT_BYTECAP(len) void *dst, SDL_IN_
extern DECLSPEC void *SDLCALL SDL_memmove(SDL_OUT_BYTECAP(len) void *dst, SDL_IN_BYTECAP(len) const void *src, size_t len); extern DECLSPEC void *SDLCALL SDL_memmove(SDL_OUT_BYTECAP(len) void *dst, SDL_IN_BYTECAP(len) const void *src, size_t len);
extern DECLSPEC int SDLCALL SDL_memcmp(const void *s1, const void *s2, size_t len); extern DECLSPEC int SDLCALL SDL_memcmp(const void *s1, const void *s2, size_t len);
extern DECLSPEC wchar_t *SDLCALL SDL_wcsdup(const wchar_t *wstr);
extern DECLSPEC size_t SDLCALL SDL_wcslen(const wchar_t *wstr); extern DECLSPEC size_t SDLCALL SDL_wcslen(const wchar_t *wstr);
extern DECLSPEC size_t SDLCALL SDL_wcslcpy(SDL_OUT_Z_CAP(maxlen) wchar_t *dst, const wchar_t *src, size_t maxlen); extern DECLSPEC size_t SDLCALL SDL_wcslcpy(SDL_OUT_Z_CAP(maxlen) wchar_t *dst, const wchar_t *src, size_t maxlen);
extern DECLSPEC size_t SDLCALL SDL_wcslcat(SDL_INOUT_Z_CAP(maxlen) wchar_t *dst, const wchar_t *src, size_t maxlen); extern DECLSPEC size_t SDLCALL SDL_wcslcat(SDL_INOUT_Z_CAP(maxlen) wchar_t *dst, const wchar_t *src, size_t maxlen);
+3
View File
@@ -677,3 +677,6 @@
#define SDL_AndroidBackButton SDL_AndroidBackButton_REAL #define SDL_AndroidBackButton SDL_AndroidBackButton_REAL
#define SDL_exp SDL_exp_REAL #define SDL_exp SDL_exp_REAL
#define SDL_expf SDL_expf_REAL #define SDL_expf SDL_expf_REAL
#define SDL_wcsdup SDL_wcsdup_REAL
#define SDL_GameControllerRumble SDL_GameControllerRumble_REAL
#define SDL_JoystickRumble SDL_JoystickRumble_REAL
+3 -2
View File
@@ -715,9 +715,10 @@ SDL_DYNAPI_PROC(SDL_bool,SDL_HasAVX512F,(void),(),return)
#ifdef __ANDROID__ #ifdef __ANDROID__
SDL_DYNAPI_PROC(SDL_bool,SDL_IsChromebook,(void),(),return) SDL_DYNAPI_PROC(SDL_bool,SDL_IsChromebook,(void),(),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_IsDeXMode,(void),(),return) SDL_DYNAPI_PROC(SDL_bool,SDL_IsDeXMode,(void),(),return)
#endif
#ifdef __ANDROID__
SDL_DYNAPI_PROC(void,SDL_AndroidBackButton,(void),(),return) SDL_DYNAPI_PROC(void,SDL_AndroidBackButton,(void),(),return)
#endif #endif
SDL_DYNAPI_PROC(double,SDL_exp,(double a),(a),return) SDL_DYNAPI_PROC(double,SDL_exp,(double a),(a),return)
SDL_DYNAPI_PROC(float,SDL_expf,(float a),(a),return) SDL_DYNAPI_PROC(float,SDL_expf,(float a),(a),return)
SDL_DYNAPI_PROC(wchar_t*,SDL_wcsdup,(const wchar_t *a),(a),return)
SDL_DYNAPI_PROC(int,SDL_GameControllerRumble,(SDL_GameController *a, Uint16 b, Uint16 c, Uint32 d),(a,b,c,d),return)
SDL_DYNAPI_PROC(int,SDL_JoystickRumble,(SDL_Joystick *a, Uint16 b, Uint16 c, Uint32 d),(a,b,c,d),return)
+21 -8
View File
@@ -102,6 +102,7 @@ typedef struct _ControllerMapping_t
static SDL_JoystickGUID s_zeroGUID; static SDL_JoystickGUID s_zeroGUID;
static ControllerMapping_t *s_pSupportedControllers = NULL; static ControllerMapping_t *s_pSupportedControllers = NULL;
static ControllerMapping_t *s_pDefaultMapping = NULL; static ControllerMapping_t *s_pDefaultMapping = NULL;
static ControllerMapping_t *s_pHIDAPIMapping = NULL;
static ControllerMapping_t *s_pXInputMapping = NULL; static ControllerMapping_t *s_pXInputMapping = NULL;
/* The SDL game controller structure */ /* The SDL game controller structure */
@@ -430,6 +431,10 @@ static ControllerMapping_t *SDL_PrivateGetControllerMappingForGUID(SDL_JoystickG
} }
pSupportedController = pSupportedController->next; pSupportedController = pSupportedController->next;
} }
if (guid->data[14] == 'h') {
/* This is a HIDAPI device */
return s_pHIDAPIMapping;
}
#if SDL_JOYSTICK_XINPUT #if SDL_JOYSTICK_XINPUT
if (guid->data[14] == 'x') { if (guid->data[14] == 'x') {
/* This is an XInput device */ /* This is an XInput device */
@@ -1130,6 +1135,7 @@ SDL_PrivateGameControllerAddMapping(const char *mappingString, SDL_ControllerMap
char *pchGUID; char *pchGUID;
SDL_JoystickGUID jGUID; SDL_JoystickGUID jGUID;
SDL_bool is_default_mapping = SDL_FALSE; SDL_bool is_default_mapping = SDL_FALSE;
SDL_bool is_hidapi_mapping = SDL_FALSE;
SDL_bool is_xinput_mapping = SDL_FALSE; SDL_bool is_xinput_mapping = SDL_FALSE;
SDL_bool existing = SDL_FALSE; SDL_bool existing = SDL_FALSE;
ControllerMapping_t *pControllerMapping; ControllerMapping_t *pControllerMapping;
@@ -1144,6 +1150,8 @@ SDL_PrivateGameControllerAddMapping(const char *mappingString, SDL_ControllerMap
} }
if (!SDL_strcasecmp(pchGUID, "default")) { if (!SDL_strcasecmp(pchGUID, "default")) {
is_default_mapping = SDL_TRUE; is_default_mapping = SDL_TRUE;
} else if (!SDL_strcasecmp(pchGUID, "hidapi")) {
is_hidapi_mapping = SDL_TRUE;
} else if (!SDL_strcasecmp(pchGUID, "xinput")) { } else if (!SDL_strcasecmp(pchGUID, "xinput")) {
is_xinput_mapping = SDL_TRUE; is_xinput_mapping = SDL_TRUE;
} }
@@ -1160,6 +1168,8 @@ SDL_PrivateGameControllerAddMapping(const char *mappingString, SDL_ControllerMap
} else { } else {
if (is_default_mapping) { if (is_default_mapping) {
s_pDefaultMapping = pControllerMapping; s_pDefaultMapping = pControllerMapping;
} else if (is_hidapi_mapping) {
s_pHIDAPIMapping = pControllerMapping;
} else if (is_xinput_mapping) { } else if (is_xinput_mapping) {
s_pXInputMapping = pControllerMapping; s_pXInputMapping = pControllerMapping;
} }
@@ -1458,7 +1468,6 @@ SDL_bool SDL_ShouldIgnoreGameController(const char *name, SDL_JoystickGUID guid)
} }
SDL_GetJoystickGUIDInfo(guid, &vendor, &product, NULL); SDL_GetJoystickGUIDInfo(guid, &vendor, &product, NULL);
vidpid = MAKE_VIDPID(vendor, product);
if (SDL_GetHintBoolean("SDL_GAMECONTROLLER_ALLOW_STEAM_VIRTUAL_GAMEPAD", SDL_FALSE)) { if (SDL_GetHintBoolean("SDL_GAMECONTROLLER_ALLOW_STEAM_VIRTUAL_GAMEPAD", SDL_FALSE)) {
/* We shouldn't ignore Steam's virtual gamepad since it's using the hints to filter out the real controllers so it can remap input for the virtual controller */ /* We shouldn't ignore Steam's virtual gamepad since it's using the hints to filter out the real controllers so it can remap input for the virtual controller */
@@ -1476,6 +1485,8 @@ SDL_bool SDL_ShouldIgnoreGameController(const char *name, SDL_JoystickGUID guid)
} }
} }
vidpid = MAKE_VIDPID(vendor, product);
if (SDL_allowed_controllers.num_entries > 0) { if (SDL_allowed_controllers.num_entries > 0) {
for (i = 0; i < SDL_allowed_controllers.num_entries; ++i) { for (i = 0; i < SDL_allowed_controllers.num_entries; ++i) {
if (vidpid == SDL_allowed_controllers.entries[i]) { if (vidpid == SDL_allowed_controllers.entries[i]) {
@@ -1503,22 +1514,18 @@ SDL_bool SDL_ShouldIgnoreGameController(const char *name, SDL_JoystickGUID guid)
SDL_GameController * SDL_GameController *
SDL_GameControllerOpen(int device_index) SDL_GameControllerOpen(int device_index)
{ {
SDL_JoystickID instance_id;
SDL_GameController *gamecontroller; SDL_GameController *gamecontroller;
SDL_GameController *gamecontrollerlist; SDL_GameController *gamecontrollerlist;
ControllerMapping_t *pSupportedController = NULL; ControllerMapping_t *pSupportedController = NULL;
SDL_LockJoysticks(); SDL_LockJoysticks();
if ((device_index < 0) || (device_index >= SDL_NumJoysticks())) {
SDL_SetError("There are %d joysticks available", SDL_NumJoysticks());
SDL_UnlockJoysticks();
return (NULL);
}
gamecontrollerlist = SDL_gamecontrollers; gamecontrollerlist = SDL_gamecontrollers;
/* If the controller is already open, return it */ /* If the controller is already open, return it */
instance_id = SDL_JoystickGetDeviceInstanceID(device_index);
while (gamecontrollerlist) { while (gamecontrollerlist) {
if (SDL_SYS_GetInstanceIdOfDeviceIndex(device_index) == gamecontrollerlist->joystick->instance_id) { if (instance_id == gamecontrollerlist->joystick->instance_id) {
gamecontroller = gamecontrollerlist; gamecontroller = gamecontrollerlist;
++gamecontroller->ref_count; ++gamecontroller->ref_count;
SDL_UnlockJoysticks(); SDL_UnlockJoysticks();
@@ -1834,6 +1841,12 @@ SDL_GameControllerButtonBind SDL_GameControllerGetBindForButton(SDL_GameControll
} }
int
SDL_GameControllerRumble(SDL_GameController *gamecontroller, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble, Uint32 duration_ms)
{
return SDL_JoystickRumble(SDL_GameControllerGetJoystick(gamecontroller), low_frequency_rumble, high_frequency_rumble, duration_ms);
}
void void
SDL_GameControllerClose(SDL_GameController * gamecontroller) SDL_GameControllerClose(SDL_GameController * gamecontroller)
{ {
+2
View File
@@ -555,6 +555,7 @@ static const char *s_ControllerMappings [] =
"05000000bc20000000550000ffff3f00,GameSir G3w,a:b0,b:b1,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,leftshoulder:b9,leftstick:b7,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a4,rightx:a2,righty:a3,start:b6,x:b2,y:b3,", "05000000bc20000000550000ffff3f00,GameSir G3w,a:b0,b:b1,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,leftshoulder:b9,leftstick:b7,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a4,rightx:a2,righty:a3,start:b6,x:b2,y:b3,",
"050000005509000003720000cf7f3f00,NVIDIA Controller v01.01,a:b0,b:b1,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b2,y:b3,", "050000005509000003720000cf7f3f00,NVIDIA Controller v01.01,a:b0,b:b1,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b2,y:b3,",
"050000005509000010720000ffff3f00,NVIDIA Controller v01.03,a:b0,b:b1,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b2,y:b3,", "050000005509000010720000ffff3f00,NVIDIA Controller v01.03,a:b0,b:b1,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b2,y:b3,",
"050000007e05000009200000ffff0f00,Nintendo Switch Pro Controller,a:b0,b:b1,back:b15,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b5,leftshoulder:b3,leftstick:b4,lefttrigger:b9,leftx:a0,lefty:a1,rightshoulder:b18,rightstick:b6,righttrigger:b10,rightx:a2,righty:a3,start:b16,x:b17,y:b2,", /* Extremely slow in Bluetooth mode on Android */
"050000004c05000068020000dfff3f00,PS3 Controller,a:b0,b:b1,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b2,y:b3,", "050000004c05000068020000dfff3f00,PS3 Controller,a:b0,b:b1,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b2,y:b3,",
"050000004c050000c4050000fffe3f00,PS4 Controller,a:b1,b:b17,back:b15,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b5,leftshoulder:b3,leftstick:b4,lefttrigger:+a3,leftx:a0,lefty:a1,rightshoulder:b18,rightstick:b6,righttrigger:+a4,rightx:a2,righty:a5,start:b16,x:b0,y:b2,", "050000004c050000c4050000fffe3f00,PS4 Controller,a:b1,b:b17,back:b15,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b5,leftshoulder:b3,leftstick:b4,lefttrigger:+a3,leftx:a0,lefty:a1,rightshoulder:b18,rightstick:b6,righttrigger:+a4,rightx:a2,righty:a5,start:b16,x:b0,y:b2,",
"050000004c050000cc090000fffe3f00,PS4 Controller,a:b1,b:b17,back:b15,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b5,leftshoulder:b3,leftstick:b4,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b18,rightstick:b6,righttrigger:a4,rightx:a2,righty:a5,start:b16,x:b0,y:b2,", "050000004c050000cc090000fffe3f00,PS4 Controller,a:b1,b:b17,back:b15,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b5,leftshoulder:b3,leftstick:b4,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b18,rightstick:b6,righttrigger:a4,rightx:a2,righty:a5,start:b16,x:b0,y:b2,",
@@ -575,6 +576,7 @@ static const char *s_ControllerMappings [] =
#if defined(SDL_JOYSTICK_EMSCRIPTEN) #if defined(SDL_JOYSTICK_EMSCRIPTEN)
"default,Standard Gamepad,a:b0,b:b1,back:b8,dpdown:b13,dpleft:b14,dpright:b15,dpup:b12,guide:b16,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,", "default,Standard Gamepad,a:b0,b:b1,back:b8,dpdown:b13,dpleft:b14,dpright:b15,dpup:b12,guide:b16,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,",
#endif #endif
"hidapi,*,a:b0,b:b1,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b5,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b2,y:b3,",
NULL NULL
}; };
File diff suppressed because it is too large Load Diff
+30 -1
View File
@@ -23,19 +23,48 @@
/* Useful functions and variables from SDL_joystick.c */ /* Useful functions and variables from SDL_joystick.c */
#include "SDL_joystick.h" #include "SDL_joystick.h"
struct _SDL_JoystickDriver;
/* Initialization and shutdown functions */ /* Initialization and shutdown functions */
extern int SDL_JoystickInit(void); extern int SDL_JoystickInit(void);
extern void SDL_JoystickQuit(void); extern void SDL_JoystickQuit(void);
/* Function to get the next available joystick instance ID */
extern SDL_JoystickID SDL_GetNextJoystickInstanceID(void);
/* Initialization and shutdown functions */ /* Initialization and shutdown functions */
extern int SDL_GameControllerInitMappings(void); extern int SDL_GameControllerInitMappings(void);
extern void SDL_GameControllerQuitMappings(void); extern void SDL_GameControllerQuitMappings(void);
extern int SDL_GameControllerInit(void); extern int SDL_GameControllerInit(void);
extern void SDL_GameControllerQuit(void); extern void SDL_GameControllerQuit(void);
/* Function to get the joystick driver and device index for an API device index */
extern SDL_bool SDL_GetDriverAndJoystickIndex(int device_index, struct _SDL_JoystickDriver **driver, int *driver_index);
/* Function to return the device index for a joystick ID, or -1 if not found */
extern int SDL_JoystickGetDeviceIndexFromInstanceID(SDL_JoystickID instance_id);
/* Function to extract information from an SDL joystick GUID */ /* Function to extract information from an SDL joystick GUID */
extern void SDL_GetJoystickGUIDInfo(SDL_JoystickGUID guid, Uint16 *vendor, Uint16 *product, Uint16 *version); extern void SDL_GetJoystickGUIDInfo(SDL_JoystickGUID guid, Uint16 *vendor, Uint16 *product, Uint16 *version);
/* Function to return whether a joystick is a PS4 controller */
extern SDL_bool SDL_IsJoystickPS4(Uint16 vendor_id, Uint16 product_id);
/* Function to return whether a joystick is a Nintendo Switch Pro controller */
extern SDL_bool SDL_IsJoystickNintendoSwitchPro(Uint16 vendor_id, Uint16 product_id);
/* Function to return whether a joystick is a Steam Controller */
extern SDL_bool SDL_IsJoystickSteamController(Uint16 vendor_id, Uint16 product_id);
/* Function to return whether a joystick is an Xbox 360 controller */
extern SDL_bool SDL_IsJoystickXbox360(Uint16 vendor_id, Uint16 product_id);
/* Function to return whether a joystick is an Xbox One controller */
extern SDL_bool SDL_IsJoystickXboxOne(Uint16 vendor_id, Uint16 product_id);
/* Function to return whether a joystick should be ignored */
extern SDL_bool SDL_ShouldIgnoreJoystick(const char *name, SDL_JoystickGUID guid);
/* Function to return whether a joystick name and GUID is a game controller */ /* Function to return whether a joystick name and GUID is a game controller */
extern SDL_bool SDL_IsGameControllerNameAndGUID(const char *name, SDL_JoystickGUID guid); extern SDL_bool SDL_IsGameControllerNameAndGUID(const char *name, SDL_JoystickGUID guid);
@@ -46,7 +75,7 @@ extern SDL_bool SDL_ShouldIgnoreGameController(const char *name, SDL_JoystickGUI
extern void SDL_GameControllerHandleDelayedGuideButton(SDL_Joystick *joystick); extern void SDL_GameControllerHandleDelayedGuideButton(SDL_Joystick *joystick);
/* Internal event queueing functions */ /* Internal event queueing functions */
extern void SDL_PrivateJoystickAdded(int device_index); extern void SDL_PrivateJoystickAdded(SDL_JoystickID device_instance);
extern void SDL_PrivateJoystickRemoved(SDL_JoystickID device_instance); extern void SDL_PrivateJoystickRemoved(SDL_JoystickID device_instance);
extern int SDL_PrivateJoystickAxis(SDL_Joystick * joystick, extern int SDL_PrivateJoystickAxis(SDL_Joystick * joystick,
Uint8 axis, Sint16 value); Uint8 axis, Sint16 value);
+69 -42
View File
@@ -42,6 +42,7 @@ struct _SDL_Joystick
{ {
SDL_JoystickID instance_id; /* Device instance, monotonically increasing from 0 */ SDL_JoystickID instance_id; /* Device instance, monotonically increasing from 0 */
char *name; /* Joystick name - system dependent */ char *name; /* Joystick name - system dependent */
SDL_JoystickGUID guid; /* Joystick guid */
int naxes; /* Number of axis controls on the joystick */ int naxes; /* Number of axis controls on the joystick */
SDL_JoystickAxisInfo *axes; SDL_JoystickAxisInfo *axes;
@@ -58,69 +59,95 @@ struct _SDL_Joystick
int nbuttons; /* Number of buttons on the joystick */ int nbuttons; /* Number of buttons on the joystick */
Uint8 *buttons; /* Current button states */ Uint8 *buttons; /* Current button states */
struct joystick_hwdata *hwdata; /* Driver dependent information */
int ref_count; /* Reference count for multiple opens */
SDL_bool is_game_controller; SDL_bool is_game_controller;
SDL_bool delayed_guide_button; /* SDL_TRUE if this device has the guide button event delayed */ SDL_bool delayed_guide_button; /* SDL_TRUE if this device has the guide button event delayed */
SDL_bool force_recentering; /* SDL_TRUE if this device needs to have its state reset to 0 */ SDL_bool force_recentering; /* SDL_TRUE if this device needs to have its state reset to 0 */
SDL_JoystickPowerLevel epowerlevel; /* power level of this joystick, SDL_JOYSTICK_POWER_UNKNOWN if not supported */ SDL_JoystickPowerLevel epowerlevel; /* power level of this joystick, SDL_JOYSTICK_POWER_UNKNOWN if not supported */
struct _SDL_JoystickDriver *driver;
struct joystick_hwdata *hwdata; /* Driver dependent information */
int ref_count; /* Reference count for multiple opens */
struct _SDL_Joystick *next; /* pointer to next joystick we have allocated */ struct _SDL_Joystick *next; /* pointer to next joystick we have allocated */
}; };
#if defined(__IPHONEOS__) || defined(__ANDROID__)
#define HAVE_STEAMCONTROLLERS
#define USE_STEAMCONTROLLER_HIDAPI
#elif defined(__LINUX__)
#define HAVE_STEAMCONTROLLERS
#define USE_STEAMCONTROLLER_LINUX
#endif
/* Device bus definitions */
#define SDL_HARDWARE_BUS_USB 0x03
#define SDL_HARDWARE_BUS_BLUETOOTH 0x05
/* Macro to combine a USB vendor ID and product ID into a single Uint32 value */ /* Macro to combine a USB vendor ID and product ID into a single Uint32 value */
#define MAKE_VIDPID(VID, PID) (((Uint32)(VID))<<16|(PID)) #define MAKE_VIDPID(VID, PID) (((Uint32)(VID))<<16|(PID))
/* Function to scan the system for joysticks. typedef struct _SDL_JoystickDriver
* Joystick 0 should be the system default joystick. {
* This function should return the number of available joysticks, or -1 /* Function to scan the system for joysticks.
* on an unrecoverable fatal error. * Joystick 0 should be the system default joystick.
*/ * This function should return 0, or -1 on an unrecoverable error.
extern int SDL_SYS_JoystickInit(void); */
int (*Init)(void);
/* Function to return the number of joystick devices plugged in right now */ /* Function to return the number of joystick devices plugged in right now */
extern int SDL_SYS_NumJoysticks(void); int (*GetCount)(void);
/* Function to cause any queued joystick insertions to be processed */ /* Function to cause any queued joystick insertions to be processed */
extern void SDL_SYS_JoystickDetect(void); void (*Detect)(void);
/* Function to get the device-dependent name of a joystick */ /* Function to get the device-dependent name of a joystick */
extern const char *SDL_SYS_JoystickNameForDeviceIndex(int device_index); const char *(*GetDeviceName)(int device_index);
/* Function to get the current instance id of the joystick located at device_index */ /* Function to return the stable GUID for a plugged in device */
extern SDL_JoystickID SDL_SYS_GetInstanceIdOfDeviceIndex(int device_index); SDL_JoystickGUID (*GetDeviceGUID)(int device_index);
/* Function to open a joystick for use. /* Function to get the current instance id of the joystick located at device_index */
The joystick to open is specified by the device index. SDL_JoystickID (*GetDeviceInstanceID)(int device_index);
This should fill the nbuttons and naxes fields of the joystick structure.
It returns 0, or -1 if there is an error.
*/
extern int SDL_SYS_JoystickOpen(SDL_Joystick * joystick, int device_index);
/* Function to query if the joystick is currently attached /* Function to open a joystick for use.
* It returns SDL_TRUE if attached, SDL_FALSE otherwise. The joystick to open is specified by the device index.
*/ This should fill the nbuttons and naxes fields of the joystick structure.
extern SDL_bool SDL_SYS_JoystickAttached(SDL_Joystick * joystick); It returns 0, or -1 if there is an error.
*/
int (*Open)(SDL_Joystick * joystick, int device_index);
/* Function to update the state of a joystick - called as a device poll. /* Function to query if the joystick is currently attached
* This function shouldn't update the joystick structure directly, * It returns SDL_TRUE if attached, SDL_FALSE otherwise.
* but instead should call SDL_PrivateJoystick*() to deliver events */
* and update joystick device state. SDL_bool (*IsAttached)(SDL_Joystick * joystick);
*/
extern void SDL_SYS_JoystickUpdate(SDL_Joystick * joystick);
/* Function to close a joystick after use */ /* Rumble functionality */
extern void SDL_SYS_JoystickClose(SDL_Joystick * joystick); int (*Rumble)(SDL_Joystick * joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble, Uint32 duration_ms);
/* Function to perform any system-specific joystick related cleanup */ /* Function to update the state of a joystick - called as a device poll.
extern void SDL_SYS_JoystickQuit(void); * This function shouldn't update the joystick structure directly,
* but instead should call SDL_PrivateJoystick*() to deliver events
* and update joystick device state.
*/
void (*Update)(SDL_Joystick * joystick);
/* Function to return the stable GUID for a plugged in device */ /* Function to close a joystick after use */
extern SDL_JoystickGUID SDL_SYS_JoystickGetDeviceGUID(int device_index); void (*Close)(SDL_Joystick * joystick);
/* Function to return the stable GUID for a opened joystick */ /* Function to perform any system-specific joystick related cleanup */
extern SDL_JoystickGUID SDL_SYS_JoystickGetGUID(SDL_Joystick * joystick); void (*Quit)(void);
} SDL_JoystickDriver;
/* The available joystick drivers */
extern SDL_JoystickDriver SDL_ANDROID_JoystickDriver;
extern SDL_JoystickDriver SDL_DARWIN_JoystickDriver;
extern SDL_JoystickDriver SDL_DUMMY_JoystickDriver;
extern SDL_JoystickDriver SDL_HIDAPI_JoystickDriver;
extern SDL_JoystickDriver SDL_IOS_JoystickDriver;
extern SDL_JoystickDriver SDL_LINUX_JoystickDriver;
extern SDL_JoystickDriver SDL_WINDOWS_JoystickDriver;
#endif /* SDL_sysjoystick_h_ */ #endif /* SDL_sysjoystick_h_ */
+62 -139
View File
@@ -36,7 +36,7 @@
#include "../SDL_joystick_c.h" #include "../SDL_joystick_c.h"
#include "../../events/SDL_keyboard_c.h" #include "../../events/SDL_keyboard_c.h"
#include "../../core/android/SDL_android.h" #include "../../core/android/SDL_android.h"
#include "../steam/SDL_steamcontroller.h" #include "../hidapi/SDL_hidapijoystick_c.h"
#include "android/keycodes.h" #include "android/keycodes.h"
@@ -69,7 +69,6 @@ static SDL_joylist_item * JoystickByDeviceId(int device_id);
static SDL_joylist_item *SDL_joylist = NULL; static SDL_joylist_item *SDL_joylist = NULL;
static SDL_joylist_item *SDL_joylist_tail = NULL; static SDL_joylist_item *SDL_joylist_tail = NULL;
static int numjoysticks = 0; static int numjoysticks = 0;
static int instance_counter = 0;
/* Public domain CRC implementation adapted from: /* Public domain CRC implementation adapted from:
@@ -326,7 +325,6 @@ Android_OnHat(int device_id, int hat_id, int x, int y)
int int
Android_AddJoystick(int device_id, const char *name, const char *desc, int vendor_id, int product_id, SDL_bool is_accelerometer, int button_mask, int naxes, int nhats, int nballs) Android_AddJoystick(int device_id, const char *name, const char *desc, int vendor_id, int product_id, SDL_bool is_accelerometer, int button_mask, int naxes, int nhats, int nballs)
{ {
const Uint16 BUS_BLUETOOTH = 0x05;
SDL_joylist_item *item; SDL_joylist_item *item;
SDL_JoystickGUID guid; SDL_JoystickGUID guid;
Uint16 *guid16 = (Uint16 *)guid.data; Uint16 *guid16 = (Uint16 *)guid.data;
@@ -345,6 +343,13 @@ Android_AddJoystick(int device_id, const char *name, const char *desc, int vendo
return -1; return -1;
} }
#ifdef SDL_JOYSTICK_HIDAPI
if (HIDAPI_IsDevicePresent(vendor_id, product_id)) {
/* The HIDAPI driver is taking care of this device */
return -1;
}
#endif
#ifdef DEBUG_JOYSTICK #ifdef DEBUG_JOYSTICK
SDL_Log("Joystick: %s, descriptor %s, vendor = 0x%.4x, product = 0x%.4x, %d axes, %d hats\n", name, desc, vendor_id, product_id, naxes, nhats); SDL_Log("Joystick: %s, descriptor %s, vendor = 0x%.4x, product = 0x%.4x, %d axes, %d hats\n", name, desc, vendor_id, product_id, naxes, nhats);
#endif #endif
@@ -378,7 +383,7 @@ Android_AddJoystick(int device_id, const char *name, const char *desc, int vendo
/* We only need 16 bits for each of these; space them out to fill 128. */ /* We only need 16 bits for each of these; space them out to fill 128. */
/* Byteswap so devices get same GUID on little/big endian platforms. */ /* Byteswap so devices get same GUID on little/big endian platforms. */
*guid16++ = SDL_SwapLE16(BUS_BLUETOOTH); *guid16++ = SDL_SwapLE16(SDL_HARDWARE_BUS_BLUETOOTH);
*guid16++ = 0; *guid16++ = 0;
if (vendor_id && product_id) { if (vendor_id && product_id) {
@@ -424,7 +429,7 @@ Android_AddJoystick(int device_id, const char *name, const char *desc, int vendo
item->naxes = naxes; item->naxes = naxes;
item->nhats = nhats; item->nhats = nhats;
item->nballs = nballs; item->nballs = nballs;
item->device_instance = instance_counter++; item->device_instance = SDL_GetNextJoystickInstanceID();
if (SDL_joylist_tail == NULL) { if (SDL_joylist_tail == NULL) {
SDL_joylist = SDL_joylist_tail = item; SDL_joylist = SDL_joylist_tail = item;
} else { } else {
@@ -435,7 +440,7 @@ Android_AddJoystick(int device_id, const char *name, const char *desc, int vendo
/* Need to increment the joystick count before we post the event */ /* Need to increment the joystick count before we post the event */
++numjoysticks; ++numjoysticks;
SDL_PrivateJoystickAdded(numjoysticks - 1); SDL_PrivateJoystickAdded(item->device_instance);
#ifdef DEBUG_JOYSTICK #ifdef DEBUG_JOYSTICK
SDL_Log("Added joystick %s with device_id %d", name, device_id); SDL_Log("Added joystick %s with device_id %d", name, device_id);
@@ -492,104 +497,29 @@ Android_RemoveJoystick(int device_id)
} }
static SDL_bool SteamControllerConnectedCallback(const char *name, SDL_JoystickGUID guid, int *device_instance) static void ANDROID_JoystickDetect();
static int
ANDROID_JoystickInit(void)
{ {
SDL_joylist_item *item; ANDROID_JoystickDetect();
item = (SDL_joylist_item *)SDL_calloc(1, sizeof (SDL_joylist_item));
if (item == NULL) {
return SDL_FALSE;
}
*device_instance = item->device_instance = instance_counter++;
item->device_id = -1;
item->name = SDL_strdup(name);
item->guid = guid;
SDL_GetSteamControllerInputs(&item->nbuttons,
&item->naxes,
&item->nhats);
item->m_bSteamController = SDL_TRUE;
if (SDL_joylist_tail == NULL) {
SDL_joylist = SDL_joylist_tail = item;
} else {
SDL_joylist_tail->next = item;
SDL_joylist_tail = item;
}
/* Need to increment the joystick count before we post the event */
++numjoysticks;
SDL_PrivateJoystickAdded(numjoysticks - 1);
return SDL_TRUE;
}
static void SteamControllerDisconnectedCallback(int device_instance)
{
SDL_joylist_item *item = SDL_joylist;
SDL_joylist_item *prev = NULL;
while (item != NULL) {
if (item->device_instance == device_instance) {
break;
}
prev = item;
item = item->next;
}
if (item == NULL) {
return;
}
if (item->joystick) {
item->joystick->hwdata = NULL;
}
if (prev != NULL) {
prev->next = item->next;
} else {
SDL_assert(SDL_joylist == item);
SDL_joylist = item->next;
}
if (item == SDL_joylist_tail) {
SDL_joylist_tail = prev;
}
/* Need to decrement the joystick count before we post the event */
--numjoysticks;
SDL_PrivateJoystickRemoved(item->device_instance);
SDL_free(item->name);
SDL_free(item);
}
int
SDL_SYS_JoystickInit(void)
{
SDL_SYS_JoystickDetect();
if (SDL_GetHintBoolean(SDL_HINT_ACCELEROMETER_AS_JOYSTICK, SDL_TRUE)) { if (SDL_GetHintBoolean(SDL_HINT_ACCELEROMETER_AS_JOYSTICK, SDL_TRUE)) {
/* Default behavior, accelerometer as joystick */ /* Default behavior, accelerometer as joystick */
Android_AddJoystick(ANDROID_ACCELEROMETER_DEVICE_ID, ANDROID_ACCELEROMETER_NAME, ANDROID_ACCELEROMETER_NAME, 0, 0, SDL_TRUE, 0, 3, 0, 0); Android_AddJoystick(ANDROID_ACCELEROMETER_DEVICE_ID, ANDROID_ACCELEROMETER_NAME, ANDROID_ACCELEROMETER_NAME, 0, 0, SDL_TRUE, 0, 3, 0, 0);
} }
return 0;
SDL_InitSteamControllers(SteamControllerConnectedCallback,
SteamControllerDisconnectedCallback);
return (numjoysticks);
} }
int static int
SDL_SYS_NumJoysticks(void) ANDROID_JoystickGetCount(void)
{ {
return numjoysticks; return numjoysticks;
} }
void static void
SDL_SYS_JoystickDetect(void) ANDROID_JoystickDetect(void)
{ {
/* Support for device connect/disconnect is API >= 16 only, /* Support for device connect/disconnect is API >= 16 only,
* so we poll every three seconds * so we poll every three seconds
@@ -600,8 +530,6 @@ SDL_SYS_JoystickDetect(void)
timeout = SDL_GetTicks() + 3000; timeout = SDL_GetTicks() + 3000;
Android_JNI_PollInputDevices(); Android_JNI_PollInputDevices();
} }
SDL_UpdateSteamControllers();
} }
static SDL_joylist_item * static SDL_joylist_item *
@@ -635,7 +563,7 @@ JoystickByDeviceId(int device_id)
} }
/* Joystick not found, try adding it */ /* Joystick not found, try adding it */
SDL_SYS_JoystickDetect(); ANDROID_JoystickDetect();
while (item != NULL) { while (item != NULL) {
if (item->device_id == device_id) { if (item->device_id == device_id) {
@@ -647,26 +575,26 @@ JoystickByDeviceId(int device_id)
return NULL; return NULL;
} }
/* Function to get the device-dependent name of a joystick */ static const char *
const char * ANDROID_JoystickGetDeviceName(int device_index)
SDL_SYS_JoystickNameForDeviceIndex(int device_index)
{ {
return JoystickByDevIndex(device_index)->name; return JoystickByDevIndex(device_index)->name;
} }
/* Function to perform the mapping from device index to the instance id for this index */ static SDL_JoystickGUID
SDL_JoystickID SDL_SYS_GetInstanceIdOfDeviceIndex(int device_index) ANDROID_JoystickGetDeviceGUID(int device_index)
{
return JoystickByDevIndex(device_index)->guid;
}
static SDL_JoystickID
ANDROID_JoystickGetDeviceInstanceID(int device_index)
{ {
return JoystickByDevIndex(device_index)->device_instance; return JoystickByDevIndex(device_index)->device_instance;
} }
/* Function to open a joystick for use. static int
The joystick to open is specified by the device index. ANDROID_JoystickOpen(SDL_Joystick * joystick, int device_index)
This should fill the nbuttons and naxes fields of the joystick structure.
It returns 0, or -1 if there is an error.
*/
int
SDL_SYS_JoystickOpen(SDL_Joystick * joystick, int device_index)
{ {
SDL_joylist_item *item = JoystickByDevIndex(device_index); SDL_joylist_item *item = JoystickByDevIndex(device_index);
@@ -689,14 +617,20 @@ SDL_SYS_JoystickOpen(SDL_Joystick * joystick, int device_index)
return (0); return (0);
} }
/* Function to determine if this joystick is attached to the system right now */ static SDL_bool
SDL_bool SDL_SYS_JoystickAttached(SDL_Joystick *joystick) ANDROID_JoystickIsAttached(SDL_Joystick *joystick)
{ {
return joystick->hwdata != NULL; return joystick->hwdata != NULL;
} }
void static int
SDL_SYS_JoystickUpdate(SDL_Joystick * joystick) ANDROID_JoystickRumble(SDL_Joystick * joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble, Uint32 duration_ms)
{
return SDL_Unsupported();
}
static void
ANDROID_JoystickUpdate(SDL_Joystick * joystick)
{ {
SDL_joylist_item *item = (SDL_joylist_item *) joystick->hwdata; SDL_joylist_item *item = (SDL_joylist_item *) joystick->hwdata;
@@ -704,11 +638,6 @@ SDL_SYS_JoystickUpdate(SDL_Joystick * joystick)
return; return;
} }
if (item->m_bSteamController) {
SDL_UpdateSteamController(joystick);
return;
}
if (item->is_accelerometer) { if (item->is_accelerometer) {
int i; int i;
Sint16 value; Sint16 value;
@@ -729,9 +658,8 @@ SDL_SYS_JoystickUpdate(SDL_Joystick * joystick)
} }
} }
/* Function to close a joystick after use */ static void
void ANDROID_JoystickClose(SDL_Joystick * joystick)
SDL_SYS_JoystickClose(SDL_Joystick * joystick)
{ {
SDL_joylist_item *item = (SDL_joylist_item *) joystick->hwdata; SDL_joylist_item *item = (SDL_joylist_item *) joystick->hwdata;
if (item) { if (item) {
@@ -739,9 +667,8 @@ SDL_SYS_JoystickClose(SDL_Joystick * joystick)
} }
} }
/* Function to perform any system-specific joystick related cleanup */ static void
void ANDROID_JoystickQuit(void)
SDL_SYS_JoystickQuit(void)
{ {
/* We don't have any way to scan for joysticks at init, so don't wipe the list /* We don't have any way to scan for joysticks at init, so don't wipe the list
* of joysticks here in case this is a reinit. * of joysticks here in case this is a reinit.
@@ -759,28 +686,24 @@ SDL_SYS_JoystickQuit(void)
SDL_joylist = SDL_joylist_tail = NULL; SDL_joylist = SDL_joylist_tail = NULL;
numjoysticks = 0; numjoysticks = 0;
instance_counter = 0;
#endif /* 0 */ #endif /* 0 */
SDL_QuitSteamControllers();
} }
SDL_JoystickGUID SDL_SYS_JoystickGetDeviceGUID(int device_index) SDL_JoystickDriver SDL_ANDROID_JoystickDriver =
{ {
return JoystickByDevIndex(device_index)->guid; ANDROID_JoystickInit,
} ANDROID_JoystickGetCount,
ANDROID_JoystickDetect,
SDL_JoystickGUID SDL_SYS_JoystickGetGUID(SDL_Joystick * joystick) ANDROID_JoystickGetDeviceName,
{ ANDROID_JoystickGetDeviceGUID,
SDL_JoystickGUID guid; ANDROID_JoystickGetDeviceInstanceID,
ANDROID_JoystickOpen,
if (joystick->hwdata != NULL) { ANDROID_JoystickIsAttached,
return ((SDL_joylist_item*)joystick->hwdata)->guid; ANDROID_JoystickRumble,
} ANDROID_JoystickUpdate,
ANDROID_JoystickClose,
SDL_zero(guid); ANDROID_JoystickQuit,
return guid; };
}
#endif /* SDL_JOYSTICK_ANDROID */ #endif /* SDL_JOYSTICK_ANDROID */
-3
View File
@@ -47,9 +47,6 @@ typedef struct SDL_joylist_item
int nbuttons, naxes, nhats, nballs; int nbuttons, naxes, nhats, nballs;
int dpad_state; int dpad_state;
/* Steam Controller support */
SDL_bool m_bSteamController;
struct SDL_joylist_item *next; struct SDL_joylist_item *next;
} SDL_joylist_item; } SDL_joylist_item;
+267 -85
View File
@@ -22,29 +22,79 @@
#ifdef SDL_JOYSTICK_IOKIT #ifdef SDL_JOYSTICK_IOKIT
#include <IOKit/hid/IOHIDLib.h> #include "SDL_events.h"
/* For force feedback testing. */
#include <ForceFeedback/ForceFeedback.h>
#include <ForceFeedback/ForceFeedbackConstants.h>
#include "SDL_joystick.h" #include "SDL_joystick.h"
#include "../SDL_sysjoystick.h" #include "../SDL_sysjoystick.h"
#include "../SDL_joystick_c.h" #include "../SDL_joystick_c.h"
#include "SDL_sysjoystick_c.h" #include "SDL_sysjoystick_c.h"
#include "SDL_events.h" #include "../hidapi/SDL_hidapijoystick_c.h"
#include "../../haptic/darwin/SDL_syshaptic_c.h" /* For haptic hot plugging */ #include "../../haptic/darwin/SDL_syshaptic_c.h" /* For haptic hot plugging */
#define SDL_JOYSTICK_RUNLOOP_MODE CFSTR("SDLJoystick") #define SDL_JOYSTICK_RUNLOOP_MODE CFSTR("SDLJoystick")
#define CONVERT_MAGNITUDE(x) (((x)*10000) / 0x7FFF)
/* The base object of the HID Manager API */ /* The base object of the HID Manager API */
static IOHIDManagerRef hidman = NULL; static IOHIDManagerRef hidman = NULL;
/* Linked list of all available devices */ /* Linked list of all available devices */
static recDevice *gpDeviceList = NULL; static recDevice *gpDeviceList = NULL;
/* static incrementing counter for new joystick devices seen on the system. Devices should start with index 0 */ void FreeRumbleEffectData(FFEFFECT *effect)
static int s_joystick_instance_id = -1; {
if (!effect) {
return;
}
SDL_free(effect->rgdwAxes);
SDL_free(effect->rglDirection);
SDL_free(effect->lpvTypeSpecificParams);
SDL_free(effect);
}
FFEFFECT *CreateRumbleEffectData(Sint16 magnitude, Uint32 duration_ms)
{
FFEFFECT *effect;
FFPERIODIC *periodic;
/* Create the effect */
effect = (FFEFFECT *)SDL_calloc(1, sizeof(*effect));
if (!effect) {
return NULL;
}
effect->dwSize = sizeof(*effect);
effect->dwGain = 10000;
effect->dwFlags = FFEFF_OBJECTOFFSETS;
effect->dwDuration = duration_ms * 1000; /* In microseconds. */
effect->dwTriggerButton = FFEB_NOTRIGGER;
effect->cAxes = 2;
effect->rgdwAxes = (DWORD *)SDL_calloc(effect->cAxes, sizeof(DWORD));
if (!effect->rgdwAxes) {
FreeRumbleEffectData(effect);
return NULL;
}
effect->rglDirection = (LONG *)SDL_calloc(effect->cAxes, sizeof(LONG));
if (!effect->rglDirection) {
FreeRumbleEffectData(effect);
return NULL;
}
effect->dwFlags |= FFEFF_CARTESIAN;
periodic = (FFPERIODIC *)SDL_calloc(1, sizeof(*periodic));
if (!periodic) {
FreeRumbleEffectData(effect);
return NULL;
}
periodic->dwMagnitude = CONVERT_MAGNITUDE(magnitude);
periodic->dwPeriod = 1000000;
effect->cbTypeSpecificParams = sizeof(*periodic);
effect->lpvTypeSpecificParams = periodic;
return effect;
}
static recDevice *GetDeviceForIndex(int device_index) static recDevice *GetDeviceForIndex(int device_index)
{ {
@@ -157,6 +207,19 @@ JoystickDeviceWasRemovedCallback(void *ctx, IOReturn result, void *sender)
recDevice *device = (recDevice *) ctx; recDevice *device = (recDevice *) ctx;
device->removed = SDL_TRUE; device->removed = SDL_TRUE;
device->deviceRef = NULL; // deviceRef was invalidated due to the remove device->deviceRef = NULL; // deviceRef was invalidated due to the remove
if (device->ffeffect_ref) {
FFDeviceReleaseEffect(device->ffdevice, device->ffeffect_ref);
device->ffeffect_ref = NULL;
}
if (device->ffeffect) {
FreeRumbleEffectData(device->ffeffect);
device->ffeffect = NULL;
}
if (device->ffdevice) {
FFReleaseDevice(device->ffdevice);
device->ffdevice = NULL;
device->ff_initialized = SDL_FALSE;
}
#if SDL_HAPTIC_IOKIT #if SDL_HAPTIC_IOKIT
MacHaptic_MaybeRemoveDevice(device->ffservice); MacHaptic_MaybeRemoveDevice(device->ffservice);
#endif #endif
@@ -333,8 +396,6 @@ AddHIDElement(const void *value, void *parameter)
static SDL_bool static SDL_bool
GetDeviceInfo(IOHIDDeviceRef hidDevice, recDevice *pDevice) GetDeviceInfo(IOHIDDeviceRef hidDevice, recDevice *pDevice)
{ {
const Uint16 BUS_USB = 0x03;
const Uint16 BUS_BLUETOOTH = 0x05;
Sint32 vendor = 0; Sint32 vendor = 0;
Sint32 product = 0; Sint32 product = 0;
Sint32 version = 0; Sint32 version = 0;
@@ -389,10 +450,17 @@ GetDeviceInfo(IOHIDDeviceRef hidDevice, recDevice *pDevice)
CFNumberGetValue(refCF, kCFNumberSInt32Type, &version); CFNumberGetValue(refCF, kCFNumberSInt32Type, &version);
} }
#ifdef SDL_JOYSTICK_HIDAPI
if (HIDAPI_IsDevicePresent(vendor, product)) {
/* The HIDAPI driver is taking care of this device */
return 0;
}
#endif
SDL_memset(pDevice->guid.data, 0, sizeof(pDevice->guid.data)); SDL_memset(pDevice->guid.data, 0, sizeof(pDevice->guid.data));
if (vendor && product) { if (vendor && product) {
*guid16++ = SDL_SwapLE16(BUS_USB); *guid16++ = SDL_SwapLE16(SDL_HARDWARE_BUS_USB);
*guid16++ = 0; *guid16++ = 0;
*guid16++ = SDL_SwapLE16((Uint16)vendor); *guid16++ = SDL_SwapLE16((Uint16)vendor);
*guid16++ = 0; *guid16++ = 0;
@@ -401,7 +469,7 @@ GetDeviceInfo(IOHIDDeviceRef hidDevice, recDevice *pDevice)
*guid16++ = SDL_SwapLE16((Uint16)version); *guid16++ = SDL_SwapLE16((Uint16)version);
*guid16++ = 0; *guid16++ = 0;
} else { } else {
*guid16++ = SDL_SwapLE16(BUS_BLUETOOTH); *guid16++ = SDL_SwapLE16(SDL_HARDWARE_BUS_BLUETOOTH);
*guid16++ = 0; *guid16++ = 0;
SDL_strlcpy((char*)guid16, pDevice->product, sizeof(pDevice->guid.data) - 4); SDL_strlcpy((char*)guid16, pDevice->product, sizeof(pDevice->guid.data) - 4);
} }
@@ -444,7 +512,6 @@ JoystickDeviceWasAddedCallback(void *ctx, IOReturn res, void *sender, IOHIDDevic
} }
device = (recDevice *) SDL_calloc(1, sizeof(recDevice)); device = (recDevice *) SDL_calloc(1, sizeof(recDevice));
if (!device) { if (!device) {
SDL_OutOfMemory(); SDL_OutOfMemory();
return; return;
@@ -455,8 +522,7 @@ JoystickDeviceWasAddedCallback(void *ctx, IOReturn res, void *sender, IOHIDDevic
return; /* not a device we care about, probably. */ return; /* not a device we care about, probably. */
} }
if (SDL_IsGameControllerNameAndGUID(device->product, device->guid) && if (SDL_ShouldIgnoreJoystick(device->product, device->guid)) {
SDL_ShouldIgnoreGameController(device->product, device->guid)) {
SDL_free(device); SDL_free(device);
return; return;
} }
@@ -466,16 +532,16 @@ JoystickDeviceWasAddedCallback(void *ctx, IOReturn res, void *sender, IOHIDDevic
IOHIDDeviceScheduleWithRunLoop(ioHIDDeviceObject, CFRunLoopGetCurrent(), SDL_JOYSTICK_RUNLOOP_MODE); IOHIDDeviceScheduleWithRunLoop(ioHIDDeviceObject, CFRunLoopGetCurrent(), SDL_JOYSTICK_RUNLOOP_MODE);
/* Allocate an instance ID for this device */ /* Allocate an instance ID for this device */
device->instance_id = ++s_joystick_instance_id; device->instance_id = SDL_GetNextJoystickInstanceID();
/* We have to do some storage of the io_service_t for SDL_HapticOpenFromJoystick */ /* We have to do some storage of the io_service_t for SDL_HapticOpenFromJoystick */
ioservice = IOHIDDeviceGetService(ioHIDDeviceObject); ioservice = IOHIDDeviceGetService(ioHIDDeviceObject);
#if SDL_HAPTIC_IOKIT
if ((ioservice) && (FFIsForceFeedback(ioservice) == FF_OK)) { if ((ioservice) && (FFIsForceFeedback(ioservice) == FF_OK)) {
device->ffservice = ioservice; device->ffservice = ioservice;
#if SDL_HAPTIC_IOKIT
MacHaptic_MaybeAddDevice(ioservice); MacHaptic_MaybeAddDevice(ioservice);
}
#endif #endif
}
/* Add device to the end of the list */ /* Add device to the end of the list */
if ( !gpDeviceList ) { if ( !gpDeviceList ) {
@@ -492,7 +558,7 @@ JoystickDeviceWasAddedCallback(void *ctx, IOReturn res, void *sender, IOHIDDevic
++device_index; /* bump by one since we counted by pNext. */ ++device_index; /* bump by one since we counted by pNext. */
} }
SDL_PrivateJoystickAdded(device_index); SDL_PrivateJoystickAdded(device->instance_id);
} }
static SDL_bool static SDL_bool
@@ -577,13 +643,8 @@ CreateHIDManager(void)
} }
/* Function to scan the system for joysticks. static int
* Joystick 0 should be the system default joystick. DARWIN_JoystickInit(void)
* This function should return the number of available joysticks, or -1
* on an unrecoverable fatal error.
*/
int
SDL_SYS_JoystickInit(void)
{ {
if (gpDeviceList) { if (gpDeviceList) {
return SDL_SetError("Joystick: Device list already inited."); return SDL_SetError("Joystick: Device list already inited.");
@@ -593,12 +654,11 @@ SDL_SYS_JoystickInit(void)
return SDL_SetError("Joystick: Couldn't initialize HID Manager"); return SDL_SetError("Joystick: Couldn't initialize HID Manager");
} }
return SDL_SYS_NumJoysticks(); return 0;
} }
/* Function to return the number of joystick devices plugged in right now */ static int
int DARWIN_JoystickGetCount(void)
SDL_SYS_NumJoysticks(void)
{ {
recDevice *device = gpDeviceList; recDevice *device = gpDeviceList;
int nJoySticks = 0; int nJoySticks = 0;
@@ -613,10 +673,8 @@ SDL_SYS_NumJoysticks(void)
return nJoySticks; return nJoySticks;
} }
/* Function to cause any queued joystick insertions to be processed static void
*/ DARWIN_JoystickDetect(void)
void
SDL_SYS_JoystickDetect(void)
{ {
recDevice *device = gpDeviceList; recDevice *device = gpDeviceList;
while (device) { while (device) {
@@ -627,37 +685,43 @@ SDL_SYS_JoystickDetect(void)
} }
} }
/* run this after the checks above so we don't set device->removed and delete the device before /* run this after the checks above so we don't set device->removed and delete the device before
SDL_SYS_JoystickUpdate can run to clean up the SDL_Joystick object that owns this device */ DARWIN_JoystickUpdate can run to clean up the SDL_Joystick object that owns this device */
while (CFRunLoopRunInMode(SDL_JOYSTICK_RUNLOOP_MODE,0,TRUE) == kCFRunLoopRunHandledSource) { while (CFRunLoopRunInMode(SDL_JOYSTICK_RUNLOOP_MODE,0,TRUE) == kCFRunLoopRunHandledSource) {
/* no-op. Pending callbacks will fire in CFRunLoopRunInMode(). */ /* no-op. Pending callbacks will fire in CFRunLoopRunInMode(). */
} }
} }
/* Function to get the device-dependent name of a joystick */ /* Function to get the device-dependent name of a joystick */
const char * const char *
SDL_SYS_JoystickNameForDeviceIndex(int device_index) DARWIN_JoystickGetDeviceName(int device_index)
{ {
recDevice *device = GetDeviceForIndex(device_index); recDevice *device = GetDeviceForIndex(device_index);
return device ? device->product : "UNKNOWN"; return device ? device->product : "UNKNOWN";
} }
/* Function to return the instance id of the joystick at device_index static SDL_JoystickGUID
*/ DARWIN_JoystickGetDeviceGUID( int device_index )
SDL_JoystickID {
SDL_SYS_GetInstanceIdOfDeviceIndex(int device_index) recDevice *device = GetDeviceForIndex(device_index);
SDL_JoystickGUID guid;
if (device) {
guid = device->guid;
} else {
SDL_zero(guid);
}
return guid;
}
static SDL_JoystickID
DARWIN_JoystickGetDeviceInstanceID(int device_index)
{ {
recDevice *device = GetDeviceForIndex(device_index); recDevice *device = GetDeviceForIndex(device_index);
return device ? device->instance_id : 0; return device ? device->instance_id : 0;
} }
/* Function to open a joystick for use. static int
* The joystick to open is specified by the device index. DARWIN_JoystickOpen(SDL_Joystick * joystick, int device_index)
* This should fill the nbuttons and naxes fields of the joystick structure.
* It returns 0, or -1 if there is an error.
*/
int
SDL_SYS_JoystickOpen(SDL_Joystick * joystick, int device_index)
{ {
recDevice *device = GetDeviceForIndex(device_index); recDevice *device = GetDeviceForIndex(device_index);
@@ -672,22 +736,144 @@ SDL_SYS_JoystickOpen(SDL_Joystick * joystick, int device_index)
return 0; return 0;
} }
/* Function to query if the joystick is currently attached static SDL_bool
* It returns SDL_TRUE if attached, SDL_FALSE otherwise. DARWIN_JoystickIsAttached(SDL_Joystick * joystick)
*/
SDL_bool
SDL_SYS_JoystickAttached(SDL_Joystick * joystick)
{ {
return joystick->hwdata != NULL; return joystick->hwdata != NULL;
} }
/* Function to update the state of a joystick - called as a device poll. /*
* This function shouldn't update the joystick structure directly, * Like strerror but for force feedback errors.
* but instead should call SDL_PrivateJoystick*() to deliver events
* and update joystick device state.
*/ */
void static const char *
SDL_SYS_JoystickUpdate(SDL_Joystick * joystick) FFStrError(unsigned int err)
{
switch (err) {
case FFERR_DEVICEFULL:
return "device full";
/* This should be valid, but for some reason isn't defined... */
/* case FFERR_DEVICENOTREG:
return "device not registered"; */
case FFERR_DEVICEPAUSED:
return "device paused";
case FFERR_DEVICERELEASED:
return "device released";
case FFERR_EFFECTPLAYING:
return "effect playing";
case FFERR_EFFECTTYPEMISMATCH:
return "effect type mismatch";
case FFERR_EFFECTTYPENOTSUPPORTED:
return "effect type not supported";
case FFERR_GENERIC:
return "undetermined error";
case FFERR_HASEFFECTS:
return "device has effects";
case FFERR_INCOMPLETEEFFECT:
return "incomplete effect";
case FFERR_INTERNAL:
return "internal fault";
case FFERR_INVALIDDOWNLOADID:
return "invalid download id";
case FFERR_INVALIDPARAM:
return "invalid parameter";
case FFERR_MOREDATA:
return "more data";
case FFERR_NOINTERFACE:
return "interface not supported";
case FFERR_NOTDOWNLOADED:
return "effect is not downloaded";
case FFERR_NOTINITIALIZED:
return "object has not been initialized";
case FFERR_OUTOFMEMORY:
return "out of memory";
case FFERR_UNPLUGGED:
return "device is unplugged";
case FFERR_UNSUPPORTED:
return "function call unsupported";
case FFERR_UNSUPPORTEDAXIS:
return "axis unsupported";
default:
return "unknown error";
}
}
static int
DARWIN_JoystickInitRumble(recDevice *device, Sint16 magnitude, Uint32 duration_ms)
{
HRESULT result;
if (!device->ffdevice) {
result = FFCreateDevice(device->ffservice, &device->ffdevice);
if (result != FF_OK) {
return SDL_SetError("Unable to create force feedback device from service: %s", FFStrError(result));
}
}
/* Reset and then enable actuators */
result = FFDeviceSendForceFeedbackCommand(device->ffdevice, FFSFFC_RESET);
if (result != FF_OK) {
return SDL_SetError("Unable to reset force feedback device: %s", FFStrError(result));
}
result = FFDeviceSendForceFeedbackCommand(device->ffdevice, FFSFFC_SETACTUATORSON);
if (result != FF_OK) {
return SDL_SetError("Unable to enable force feedback actuators: %s", FFStrError(result));
}
/* Create the effect */
device->ffeffect = CreateRumbleEffectData(magnitude, duration_ms);
if (!device->ffeffect) {
return SDL_OutOfMemory();
}
result = FFDeviceCreateEffect(device->ffdevice, kFFEffectType_Sine_ID,
device->ffeffect, &device->ffeffect_ref);
if (result != FF_OK) {
return SDL_SetError("Haptic: Unable to create effect: %s", FFStrError(result));
}
return 0;
}
static int
DARWIN_JoystickRumble(SDL_Joystick * joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble, Uint32 duration_ms)
{
HRESULT result;
recDevice *device = joystick->hwdata;
/* Scale and average the two rumble strengths */
Sint16 magnitude = (Sint16)(((low_frequency_rumble / 2) + (high_frequency_rumble / 2)) / 2);
if (!device->ffservice) {
return SDL_Unsupported();
}
if (device->ff_initialized) {
FFPERIODIC *periodic = ((FFPERIODIC *)device->ffeffect->lpvTypeSpecificParams);
device->ffeffect->dwDuration = duration_ms * 1000; /* In microseconds. */
periodic->dwMagnitude = CONVERT_MAGNITUDE(magnitude);
result = FFEffectSetParameters(device->ffeffect_ref, device->ffeffect,
(FFEP_DURATION | FFEP_TYPESPECIFICPARAMS));
if (result != FF_OK) {
return SDL_SetError("Unable to update rumble effect: %s", FFStrError(result));
}
} else {
if (DARWIN_JoystickInitRumble(device, magnitude, duration_ms) < 0) {
return -1;
}
device->ff_initialized = SDL_TRUE;
}
result = FFEffectStart(device->ffeffect_ref, 1, 0);
if (result != FF_OK) {
return SDL_SetError("Unable to run the rumble effect: %s", FFStrError(result));
}
return 0;
}
static void
DARWIN_JoystickUpdate(SDL_Joystick * joystick)
{ {
recDevice *device = joystick->hwdata; recDevice *device = joystick->hwdata;
recElement *element; recElement *element;
@@ -792,15 +978,13 @@ SDL_SYS_JoystickUpdate(SDL_Joystick * joystick)
} }
} }
/* Function to close a joystick after use */ static void
void DARWIN_JoystickClose(SDL_Joystick * joystick)
SDL_SYS_JoystickClose(SDL_Joystick * joystick)
{ {
} }
/* Function to perform any system-specific joystick related cleanup */ static void
void DARWIN_JoystickQuit(void)
SDL_SYS_JoystickQuit(void)
{ {
while (FreeDevice(gpDeviceList)) { while (FreeDevice(gpDeviceList)) {
/* spin */ /* spin */
@@ -814,23 +998,21 @@ SDL_SYS_JoystickQuit(void)
} }
} }
SDL_JoystickDriver SDL_DARWIN_JoystickDriver =
SDL_JoystickGUID SDL_SYS_JoystickGetDeviceGUID( int device_index )
{ {
recDevice *device = GetDeviceForIndex(device_index); DARWIN_JoystickInit,
SDL_JoystickGUID guid; DARWIN_JoystickGetCount,
if (device) { DARWIN_JoystickDetect,
guid = device->guid; DARWIN_JoystickGetDeviceName,
} else { DARWIN_JoystickGetDeviceGUID,
SDL_zero(guid); DARWIN_JoystickGetDeviceInstanceID,
} DARWIN_JoystickOpen,
return guid; DARWIN_JoystickIsAttached,
} DARWIN_JoystickRumble,
DARWIN_JoystickUpdate,
SDL_JoystickGUID SDL_SYS_JoystickGetGUID(SDL_Joystick *joystick) DARWIN_JoystickClose,
{ DARWIN_JoystickQuit,
return joystick->hwdata->guid; };
}
#endif /* SDL_JOYSTICK_IOKIT */ #endif /* SDL_JOYSTICK_IOKIT */
+6
View File
@@ -24,6 +24,8 @@
#define SDL_JOYSTICK_IOKIT_H #define SDL_JOYSTICK_IOKIT_H
#include <IOKit/hid/IOHIDLib.h> #include <IOKit/hid/IOHIDLib.h>
#include <ForceFeedback/ForceFeedback.h>
#include <ForceFeedback/ForceFeedbackConstants.h>
struct recElement struct recElement
{ {
@@ -45,6 +47,10 @@ struct joystick_hwdata
{ {
IOHIDDeviceRef deviceRef; /* HIDManager device handle */ IOHIDDeviceRef deviceRef; /* HIDManager device handle */
io_service_t ffservice; /* Interface for force feedback, 0 = no ff */ io_service_t ffservice; /* Interface for force feedback, 0 = no ff */
FFDeviceObjectReference ffdevice;
FFEFFECT *ffeffect;
FFEffectObjectReference ffeffect_ref;
SDL_bool ff_initialized;
char product[256]; /* name of product */ char product[256]; /* name of product */
uint32_t usage; /* usage page from IOUSBHID Parser.h which defines general usage */ uint32_t usage; /* usage page from IOUSBHID Parser.h which defines general usage */
+52 -59
View File
@@ -28,99 +28,92 @@
#include "../SDL_sysjoystick.h" #include "../SDL_sysjoystick.h"
#include "../SDL_joystick_c.h" #include "../SDL_joystick_c.h"
/* Function to scan the system for joysticks.
* It should return 0, or -1 on an unrecoverable fatal error. static int
*/ DUMMY_JoystickInit(void)
int
SDL_SYS_JoystickInit(void)
{ {
return 0; return 0;
} }
int static int
SDL_SYS_NumJoysticks(void) DUMMY_JoystickGetCount(void)
{ {
return 0; return 0;
} }
void static void
SDL_SYS_JoystickDetect(void) DUMMY_JoystickDetect(void)
{ {
} }
/* Function to get the device-dependent name of a joystick */ static const char *
const char * DUMMY_JoystickGetDeviceName(int device_index)
SDL_SYS_JoystickNameForDeviceIndex(int device_index)
{ {
SDL_SetError("Logic error: No joysticks available"); return NULL;
return (NULL);
} }
/* Function to perform the mapping from device index to the instance id for this index */ static SDL_JoystickGUID
SDL_JoystickID SDL_SYS_GetInstanceIdOfDeviceIndex(int device_index) DUMMY_JoystickGetDeviceGUID(int device_index)
{ {
return device_index; SDL_JoystickGUID guid;
SDL_zero(guid);
return guid;
} }
/* Function to open a joystick for use. static SDL_JoystickID
The joystick to open is specified by the device index. DUMMY_JoystickGetDeviceInstanceID(int device_index)
This should fill the nbuttons and naxes fields of the joystick structure. {
It returns 0, or -1 if there is an error. return -1;
*/ }
int
SDL_SYS_JoystickOpen(SDL_Joystick * joystick, int device_index) static int
DUMMY_JoystickOpen(SDL_Joystick * joystick, int device_index)
{ {
return SDL_SetError("Logic error: No joysticks available"); return SDL_SetError("Logic error: No joysticks available");
} }
/* Function to determine if this joystick is attached to the system right now */ static SDL_bool
SDL_bool SDL_SYS_JoystickAttached(SDL_Joystick *joystick) DUMMY_JoystickIsAttached(SDL_Joystick *joystick)
{ {
return SDL_TRUE; return SDL_FALSE;
} }
/* Function to update the state of a joystick - called as a device poll. static int
* This function shouldn't update the joystick structure directly, DUMMY_JoystickRumble(SDL_Joystick * joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble, Uint32 duration_ms)
* but instead should call SDL_PrivateJoystick*() to deliver events {
* and update joystick device state. return SDL_Unsupported();
*/ }
void
SDL_SYS_JoystickUpdate(SDL_Joystick * joystick) static void
DUMMY_JoystickUpdate(SDL_Joystick * joystick)
{ {
} }
/* Function to close a joystick after use */ static void
void DUMMY_JoystickClose(SDL_Joystick * joystick)
SDL_SYS_JoystickClose(SDL_Joystick * joystick)
{ {
} }
/* Function to perform any system-specific joystick related cleanup */ static void
void DUMMY_JoystickQuit(void)
SDL_SYS_JoystickQuit(void)
{ {
} }
SDL_JoystickGUID SDL_SYS_JoystickGetDeviceGUID( int device_index ) SDL_JoystickDriver SDL_DUMMY_JoystickDriver =
{ {
SDL_JoystickGUID guid; DUMMY_JoystickInit,
/* the GUID is just the first 16 chars of the name for now */ DUMMY_JoystickGetCount,
const char *name = SDL_SYS_JoystickNameForDeviceIndex( device_index ); DUMMY_JoystickDetect,
SDL_zero( guid ); DUMMY_JoystickGetDeviceName,
SDL_memcpy( &guid, name, SDL_min( sizeof(guid), SDL_strlen( name ) ) ); DUMMY_JoystickGetDeviceGUID,
return guid; DUMMY_JoystickGetDeviceInstanceID,
} DUMMY_JoystickOpen,
DUMMY_JoystickIsAttached,
DUMMY_JoystickRumble,
SDL_JoystickGUID SDL_SYS_JoystickGetGUID(SDL_Joystick * joystick) DUMMY_JoystickUpdate,
{ DUMMY_JoystickClose,
SDL_JoystickGUID guid; DUMMY_JoystickQuit,
/* the GUID is just the first 16 chars of the name for now */ };
const char *name = joystick->name;
SDL_zero( guid );
SDL_memcpy( &guid, name, SDL_min( sizeof(guid), SDL_strlen( name ) ) );
return guid;
}
#endif /* SDL_JOYSTICK_DUMMY || SDL_JOYSTICK_DISABLED */ #endif /* SDL_JOYSTICK_DUMMY || SDL_JOYSTICK_DISABLED */
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+363
View File
@@ -0,0 +1,363 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "../../SDL_internal.h"
#ifdef SDL_JOYSTICK_HIDAPI
#include "SDL_hints.h"
#include "SDL_log.h"
#include "SDL_events.h"
#include "SDL_timer.h"
#include "SDL_joystick.h"
#include "SDL_gamecontroller.h"
#include "../SDL_sysjoystick.h"
#include "SDL_hidapijoystick_c.h"
#ifdef SDL_JOYSTICK_HIDAPI_XBOX360
#define USB_PACKET_LENGTH 64
typedef struct
{
Uint16 vendor_id;
Uint16 product_id;
const char *name;
} SDL_DriverXbox360_DeviceName;
static const SDL_DriverXbox360_DeviceName xbox360_devicenames[] = {
{ 0x0079, 0x18d4, "GPD Win 2 X-Box Controller" },
{ 0x044f, 0xb326, "Thrustmaster Gamepad GP XID" },
{ 0x045e, 0x028e, "Microsoft X-Box 360 pad" },
{ 0x045e, 0x028f, "Microsoft X-Box 360 pad v2" },
{ 0x045e, 0x0291, "Xbox 360 Wireless Receiver (XBOX)" },
{ 0x045e, 0x0719, "Xbox 360 Wireless Receiver" },
{ 0x046d, 0xc21d, "Logitech Gamepad F310" },
{ 0x046d, 0xc21e, "Logitech Gamepad F510" },
{ 0x046d, 0xc21f, "Logitech Gamepad F710" },
{ 0x046d, 0xc242, "Logitech Chillstream Controller" },
{ 0x046d, 0xcaa3, "Logitech DriveFx Racing Wheel" },
{ 0x056e, 0x2004, "Elecom JC-U3613M" },
{ 0x06a3, 0xf51a, "Saitek P3600" },
{ 0x0738, 0x4716, "Mad Catz Wired Xbox 360 Controller" },
{ 0x0738, 0x4718, "Mad Catz Street Fighter IV FightStick SE" },
{ 0x0738, 0x4726, "Mad Catz Xbox 360 Controller" },
{ 0x0738, 0x4728, "Mad Catz Street Fighter IV FightPad" },
{ 0x0738, 0x4736, "Mad Catz MicroCon Gamepad" },
{ 0x0738, 0x4738, "Mad Catz Wired Xbox 360 Controller (SFIV)" },
{ 0x0738, 0x4740, "Mad Catz Beat Pad" },
{ 0x0738, 0x4758, "Mad Catz Arcade Game Stick" },
{ 0x0738, 0x9871, "Mad Catz Portable Drum" },
{ 0x0738, 0xb726, "Mad Catz Xbox controller - MW2" },
{ 0x0738, 0xb738, "Mad Catz MVC2TE Stick 2" },
{ 0x0738, 0xbeef, "Mad Catz JOYTECH NEO SE Advanced GamePad" },
{ 0x0738, 0xcb02, "Saitek Cyborg Rumble Pad - PC/Xbox 360" },
{ 0x0738, 0xcb03, "Saitek P3200 Rumble Pad - PC/Xbox 360" },
{ 0x0738, 0xcb29, "Saitek Aviator Stick AV8R02" },
{ 0x0738, 0xf738, "Super SFIV FightStick TE S" },
{ 0x07ff, 0xffff, "Mad Catz GamePad" },
{ 0x0e6f, 0x0105, "HSM3 Xbox360 dancepad" },
{ 0x0e6f, 0x0113, "Afterglow AX.1 Gamepad for Xbox 360" },
{ 0x0e6f, 0x011f, "Rock Candy Gamepad Wired Controller" },
{ 0x0e6f, 0x0131, "PDP EA Sports Controller" },
{ 0x0e6f, 0x0133, "Xbox 360 Wired Controller" },
{ 0x0e6f, 0x0201, "Pelican PL-3601 'TSZ' Wired Xbox 360 Controller" },
{ 0x0e6f, 0x0213, "Afterglow Gamepad for Xbox 360" },
{ 0x0e6f, 0x021f, "Rock Candy Gamepad for Xbox 360" },
{ 0x0e6f, 0x0301, "Logic3 Controller" },
{ 0x0e6f, 0x0401, "Logic3 Controller" },
{ 0x0e6f, 0x0413, "Afterglow AX.1 Gamepad for Xbox 360" },
{ 0x0e6f, 0x0501, "PDP Xbox 360 Controller" },
{ 0x0e6f, 0xf900, "PDP Afterglow AX.1" },
{ 0x0f0d, 0x000a, "Hori Co. DOA4 FightStick" },
{ 0x0f0d, 0x000c, "Hori PadEX Turbo" },
{ 0x0f0d, 0x000d, "Hori Fighting Stick EX2" },
{ 0x0f0d, 0x0016, "Hori Real Arcade Pro.EX" },
{ 0x0f0d, 0x001b, "Hori Real Arcade Pro VX" },
{ 0x11c9, 0x55f0, "Nacon GC-100XF" },
{ 0x12ab, 0x0004, "Honey Bee Xbox360 dancepad" },
{ 0x12ab, 0x0301, "PDP AFTERGLOW AX.1" },
{ 0x12ab, 0x0303, "Mortal Kombat Klassic FightStick" },
{ 0x1430, 0x4748, "RedOctane Guitar Hero X-plorer" },
{ 0x1430, 0xf801, "RedOctane Controller" },
{ 0x146b, 0x0601, "BigBen Interactive XBOX 360 Controller" },
{ 0x1532, 0x0037, "Razer Sabertooth" },
{ 0x15e4, 0x3f00, "Power A Mini Pro Elite" },
{ 0x15e4, 0x3f0a, "Xbox Airflo wired controller" },
{ 0x15e4, 0x3f10, "Batarang Xbox 360 controller" },
{ 0x162e, 0xbeef, "Joytech Neo-Se Take2" },
{ 0x1689, 0xfd00, "Razer Onza Tournament Edition" },
{ 0x1689, 0xfd01, "Razer Onza Classic Edition" },
{ 0x1689, 0xfe00, "Razer Sabertooth" },
{ 0x1bad, 0x0002, "Harmonix Rock Band Guitar" },
{ 0x1bad, 0x0003, "Harmonix Rock Band Drumkit" },
{ 0x1bad, 0x0130, "Ion Drum Rocker" },
{ 0x1bad, 0xf016, "Mad Catz Xbox 360 Controller" },
{ 0x1bad, 0xf018, "Mad Catz Street Fighter IV SE Fighting Stick" },
{ 0x1bad, 0xf019, "Mad Catz Brawlstick for Xbox 360" },
{ 0x1bad, 0xf021, "Mad Cats Ghost Recon FS GamePad" },
{ 0x1bad, 0xf023, "MLG Pro Circuit Controller (Xbox)" },
{ 0x1bad, 0xf025, "Mad Catz Call Of Duty" },
{ 0x1bad, 0xf027, "Mad Catz FPS Pro" },
{ 0x1bad, 0xf028, "Street Fighter IV FightPad" },
{ 0x1bad, 0xf02e, "Mad Catz Fightpad" },
{ 0x1bad, 0xf030, "Mad Catz Xbox 360 MC2 MicroCon Racing Wheel" },
{ 0x1bad, 0xf036, "Mad Catz MicroCon GamePad Pro" },
{ 0x1bad, 0xf038, "Street Fighter IV FightStick TE" },
{ 0x1bad, 0xf039, "Mad Catz MvC2 TE" },
{ 0x1bad, 0xf03a, "Mad Catz SFxT Fightstick Pro" },
{ 0x1bad, 0xf03d, "Street Fighter IV Arcade Stick TE - Chun Li" },
{ 0x1bad, 0xf03e, "Mad Catz MLG FightStick TE" },
{ 0x1bad, 0xf03f, "Mad Catz FightStick SoulCaliber" },
{ 0x1bad, 0xf042, "Mad Catz FightStick TES+" },
{ 0x1bad, 0xf080, "Mad Catz FightStick TE2" },
{ 0x1bad, 0xf501, "HoriPad EX2 Turbo" },
{ 0x1bad, 0xf502, "Hori Real Arcade Pro.VX SA" },
{ 0x1bad, 0xf503, "Hori Fighting Stick VX" },
{ 0x1bad, 0xf504, "Hori Real Arcade Pro. EX" },
{ 0x1bad, 0xf505, "Hori Fighting Stick EX2B" },
{ 0x1bad, 0xf506, "Hori Real Arcade Pro.EX Premium VLX" },
{ 0x1bad, 0xf900, "Harmonix Xbox 360 Controller" },
{ 0x1bad, 0xf901, "Gamestop Xbox 360 Controller" },
{ 0x1bad, 0xf903, "Tron Xbox 360 controller" },
{ 0x1bad, 0xf904, "PDP Versus Fighting Pad" },
{ 0x1bad, 0xf906, "MortalKombat FightStick" },
{ 0x1bad, 0xfa01, "MadCatz GamePad" },
{ 0x1bad, 0xfd00, "Razer Onza TE" },
{ 0x1bad, 0xfd01, "Razer Onza" },
{ 0x24c6, 0x5000, "Razer Atrox Arcade Stick" },
{ 0x24c6, 0x5300, "PowerA MINI PROEX Controller" },
{ 0x24c6, 0x5303, "Xbox Airflo wired controller" },
{ 0x24c6, 0x530a, "Xbox 360 Pro EX Controller" },
{ 0x24c6, 0x531a, "PowerA Pro Ex" },
{ 0x24c6, 0x5397, "FUS1ON Tournament Controller" },
{ 0x24c6, 0x5500, "Hori XBOX 360 EX 2 with Turbo" },
{ 0x24c6, 0x5501, "Hori Real Arcade Pro VX-SA" },
{ 0x24c6, 0x5502, "Hori Fighting Stick VX Alt" },
{ 0x24c6, 0x5503, "Hori Fighting Edge" },
{ 0x24c6, 0x5506, "Hori SOULCALIBUR V Stick" },
{ 0x24c6, 0x550d, "Hori GEM Xbox controller" },
{ 0x24c6, 0x550e, "Hori Real Arcade Pro V Kai 360" },
{ 0x24c6, 0x5b00, "ThrustMaster Ferrari 458 Racing Wheel" },
{ 0x24c6, 0x5b02, "Thrustmaster, Inc. GPX Controller" },
{ 0x24c6, 0x5b03, "Thrustmaster Ferrari 458 Racing Wheel" },
{ 0x24c6, 0x5d04, "Razer Sabertooth" },
{ 0x24c6, 0xfafe, "Rock Candy Gamepad for Xbox 360" },
};
typedef struct {
Uint8 last_state[USB_PACKET_LENGTH];
Uint32 rumble_expiration;
} SDL_DriverXbox360_Context;
static SDL_bool
HIDAPI_DriverXbox360_IsSupportedDevice(Uint16 vendor_id, Uint16 product_id, int interface_number, Uint16 usage_page, Uint16 usage)
{
#ifdef __MACOSX__
return SDL_IsJoystickXbox360(vendor_id, product_id) || SDL_IsJoystickXboxOne(vendor_id, product_id);
#else
return SDL_IsJoystickXbox360(vendor_id, product_id);
#endif
}
static const char *
HIDAPI_DriverXbox360_GetDeviceName(Uint16 vendor_id, Uint16 product_id)
{
int i;
for (i = 0; i < SDL_arraysize(xbox360_devicenames); ++i) {
const SDL_DriverXbox360_DeviceName *entry = &xbox360_devicenames[i];
if (vendor_id == entry->vendor_id && product_id == entry->product_id) {
return entry->name;
}
}
return NULL;
}
static SDL_bool SetSlotLED(hid_device *dev, Uint8 slot)
{
const Uint8 led_packet[] = { 0x01, 0x03, (2 + slot) };
if (hid_write(dev, led_packet, sizeof(led_packet)) != sizeof(led_packet)) {
return SDL_FALSE;
}
return SDL_TRUE;
}
static SDL_bool
HIDAPI_DriverXbox360_Init(SDL_Joystick *joystick, hid_device *dev, Uint16 vendor_id, Uint16 product_id, void **context)
{
SDL_DriverXbox360_Context *ctx;
ctx = (SDL_DriverXbox360_Context *)SDL_calloc(1, sizeof(*ctx));
if (!ctx) {
SDL_OutOfMemory();
return SDL_FALSE;
}
*context = ctx;
/* Set the controller LED */
SetSlotLED(dev, (joystick->instance_id % 4));
/* Initialize the joystick capabilities */
joystick->nbuttons = SDL_CONTROLLER_BUTTON_MAX;
joystick->naxes = SDL_CONTROLLER_AXIS_MAX;
joystick->epowerlevel = SDL_JOYSTICK_POWER_WIRED;
return SDL_TRUE;
}
static int
HIDAPI_DriverXbox360_Rumble(SDL_Joystick *joystick, hid_device *dev, void *context, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble, Uint32 duration_ms)
{
SDL_DriverXbox360_Context *ctx = (SDL_DriverXbox360_Context *)context;
#ifdef __MACOSX__
/* On Mac OS X the 360Controller driver uses this short report,
and we need to prefix it with a magic token so hidapi passes it through untouched
*/
Uint8 rumble_packet[] = { 'M', 'A', 'G', 'I', 'C', '0', 0x00, 0x04, 0x00, 0x00 };
rumble_packet[6+2] = (low_frequency_rumble >> 8);
rumble_packet[6+3] = (high_frequency_rumble >> 8);
#else
Uint8 rumble_packet[] = { 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
rumble_packet[3] = (low_frequency_rumble >> 8);
rumble_packet[4] = (high_frequency_rumble >> 8);
#endif
if (hid_write(dev, rumble_packet, sizeof(rumble_packet)) != sizeof(rumble_packet)) {
return SDL_SetError("Couldn't send rumble packet");
}
if ((low_frequency_rumble || high_frequency_rumble) && duration_ms) {
ctx->rumble_expiration = SDL_GetTicks() + duration_ms;
} else {
ctx->rumble_expiration = 0;
}
return 0;
}
static void
HIDAPI_DriverXbox360_HandleStatePacket(SDL_Joystick *joystick, hid_device *dev, SDL_DriverXbox360_Context *ctx, Uint8 *data, int size)
{
Sint16 axis;
#ifdef __MACOSX__
const SDL_bool invert_y_axes = SDL_FALSE;
#else
const SDL_bool invert_y_axes = SDL_TRUE;
#endif
if (ctx->last_state[2] != data[2]) {
SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_DPAD_UP, (data[2] & 0x01) ? SDL_PRESSED : SDL_RELEASED);
SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_DPAD_DOWN, (data[2] & 0x02) ? SDL_PRESSED : SDL_RELEASED);
SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_DPAD_LEFT, (data[2] & 0x04) ? SDL_PRESSED : SDL_RELEASED);
SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_DPAD_RIGHT, (data[2] & 0x08) ? SDL_PRESSED : SDL_RELEASED);
SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_START, (data[2] & 0x10) ? SDL_PRESSED : SDL_RELEASED);
SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_BACK, (data[2] & 0x20) ? SDL_PRESSED : SDL_RELEASED);
SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_LEFTSTICK, (data[2] & 0x40) ? SDL_PRESSED : SDL_RELEASED);
SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_RIGHTSTICK, (data[2] & 0x80) ? SDL_PRESSED : SDL_RELEASED);
}
if (ctx->last_state[3] != data[3]) {
SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_LEFTSHOULDER, (data[3] & 0x01) ? SDL_PRESSED : SDL_RELEASED);
SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_RIGHTSHOULDER, (data[3] & 0x02) ? SDL_PRESSED : SDL_RELEASED);
SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_GUIDE, (data[3] & 0x04) ? SDL_PRESSED : SDL_RELEASED);
SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_A, (data[3] & 0x10) ? SDL_PRESSED : SDL_RELEASED);
SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_B, (data[3] & 0x20) ? SDL_PRESSED : SDL_RELEASED);
SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_X, (data[3] & 0x40) ? SDL_PRESSED : SDL_RELEASED);
SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_Y, (data[3] & 0x80) ? SDL_PRESSED : SDL_RELEASED);
}
axis = ((int)data[4] * 257) - 32768;
SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_TRIGGERLEFT, axis);
axis = ((int)data[5] * 257) - 32768;
SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_TRIGGERRIGHT, axis);
axis = *(Sint16*)(&data[6]);
SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_LEFTX, axis);
axis = *(Sint16*)(&data[8]);
if (invert_y_axes) {
axis = ~axis;
}
SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_LEFTY, axis);
axis = *(Sint16*)(&data[10]);
SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_RIGHTX, axis);
axis = *(Sint16*)(&data[12]);
if (invert_y_axes) {
axis = ~axis;
}
SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_RIGHTY, axis);
SDL_memcpy(ctx->last_state, data, SDL_min(size, sizeof(ctx->last_state)));
}
static void
HIDAPI_DriverXbox360_Update(SDL_Joystick *joystick, hid_device *dev, void *context)
{
SDL_DriverXbox360_Context *ctx = (SDL_DriverXbox360_Context *)context;
Uint8 data[USB_PACKET_LENGTH];
int size;
while ((size = hid_read_timeout(dev, data, sizeof(data), 0)) > 0) {
switch (data[0]) {
case 0x00:
HIDAPI_DriverXbox360_HandleStatePacket(joystick, dev, ctx, data, size);
break;
default:
#ifdef DEBUG_JOYSTICK
SDL_Log("Unknown Xbox 360 packet: 0x%.2x\n", data[0]);
#endif
break;
}
}
if (ctx->rumble_expiration) {
Uint32 now = SDL_GetTicks();
if (SDL_TICKS_PASSED(now, ctx->rumble_expiration)) {
HIDAPI_DriverXbox360_Rumble(joystick, dev, context, 0, 0, 0);
}
}
}
static void
HIDAPI_DriverXbox360_Quit(SDL_Joystick *joystick, hid_device *dev, void *context)
{
SDL_free(context);
}
SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverXbox360 =
{
SDL_HINT_JOYSTICK_HIDAPI_XBOX360,
SDL_TRUE,
HIDAPI_DriverXbox360_IsSupportedDevice,
HIDAPI_DriverXbox360_GetDeviceName,
HIDAPI_DriverXbox360_Init,
HIDAPI_DriverXbox360_Rumble,
HIDAPI_DriverXbox360_Update,
HIDAPI_DriverXbox360_Quit
};
#endif /* SDL_JOYSTICK_HIDAPI_XBOX360 */
#endif /* SDL_JOYSTICK_HIDAPI */
/* vi: set ts=4 sw=4 expandtab: */
+364
View File
@@ -0,0 +1,364 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "../../SDL_internal.h"
#ifdef SDL_JOYSTICK_HIDAPI
#include "SDL_hints.h"
#include "SDL_log.h"
#include "SDL_events.h"
#include "SDL_timer.h"
#include "SDL_joystick.h"
#include "SDL_gamecontroller.h"
#include "../SDL_sysjoystick.h"
#include "SDL_hidapijoystick_c.h"
#ifdef SDL_JOYSTICK_HIDAPI_XBOXONE
#define USB_PACKET_LENGTH 64
typedef struct
{
Uint16 vendor_id;
Uint16 product_id;
const char *name;
} SDL_DriverXboxOne_DeviceName;
static const SDL_DriverXboxOne_DeviceName xboxone_devicenames[] = {
{ 0x045e, 0x02d1, "Microsoft X-Box One pad" },
{ 0x045e, 0x02dd, "Microsoft X-Box One pad (Firmware 2015)" },
{ 0x045e, 0x02e3, "Microsoft X-Box One Elite pad" },
{ 0x045e, 0x02ea, "Microsoft X-Box One S pad" },
{ 0x045e, 0x02ff, "Microsoft X-Box One pad" },
{ 0x0738, 0x4a01, "Mad Catz FightStick TE 2" },
{ 0x0e6f, 0x0139, "Afterglow Prismatic Wired Controller" },
{ 0x0e6f, 0x013a, "PDP Xbox One Controller" },
{ 0x0e6f, 0x0146, "Rock Candy Wired Controller for Xbox One" },
{ 0x0e6f, 0x0147, "PDP Marvel Xbox One Controller" },
{ 0x0e6f, 0x015c, "PDP Xbox One Arcade Stick" },
{ 0x0e6f, 0x0161, "PDP Xbox One Controller" },
{ 0x0e6f, 0x0162, "PDP Xbox One Controller" },
{ 0x0e6f, 0x0163, "PDP Xbox One Controller" },
{ 0x0e6f, 0x0164, "PDP Battlefield One" },
{ 0x0e6f, 0x0165, "PDP Titanfall 2" },
{ 0x0e6f, 0x0246, "Rock Candy Gamepad for Xbox One 2015" },
{ 0x0e6f, 0x02ab, "PDP Controller for Xbox One" },
{ 0x0e6f, 0x02a4, "PDP Wired Controller for Xbox One - Stealth Series" },
{ 0x0e6f, 0x0346, "Rock Candy Gamepad for Xbox One 2016" },
{ 0x0f0d, 0x0063, "Hori Real Arcade Pro Hayabusa (USA) Xbox One" },
{ 0x0f0d, 0x0067, "HORIPAD ONE" },
{ 0x0f0d, 0x0078, "Hori Real Arcade Pro V Kai Xbox One" },
{ 0x1532, 0x0a00, "Razer Atrox Arcade Stick" },
{ 0x1532, 0x0a03, "Razer Wildcat" },
{ 0x24c6, 0x541a, "PowerA Xbox One Mini Wired Controller" },
{ 0x24c6, 0x542a, "Xbox ONE spectra" },
{ 0x24c6, 0x543a, "PowerA Xbox One wired controller" },
{ 0x24c6, 0x551a, "PowerA FUSION Pro Controller" },
{ 0x24c6, 0x561a, "PowerA FUSION Controller" },
};
/*
* This packet is required for all Xbox One pads with 2015
* or later firmware installed (or present from the factory).
*/
static const Uint8 xboxone_fw2015_init[] = {
0x05, 0x20, 0x00, 0x01, 0x00
};
/*
* This packet is required for the Titanfall 2 Xbox One pads
* (0x0e6f:0x0165) to finish initialization and for Hori pads
* (0x0f0d:0x0067) to make the analog sticks work.
*/
static const Uint8 xboxone_hori_init[] = {
0x01, 0x20, 0x00, 0x09, 0x00, 0x04, 0x20, 0x3a,
0x00, 0x00, 0x00, 0x80, 0x00
};
/*
* This packet is required for some of the PDP pads to start
* sending input reports. These pads include: (0x0e6f:0x02ab),
* (0x0e6f:0x02a4).
*/
static const Uint8 xboxone_pdp_init1[] = {
0x0a, 0x20, 0x00, 0x03, 0x00, 0x01, 0x14
};
/*
* This packet is required for some of the PDP pads to start
* sending input reports. These pads include: (0x0e6f:0x02ab),
* (0x0e6f:0x02a4).
*/
static const Uint8 xboxone_pdp_init2[] = {
0x06, 0x20, 0x00, 0x02, 0x01, 0x00
};
/*
* A specific rumble packet is required for some PowerA pads to start
* sending input reports. One of those pads is (0x24c6:0x543a).
*/
static const Uint8 xboxone_rumblebegin_init[] = {
0x09, 0x00, 0x00, 0x09, 0x00, 0x0F, 0x00, 0x00,
0x1D, 0x1D, 0xFF, 0x00, 0x00
};
/*
* A rumble packet with zero FF intensity will immediately
* terminate the rumbling required to init PowerA pads.
* This should happen fast enough that the motors don't
* spin up to enough speed to actually vibrate the gamepad.
*/
static const Uint8 xboxone_rumbleend_init[] = {
0x09, 0x00, 0x00, 0x09, 0x00, 0x0F, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00
};
/*
* This specifies the selection of init packets that a gamepad
* will be sent on init *and* the order in which they will be
* sent. The correct sequence number will be added when the
* packet is going to be sent.
*/
typedef struct {
Uint16 vendor_id;
Uint16 product_id;
const Uint8 *data;
int size;
} SDL_DriverXboxOne_InitPacket;
static const SDL_DriverXboxOne_InitPacket xboxone_init_packets[] = {
{ 0x0e6f, 0x0165, xboxone_hori_init, sizeof(xboxone_hori_init) },
{ 0x0f0d, 0x0067, xboxone_hori_init, sizeof(xboxone_hori_init) },
{ 0x0000, 0x0000, xboxone_fw2015_init, sizeof(xboxone_fw2015_init) },
{ 0x0e6f, 0x0246, xboxone_pdp_init1, sizeof(xboxone_pdp_init1) },
{ 0x0e6f, 0x0246, xboxone_pdp_init2, sizeof(xboxone_pdp_init2) },
{ 0x0e6f, 0x02ab, xboxone_pdp_init1, sizeof(xboxone_pdp_init1) },
{ 0x0e6f, 0x02ab, xboxone_pdp_init2, sizeof(xboxone_pdp_init2) },
{ 0x0e6f, 0x02a4, xboxone_pdp_init1, sizeof(xboxone_pdp_init1) },
{ 0x0e6f, 0x02a4, xboxone_pdp_init2, sizeof(xboxone_pdp_init2) },
{ 0x24c6, 0x541a, xboxone_rumblebegin_init, sizeof(xboxone_rumblebegin_init) },
{ 0x24c6, 0x542a, xboxone_rumblebegin_init, sizeof(xboxone_rumblebegin_init) },
{ 0x24c6, 0x543a, xboxone_rumblebegin_init, sizeof(xboxone_rumblebegin_init) },
{ 0x24c6, 0x541a, xboxone_rumbleend_init, sizeof(xboxone_rumbleend_init) },
{ 0x24c6, 0x542a, xboxone_rumbleend_init, sizeof(xboxone_rumbleend_init) },
{ 0x24c6, 0x543a, xboxone_rumbleend_init, sizeof(xboxone_rumbleend_init) },
};
typedef struct {
Uint8 sequence;
Uint8 last_state[USB_PACKET_LENGTH];
Uint32 rumble_expiration;
} SDL_DriverXboxOne_Context;
static SDL_bool
HIDAPI_DriverXboxOne_IsSupportedDevice(Uint16 vendor_id, Uint16 product_id, int interface_number, Uint16 usage_page, Uint16 usage)
{
return SDL_IsJoystickXboxOne(vendor_id, product_id);
}
static const char *
HIDAPI_DriverXboxOne_GetDeviceName(Uint16 vendor_id, Uint16 product_id)
{
int i;
for (i = 0; i < SDL_arraysize(xboxone_devicenames); ++i) {
const SDL_DriverXboxOne_DeviceName *entry = &xboxone_devicenames[i];
if (vendor_id == entry->vendor_id && product_id == entry->product_id) {
return entry->name;
}
}
return NULL;
}
static SDL_bool
HIDAPI_DriverXboxOne_Init(SDL_Joystick *joystick, hid_device *dev, Uint16 vendor_id, Uint16 product_id, void **context)
{
SDL_DriverXboxOne_Context *ctx;
int i;
Uint8 init_packet[USB_PACKET_LENGTH];
ctx = (SDL_DriverXboxOne_Context *)SDL_calloc(1, sizeof(*ctx));
if (!ctx) {
SDL_OutOfMemory();
return SDL_FALSE;
}
*context = ctx;
/* Send the controller init data */
for (i = 0; i < SDL_arraysize(xboxone_init_packets); ++i) {
const SDL_DriverXboxOne_InitPacket *packet = &xboxone_init_packets[i];
if (!packet->vendor_id || (vendor_id == packet->vendor_id && product_id == packet->product_id)) {
SDL_memcpy(init_packet, packet->data, packet->size);
init_packet[2] = ctx->sequence++;
if (hid_write(dev, init_packet, packet->size) != packet->size) {
SDL_SetError("Couldn't write Xbox One initialization packet");
SDL_free(ctx);
return SDL_FALSE;
}
}
}
/* Initialize the joystick capabilities */
joystick->nbuttons = SDL_CONTROLLER_BUTTON_MAX;
joystick->naxes = SDL_CONTROLLER_AXIS_MAX;
joystick->epowerlevel = SDL_JOYSTICK_POWER_WIRED;
return SDL_TRUE;
}
static int
HIDAPI_DriverXboxOne_Rumble(SDL_Joystick *joystick, hid_device *dev, void *context, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble, Uint32 duration_ms)
{
SDL_DriverXboxOne_Context *ctx = (SDL_DriverXboxOne_Context *)context;
Uint8 rumble_packet[] = { 0x09, 0x00, 0x00, 0x09, 0x00, 0x0F, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0xFF };
/* The Rock Candy Xbox One Controller limits the range of
low frequency rumble strength in the range of [0 - 0x99]
high frequency rumble strength in the range of [0 - 0x82]
I think the valid range of rumble at the firmware level is [0 - 0x7F]
*/
rumble_packet[2] = ctx->sequence++;
rumble_packet[8] = (low_frequency_rumble >> 9);
rumble_packet[9] = (high_frequency_rumble >> 9);
if (hid_write(dev, rumble_packet, sizeof(rumble_packet)) != sizeof(rumble_packet)) {
return SDL_SetError("Couldn't send rumble packet");
}
if ((low_frequency_rumble || high_frequency_rumble) && duration_ms) {
ctx->rumble_expiration = SDL_GetTicks() + duration_ms;
} else {
ctx->rumble_expiration = 0;
}
return 0;
}
static void
HIDAPI_DriverXboxOne_HandleStatePacket(SDL_Joystick *joystick, hid_device *dev, SDL_DriverXboxOne_Context *ctx, Uint8 *data, int size)
{
Sint16 axis;
if (ctx->last_state[4] != data[4]) {
SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_START, (data[4] & 0x04) ? SDL_PRESSED : SDL_RELEASED);
SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_BACK, (data[4] & 0x08) ? SDL_PRESSED : SDL_RELEASED);
SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_A, (data[4] & 0x10) ? SDL_PRESSED : SDL_RELEASED);
SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_B, (data[4] & 0x20) ? SDL_PRESSED : SDL_RELEASED);
SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_X, (data[4] & 0x40) ? SDL_PRESSED : SDL_RELEASED);
SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_Y, (data[4] & 0x80) ? SDL_PRESSED : SDL_RELEASED);
}
if (ctx->last_state[5] != data[5]) {
SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_DPAD_UP, (data[5] & 0x01) ? SDL_PRESSED : SDL_RELEASED);
SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_DPAD_DOWN, (data[5] & 0x02) ? SDL_PRESSED : SDL_RELEASED);
SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_DPAD_LEFT, (data[5] & 0x04) ? SDL_PRESSED : SDL_RELEASED);
SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_DPAD_RIGHT, (data[5] & 0x08) ? SDL_PRESSED : SDL_RELEASED);
SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_LEFTSHOULDER, (data[5] & 0x10) ? SDL_PRESSED : SDL_RELEASED);
SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_RIGHTSHOULDER, (data[5] & 0x20) ? SDL_PRESSED : SDL_RELEASED);
SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_LEFTSTICK, (data[5] & 0x40) ? SDL_PRESSED : SDL_RELEASED);
SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_RIGHTSTICK, (data[5] & 0x80) ? SDL_PRESSED : SDL_RELEASED);
}
axis = ((int)*(Sint16*)(&data[6]) * 64) - 32768;
SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_TRIGGERLEFT, axis);
axis = ((int)*(Sint16*)(&data[8]) * 64) - 32768;
SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_TRIGGERRIGHT, axis);
axis = *(Sint16*)(&data[10]);
SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_LEFTX, axis);
axis = *(Sint16*)(&data[12]);
SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_LEFTY, ~axis);
axis = *(Sint16*)(&data[14]);
SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_RIGHTX, axis);
axis = *(Sint16*)(&data[16]);
SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_RIGHTY, ~axis);
SDL_memcpy(ctx->last_state, data, SDL_min(size, sizeof(ctx->last_state)));
}
static void
HIDAPI_DriverXboxOne_HandleModePacket(SDL_Joystick *joystick, hid_device *dev, SDL_DriverXboxOne_Context *ctx, Uint8 *data, int size)
{
if (data[1] == 0x30) {
/* The Xbox One S controller needs acks for mode reports */
const Uint8 seqnum = data[2];
const Uint8 ack[] = { 0x01, 0x20, seqnum, 0x09, 0x00, 0x07, 0x20, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00 };
hid_write(dev, ack, sizeof(ack));
}
SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_GUIDE, (data[4] & 0x01) ? SDL_PRESSED : SDL_RELEASED);
}
static void
HIDAPI_DriverXboxOne_Update(SDL_Joystick *joystick, hid_device *dev, void *context)
{
SDL_DriverXboxOne_Context *ctx = (SDL_DriverXboxOne_Context *)context;
Uint8 data[USB_PACKET_LENGTH];
int size;
while ((size = hid_read_timeout(dev, data, sizeof(data), 0)) > 0) {
switch (data[0]) {
case 0x20:
HIDAPI_DriverXboxOne_HandleStatePacket(joystick, dev, ctx, data, size);
break;
case 0x07:
HIDAPI_DriverXboxOne_HandleModePacket(joystick, dev, ctx, data, size);
break;
default:
#ifdef DEBUG_JOYSTICK
SDL_Log("Unknown Xbox One packet: 0x%.2x\n", data[0]);
#endif
break;
}
}
if (ctx->rumble_expiration) {
Uint32 now = SDL_GetTicks();
if (SDL_TICKS_PASSED(now, ctx->rumble_expiration)) {
HIDAPI_DriverXboxOne_Rumble(joystick, dev, context, 0, 0, 0);
}
}
}
static void
HIDAPI_DriverXboxOne_Quit(SDL_Joystick *joystick, hid_device *dev, void *context)
{
SDL_free(context);
}
SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverXboxOne =
{
SDL_HINT_JOYSTICK_HIDAPI_XBOXONE,
SDL_TRUE,
HIDAPI_DriverXboxOne_IsSupportedDevice,
HIDAPI_DriverXboxOne_GetDeviceName,
HIDAPI_DriverXboxOne_Init,
HIDAPI_DriverXboxOne_Rumble,
HIDAPI_DriverXboxOne_Update,
HIDAPI_DriverXboxOne_Quit
};
#endif /* SDL_JOYSTICK_HIDAPI_XBOXONE */
#endif /* SDL_JOYSTICK_HIDAPI */
/* vi: set ts=4 sw=4 expandtab: */
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,70 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "../../SDL_internal.h"
#ifndef SDL_JOYSTICK_HIDAPI_H
#define SDL_JOYSTICK_HIDAPI_H
#include "../../hidapi/hidapi/hidapi.h"
/* This is the full set of HIDAPI drivers available */
#define SDL_JOYSTICK_HIDAPI_PS4
#define SDL_JOYSTICK_HIDAPI_SWITCH
#define SDL_JOYSTICK_HIDAPI_XBOX360
#define SDL_JOYSTICK_HIDAPI_XBOXONE
#ifdef __WINDOWS__
/* On Windows, Xbox controllers are handled by the XInput driver */
#undef SDL_JOYSTICK_HIDAPI_XBOX360
#undef SDL_JOYSTICK_HIDAPI_XBOXONE
#endif
#ifdef __MACOSX__
/* On Mac OS X, Xbox One controllers are handled by the Xbox 360 driver */
#undef SDL_JOYSTICK_HIDAPI_XBOXONE
#endif
typedef struct _SDL_HIDAPI_DeviceDriver
{
const char *hint;
SDL_bool enabled;
SDL_bool (*IsSupportedDevice)(Uint16 vendor_id, Uint16 product_id, int interface_number, Uint16 usage_page, Uint16 usage);
const char *(*GetDeviceName)(Uint16 vendor_id, Uint16 product_id);
SDL_bool (*Init)(SDL_Joystick *joystick, hid_device *dev, Uint16 vendor_id, Uint16 product_id, void **context);
int (*Rumble)(SDL_Joystick *joystick, hid_device *dev, void *context, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble, Uint32 duration_ms);
void (*Update)(SDL_Joystick *joystick, hid_device *dev, void *context);
void (*Quit)(SDL_Joystick *joystick, hid_device *dev, void *context);
} SDL_HIDAPI_DeviceDriver;
/* HIDAPI device support */
extern SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverPS4;
extern SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverSteam;
extern SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverSwitch;
extern SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverXbox360;
extern SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverXboxOne;
/* Return true if a HID device is present and supported as a joystick */
extern SDL_bool HIDAPI_IsDevicePresent(Uint16 vendor_id, Uint16 product_id);
#endif /* SDL_JOYSTICK_HIDAPI_H */
/* vi: set ts=4 sw=4 expandtab: */
+75 -141
View File
@@ -33,7 +33,6 @@
#include "SDL_stdinc.h" #include "SDL_stdinc.h"
#include "../SDL_sysjoystick.h" #include "../SDL_sysjoystick.h"
#include "../SDL_joystick_c.h" #include "../SDL_joystick_c.h"
#include "../steam/SDL_steamcontroller.h"
#if !SDL_EVENTS_DISABLED #if !SDL_EVENTS_DISABLED
@@ -59,7 +58,6 @@ static CMMotionManager *motionManager = nil;
static SDL_JoystickDeviceItem *deviceList = NULL; static SDL_JoystickDeviceItem *deviceList = NULL;
static int numjoysticks = 0; static int numjoysticks = 0;
static SDL_JoystickID instancecounter = 0;
int SDL_AppleTVRemoteOpenedAsJoystick = 0; int SDL_AppleTVRemoteOpenedAsJoystick = 0;
static SDL_JoystickDeviceItem * static SDL_JoystickDeviceItem *
@@ -80,10 +78,9 @@ GetDeviceForIndex(int device_index)
} }
static void static void
SDL_SYS_AddMFIJoystickDevice(SDL_JoystickDeviceItem *device, GCController *controller) IOS_AddMFIJoystickDevice(SDL_JoystickDeviceItem *device, GCController *controller)
{ {
#ifdef SDL_JOYSTICK_MFI #ifdef SDL_JOYSTICK_MFI
const Uint16 BUS_BLUETOOTH = 0x05;
const Uint16 VENDOR_APPLE = 0x05AC; const Uint16 VENDOR_APPLE = 0x05AC;
Uint16 *guid16 = (Uint16 *)device->guid.data; Uint16 *guid16 = (Uint16 *)device->guid.data;
Uint16 vendor = 0; Uint16 vendor = 0;
@@ -136,7 +133,7 @@ SDL_SYS_AddMFIJoystickDevice(SDL_JoystickDeviceItem *device, GCController *contr
/* We only need 16 bits for each of these; space them out to fill 128. */ /* We only need 16 bits for each of these; space them out to fill 128. */
/* Byteswap so devices get same GUID on little/big endian platforms. */ /* Byteswap so devices get same GUID on little/big endian platforms. */
*guid16++ = SDL_SwapLE16(BUS_BLUETOOTH); *guid16++ = SDL_SwapLE16(SDL_HARDWARE_BUS_BLUETOOTH);
*guid16++ = 0; *guid16++ = 0;
*guid16++ = SDL_SwapLE16(vendor); *guid16++ = SDL_SwapLE16(vendor);
*guid16++ = 0; *guid16++ = 0;
@@ -157,7 +154,7 @@ SDL_SYS_AddMFIJoystickDevice(SDL_JoystickDeviceItem *device, GCController *contr
} }
static void static void
SDL_SYS_AddJoystickDevice(GCController *controller, SDL_bool accelerometer) IOS_AddJoystickDevice(GCController *controller, SDL_bool accelerometer)
{ {
SDL_JoystickDeviceItem *device = deviceList; SDL_JoystickDeviceItem *device = deviceList;
@@ -183,7 +180,7 @@ SDL_SYS_AddJoystickDevice(GCController *controller, SDL_bool accelerometer)
} }
device->accelerometer = accelerometer; device->accelerometer = accelerometer;
device->instance_id = instancecounter++; device->instance_id = SDL_GetNextJoystickInstanceID();
if (accelerometer) { if (accelerometer) {
#if TARGET_OS_TV #if TARGET_OS_TV
@@ -199,7 +196,7 @@ SDL_SYS_AddJoystickDevice(GCController *controller, SDL_bool accelerometer)
SDL_memcpy(&device->guid.data, device->name, SDL_min(sizeof(SDL_JoystickGUID), SDL_strlen(device->name))); SDL_memcpy(&device->guid.data, device->name, SDL_min(sizeof(SDL_JoystickGUID), SDL_strlen(device->name)));
#endif /* TARGET_OS_TV */ #endif /* TARGET_OS_TV */
} else if (controller) { } else if (controller) {
SDL_SYS_AddMFIJoystickDevice(device, controller); IOS_AddMFIJoystickDevice(device, controller);
} }
if (deviceList == NULL) { if (deviceList == NULL) {
@@ -214,11 +211,11 @@ SDL_SYS_AddJoystickDevice(GCController *controller, SDL_bool accelerometer)
++numjoysticks; ++numjoysticks;
SDL_PrivateJoystickAdded(numjoysticks - 1); SDL_PrivateJoystickAdded(device->instance_id);
} }
static SDL_JoystickDeviceItem * static SDL_JoystickDeviceItem *
SDL_SYS_RemoveJoystickDevice(SDL_JoystickDeviceItem *device) IOS_RemoveJoystickDevice(SDL_JoystickDeviceItem *device)
{ {
SDL_JoystickDeviceItem *prev = NULL; SDL_JoystickDeviceItem *prev = NULL;
SDL_JoystickDeviceItem *next = NULL; SDL_JoystickDeviceItem *next = NULL;
@@ -287,78 +284,27 @@ SDL_AppleTVRemoteRotationHintChanged(void *udata, const char *name, const char *
} }
#endif /* TARGET_OS_TV */ #endif /* TARGET_OS_TV */
static SDL_bool SteamControllerConnectedCallback(const char *name, SDL_JoystickGUID guid, int *device_instance) static int
{ IOS_JoystickInit(void)
SDL_JoystickDeviceItem *device = (SDL_JoystickDeviceItem *)SDL_calloc(1, sizeof(SDL_JoystickDeviceItem));
if (device == NULL) {
return SDL_FALSE;
}
*device_instance = device->instance_id = instancecounter++;
device->name = SDL_strdup(name);
device->guid = guid;
SDL_GetSteamControllerInputs(&device->nbuttons,
&device->naxes,
&device->nhats);
device->m_bSteamController = SDL_TRUE;
if (deviceList == NULL) {
deviceList = device;
} else {
SDL_JoystickDeviceItem *lastdevice = deviceList;
while (lastdevice->next != NULL) {
lastdevice = lastdevice->next;
}
lastdevice->next = device;
}
++numjoysticks;
SDL_PrivateJoystickAdded(numjoysticks - 1);
return SDL_TRUE;
}
static void SteamControllerDisconnectedCallback(int device_instance)
{
SDL_JoystickDeviceItem *item;
for (item = deviceList; item; item = item->next) {
if (item->instance_id == device_instance) {
SDL_SYS_RemoveJoystickDevice(item);
break;
}
}
}
/* Function to scan the system for joysticks.
* Joystick 0 should be the system default joystick.
* It should return 0, or -1 on an unrecoverable fatal error.
*/
int
SDL_SYS_JoystickInit(void)
{ {
@autoreleasepool { @autoreleasepool {
NSNotificationCenter *center = [NSNotificationCenter defaultCenter]; NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
SDL_InitSteamControllers(SteamControllerConnectedCallback,
SteamControllerDisconnectedCallback);
#if !TARGET_OS_TV #if !TARGET_OS_TV
if (SDL_GetHintBoolean(SDL_HINT_ACCELEROMETER_AS_JOYSTICK, SDL_TRUE)) { if (SDL_GetHintBoolean(SDL_HINT_ACCELEROMETER_AS_JOYSTICK, SDL_TRUE)) {
/* Default behavior, accelerometer as joystick */ /* Default behavior, accelerometer as joystick */
SDL_SYS_AddJoystickDevice(nil, SDL_TRUE); IOS_AddJoystickDevice(nil, SDL_TRUE);
} }
#endif /* !TARGET_OS_TV */ #endif /* !TARGET_OS_TV */
#ifdef SDL_JOYSTICK_MFI #ifdef SDL_JOYSTICK_MFI
/* GameController.framework was added in iOS 7. */ /* GameController.framework was added in iOS 7. */
if (![GCController class]) { if (![GCController class]) {
return numjoysticks; return 0;
} }
for (GCController *controller in [GCController controllers]) { for (GCController *controller in [GCController controllers]) {
SDL_SYS_AddJoystickDevice(controller, SDL_FALSE); IOS_AddJoystickDevice(controller, SDL_FALSE);
} }
#if TARGET_OS_TV #if TARGET_OS_TV
@@ -371,7 +317,7 @@ SDL_SYS_JoystickInit(void)
queue:nil queue:nil
usingBlock:^(NSNotification *note) { usingBlock:^(NSNotification *note) {
GCController *controller = note.object; GCController *controller = note.object;
SDL_SYS_AddJoystickDevice(controller, SDL_FALSE); IOS_AddJoystickDevice(controller, SDL_FALSE);
}]; }];
disconnectObserver = [center addObserverForName:GCControllerDidDisconnectNotification disconnectObserver = [center addObserverForName:GCControllerDidDisconnectNotification
@@ -382,7 +328,7 @@ SDL_SYS_JoystickInit(void)
SDL_JoystickDeviceItem *device = deviceList; SDL_JoystickDeviceItem *device = deviceList;
while (device != NULL) { while (device != NULL) {
if (device->controller == controller) { if (device->controller == controller) {
SDL_SYS_RemoveJoystickDevice(device); IOS_RemoveJoystickDevice(device);
break; break;
} }
device = device->next; device = device->next;
@@ -391,43 +337,49 @@ SDL_SYS_JoystickInit(void)
#endif /* SDL_JOYSTICK_MFI */ #endif /* SDL_JOYSTICK_MFI */
} }
return numjoysticks; return 0;
} }
int static int
SDL_SYS_NumJoysticks(void) IOS_JoystickGetCount(void)
{ {
return numjoysticks; return numjoysticks;
} }
void static void
SDL_SYS_JoystickDetect(void) IOS_JoystickDetect(void)
{ {
SDL_UpdateSteamControllers();
} }
/* Function to get the device-dependent name of a joystick */ static const char *
const char * IOS_JoystickGetDeviceName(int device_index)
SDL_SYS_JoystickNameForDeviceIndex(int device_index)
{ {
SDL_JoystickDeviceItem *device = GetDeviceForIndex(device_index); SDL_JoystickDeviceItem *device = GetDeviceForIndex(device_index);
return device ? device->name : "Unknown"; return device ? device->name : "Unknown";
} }
/* Function to perform the mapping from device index to the instance id for this index */ static SDL_JoystickGUID
SDL_JoystickID SDL_SYS_GetInstanceIdOfDeviceIndex(int device_index) IOS_JoystickGetDeviceGUID( int device_index )
{ {
SDL_JoystickDeviceItem *device = GetDeviceForIndex(device_index); SDL_JoystickDeviceItem *device = GetDeviceForIndex(device_index);
return device ? device->instance_id : 0; SDL_JoystickGUID guid;
if (device) {
guid = device->guid;
} else {
SDL_zero(guid);
}
return guid;
} }
/* Function to open a joystick for use. static SDL_JoystickID
The joystick to open is specified by the device index. IOS_JoystickGetDeviceInstanceID(int device_index)
This should fill the nbuttons and naxes fields of the joystick structure. {
It returns 0, or -1 if there is an error. SDL_JoystickDeviceItem *device = GetDeviceForIndex(device_index);
*/ return device ? device->instance_id : -1;
int }
SDL_SYS_JoystickOpen(SDL_Joystick * joystick, int device_index)
static int
IOS_JoystickOpen(SDL_Joystick * joystick, int device_index)
{ {
SDL_JoystickDeviceItem *device = GetDeviceForIndex(device_index); SDL_JoystickDeviceItem *device = GetDeviceForIndex(device_index);
if (device == NULL) { if (device == NULL) {
@@ -473,15 +425,14 @@ SDL_SYS_JoystickOpen(SDL_Joystick * joystick, int device_index)
return 0; return 0;
} }
/* Function to determine if this joystick is attached to the system right now */ static SDL_bool
SDL_bool IOS_JoystickIsAttached(SDL_Joystick *joystick)
SDL_SYS_JoystickAttached(SDL_Joystick *joystick)
{ {
return joystick->hwdata != NULL; return joystick->hwdata != NULL;
} }
static void static void
SDL_SYS_AccelerometerUpdate(SDL_Joystick * joystick) IOS_AccelerometerUpdate(SDL_Joystick * joystick)
{ {
#if !TARGET_OS_TV #if !TARGET_OS_TV
const float maxgforce = SDL_IPHONE_MAX_GFORCE; const float maxgforce = SDL_IPHONE_MAX_GFORCE;
@@ -526,7 +477,7 @@ SDL_SYS_AccelerometerUpdate(SDL_Joystick * joystick)
#ifdef SDL_JOYSTICK_MFI #ifdef SDL_JOYSTICK_MFI
static Uint8 static Uint8
SDL_SYS_MFIJoystickHatStateForDPad(GCControllerDirectionPad *dpad) IOS_MFIJoystickHatStateForDPad(GCControllerDirectionPad *dpad)
{ {
Uint8 hat = 0; Uint8 hat = 0;
@@ -551,7 +502,7 @@ SDL_SYS_MFIJoystickHatStateForDPad(GCControllerDirectionPad *dpad)
#endif #endif
static void static void
SDL_SYS_MFIJoystickUpdate(SDL_Joystick * joystick) IOS_MFIJoystickUpdate(SDL_Joystick * joystick)
{ {
#if SDL_JOYSTICK_MFI #if SDL_JOYSTICK_MFI
@autoreleasepool { @autoreleasepool {
@@ -581,7 +532,7 @@ SDL_SYS_MFIJoystickUpdate(SDL_Joystick * joystick)
gamepad.rightShoulder.isPressed, gamepad.rightShoulder.isPressed,
}; };
hatstate = SDL_SYS_MFIJoystickHatStateForDPad(gamepad.dpad); hatstate = IOS_MFIJoystickHatStateForDPad(gamepad.dpad);
for (i = 0; i < SDL_arraysize(axes); i++) { for (i = 0; i < SDL_arraysize(axes); i++) {
/* The triggers (axes 2 and 5) are resting at -32768 but SDL /* The triggers (axes 2 and 5) are resting at -32768 but SDL
@@ -608,7 +559,7 @@ SDL_SYS_MFIJoystickUpdate(SDL_Joystick * joystick)
gamepad.rightShoulder.isPressed, gamepad.rightShoulder.isPressed,
}; };
hatstate = SDL_SYS_MFIJoystickHatStateForDPad(gamepad.dpad); hatstate = IOS_MFIJoystickHatStateForDPad(gamepad.dpad);
for (i = 0; i < SDL_arraysize(buttons); i++) { for (i = 0; i < SDL_arraysize(buttons); i++) {
updateplayerindex |= (joystick->buttons[i] != buttons[i]); updateplayerindex |= (joystick->buttons[i] != buttons[i]);
@@ -678,13 +629,14 @@ SDL_SYS_MFIJoystickUpdate(SDL_Joystick * joystick)
#endif /* SDL_JOYSTICK_MFI */ #endif /* SDL_JOYSTICK_MFI */
} }
/* Function to update the state of a joystick - called as a device poll. static int
* This function shouldn't update the joystick structure directly, IOS_JoystickRumble(SDL_Joystick * joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble, Uint32 duration_ms)
* but instead should call SDL_PrivateJoystick*() to deliver events {
* and update joystick device state. return SDL_Unsupported();
*/ }
void
SDL_SYS_JoystickUpdate(SDL_Joystick * joystick) static void
IOS_JoystickUpdate(SDL_Joystick * joystick)
{ {
SDL_JoystickDeviceItem *device = joystick->hwdata; SDL_JoystickDeviceItem *device = joystick->hwdata;
@@ -692,21 +644,15 @@ SDL_SYS_JoystickUpdate(SDL_Joystick * joystick)
return; return;
} }
if (device->m_bSteamController) {
SDL_UpdateSteamController(joystick);
return;
}
if (device->accelerometer) { if (device->accelerometer) {
SDL_SYS_AccelerometerUpdate(joystick); IOS_AccelerometerUpdate(joystick);
} else if (device->controller) { } else if (device->controller) {
SDL_SYS_MFIJoystickUpdate(joystick); IOS_MFIJoystickUpdate(joystick);
} }
} }
/* Function to close a joystick after use */ static void
void IOS_JoystickClose(SDL_Joystick * joystick)
SDL_SYS_JoystickClose(SDL_Joystick * joystick)
{ {
SDL_JoystickDeviceItem *device = joystick->hwdata; SDL_JoystickDeviceItem *device = joystick->hwdata;
@@ -734,9 +680,8 @@ SDL_SYS_JoystickClose(SDL_Joystick * joystick)
} }
} }
/* Function to perform any system-specific joystick related cleanup */ static void
void IOS_JoystickQuit(void)
SDL_SYS_JoystickQuit(void)
{ {
@autoreleasepool { @autoreleasepool {
#ifdef SDL_JOYSTICK_MFI #ifdef SDL_JOYSTICK_MFI
@@ -759,7 +704,7 @@ SDL_SYS_JoystickQuit(void)
#endif /* SDL_JOYSTICK_MFI */ #endif /* SDL_JOYSTICK_MFI */
while (deviceList != NULL) { while (deviceList != NULL) {
SDL_SYS_RemoveJoystickDevice(deviceList); IOS_RemoveJoystickDevice(deviceList);
} }
#if !TARGET_OS_TV #if !TARGET_OS_TV
@@ -767,34 +712,23 @@ SDL_SYS_JoystickQuit(void)
#endif /* !TARGET_OS_TV */ #endif /* !TARGET_OS_TV */
} }
SDL_QuitSteamControllers();
numjoysticks = 0; numjoysticks = 0;
} }
SDL_JoystickGUID SDL_JoystickDriver SDL_IOS_JoystickDriver =
SDL_SYS_JoystickGetDeviceGUID( int device_index )
{ {
SDL_JoystickDeviceItem *device = GetDeviceForIndex(device_index); IOS_JoystickInit,
SDL_JoystickGUID guid; IOS_JoystickGetCount,
if (device) { IOS_JoystickDetect,
guid = device->guid; IOS_JoystickGetDeviceName,
} else { IOS_JoystickGetDeviceGUID,
SDL_zero(guid); IOS_JoystickGetDeviceInstanceID,
} IOS_JoystickOpen,
return guid; IOS_JoystickIsAttached,
} IOS_JoystickRumble,
IOS_JoystickUpdate,
SDL_JoystickGUID IOS_JoystickClose,
SDL_SYS_JoystickGetGUID(SDL_Joystick * joystick) IOS_JoystickQuit,
{ };
SDL_JoystickGUID guid;
if (joystick->hwdata) {
guid = joystick->hwdata->guid;
} else {
SDL_zero(guid);
}
return guid;
}
/* vi: set ts=4 sw=4 expandtab: */ /* vi: set ts=4 sw=4 expandtab: */
@@ -46,9 +46,6 @@ typedef struct joystick_hwdata
int nbuttons; int nbuttons;
int nhats; int nhats;
/* Steam Controller support */
SDL_bool m_bSteamController;
struct joystick_hwdata *next; struct joystick_hwdata *next;
} joystick_hwdata; } joystick_hwdata;
+115 -40
View File
@@ -29,10 +29,11 @@
/* This is the Linux implementation of the SDL joystick API */ /* This is the Linux implementation of the SDL joystick API */
#include <sys/stat.h> #include <sys/stat.h>
#include <unistd.h> #include <errno.h> /* errno, strerror */
#include <fcntl.h> #include <fcntl.h>
#include <sys/ioctl.h>
#include <limits.h> /* For the definition of PATH_MAX */ #include <limits.h> /* For the definition of PATH_MAX */
#include <sys/ioctl.h>
#include <unistd.h>
#include <linux/joystick.h> #include <linux/joystick.h>
#include "SDL_assert.h" #include "SDL_assert.h"
@@ -43,6 +44,7 @@
#include "../SDL_joystick_c.h" #include "../SDL_joystick_c.h"
#include "../steam/SDL_steamcontroller.h" #include "../steam/SDL_steamcontroller.h"
#include "SDL_sysjoystick_c.h" #include "SDL_sysjoystick_c.h"
#include "../hidapi/SDL_hidapijoystick_c.h"
/* This isn't defined in older Linux kernel headers */ /* This isn't defined in older Linux kernel headers */
#ifndef SYN_DROPPED #ifndef SYN_DROPPED
@@ -76,7 +78,6 @@ typedef struct SDL_joylist_item
static SDL_joylist_item *SDL_joylist = NULL; static SDL_joylist_item *SDL_joylist = NULL;
static SDL_joylist_item *SDL_joylist_tail = NULL; static SDL_joylist_item *SDL_joylist_tail = NULL;
static int numjoysticks = 0; static int numjoysticks = 0;
static int instance_counter = 0;
#define test_bit(nr, addr) \ #define test_bit(nr, addr) \
@@ -209,6 +210,13 @@ IsJoystick(int fd, char *namebuf, const size_t namebuflen, SDL_JoystickGUID *gui
return 0; return 0;
} }
#ifdef SDL_JOYSTICK_HIDAPI
if (HIDAPI_IsDevicePresent(inpid.vendor, inpid.product)) {
/* The HIDAPI driver is taking care of this device */
return 0;
}
#endif
/* Check the joystick blacklist */ /* Check the joystick blacklist */
id = MAKE_VIDPID(inpid.vendor, inpid.product); id = MAKE_VIDPID(inpid.vendor, inpid.product);
for (i = 0; i < SDL_arraysize(joystick_blacklist); ++i) { for (i = 0; i < SDL_arraysize(joystick_blacklist); ++i) {
@@ -239,8 +247,7 @@ IsJoystick(int fd, char *namebuf, const size_t namebuflen, SDL_JoystickGUID *gui
SDL_strlcpy((char*)guid16, namebuf, sizeof(guid->data) - 4); SDL_strlcpy((char*)guid16, namebuf, sizeof(guid->data) - 4);
} }
if (SDL_IsGameControllerNameAndGUID(namebuf, *guid) && if (SDL_ShouldIgnoreJoystick(namebuf, *guid)) {
SDL_ShouldIgnoreGameController(namebuf, *guid)) {
return 0; return 0;
} }
return 1; return 1;
@@ -325,14 +332,14 @@ MaybeAddDevice(const char *path)
item->name = SDL_strdup(namebuf); item->name = SDL_strdup(namebuf);
item->guid = guid; item->guid = guid;
if ( (item->path == NULL) || (item->name == NULL) ) { if ((item->path == NULL) || (item->name == NULL)) {
SDL_free(item->path); SDL_free(item->path);
SDL_free(item->name); SDL_free(item->name);
SDL_free(item); SDL_free(item);
return -1; return -1;
} }
item->device_instance = instance_counter++; item->device_instance = SDL_GetNextJoystickInstanceID();
if (SDL_joylist_tail == NULL) { if (SDL_joylist_tail == NULL) {
SDL_joylist = SDL_joylist_tail = item; SDL_joylist = SDL_joylist_tail = item;
} else { } else {
@@ -343,7 +350,7 @@ MaybeAddDevice(const char *path)
/* Need to increment the joystick count before we post the event */ /* Need to increment the joystick count before we post the event */
++numjoysticks; ++numjoysticks;
SDL_PrivateJoystickAdded(numjoysticks - 1); SDL_PrivateJoystickAdded(item->device_instance);
return numjoysticks; return numjoysticks;
} }
@@ -409,7 +416,7 @@ JoystickInitWithoutUdev(void)
MaybeAddDevice(path); MaybeAddDevice(path);
} }
return numjoysticks; return 0;
} }
#endif #endif
@@ -430,7 +437,7 @@ JoystickInitWithUdev(void)
/* Force a scan to build the initial device list */ /* Force a scan to build the initial device list */
SDL_UDEV_Scan(); SDL_UDEV_Scan();
return numjoysticks; return 0;
} }
#endif #endif
@@ -455,7 +462,7 @@ static SDL_bool SteamControllerConnectedCallback(const char *name, SDL_JoystickG
return SDL_FALSE; return SDL_FALSE;
} }
*device_instance = item->device_instance = instance_counter++; *device_instance = item->device_instance = SDL_GetNextJoystickInstanceID();
if (SDL_joylist_tail == NULL) { if (SDL_joylist_tail == NULL) {
SDL_joylist = SDL_joylist_tail = item; SDL_joylist = SDL_joylist_tail = item;
} else { } else {
@@ -466,7 +473,7 @@ static SDL_bool SteamControllerConnectedCallback(const char *name, SDL_JoystickG
/* Need to increment the joystick count before we post the event */ /* Need to increment the joystick count before we post the event */
++numjoysticks; ++numjoysticks;
SDL_PrivateJoystickAdded(numjoysticks - 1); SDL_PrivateJoystickAdded(item->device_instance);
return SDL_TRUE; return SDL_TRUE;
} }
@@ -505,8 +512,8 @@ static void SteamControllerDisconnectedCallback(int device_instance)
} }
} }
int static int
SDL_SYS_JoystickInit(void) LINUX_JoystickInit(void)
{ {
/* First see if the user specified one or more joysticks to use */ /* First see if the user specified one or more joysticks to use */
if (SDL_getenv("SDL_JOYSTICK_DEVICE") != NULL) { if (SDL_getenv("SDL_JOYSTICK_DEVICE") != NULL) {
@@ -534,14 +541,14 @@ SDL_SYS_JoystickInit(void)
#endif #endif
} }
int static int
SDL_SYS_NumJoysticks(void) LINUX_JoystickGetCount(void)
{ {
return numjoysticks; return numjoysticks;
} }
void static void
SDL_SYS_JoystickDetect(void) LINUX_JoystickDetect(void)
{ {
#if SDL_USE_LIBUDEV #if SDL_USE_LIBUDEV
SDL_UDEV_Poll(); SDL_UDEV_Poll();
@@ -569,14 +576,21 @@ JoystickByDevIndex(int device_index)
} }
/* Function to get the device-dependent name of a joystick */ /* Function to get the device-dependent name of a joystick */
const char * static const char *
SDL_SYS_JoystickNameForDeviceIndex(int device_index) LINUX_JoystickGetDeviceName(int device_index)
{ {
return JoystickByDevIndex(device_index)->name; return JoystickByDevIndex(device_index)->name;
} }
static SDL_JoystickGUID
LINUX_JoystickGetDeviceGUID( int device_index )
{
return JoystickByDevIndex(device_index)->guid;
}
/* Function to perform the mapping from device index to the instance id for this index */ /* Function to perform the mapping from device index to the instance id for this index */
SDL_JoystickID SDL_SYS_GetInstanceIdOfDeviceIndex(int device_index) static SDL_JoystickID
LINUX_JoystickGetDeviceInstanceID(int device_index)
{ {
return JoystickByDevIndex(device_index)->device_instance; return JoystickByDevIndex(device_index)->device_instance;
} }
@@ -624,6 +638,7 @@ ConfigJoystick(SDL_Joystick * joystick, int fd)
unsigned long keybit[NBITS(KEY_MAX)] = { 0 }; unsigned long keybit[NBITS(KEY_MAX)] = { 0 };
unsigned long absbit[NBITS(ABS_MAX)] = { 0 }; unsigned long absbit[NBITS(ABS_MAX)] = { 0 };
unsigned long relbit[NBITS(REL_MAX)] = { 0 }; unsigned long relbit[NBITS(REL_MAX)] = { 0 };
unsigned long ffbit[NBITS(FF_MAX)] = { 0 };
/* See if this device uses the new unified event API */ /* See if this device uses the new unified event API */
if ((ioctl(fd, EVIOCGBIT(EV_KEY, sizeof(keybit)), keybit) >= 0) && if ((ioctl(fd, EVIOCGBIT(EV_KEY, sizeof(keybit)), keybit) >= 0) &&
@@ -719,6 +734,15 @@ ConfigJoystick(SDL_Joystick * joystick, int fd)
} }
} }
} }
if (ioctl(fd, EVIOCGBIT(EV_FF, sizeof(ffbit)), ffbit) >= 0) {
if (test_bit(FF_RUMBLE, ffbit)) {
joystick->hwdata->ff_rumble = SDL_TRUE;
}
if (test_bit(FF_SINE, ffbit)) {
joystick->hwdata->ff_sine = SDL_TRUE;
}
}
} }
@@ -727,8 +751,8 @@ ConfigJoystick(SDL_Joystick * joystick, int fd)
This should fill the nbuttons and naxes fields of the joystick structure. This should fill the nbuttons and naxes fields of the joystick structure.
It returns 0, or -1 if there is an error. It returns 0, or -1 if there is an error.
*/ */
int static int
SDL_SYS_JoystickOpen(SDL_Joystick * joystick, int device_index) LINUX_JoystickOpen(SDL_Joystick * joystick, int device_index)
{ {
SDL_joylist_item *item = JoystickByDevIndex(device_index); SDL_joylist_item *item = JoystickByDevIndex(device_index);
@@ -744,6 +768,7 @@ SDL_SYS_JoystickOpen(SDL_Joystick * joystick, int device_index)
} }
joystick->hwdata->item = item; joystick->hwdata->item = item;
joystick->hwdata->guid = item->guid; joystick->hwdata->guid = item->guid;
joystick->hwdata->effect.id = -1;
joystick->hwdata->m_bSteamController = item->m_bSteamController; joystick->hwdata->m_bSteamController = item->m_bSteamController;
if (item->m_bSteamController) { if (item->m_bSteamController) {
@@ -752,7 +777,7 @@ SDL_SYS_JoystickOpen(SDL_Joystick * joystick, int device_index)
&joystick->naxes, &joystick->naxes,
&joystick->nhats); &joystick->nhats);
} else { } else {
int fd = open(item->path, O_RDONLY, 0); int fd = open(item->path, O_RDWR, 0);
if (fd < 0) { if (fd < 0) {
SDL_free(joystick->hwdata); SDL_free(joystick->hwdata);
joystick->hwdata = NULL; joystick->hwdata = NULL;
@@ -785,11 +810,52 @@ SDL_SYS_JoystickOpen(SDL_Joystick * joystick, int device_index)
} }
/* Function to determine if this joystick is attached to the system right now */ /* Function to determine if this joystick is attached to the system right now */
SDL_bool SDL_SYS_JoystickAttached(SDL_Joystick *joystick) static SDL_bool
LINUX_JoystickIsAttached(SDL_Joystick *joystick)
{ {
return joystick->hwdata->item != NULL; return joystick->hwdata->item != NULL;
} }
static int
LINUX_JoystickRumble(SDL_Joystick * joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble, Uint32 duration_ms)
{
struct input_event event;
if (joystick->hwdata->effect.id < 0) {
if (joystick->hwdata->ff_rumble) {
struct ff_effect *effect = &joystick->hwdata->effect;
effect->type = FF_RUMBLE;
effect->replay.length = SDL_min(duration_ms, 32767);
effect->u.rumble.strong_magnitude = low_frequency_rumble;
effect->u.rumble.weak_magnitude = high_frequency_rumble;
} else if (joystick->hwdata->ff_sine) {
/* Scale and average the two rumble strengths */
Sint16 magnitude = (Sint16)(((low_frequency_rumble / 2) + (high_frequency_rumble / 2)) / 2);
struct ff_effect *effect = &joystick->hwdata->effect;
effect->type = FF_PERIODIC;
effect->replay.length = SDL_min(duration_ms, 32767);
effect->u.periodic.waveform = FF_SINE;
effect->u.periodic.magnitude = magnitude;
} else {
return SDL_Unsupported();
}
}
if (ioctl(joystick->hwdata->fd, EVIOCSFF, &joystick->hwdata->effect) < 0) {
return SDL_SetError("Couldn't update rumble effect: %s", strerror(errno));
}
event.type = EV_FF;
event.code = joystick->hwdata->effect.id;
event.value = 1;
if (write(joystick->hwdata->fd, &event, sizeof(event)) < 0) {
return SDL_SetError("Couldn't start rumble effect: %s", strerror(errno));
}
return 0;
}
static SDL_INLINE void static SDL_INLINE void
HandleHat(SDL_Joystick * stick, Uint8 hat, int axis, int value) HandleHat(SDL_Joystick * stick, Uint8 hat, int axis, int value)
{ {
@@ -963,8 +1029,8 @@ HandleInputEvents(SDL_Joystick * joystick)
} }
} }
void static void
SDL_SYS_JoystickUpdate(SDL_Joystick * joystick) LINUX_JoystickUpdate(SDL_Joystick * joystick)
{ {
int i; int i;
@@ -990,10 +1056,14 @@ SDL_SYS_JoystickUpdate(SDL_Joystick * joystick)
} }
/* Function to close a joystick after use */ /* Function to close a joystick after use */
void static void
SDL_SYS_JoystickClose(SDL_Joystick * joystick) LINUX_JoystickClose(SDL_Joystick * joystick)
{ {
if (joystick->hwdata) { if (joystick->hwdata) {
if (joystick->hwdata->effect.id >= 0) {
ioctl(joystick->hwdata->fd, EVIOCRMFF, joystick->hwdata->effect.id);
joystick->hwdata->effect.id = -1;
}
if (joystick->hwdata->fd >= 0) { if (joystick->hwdata->fd >= 0) {
close(joystick->hwdata->fd); close(joystick->hwdata->fd);
} }
@@ -1008,8 +1078,8 @@ SDL_SYS_JoystickClose(SDL_Joystick * joystick)
} }
/* Function to perform any system-specific joystick related cleanup */ /* Function to perform any system-specific joystick related cleanup */
void static void
SDL_SYS_JoystickQuit(void) LINUX_JoystickQuit(void)
{ {
SDL_joylist_item *item = NULL; SDL_joylist_item *item = NULL;
SDL_joylist_item *next = NULL; SDL_joylist_item *next = NULL;
@@ -1024,7 +1094,6 @@ SDL_SYS_JoystickQuit(void)
SDL_joylist = SDL_joylist_tail = NULL; SDL_joylist = SDL_joylist_tail = NULL;
numjoysticks = 0; numjoysticks = 0;
instance_counter = 0;
#if SDL_USE_LIBUDEV #if SDL_USE_LIBUDEV
SDL_UDEV_DelCallback(joystick_udev_callback); SDL_UDEV_DelCallback(joystick_udev_callback);
@@ -1034,15 +1103,21 @@ SDL_SYS_JoystickQuit(void)
SDL_QuitSteamControllers(); SDL_QuitSteamControllers();
} }
SDL_JoystickGUID SDL_SYS_JoystickGetDeviceGUID( int device_index ) SDL_JoystickDriver SDL_LINUX_JoystickDriver =
{ {
return JoystickByDevIndex(device_index)->guid; LINUX_JoystickInit,
} LINUX_JoystickGetCount,
LINUX_JoystickDetect,
SDL_JoystickGUID SDL_SYS_JoystickGetGUID(SDL_Joystick * joystick) LINUX_JoystickGetDeviceName,
{ LINUX_JoystickGetDeviceGUID,
return joystick->hwdata->guid; LINUX_JoystickGetDeviceInstanceID,
} LINUX_JoystickOpen,
LINUX_JoystickIsAttached,
LINUX_JoystickRumble,
LINUX_JoystickUpdate,
LINUX_JoystickClose,
LINUX_JoystickQuit,
};
#endif /* SDL_JOYSTICK_LINUX */ #endif /* SDL_JOYSTICK_LINUX */
+4
View File
@@ -31,6 +31,10 @@ struct joystick_hwdata
SDL_JoystickGUID guid; SDL_JoystickGUID guid;
char *fname; /* Used in haptic subsystem */ char *fname; /* Used in haptic subsystem */
SDL_bool ff_rumble;
SDL_bool ff_sine;
struct ff_effect effect;
/* The current Linux joystick driver maps hats to two axes */ /* The current Linux joystick driver maps hats to two axes */
struct hwdata_hat struct hwdata_hat
{ {
File diff suppressed because it is too large Load Diff
@@ -23,6 +23,7 @@
extern int SDL_DINPUT_JoystickInit(void); extern int SDL_DINPUT_JoystickInit(void);
extern void SDL_DINPUT_JoystickDetect(JoyStick_DeviceData **pContext); extern void SDL_DINPUT_JoystickDetect(JoyStick_DeviceData **pContext);
extern int SDL_DINPUT_JoystickOpen(SDL_Joystick * joystick, JoyStick_DeviceData *joystickdevice); extern int SDL_DINPUT_JoystickOpen(SDL_Joystick * joystick, JoyStick_DeviceData *joystickdevice);
extern int SDL_DINPUT_JoystickRumble(SDL_Joystick * joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble, Uint32 duration_ms);
extern void SDL_DINPUT_JoystickUpdate(SDL_Joystick * joystick); extern void SDL_DINPUT_JoystickUpdate(SDL_Joystick * joystick);
extern void SDL_DINPUT_JoystickClose(SDL_Joystick * joystick); extern void SDL_DINPUT_JoystickClose(SDL_Joystick * joystick);
extern void SDL_DINPUT_JoystickQuit(void); extern void SDL_DINPUT_JoystickQuit(void);
+67 -45
View File
@@ -61,7 +61,6 @@
/* local variables */ /* local variables */
static SDL_bool s_bDeviceAdded = SDL_FALSE; static SDL_bool s_bDeviceAdded = SDL_FALSE;
static SDL_bool s_bDeviceRemoved = SDL_FALSE; static SDL_bool s_bDeviceRemoved = SDL_FALSE;
static SDL_JoystickID s_nInstanceID = -1;
static SDL_cond *s_condJoystickThread = NULL; static SDL_cond *s_condJoystickThread = NULL;
static SDL_mutex *s_mutexJoyStickEnum = NULL; static SDL_mutex *s_mutexJoyStickEnum = NULL;
static SDL_Thread *s_threadJoystick = NULL; static SDL_Thread *s_threadJoystick = NULL;
@@ -271,30 +270,33 @@ SDL_JoystickThread(void *_data)
return 1; return 1;
} }
void SDL_SYS_AddJoystickDevice(JoyStick_DeviceData *device) void WINDOWS_AddJoystickDevice(JoyStick_DeviceData *device)
{ {
device->send_add_event = SDL_TRUE; device->send_add_event = SDL_TRUE;
device->nInstanceID = ++s_nInstanceID; device->nInstanceID = SDL_GetNextJoystickInstanceID();
device->pNext = SYS_Joystick; device->pNext = SYS_Joystick;
SYS_Joystick = device; SYS_Joystick = device;
s_bDeviceAdded = SDL_TRUE; s_bDeviceAdded = SDL_TRUE;
} }
static void WINDOWS_JoystickDetect(void);
static void WINDOWS_JoystickQuit(void);
/* Function to scan the system for joysticks. /* Function to scan the system for joysticks.
* Joystick 0 should be the system default joystick. * Joystick 0 should be the system default joystick.
* It should return 0, or -1 on an unrecoverable fatal error. * It should return 0, or -1 on an unrecoverable fatal error.
*/ */
int static int
SDL_SYS_JoystickInit(void) WINDOWS_JoystickInit(void)
{ {
if (SDL_DINPUT_JoystickInit() < 0) { if (SDL_DINPUT_JoystickInit() < 0) {
SDL_SYS_JoystickQuit(); WINDOWS_JoystickQuit();
return -1; return -1;
} }
if (SDL_XINPUT_JoystickInit() < 0) { if (SDL_XINPUT_JoystickInit() < 0) {
SDL_SYS_JoystickQuit(); WINDOWS_JoystickQuit();
return -1; return -1;
} }
@@ -302,19 +304,19 @@ SDL_SYS_JoystickInit(void)
s_condJoystickThread = SDL_CreateCond(); s_condJoystickThread = SDL_CreateCond();
s_bDeviceAdded = SDL_TRUE; /* force a scan of the system for joysticks this first time */ s_bDeviceAdded = SDL_TRUE; /* force a scan of the system for joysticks this first time */
SDL_SYS_JoystickDetect(); WINDOWS_JoystickDetect();
if (!s_threadJoystick) { if (!s_threadJoystick) {
/* spin up the thread to detect hotplug of devices */ /* spin up the thread to detect hotplug of devices */
s_bJoystickThreadQuit = SDL_FALSE; s_bJoystickThreadQuit = SDL_FALSE;
s_threadJoystick = SDL_CreateThreadInternal(SDL_JoystickThread, "SDL_joystick", 64 * 1024, NULL); s_threadJoystick = SDL_CreateThreadInternal(SDL_JoystickThread, "SDL_joystick", 64 * 1024, NULL);
} }
return SDL_SYS_NumJoysticks(); return 0;
} }
/* return the number of joysticks that are connected right now */ /* return the number of joysticks that are connected right now */
int static int
SDL_SYS_NumJoysticks(void) WINDOWS_JoystickGetCount(void)
{ {
int nJoysticks = 0; int nJoysticks = 0;
JoyStick_DeviceData *device = SYS_Joystick; JoyStick_DeviceData *device = SYS_Joystick;
@@ -327,8 +329,8 @@ SDL_SYS_NumJoysticks(void)
} }
/* detect any new joysticks being inserted into the system */ /* detect any new joysticks being inserted into the system */
void static void
SDL_SYS_JoystickDetect(void) WINDOWS_JoystickDetect(void)
{ {
JoyStick_DeviceData *pCurList = NULL; JoyStick_DeviceData *pCurList = NULL;
@@ -383,7 +385,7 @@ SDL_SYS_JoystickDetect(void)
SDL_DINPUT_MaybeAddDevice(&pNewJoystick->dxdevice); SDL_DINPUT_MaybeAddDevice(&pNewJoystick->dxdevice);
} }
SDL_PrivateJoystickAdded(device_index); SDL_PrivateJoystickAdded(pNewJoystick->nInstanceID);
pNewJoystick->send_add_event = SDL_FALSE; pNewJoystick->send_add_event = SDL_FALSE;
} }
@@ -394,8 +396,8 @@ SDL_SYS_JoystickDetect(void)
} }
/* Function to get the device-dependent name of a joystick */ /* Function to get the device-dependent name of a joystick */
const char * static const char *
SDL_SYS_JoystickNameForDeviceIndex(int device_index) WINDOWS_JoystickGetDeviceName(int device_index)
{ {
JoyStick_DeviceData *device = SYS_Joystick; JoyStick_DeviceData *device = SYS_Joystick;
@@ -405,9 +407,22 @@ SDL_SYS_JoystickNameForDeviceIndex(int device_index)
return device->joystickname; return device->joystickname;
} }
/* return the stable device guid for this device index */
static SDL_JoystickGUID
WINDOWS_JoystickGetDeviceGUID(int device_index)
{
JoyStick_DeviceData *device = SYS_Joystick;
int index;
for (index = device_index; index > 0; index--)
device = device->pNext;
return device->guid;
}
/* Function to perform the mapping between current device instance and this joysticks instance id */ /* Function to perform the mapping between current device instance and this joysticks instance id */
SDL_JoystickID static SDL_JoystickID
SDL_SYS_GetInstanceIdOfDeviceIndex(int device_index) WINDOWS_JoystickGetDeviceInstanceID(int device_index)
{ {
JoyStick_DeviceData *device = SYS_Joystick; JoyStick_DeviceData *device = SYS_Joystick;
int index; int index;
@@ -423,8 +438,8 @@ SDL_SYS_GetInstanceIdOfDeviceIndex(int device_index)
This should fill the nbuttons and naxes fields of the joystick structure. This should fill the nbuttons and naxes fields of the joystick structure.
It returns 0, or -1 if there is an error. It returns 0, or -1 if there is an error.
*/ */
int static int
SDL_SYS_JoystickOpen(SDL_Joystick * joystick, int device_index) WINDOWS_JoystickOpen(SDL_Joystick * joystick, int device_index)
{ {
JoyStick_DeviceData *joystickdevice = SYS_Joystick; JoyStick_DeviceData *joystickdevice = SYS_Joystick;
@@ -449,14 +464,24 @@ SDL_SYS_JoystickOpen(SDL_Joystick * joystick, int device_index)
} }
/* return true if this joystick is plugged in right now */ /* return true if this joystick is plugged in right now */
SDL_bool static SDL_bool
SDL_SYS_JoystickAttached(SDL_Joystick * joystick) WINDOWS_JoystickIsAttached(SDL_Joystick * joystick)
{ {
return joystick->hwdata && !joystick->hwdata->removed; return joystick->hwdata && !joystick->hwdata->removed;
} }
void static int
SDL_SYS_JoystickUpdate(SDL_Joystick * joystick) WINDOWS_JoystickRumble(SDL_Joystick * joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble, Uint32 duration_ms)
{
if (joystick->hwdata->bXInputDevice) {
return SDL_XINPUT_JoystickRumble(joystick, low_frequency_rumble, high_frequency_rumble, duration_ms);
} else {
return SDL_DINPUT_JoystickRumble(joystick, low_frequency_rumble, high_frequency_rumble, duration_ms);
}
}
static void
WINDOWS_JoystickUpdate(SDL_Joystick * joystick)
{ {
if (!joystick->hwdata || joystick->hwdata->removed) { if (!joystick->hwdata || joystick->hwdata->removed) {
return; return;
@@ -474,8 +499,8 @@ SDL_SYS_JoystickUpdate(SDL_Joystick * joystick)
} }
/* Function to close a joystick after use */ /* Function to close a joystick after use */
void static void
SDL_SYS_JoystickClose(SDL_Joystick * joystick) WINDOWS_JoystickClose(SDL_Joystick * joystick)
{ {
if (joystick->hwdata->bXInputDevice) { if (joystick->hwdata->bXInputDevice) {
SDL_XINPUT_JoystickClose(joystick); SDL_XINPUT_JoystickClose(joystick);
@@ -487,8 +512,8 @@ SDL_SYS_JoystickClose(SDL_Joystick * joystick)
} }
/* Function to perform any system-specific joystick related cleanup */ /* Function to perform any system-specific joystick related cleanup */
void static void
SDL_SYS_JoystickQuit(void) WINDOWS_JoystickQuit(void)
{ {
JoyStick_DeviceData *device = SYS_Joystick; JoyStick_DeviceData *device = SYS_Joystick;
@@ -524,24 +549,21 @@ SDL_SYS_JoystickQuit(void)
s_bDeviceRemoved = SDL_FALSE; s_bDeviceRemoved = SDL_FALSE;
} }
/* return the stable device guid for this device index */ SDL_JoystickDriver SDL_WINDOWS_JoystickDriver =
SDL_JoystickGUID
SDL_SYS_JoystickGetDeviceGUID(int device_index)
{ {
JoyStick_DeviceData *device = SYS_Joystick; WINDOWS_JoystickInit,
int index; WINDOWS_JoystickGetCount,
WINDOWS_JoystickDetect,
for (index = device_index; index > 0; index--) WINDOWS_JoystickGetDeviceName,
device = device->pNext; WINDOWS_JoystickGetDeviceGUID,
WINDOWS_JoystickGetDeviceInstanceID,
return device->guid; WINDOWS_JoystickOpen,
} WINDOWS_JoystickIsAttached,
WINDOWS_JoystickRumble,
SDL_JoystickGUID WINDOWS_JoystickUpdate,
SDL_SYS_JoystickGetGUID(SDL_Joystick * joystick) WINDOWS_JoystickClose,
{ WINDOWS_JoystickQuit,
return joystick->hwdata->guid; };
}
#endif /* SDL_JOYSTICK_DINPUT || SDL_JOYSTICK_XINPUT */ #endif /* SDL_JOYSTICK_DINPUT || SDL_JOYSTICK_XINPUT */
+5 -1
View File
@@ -68,6 +68,7 @@ struct joystick_hwdata
SDL_JoystickGUID guid; SDL_JoystickGUID guid;
SDL_bool removed; SDL_bool removed;
SDL_bool send_remove_event; SDL_bool send_remove_event;
Uint32 rumble_expiration;
#if SDL_JOYSTICK_DINPUT #if SDL_JOYSTICK_DINPUT
LPDIRECTINPUTDEVICE8 InputDevice; LPDIRECTINPUTDEVICE8 InputDevice;
@@ -76,6 +77,9 @@ struct joystick_hwdata
input_t Inputs[MAX_INPUTS]; input_t Inputs[MAX_INPUTS];
int NumInputs; int NumInputs;
int NumSliders; int NumSliders;
SDL_bool ff_initialized;
DIEFFECT *ffeffect;
LPDIRECTINPUTEFFECT ffeffect_ref;
#endif #endif
SDL_bool bXInputDevice; /* SDL_TRUE if this device supports using the xinput API rather than DirectInput */ SDL_bool bXInputDevice; /* SDL_TRUE if this device supports using the xinput API rather than DirectInput */
@@ -88,6 +92,6 @@ struct joystick_hwdata
extern const DIDATAFORMAT SDL_c_dfDIJoystick2; extern const DIDATAFORMAT SDL_c_dfDIJoystick2;
#endif #endif
extern void SDL_SYS_AddJoystickDevice(JoyStick_DeviceData *device); extern void WINDOWS_AddJoystickDevice(JoyStick_DeviceData *device);
/* vi: set ts=4 sw=4 expandtab: */ /* vi: set ts=4 sw=4 expandtab: */
+58 -13
View File
@@ -26,8 +26,10 @@
#include "SDL_assert.h" #include "SDL_assert.h"
#include "SDL_hints.h" #include "SDL_hints.h"
#include "SDL_timer.h"
#include "SDL_windowsjoystick_c.h" #include "SDL_windowsjoystick_c.h"
#include "SDL_xinputjoystick_c.h" #include "SDL_xinputjoystick_c.h"
#include "../hidapi/SDL_hidapijoystick_c.h"
/* /*
* Internal stuff. * Internal stuff.
@@ -186,6 +188,9 @@ GuessXInputDevice(Uint8 userid, Uint16 *pVID, Uint16 *pPID, Uint16 *pVersion)
static void static void
AddXInputDevice(Uint8 userid, BYTE SubType, JoyStick_DeviceData **pContext) AddXInputDevice(Uint8 userid, BYTE SubType, JoyStick_DeviceData **pContext)
{ {
Uint16 vendor = 0;
Uint16 product = 0;
Uint16 version = 0;
JoyStick_DeviceData *pPrevJoystick = NULL; JoyStick_DeviceData *pPrevJoystick = NULL;
JoyStick_DeviceData *pNewJoystick = *pContext; JoyStick_DeviceData *pNewJoystick = *pContext;
@@ -229,15 +234,11 @@ AddXInputDevice(Uint8 userid, BYTE SubType, JoyStick_DeviceData **pContext)
if (SDL_XInputUseOldJoystickMapping()) { if (SDL_XInputUseOldJoystickMapping()) {
SDL_zero(pNewJoystick->guid); SDL_zero(pNewJoystick->guid);
} else { } else {
const Uint16 BUS_USB = 0x03;
Uint16 vendor = 0;
Uint16 product = 0;
Uint16 version = 0;
Uint16 *guid16 = (Uint16 *)pNewJoystick->guid.data; Uint16 *guid16 = (Uint16 *)pNewJoystick->guid.data;
GuessXInputDevice(userid, &vendor, &product, &version); GuessXInputDevice(userid, &vendor, &product, &version);
*guid16++ = SDL_SwapLE16(BUS_USB); *guid16++ = SDL_SwapLE16(SDL_HARDWARE_BUS_USB);
*guid16++ = 0; *guid16++ = 0;
*guid16++ = SDL_SwapLE16(vendor); *guid16++ = SDL_SwapLE16(vendor);
*guid16++ = 0; *guid16++ = 0;
@@ -253,12 +254,20 @@ AddXInputDevice(Uint8 userid, BYTE SubType, JoyStick_DeviceData **pContext)
pNewJoystick->SubType = SubType; pNewJoystick->SubType = SubType;
pNewJoystick->XInputUserId = userid; pNewJoystick->XInputUserId = userid;
if (SDL_ShouldIgnoreGameController(pNewJoystick->joystickname, pNewJoystick->guid)) { if (SDL_ShouldIgnoreJoystick(pNewJoystick->joystickname, pNewJoystick->guid)) {
SDL_free(pNewJoystick); SDL_free(pNewJoystick);
return; return;
} }
SDL_SYS_AddJoystickDevice(pNewJoystick); #ifdef SDL_JOYSTICK_HIDAPI
if (HIDAPI_IsDevicePresent(vendor, product)) {
/* The HIDAPI driver is taking care of this device */
SDL_free(pNewJoystick);
return;
}
#endif
WINDOWS_AddJoystickDevice(pNewJoystick);
} }
void void
@@ -384,12 +393,12 @@ UpdateXInputJoystickState(SDL_Joystick * joystick, XINPUT_STATE_EX *pXInputState
Uint8 button; Uint8 button;
Uint8 hat = SDL_HAT_CENTERED; Uint8 hat = SDL_HAT_CENTERED;
SDL_PrivateJoystickAxis(joystick, 0, (Sint16)pXInputState->Gamepad.sThumbLX); SDL_PrivateJoystickAxis(joystick, 0, pXInputState->Gamepad.sThumbLX);
SDL_PrivateJoystickAxis(joystick, 1, (Sint16)(-SDL_max(-32767, pXInputState->Gamepad.sThumbLY))); SDL_PrivateJoystickAxis(joystick, 1, ~pXInputState->Gamepad.sThumbLY);
SDL_PrivateJoystickAxis(joystick, 2, (Sint16)(((int)pXInputState->Gamepad.bLeftTrigger * 65535 / 255) - 32768)); SDL_PrivateJoystickAxis(joystick, 2, ((int)pXInputState->Gamepad.bLeftTrigger * 257) - 32768);
SDL_PrivateJoystickAxis(joystick, 3, (Sint16)pXInputState->Gamepad.sThumbRX); SDL_PrivateJoystickAxis(joystick, 3, pXInputState->Gamepad.sThumbRX);
SDL_PrivateJoystickAxis(joystick, 4, (Sint16)(-SDL_max(-32767, pXInputState->Gamepad.sThumbRY))); SDL_PrivateJoystickAxis(joystick, 4, ~pXInputState->Gamepad.sThumbRY);
SDL_PrivateJoystickAxis(joystick, 5, (Sint16)(((int)pXInputState->Gamepad.bRightTrigger * 65535 / 255) - 32768)); SDL_PrivateJoystickAxis(joystick, 5, ((int)pXInputState->Gamepad.bRightTrigger * 257) - 32768);
for (button = 0; button < SDL_arraysize(s_XInputButtons); ++button) { for (button = 0; button < SDL_arraysize(s_XInputButtons); ++button) {
SDL_PrivateJoystickButton(joystick, button, (wButtons & s_XInputButtons[button]) ? SDL_PRESSED : SDL_RELEASED); SDL_PrivateJoystickButton(joystick, button, (wButtons & s_XInputButtons[button]) ? SDL_PRESSED : SDL_RELEASED);
@@ -412,6 +421,29 @@ UpdateXInputJoystickState(SDL_Joystick * joystick, XINPUT_STATE_EX *pXInputState
UpdateXInputJoystickBatteryInformation(joystick, pBatteryInformation); UpdateXInputJoystickBatteryInformation(joystick, pBatteryInformation);
} }
int
SDL_XINPUT_JoystickRumble(SDL_Joystick * joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble, Uint32 duration_ms)
{
XINPUT_VIBRATION XVibration;
if (!XINPUTSETSTATE) {
return SDL_Unsupported();
}
XVibration.wLeftMotorSpeed = low_frequency_rumble;
XVibration.wRightMotorSpeed = high_frequency_rumble;
if (XINPUTSETSTATE(joystick->hwdata->userid, &XVibration) != ERROR_SUCCESS) {
return SDL_SetError("XInputSetState() failed");
}
if ((low_frequency_rumble || high_frequency_rumble) && duration_ms) {
joystick->hwdata->rumble_expiration = SDL_GetTicks() + duration_ms;
} else {
joystick->hwdata->rumble_expiration = 0;
}
return 0;
}
void void
SDL_XINPUT_JoystickUpdate(SDL_Joystick * joystick) SDL_XINPUT_JoystickUpdate(SDL_Joystick * joystick)
{ {
@@ -449,6 +481,13 @@ SDL_XINPUT_JoystickUpdate(SDL_Joystick * joystick)
} }
joystick->hwdata->dwPacketNumber = XInputState.dwPacketNumber; joystick->hwdata->dwPacketNumber = XInputState.dwPacketNumber;
} }
if (joystick->hwdata->rumble_expiration) {
Uint32 now = SDL_GetTicks();
if (SDL_TICKS_PASSED(now, joystick->hwdata->rumble_expiration)) {
SDL_XINPUT_JoystickRumble(joystick, 0, 0, 0);
}
}
} }
void void
@@ -490,6 +529,12 @@ SDL_XINPUT_JoystickOpen(SDL_Joystick * joystick, JoyStick_DeviceData *joystickde
return SDL_Unsupported(); return SDL_Unsupported();
} }
int
SDL_XINPUT_JoystickRumble(SDL_Joystick * joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble, Uint32 duration_ms)
{
return SDL_Unsupported();
}
void void
SDL_XINPUT_JoystickUpdate(SDL_Joystick * joystick) SDL_XINPUT_JoystickUpdate(SDL_Joystick * joystick)
{ {
@@ -26,6 +26,7 @@ extern SDL_bool SDL_XINPUT_Enabled(void);
extern int SDL_XINPUT_JoystickInit(void); extern int SDL_XINPUT_JoystickInit(void);
extern void SDL_XINPUT_JoystickDetect(JoyStick_DeviceData **pContext); extern void SDL_XINPUT_JoystickDetect(JoyStick_DeviceData **pContext);
extern int SDL_XINPUT_JoystickOpen(SDL_Joystick * joystick, JoyStick_DeviceData *joystickdevice); extern int SDL_XINPUT_JoystickOpen(SDL_Joystick * joystick, JoyStick_DeviceData *joystickdevice);
extern int SDL_XINPUT_JoystickRumble(SDL_Joystick * joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble, Uint32 duration_ms);
extern void SDL_XINPUT_JoystickUpdate(SDL_Joystick * joystick); extern void SDL_XINPUT_JoystickUpdate(SDL_Joystick * joystick);
extern void SDL_XINPUT_JoystickClose(SDL_Joystick * joystick); extern void SDL_XINPUT_JoystickClose(SDL_Joystick * joystick);
extern void SDL_XINPUT_JoystickQuit(void); extern void SDL_XINPUT_JoystickQuit(void);

Some files were not shown because too many files have changed in this diff Show More