Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
This commit is contained in:
parent
2a4a81ad63
commit
34b88dfaae
30 changed files with 4191 additions and 580 deletions
|
@ -53,6 +53,7 @@ HDRS = \
|
||||||
SDL_endian.h \
|
SDL_endian.h \
|
||||||
SDL_error.h \
|
SDL_error.h \
|
||||||
SDL_events.h \
|
SDL_events.h \
|
||||||
|
SDL_gamecontroller.h \
|
||||||
SDL_gesture.h \
|
SDL_gesture.h \
|
||||||
SDL_haptic.h \
|
SDL_haptic.h \
|
||||||
SDL_hints.h \
|
SDL_hints.h \
|
||||||
|
|
|
@ -98,7 +98,7 @@
|
||||||
<Culture>0x0409</Culture>
|
<Culture>0x0409</Culture>
|
||||||
</ResourceCompile>
|
</ResourceCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<AdditionalDependencies>winmm.lib;imm32.lib;version.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>winmm.lib;imm32.lib;oleaut32.lib;version.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
<IgnoreAllDefaultLibraries>true</IgnoreAllDefaultLibraries>
|
<IgnoreAllDefaultLibraries>true</IgnoreAllDefaultLibraries>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
<SubSystem>Windows</SubSystem>
|
<SubSystem>Windows</SubSystem>
|
||||||
|
@ -129,7 +129,7 @@
|
||||||
<Culture>0x0409</Culture>
|
<Culture>0x0409</Culture>
|
||||||
</ResourceCompile>
|
</ResourceCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<AdditionalDependencies>winmm.lib;imm32.lib;version.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>winmm.lib;imm32.lib;oleaut32.lib;version.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
<IgnoreAllDefaultLibraries>true</IgnoreAllDefaultLibraries>
|
<IgnoreAllDefaultLibraries>true</IgnoreAllDefaultLibraries>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
<SubSystem>Windows</SubSystem>
|
<SubSystem>Windows</SubSystem>
|
||||||
|
@ -165,7 +165,7 @@
|
||||||
<Culture>0x0409</Culture>
|
<Culture>0x0409</Culture>
|
||||||
</ResourceCompile>
|
</ResourceCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<AdditionalDependencies>winmm.lib;imm32.lib;version.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>winmm.lib;imm32.lib;oleaut32.lib;version.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
<IgnoreAllDefaultLibraries>true</IgnoreAllDefaultLibraries>
|
<IgnoreAllDefaultLibraries>true</IgnoreAllDefaultLibraries>
|
||||||
<SubSystem>Windows</SubSystem>
|
<SubSystem>Windows</SubSystem>
|
||||||
<AdditionalLibraryDirectories>$(DXSDK_DIR)\lib\x86</AdditionalLibraryDirectories>
|
<AdditionalLibraryDirectories>$(DXSDK_DIR)\lib\x86</AdditionalLibraryDirectories>
|
||||||
|
@ -196,7 +196,7 @@
|
||||||
<Culture>0x0409</Culture>
|
<Culture>0x0409</Culture>
|
||||||
</ResourceCompile>
|
</ResourceCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<AdditionalDependencies>winmm.lib;imm32.lib;version.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>winmm.lib;imm32.lib;oleaut32.lib;version.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
<IgnoreAllDefaultLibraries>true</IgnoreAllDefaultLibraries>
|
<IgnoreAllDefaultLibraries>true</IgnoreAllDefaultLibraries>
|
||||||
<SubSystem>Windows</SubSystem>
|
<SubSystem>Windows</SubSystem>
|
||||||
<AdditionalLibraryDirectories>$(DXSDK_DIR)\lib\x64</AdditionalLibraryDirectories>
|
<AdditionalLibraryDirectories>$(DXSDK_DIR)\lib\x64</AdditionalLibraryDirectories>
|
||||||
|
@ -221,6 +221,7 @@
|
||||||
<ClInclude Include="..\..\include\SDL_hints.h" />
|
<ClInclude Include="..\..\include\SDL_hints.h" />
|
||||||
<ClInclude Include="..\..\include\SDL_input.h" />
|
<ClInclude Include="..\..\include\SDL_input.h" />
|
||||||
<ClInclude Include="..\..\include\SDL_joystick.h" />
|
<ClInclude Include="..\..\include\SDL_joystick.h" />
|
||||||
|
<ClInclude Include="..\..\include\SDL_gamecontroller.h" />
|
||||||
<ClInclude Include="..\..\include\SDL_keyboard.h" />
|
<ClInclude Include="..\..\include\SDL_keyboard.h" />
|
||||||
<ClInclude Include="..\..\include\SDL_keycode.h" />
|
<ClInclude Include="..\..\include\SDL_keycode.h" />
|
||||||
<ClInclude Include="..\..\include\SDL_loadso.h" />
|
<ClInclude Include="..\..\include\SDL_loadso.h" />
|
||||||
|
@ -399,6 +400,7 @@
|
||||||
<ClCompile Include="..\..\src\haptic\SDL_haptic.c" />
|
<ClCompile Include="..\..\src\haptic\SDL_haptic.c" />
|
||||||
<ClCompile Include="..\..\src\stdlib\SDL_iconv.c" />
|
<ClCompile Include="..\..\src\stdlib\SDL_iconv.c" />
|
||||||
<ClCompile Include="..\..\src\joystick\SDL_joystick.c" />
|
<ClCompile Include="..\..\src\joystick\SDL_joystick.c" />
|
||||||
|
<ClCompile Include="..\..\src\joystick\SDL_gamecontroller.c" />
|
||||||
<ClCompile Include="..\..\src\events\SDL_keyboard.c" />
|
<ClCompile Include="..\..\src\events\SDL_keyboard.c" />
|
||||||
<ClCompile Include="..\..\src\stdlib\SDL_malloc.c" />
|
<ClCompile Include="..\..\src\stdlib\SDL_malloc.c" />
|
||||||
<ClCompile Include="..\..\src\audio\SDL_mixer.c" />
|
<ClCompile Include="..\..\src\audio\SDL_mixer.c" />
|
||||||
|
|
|
@ -0,0 +1,227 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<ItemGroup Label="ProjectConfigurations">
|
||||||
|
<ProjectConfiguration Include="Debug|Win32">
|
||||||
|
<Configuration>Debug</Configuration>
|
||||||
|
<Platform>Win32</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Debug|x64">
|
||||||
|
<Configuration>Debug</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release|Win32">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>Win32</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release|x64">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
</ItemGroup>
|
||||||
|
<PropertyGroup Label="Globals">
|
||||||
|
<ProjectName>testgamecontroller</ProjectName>
|
||||||
|
<RootNamespace>testgamecontroller</RootNamespace>
|
||||||
|
<ProjectGuid>{55812185-D13C-4022-9C81-32E0F4A08336}</ProjectGuid>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<UseOfMfc>false</UseOfMfc>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<UseOfMfc>false</UseOfMfc>
|
||||||
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<UseOfMfc>false</UseOfMfc>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<UseOfMfc>false</UseOfMfc>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||||
|
<ImportGroup Label="ExtensionSettings">
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
<Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC70.props" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
<Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC70.props" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
<Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC70.props" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
<Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC70.props" />
|
||||||
|
</ImportGroup>
|
||||||
|
<PropertyGroup Label="UserMacros" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
|
||||||
|
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(Platform)\$(Configuration)\</OutDir>
|
||||||
|
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(Platform)\$(Configuration)\</OutDir>
|
||||||
|
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(Platform)\$(Configuration)\</IntDir>
|
||||||
|
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(Platform)\$(Configuration)\</IntDir>
|
||||||
|
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental>
|
||||||
|
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</LinkIncremental>
|
||||||
|
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(Platform)\$(Configuration)\</OutDir>
|
||||||
|
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(Platform)\$(Configuration)\</OutDir>
|
||||||
|
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(Platform)\$(Configuration)\</IntDir>
|
||||||
|
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(Platform)\$(Configuration)\</IntDir>
|
||||||
|
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental>
|
||||||
|
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</LinkIncremental>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<Midl>
|
||||||
|
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<MkTypLibCompatible>true</MkTypLibCompatible>
|
||||||
|
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||||
|
<TargetEnvironment>Win32</TargetEnvironment>
|
||||||
|
</Midl>
|
||||||
|
<ClCompile>
|
||||||
|
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
|
||||||
|
<AdditionalIncludeDirectories>..\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<StringPooling>true</StringPooling>
|
||||||
|
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||||
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
|
<PrecompiledHeader>
|
||||||
|
</PrecompiledHeader>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||||
|
<CompileAs>Default</CompileAs>
|
||||||
|
</ClCompile>
|
||||||
|
<ResourceCompile>
|
||||||
|
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<Culture>0x0409</Culture>
|
||||||
|
</ResourceCompile>
|
||||||
|
<Link>
|
||||||
|
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||||
|
<SubSystem>Windows</SubSystem>
|
||||||
|
</Link>
|
||||||
|
<PostBuildEvent>
|
||||||
|
<Command>copy "$(SolutionDir)\SDL\$(Platform)\$(Configuration)\SDL.dll" "$(TargetDir)\SDL.dll"</Command>
|
||||||
|
</PostBuildEvent>
|
||||||
|
<PostBuildEvent>
|
||||||
|
<Message>Copy SDL</Message>
|
||||||
|
</PostBuildEvent>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
|
<Midl>
|
||||||
|
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<MkTypLibCompatible>true</MkTypLibCompatible>
|
||||||
|
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||||
|
</Midl>
|
||||||
|
<ClCompile>
|
||||||
|
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
|
||||||
|
<AdditionalIncludeDirectories>..\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<StringPooling>true</StringPooling>
|
||||||
|
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||||
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
|
<PrecompiledHeader>
|
||||||
|
</PrecompiledHeader>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||||
|
<CompileAs>Default</CompileAs>
|
||||||
|
</ClCompile>
|
||||||
|
<ResourceCompile>
|
||||||
|
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<Culture>0x0409</Culture>
|
||||||
|
</ResourceCompile>
|
||||||
|
<Link>
|
||||||
|
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||||
|
<SubSystem>Windows</SubSystem>
|
||||||
|
</Link>
|
||||||
|
<PostBuildEvent>
|
||||||
|
<Command>copy "$(SolutionDir)\SDL\$(Platform)\$(Configuration)\SDL.dll" "$(TargetDir)\SDL.dll"</Command>
|
||||||
|
</PostBuildEvent>
|
||||||
|
<PostBuildEvent>
|
||||||
|
<Message>Copy SDL</Message>
|
||||||
|
</PostBuildEvent>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<Midl>
|
||||||
|
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<MkTypLibCompatible>true</MkTypLibCompatible>
|
||||||
|
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||||
|
<TargetEnvironment>Win32</TargetEnvironment>
|
||||||
|
</Midl>
|
||||||
|
<ClCompile>
|
||||||
|
<Optimization>Disabled</Optimization>
|
||||||
|
<AdditionalIncludeDirectories>..\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
||||||
|
<PrecompiledHeader>
|
||||||
|
</PrecompiledHeader>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||||
|
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
|
||||||
|
<CompileAs>Default</CompileAs>
|
||||||
|
</ClCompile>
|
||||||
|
<ResourceCompile>
|
||||||
|
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<Culture>0x0409</Culture>
|
||||||
|
</ResourceCompile>
|
||||||
|
<Link>
|
||||||
|
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<SubSystem>Windows</SubSystem>
|
||||||
|
</Link>
|
||||||
|
<PostBuildEvent>
|
||||||
|
<Command>copy "$(SolutionDir)\SDL\$(Platform)\$(Configuration)\SDL.dll" "$(TargetDir)\SDL.dll"</Command>
|
||||||
|
</PostBuildEvent>
|
||||||
|
<PostBuildEvent>
|
||||||
|
<Message>Copy SDL</Message>
|
||||||
|
</PostBuildEvent>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
|
<Midl>
|
||||||
|
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<MkTypLibCompatible>true</MkTypLibCompatible>
|
||||||
|
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||||
|
</Midl>
|
||||||
|
<ClCompile>
|
||||||
|
<Optimization>Disabled</Optimization>
|
||||||
|
<AdditionalIncludeDirectories>..\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
||||||
|
<PrecompiledHeader>
|
||||||
|
</PrecompiledHeader>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||||
|
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||||
|
<CompileAs>Default</CompileAs>
|
||||||
|
</ClCompile>
|
||||||
|
<ResourceCompile>
|
||||||
|
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<Culture>0x0409</Culture>
|
||||||
|
</ResourceCompile>
|
||||||
|
<Link>
|
||||||
|
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<SubSystem>Windows</SubSystem>
|
||||||
|
</Link>
|
||||||
|
<PostBuildEvent>
|
||||||
|
<Command>copy "$(SolutionDir)\SDL\$(Platform)\$(Configuration)\SDL.dll" "$(TargetDir)\SDL.dll"</Command>
|
||||||
|
</PostBuildEvent>
|
||||||
|
<PostBuildEvent>
|
||||||
|
<Message>Copy SDL</Message>
|
||||||
|
</PostBuildEvent>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Library Include="..\..\Sdl\$(Platform)\$(Configuration)\SDL.lib" />
|
||||||
|
<Library Include="..\..\SDLmain\$(Platform)\$(Configuration)\SDLmain.lib" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="..\..\..\test\testgamecontroller.c" />
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
|
<ImportGroup Label="ExtensionTargets">
|
||||||
|
</ImportGroup>
|
||||||
|
</Project>
|
|
@ -546,6 +546,8 @@
|
||||||
AABCC38E164063D200AB8930 /* SDL_cocoamessagebox.h in Headers */ = {isa = PBXBuildFile; fileRef = AABCC38B164063D200AB8930 /* SDL_cocoamessagebox.h */; };
|
AABCC38E164063D200AB8930 /* SDL_cocoamessagebox.h in Headers */ = {isa = PBXBuildFile; fileRef = AABCC38B164063D200AB8930 /* SDL_cocoamessagebox.h */; };
|
||||||
AABCC38F164063D200AB8930 /* SDL_cocoamessagebox.m in Sources */ = {isa = PBXBuildFile; fileRef = AABCC38C164063D200AB8930 /* SDL_cocoamessagebox.m */; };
|
AABCC38F164063D200AB8930 /* SDL_cocoamessagebox.m in Sources */ = {isa = PBXBuildFile; fileRef = AABCC38C164063D200AB8930 /* SDL_cocoamessagebox.m */; };
|
||||||
AABCC390164063D200AB8930 /* SDL_cocoamessagebox.m in Sources */ = {isa = PBXBuildFile; fileRef = AABCC38C164063D200AB8930 /* SDL_cocoamessagebox.m */; };
|
AABCC390164063D200AB8930 /* SDL_cocoamessagebox.m in Sources */ = {isa = PBXBuildFile; fileRef = AABCC38C164063D200AB8930 /* SDL_cocoamessagebox.m */; };
|
||||||
|
BBFC088B164C6514003E6A99 /* SDL_gamecontroller.c in Sources */ = {isa = PBXBuildFile; fileRef = BBFC088A164C6514003E6A99 /* SDL_gamecontroller.c */; };
|
||||||
|
BBFC088D164C6647003E6A99 /* SDL_gamecontroller.c in Sources */ = {isa = PBXBuildFile; fileRef = BBFC088A164C6514003E6A99 /* SDL_gamecontroller.c */; };
|
||||||
/* End PBXBuildFile section */
|
/* End PBXBuildFile section */
|
||||||
|
|
||||||
/* Begin PBXContainerItemProxy section */
|
/* Begin PBXContainerItemProxy section */
|
||||||
|
@ -891,6 +893,7 @@
|
||||||
AA9FF9591637CBF9000DF050 /* SDL_messagebox.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_messagebox.h; sourceTree = "<group>"; };
|
AA9FF9591637CBF9000DF050 /* SDL_messagebox.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_messagebox.h; sourceTree = "<group>"; };
|
||||||
AABCC38B164063D200AB8930 /* SDL_cocoamessagebox.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_cocoamessagebox.h; sourceTree = "<group>"; };
|
AABCC38B164063D200AB8930 /* SDL_cocoamessagebox.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_cocoamessagebox.h; sourceTree = "<group>"; };
|
||||||
AABCC38C164063D200AB8930 /* SDL_cocoamessagebox.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDL_cocoamessagebox.m; sourceTree = "<group>"; };
|
AABCC38C164063D200AB8930 /* SDL_cocoamessagebox.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDL_cocoamessagebox.m; sourceTree = "<group>"; };
|
||||||
|
BBFC088A164C6514003E6A99 /* SDL_gamecontroller.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_gamecontroller.c; sourceTree = "<group>"; };
|
||||||
BECDF66B0761BA81005FE872 /* Info-Framework.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "Info-Framework.plist"; sourceTree = "<group>"; };
|
BECDF66B0761BA81005FE872 /* Info-Framework.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "Info-Framework.plist"; sourceTree = "<group>"; };
|
||||||
BECDF66C0761BA81005FE872 /* SDL2.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SDL2.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
BECDF66C0761BA81005FE872 /* SDL2.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SDL2.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
BECDF6B30761BA81005FE872 /* libSDL2.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libSDL2.a; sourceTree = BUILT_PRODUCTS_DIR; };
|
BECDF6B30761BA81005FE872 /* libSDL2.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libSDL2.a; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
|
@ -1325,6 +1328,7 @@
|
||||||
04BDFE0612E6671700899322 /* darwin */,
|
04BDFE0612E6671700899322 /* darwin */,
|
||||||
04BDFE1612E6671700899322 /* SDL_joystick.c */,
|
04BDFE1612E6671700899322 /* SDL_joystick.c */,
|
||||||
04BDFE1712E6671700899322 /* SDL_joystick_c.h */,
|
04BDFE1712E6671700899322 /* SDL_joystick_c.h */,
|
||||||
|
BBFC088A164C6514003E6A99 /* SDL_gamecontroller.c */,
|
||||||
04BDFE1812E6671700899322 /* SDL_sysjoystick.h */,
|
04BDFE1812E6671700899322 /* SDL_sysjoystick.h */,
|
||||||
);
|
);
|
||||||
name = joystick;
|
name = joystick;
|
||||||
|
@ -2306,6 +2310,7 @@
|
||||||
04BD027612E6671800899322 /* SDL_syshaptic.c in Sources */,
|
04BD027612E6671800899322 /* SDL_syshaptic.c in Sources */,
|
||||||
04BD027A12E6671800899322 /* SDL_haptic.c in Sources */,
|
04BD027A12E6671800899322 /* SDL_haptic.c in Sources */,
|
||||||
04BD028112E6671800899322 /* SDL_sysjoystick.c in Sources */,
|
04BD028112E6671800899322 /* SDL_sysjoystick.c in Sources */,
|
||||||
|
BBFC088D164C6647003E6A99 /* SDL_gamecontroller.c in Sources */,
|
||||||
04BD028B12E6671800899322 /* SDL_joystick.c in Sources */,
|
04BD028B12E6671800899322 /* SDL_joystick.c in Sources */,
|
||||||
04BD02A312E6671800899322 /* SDL_sysloadso.c in Sources */,
|
04BD02A312E6671800899322 /* SDL_sysloadso.c in Sources */,
|
||||||
04BD02AE12E6671800899322 /* SDL_syspower.c in Sources */,
|
04BD02AE12E6671800899322 /* SDL_syspower.c in Sources */,
|
||||||
|
|
|
@ -559,6 +559,18 @@
|
||||||
00794F8709D2413B003FC8A1 /* sample.bmp in CopyFiles */ = {isa = PBXBuildFile; fileRef = 00794E6109D20839003FC8A1 /* sample.bmp */; };
|
00794F8709D2413B003FC8A1 /* sample.bmp in CopyFiles */ = {isa = PBXBuildFile; fileRef = 00794E6109D20839003FC8A1 /* sample.bmp */; };
|
||||||
4537749F12091551002F0F45 /* libsdlcommon.a in Frameworks */ = {isa = PBXBuildFile; fileRef = BEC567FF0761D90600A33029 /* libsdlcommon.a */; };
|
4537749F12091551002F0F45 /* libsdlcommon.a in Frameworks */ = {isa = PBXBuildFile; fileRef = BEC567FF0761D90600A33029 /* libsdlcommon.a */; };
|
||||||
453774A5120915E3002F0F45 /* testshape.c in Sources */ = {isa = PBXBuildFile; fileRef = 453774A4120915E3002F0F45 /* testshape.c */; };
|
453774A5120915E3002F0F45 /* testshape.c in Sources */ = {isa = PBXBuildFile; fileRef = 453774A4120915E3002F0F45 /* testshape.c */; };
|
||||||
|
BBFC08BF164C6862003E6A99 /* libsdlcommon.a in Frameworks */ = {isa = PBXBuildFile; fileRef = BEC567FF0761D90600A33029 /* libsdlcommon.a */; };
|
||||||
|
BBFC08C0164C6862003E6A99 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 002F33A709CA188600EBEB88 /* Cocoa.framework */; };
|
||||||
|
BBFC08C1164C6862003E6A99 /* CoreAudio.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 002A863B10730545007319AE /* CoreAudio.framework */; };
|
||||||
|
BBFC08C2164C6862003E6A99 /* ForceFeedback.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 002A863C10730545007319AE /* ForceFeedback.framework */; };
|
||||||
|
BBFC08C3164C6862003E6A99 /* IOKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 002A863D10730545007319AE /* IOKit.framework */; };
|
||||||
|
BBFC08C4164C6862003E6A99 /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 002A869F10730593007319AE /* AudioToolbox.framework */; };
|
||||||
|
BBFC08C5164C6862003E6A99 /* CoreFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 002A86A010730593007319AE /* CoreFoundation.framework */; };
|
||||||
|
BBFC08C6164C6862003E6A99 /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 002A86F2107305CE007319AE /* OpenGL.framework */; };
|
||||||
|
BBFC08C7164C6862003E6A99 /* AudioUnit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 002A871410730623007319AE /* AudioUnit.framework */; };
|
||||||
|
BBFC08C8164C6862003E6A99 /* Carbon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 002A873910730675007319AE /* Carbon.framework */; };
|
||||||
|
BBFC08C9164C6862003E6A99 /* libSDL2.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 003FA645093FFD41000C53B3 /* libSDL2.a */; };
|
||||||
|
BBFC08D0164C6876003E6A99 /* testgamecontroller.c in Sources */ = {isa = PBXBuildFile; fileRef = BBFC088E164C6820003E6A99 /* testgamecontroller.c */; };
|
||||||
BEC566B10761D90300A33029 /* checkkeys.c in Sources */ = {isa = PBXBuildFile; fileRef = 092D6D10FFB30A2C7F000001 /* checkkeys.c */; };
|
BEC566B10761D90300A33029 /* checkkeys.c in Sources */ = {isa = PBXBuildFile; fileRef = 092D6D10FFB30A2C7F000001 /* checkkeys.c */; };
|
||||||
BEC566BE0761D90300A33029 /* graywin.c in Sources */ = {isa = PBXBuildFile; fileRef = 092D6D1BFFB30C237F000001 /* graywin.c */; };
|
BEC566BE0761D90300A33029 /* graywin.c in Sources */ = {isa = PBXBuildFile; fileRef = 092D6D1BFFB30C237F000001 /* graywin.c */; };
|
||||||
BEC566CB0761D90300A33029 /* loopwave.c in Sources */ = {isa = PBXBuildFile; fileRef = 083E4872006D84C97F000001 /* loopwave.c */; };
|
BEC566CB0761D90300A33029 /* loopwave.c in Sources */ = {isa = PBXBuildFile; fileRef = 083E4872006D84C97F000001 /* loopwave.c */; };
|
||||||
|
@ -1098,6 +1110,13 @@
|
||||||
remoteGlobalIDString = BEC567F70761D90600A33029;
|
remoteGlobalIDString = BEC567F70761D90600A33029;
|
||||||
remoteInfo = sdlcommon;
|
remoteInfo = sdlcommon;
|
||||||
};
|
};
|
||||||
|
BBFC08B9164C6862003E6A99 /* PBXContainerItemProxy */ = {
|
||||||
|
isa = PBXContainerItemProxy;
|
||||||
|
containerPortal = 08FB7793FE84155DC02AAC07 /* Project object */;
|
||||||
|
proxyType = 1;
|
||||||
|
remoteGlobalIDString = BEC567F70761D90600A33029;
|
||||||
|
remoteInfo = "libsdlmain.a (Upgraded)";
|
||||||
|
};
|
||||||
BEC568300761D90600A33029 /* PBXContainerItemProxy */ = {
|
BEC568300761D90600A33029 /* PBXContainerItemProxy */ = {
|
||||||
isa = PBXContainerItemProxy;
|
isa = PBXContainerItemProxy;
|
||||||
containerPortal = 08FB7793FE84155DC02AAC07 /* Project object */;
|
containerPortal = 08FB7793FE84155DC02AAC07 /* Project object */;
|
||||||
|
@ -1452,6 +1471,21 @@
|
||||||
4537749212091504002F0F45 /* testshape.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = testshape.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
4537749212091504002F0F45 /* testshape.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = testshape.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
453774A4120915E3002F0F45 /* testshape.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = testshape.c; path = ../../test/testshape.c; sourceTree = SOURCE_ROOT; };
|
453774A4120915E3002F0F45 /* testshape.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = testshape.c; path = ../../test/testshape.c; sourceTree = SOURCE_ROOT; };
|
||||||
B207FF2404E1B19600A80002 /* sdlcommon_prefix.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = sdlcommon_prefix.h; sourceTree = "<group>"; };
|
B207FF2404E1B19600A80002 /* sdlcommon_prefix.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = sdlcommon_prefix.h; sourceTree = "<group>"; };
|
||||||
|
BBFC088E164C6820003E6A99 /* testgamecontroller.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = testgamecontroller.c; path = ../../test/testgamecontroller.c; sourceTree = "<group>"; };
|
||||||
|
BBFC089C164C684D003E6A99 /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = System/Library/Frameworks/Cocoa.framework; sourceTree = SDKROOT; };
|
||||||
|
BBFC089F164C684D003E6A99 /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = System/Library/Frameworks/AppKit.framework; sourceTree = SDKROOT; };
|
||||||
|
BBFC08A0164C684D003E6A99 /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = System/Library/Frameworks/CoreData.framework; sourceTree = SDKROOT; };
|
||||||
|
BBFC08A1164C684D003E6A99 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
|
||||||
|
BBFC08A4164C684D003E6A99 /* testgamecontroller-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "testgamecontroller-Info.plist"; sourceTree = "<group>"; };
|
||||||
|
BBFC08A6164C684D003E6A99 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; };
|
||||||
|
BBFC08A8164C684D003E6A99 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
|
||||||
|
BBFC08AA164C684D003E6A99 /* testgamecontroller-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "testgamecontroller-Prefix.pch"; sourceTree = "<group>"; };
|
||||||
|
BBFC08AC164C684D003E6A99 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.rtf; name = en; path = en.lproj/Credits.rtf; sourceTree = "<group>"; };
|
||||||
|
BBFC08AE164C684D003E6A99 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
|
||||||
|
BBFC08AF164C684D003E6A99 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
|
||||||
|
BBFC08B2164C684D003E6A99 /* en */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = en; path = en.lproj/MainMenu.xib; sourceTree = "<group>"; };
|
||||||
|
BBFC08CD164C6862003E6A99 /* testgamecontroller.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = testgamecontroller.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
|
BBFC08CF164C6863003E6A99 /* testjoystick copy-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; name = "testjoystick copy-Info.plist"; path = "/Users/alfred/valve/steam3_rel_Client/src/external/SDL2/build/Xcode/SDLTest/testjoystick copy-Info.plist"; sourceTree = "<absolute>"; };
|
||||||
BEC566B60761D90300A33029 /* checkkeys.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = checkkeys.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
BEC566B60761D90300A33029 /* checkkeys.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = checkkeys.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
BEC566C30761D90300A33029 /* graywin.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = graywin.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
BEC566C30761D90300A33029 /* graywin.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = graywin.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
BEC566D10761D90300A33029 /* loopwave.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = loopwave.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
BEC566D10761D90300A33029 /* loopwave.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = loopwave.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
|
@ -1848,6 +1882,24 @@
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
};
|
};
|
||||||
|
BBFC08BE164C6862003E6A99 /* Frameworks */ = {
|
||||||
|
isa = PBXFrameworksBuildPhase;
|
||||||
|
buildActionMask = 2147483647;
|
||||||
|
files = (
|
||||||
|
BBFC08BF164C6862003E6A99 /* libsdlcommon.a in Frameworks */,
|
||||||
|
BBFC08C0164C6862003E6A99 /* Cocoa.framework in Frameworks */,
|
||||||
|
BBFC08C1164C6862003E6A99 /* CoreAudio.framework in Frameworks */,
|
||||||
|
BBFC08C2164C6862003E6A99 /* ForceFeedback.framework in Frameworks */,
|
||||||
|
BBFC08C3164C6862003E6A99 /* IOKit.framework in Frameworks */,
|
||||||
|
BBFC08C4164C6862003E6A99 /* AudioToolbox.framework in Frameworks */,
|
||||||
|
BBFC08C5164C6862003E6A99 /* CoreFoundation.framework in Frameworks */,
|
||||||
|
BBFC08C6164C6862003E6A99 /* OpenGL.framework in Frameworks */,
|
||||||
|
BBFC08C7164C6862003E6A99 /* AudioUnit.framework in Frameworks */,
|
||||||
|
BBFC08C8164C6862003E6A99 /* Carbon.framework in Frameworks */,
|
||||||
|
BBFC08C9164C6862003E6A99 /* libSDL2.a in Frameworks */,
|
||||||
|
);
|
||||||
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
};
|
||||||
BEC566B20761D90300A33029 /* Frameworks */ = {
|
BEC566B20761D90300A33029 /* Frameworks */ = {
|
||||||
isa = PBXFrameworksBuildPhase;
|
isa = PBXFrameworksBuildPhase;
|
||||||
buildActionMask = 2147483647;
|
buildActionMask = 2147483647;
|
||||||
|
@ -2330,7 +2382,10 @@
|
||||||
B207FF2404E1B19600A80002 /* sdlcommon_prefix.h */,
|
B207FF2404E1B19600A80002 /* sdlcommon_prefix.h */,
|
||||||
002F33A209CA183B00EBEB88 /* Linked Frameworks */,
|
002F33A209CA183B00EBEB88 /* Linked Frameworks */,
|
||||||
00794E4609D207B4003FC8A1 /* Resources */,
|
00794E4609D207B4003FC8A1 /* Resources */,
|
||||||
|
BBFC08A2164C684D003E6A99 /* testgamecontroller */,
|
||||||
|
BBFC089B164C684D003E6A99 /* Frameworks */,
|
||||||
1AB674ADFE9D54B511CA2CBB /* Products */,
|
1AB674ADFE9D54B511CA2CBB /* Products */,
|
||||||
|
BBFC08CF164C6863003E6A99 /* testjoystick copy-Info.plist */,
|
||||||
);
|
);
|
||||||
comments = "I made these tests link against our \"default\" framework which includes X11 stuff. If you didn't install the X11 headers with Xcode, you might have problems building the SDL.framework (which is a dependency). You can swap the dependencies around to get around this, or you can modify the default SDL.framework target to not include X11 stuff. (Go into its target build options and remove all the Preprocessor macros.)\n\n\n\nWe are sort of in a half-way state at the moment. Going \"all-the-way\" means we copy the SDL.framework inside the app bundle so we can run the test without the step of the user \"installing\" the framework. But there is an oversight/bug in Xcode that doesn't correctly find the location of the framework when in an embedded/nested Xcode project. We could probably try to hack this with a shell script that checks multiple directories for existence, but this is messier and more work than I prefer, so I rather just wait for Apple to fix this. In the meantime...\n\nThe \"All\" target will build the SDL framework from the Xcode project. The other targets do not have this dependency set (for flexibility reasons in case we make changes). If you have not built the framework, you will probably be unable to link. You will either need to build the framework, or you need to add \"-framework SDL\" to the link options and make sure you have the SDL.framework installed somewhere where it can be seen (like /Library/Frameworks...I think we already set this one up.) \n\nTo run though, you should have a copy of the SDL.framework in /Library/Frameworks or ~/Library/Frameworks.\n\n\n\n\ntestgl and testdyngl need -DHAVE_OPENGL\ntestgl needs to link against OpenGL.framework\n\n";
|
comments = "I made these tests link against our \"default\" framework which includes X11 stuff. If you didn't install the X11 headers with Xcode, you might have problems building the SDL.framework (which is a dependency). You can swap the dependencies around to get around this, or you can modify the default SDL.framework target to not include X11 stuff. (Go into its target build options and remove all the Preprocessor macros.)\n\n\n\nWe are sort of in a half-way state at the moment. Going \"all-the-way\" means we copy the SDL.framework inside the app bundle so we can run the test without the step of the user \"installing\" the framework. But there is an oversight/bug in Xcode that doesn't correctly find the location of the framework when in an embedded/nested Xcode project. We could probably try to hack this with a shell script that checks multiple directories for existence, but this is messier and more work than I prefer, so I rather just wait for Apple to fix this. In the meantime...\n\nThe \"All\" target will build the SDL framework from the Xcode project. The other targets do not have this dependency set (for flexibility reasons in case we make changes). If you have not built the framework, you will probably be unable to link. You will either need to build the framework, or you need to add \"-framework SDL\" to the link options and make sure you have the SDL.framework installed somewhere where it can be seen (like /Library/Frameworks...I think we already set this one up.) \n\nTo run though, you should have a copy of the SDL.framework in /Library/Frameworks or ~/Library/Frameworks.\n\n\n\n\ntestgl and testdyngl need -DHAVE_OPENGL\ntestgl needs to link against OpenGL.framework\n\n";
|
||||||
name = SDLTest;
|
name = SDLTest;
|
||||||
|
@ -2363,6 +2418,7 @@
|
||||||
00179791107432FA00F5D044 /* testime.c */,
|
00179791107432FA00F5D044 /* testime.c */,
|
||||||
001797B31074339C00F5D044 /* testintersections.c */,
|
001797B31074339C00F5D044 /* testintersections.c */,
|
||||||
092D6D62FFB312AA7F000001 /* testjoystick.c */,
|
092D6D62FFB312AA7F000001 /* testjoystick.c */,
|
||||||
|
BBFC088E164C6820003E6A99 /* testgamecontroller.c */,
|
||||||
092D6D6CFFB313437F000001 /* testkeys.c */,
|
092D6D6CFFB313437F000001 /* testkeys.c */,
|
||||||
001797D31074343E00F5D044 /* testloadso.c */,
|
001797D31074343E00F5D044 /* testloadso.c */,
|
||||||
092D6D75FFB313BB7F000001 /* testlock.c */,
|
092D6D75FFB313BB7F000001 /* testlock.c */,
|
||||||
|
@ -2440,10 +2496,53 @@
|
||||||
0017991610743F1000F5D044 /* testsprite2.app */,
|
0017991610743F1000F5D044 /* testsprite2.app */,
|
||||||
0017993810743FB700F5D044 /* testwm2.app */,
|
0017993810743FB700F5D044 /* testwm2.app */,
|
||||||
4537749212091504002F0F45 /* testshape.app */,
|
4537749212091504002F0F45 /* testshape.app */,
|
||||||
|
BBFC08CD164C6862003E6A99 /* testgamecontroller.app */,
|
||||||
);
|
);
|
||||||
name = Products;
|
name = Products;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
};
|
};
|
||||||
|
BBFC089B164C684D003E6A99 /* Frameworks */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
BBFC089C164C684D003E6A99 /* Cocoa.framework */,
|
||||||
|
BBFC089E164C684D003E6A99 /* Other Frameworks */,
|
||||||
|
);
|
||||||
|
name = Frameworks;
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
|
BBFC089E164C684D003E6A99 /* Other Frameworks */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
BBFC089F164C684D003E6A99 /* AppKit.framework */,
|
||||||
|
BBFC08A0164C684D003E6A99 /* CoreData.framework */,
|
||||||
|
BBFC08A1164C684D003E6A99 /* Foundation.framework */,
|
||||||
|
);
|
||||||
|
name = "Other Frameworks";
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
|
BBFC08A2164C684D003E6A99 /* testgamecontroller */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
BBFC08AE164C684D003E6A99 /* AppDelegate.h */,
|
||||||
|
BBFC08AF164C684D003E6A99 /* AppDelegate.m */,
|
||||||
|
BBFC08B1164C684D003E6A99 /* MainMenu.xib */,
|
||||||
|
BBFC08A3164C684D003E6A99 /* Supporting Files */,
|
||||||
|
);
|
||||||
|
path = testgamecontroller;
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
|
BBFC08A3164C684D003E6A99 /* Supporting Files */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
BBFC08A4164C684D003E6A99 /* testgamecontroller-Info.plist */,
|
||||||
|
BBFC08A5164C684D003E6A99 /* InfoPlist.strings */,
|
||||||
|
BBFC08A8164C684D003E6A99 /* main.m */,
|
||||||
|
BBFC08AA164C684D003E6A99 /* testgamecontroller-Prefix.pch */,
|
||||||
|
BBFC08AB164C684D003E6A99 /* Credits.rtf */,
|
||||||
|
);
|
||||||
|
name = "Supporting Files";
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
/* End PBXGroup section */
|
/* End PBXGroup section */
|
||||||
|
|
||||||
/* Begin PBXHeadersBuildPhase section */
|
/* Begin PBXHeadersBuildPhase section */
|
||||||
|
@ -2588,6 +2687,13 @@
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
};
|
};
|
||||||
|
BBFC08BA164C6862003E6A99 /* Headers */ = {
|
||||||
|
isa = PBXHeadersBuildPhase;
|
||||||
|
buildActionMask = 2147483647;
|
||||||
|
files = (
|
||||||
|
);
|
||||||
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
};
|
||||||
BEC566AD0761D90300A33029 /* Headers */ = {
|
BEC566AD0761D90300A33029 /* Headers */ = {
|
||||||
isa = PBXHeadersBuildPhase;
|
isa = PBXHeadersBuildPhase;
|
||||||
buildActionMask = 2147483647;
|
buildActionMask = 2147483647;
|
||||||
|
@ -3182,6 +3288,26 @@
|
||||||
productReference = 4537749212091504002F0F45 /* testshape.app */;
|
productReference = 4537749212091504002F0F45 /* testshape.app */;
|
||||||
productType = "com.apple.product-type.application";
|
productType = "com.apple.product-type.application";
|
||||||
};
|
};
|
||||||
|
BBFC08B7164C6862003E6A99 /* testgamecontroller */ = {
|
||||||
|
isa = PBXNativeTarget;
|
||||||
|
buildConfigurationList = BBFC08CA164C6862003E6A99 /* Build configuration list for PBXNativeTarget "testgamecontroller" */;
|
||||||
|
buildPhases = (
|
||||||
|
BBFC08BA164C6862003E6A99 /* Headers */,
|
||||||
|
BBFC08BB164C6862003E6A99 /* Resources */,
|
||||||
|
BBFC08BC164C6862003E6A99 /* Sources */,
|
||||||
|
BBFC08BE164C6862003E6A99 /* Frameworks */,
|
||||||
|
);
|
||||||
|
buildRules = (
|
||||||
|
);
|
||||||
|
dependencies = (
|
||||||
|
BBFC08B8164C6862003E6A99 /* PBXTargetDependency */,
|
||||||
|
);
|
||||||
|
name = testgamecontroller;
|
||||||
|
productInstallPath = "$(USER_APPS_DIR)";
|
||||||
|
productName = testjoystick;
|
||||||
|
productReference = BBFC08CD164C6862003E6A99 /* testgamecontroller.app */;
|
||||||
|
productType = "com.apple.product-type.application";
|
||||||
|
};
|
||||||
BEC566AB0761D90300A33029 /* checkkeys */ = {
|
BEC566AB0761D90300A33029 /* checkkeys */ = {
|
||||||
isa = PBXNativeTarget;
|
isa = PBXNativeTarget;
|
||||||
buildConfigurationList = 001B593808BDB826006539E9 /* Build configuration list for PBXNativeTarget "checkkeys" */;
|
buildConfigurationList = 001B593808BDB826006539E9 /* Build configuration list for PBXNativeTarget "checkkeys" */;
|
||||||
|
@ -3686,6 +3812,7 @@
|
||||||
Japanese,
|
Japanese,
|
||||||
French,
|
French,
|
||||||
German,
|
German,
|
||||||
|
en,
|
||||||
);
|
);
|
||||||
mainGroup = 08FB7794FE84155DC02AAC07 /* SDLTest */;
|
mainGroup = 08FB7794FE84155DC02AAC07 /* SDLTest */;
|
||||||
projectDirPath = "";
|
projectDirPath = "";
|
||||||
|
@ -3743,6 +3870,7 @@
|
||||||
BEC567EA0761D90600A33029 /* torturethread */,
|
BEC567EA0761D90600A33029 /* torturethread */,
|
||||||
BEC567F70761D90600A33029 /* sdlcommon */,
|
BEC567F70761D90600A33029 /* sdlcommon */,
|
||||||
4537749112091504002F0F45 /* testshape */,
|
4537749112091504002F0F45 /* testshape */,
|
||||||
|
BBFC08B7164C6862003E6A99 /* testgamecontroller */,
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
/* End PBXProject section */
|
/* End PBXProject section */
|
||||||
|
@ -3933,6 +4061,13 @@
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
};
|
};
|
||||||
|
BBFC08BB164C6862003E6A99 /* Resources */ = {
|
||||||
|
isa = PBXResourcesBuildPhase;
|
||||||
|
buildActionMask = 2147483647;
|
||||||
|
files = (
|
||||||
|
);
|
||||||
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
};
|
||||||
BEC566AE0761D90300A33029 /* Resources */ = {
|
BEC566AE0761D90300A33029 /* Resources */ = {
|
||||||
isa = PBXResourcesBuildPhase;
|
isa = PBXResourcesBuildPhase;
|
||||||
buildActionMask = 2147483647;
|
buildActionMask = 2147483647;
|
||||||
|
@ -4277,6 +4412,14 @@
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
};
|
};
|
||||||
|
BBFC08BC164C6862003E6A99 /* Sources */ = {
|
||||||
|
isa = PBXSourcesBuildPhase;
|
||||||
|
buildActionMask = 2147483647;
|
||||||
|
files = (
|
||||||
|
BBFC08D0164C6876003E6A99 /* testgamecontroller.c in Sources */,
|
||||||
|
);
|
||||||
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
};
|
||||||
BEC566B00761D90300A33029 /* Sources */ = {
|
BEC566B00761D90300A33029 /* Sources */ = {
|
||||||
isa = PBXSourcesBuildPhase;
|
isa = PBXSourcesBuildPhase;
|
||||||
buildActionMask = 2147483647;
|
buildActionMask = 2147483647;
|
||||||
|
@ -4797,6 +4940,11 @@
|
||||||
target = BEC567F70761D90600A33029 /* sdlcommon */;
|
target = BEC567F70761D90600A33029 /* sdlcommon */;
|
||||||
targetProxy = 4537749D1209152D002F0F45 /* PBXContainerItemProxy */;
|
targetProxy = 4537749D1209152D002F0F45 /* PBXContainerItemProxy */;
|
||||||
};
|
};
|
||||||
|
BBFC08B8164C6862003E6A99 /* PBXTargetDependency */ = {
|
||||||
|
isa = PBXTargetDependency;
|
||||||
|
target = BEC567F70761D90600A33029 /* sdlcommon */;
|
||||||
|
targetProxy = BBFC08B9164C6862003E6A99 /* PBXContainerItemProxy */;
|
||||||
|
};
|
||||||
BEC568310761D90600A33029 /* PBXTargetDependency */ = {
|
BEC568310761D90600A33029 /* PBXTargetDependency */ = {
|
||||||
isa = PBXTargetDependency;
|
isa = PBXTargetDependency;
|
||||||
target = BEC567F70761D90600A33029 /* sdlcommon */;
|
target = BEC567F70761D90600A33029 /* sdlcommon */;
|
||||||
|
@ -4914,6 +5062,33 @@
|
||||||
};
|
};
|
||||||
/* End PBXTargetDependency section */
|
/* End PBXTargetDependency section */
|
||||||
|
|
||||||
|
/* Begin PBXVariantGroup section */
|
||||||
|
BBFC08A5164C684D003E6A99 /* InfoPlist.strings */ = {
|
||||||
|
isa = PBXVariantGroup;
|
||||||
|
children = (
|
||||||
|
BBFC08A6164C684D003E6A99 /* en */,
|
||||||
|
);
|
||||||
|
name = InfoPlist.strings;
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
|
BBFC08AB164C684D003E6A99 /* Credits.rtf */ = {
|
||||||
|
isa = PBXVariantGroup;
|
||||||
|
children = (
|
||||||
|
BBFC08AC164C684D003E6A99 /* en */,
|
||||||
|
);
|
||||||
|
name = Credits.rtf;
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
|
BBFC08B1164C684D003E6A99 /* MainMenu.xib */ = {
|
||||||
|
isa = PBXVariantGroup;
|
||||||
|
children = (
|
||||||
|
BBFC08B2164C684D003E6A99 /* en */,
|
||||||
|
);
|
||||||
|
name = MainMenu.xib;
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
|
/* End PBXVariantGroup section */
|
||||||
|
|
||||||
/* Begin XCBuildConfiguration section */
|
/* Begin XCBuildConfiguration section */
|
||||||
0017958910741F7900F5D044 /* Debug */ = {
|
0017958910741F7900F5D044 /* Debug */ = {
|
||||||
isa = XCBuildConfiguration;
|
isa = XCBuildConfiguration;
|
||||||
|
@ -5830,6 +6005,24 @@
|
||||||
};
|
};
|
||||||
name = Release;
|
name = Release;
|
||||||
};
|
};
|
||||||
|
BBFC08CB164C6862003E6A99 /* Debug */ = {
|
||||||
|
isa = XCBuildConfiguration;
|
||||||
|
buildSettings = {
|
||||||
|
INFOPLIST_FILE = "testgamecontroller-Info.plist";
|
||||||
|
PRODUCT_NAME = testgamecontroller;
|
||||||
|
WRAPPER_EXTENSION = app;
|
||||||
|
};
|
||||||
|
name = Debug;
|
||||||
|
};
|
||||||
|
BBFC08CC164C6862003E6A99 /* Release */ = {
|
||||||
|
isa = XCBuildConfiguration;
|
||||||
|
buildSettings = {
|
||||||
|
INFOPLIST_FILE = "testgamecontroller-Info.plist";
|
||||||
|
PRODUCT_NAME = testgamecontroller;
|
||||||
|
WRAPPER_EXTENSION = app;
|
||||||
|
};
|
||||||
|
name = Release;
|
||||||
|
};
|
||||||
/* End XCBuildConfiguration section */
|
/* End XCBuildConfiguration section */
|
||||||
|
|
||||||
/* Begin XCConfigurationList section */
|
/* Begin XCConfigurationList section */
|
||||||
|
@ -6256,6 +6449,15 @@
|
||||||
defaultConfigurationIsVisible = 0;
|
defaultConfigurationIsVisible = 0;
|
||||||
defaultConfigurationName = Debug;
|
defaultConfigurationName = Debug;
|
||||||
};
|
};
|
||||||
|
BBFC08CA164C6862003E6A99 /* Build configuration list for PBXNativeTarget "testgamecontroller" */ = {
|
||||||
|
isa = XCConfigurationList;
|
||||||
|
buildConfigurations = (
|
||||||
|
BBFC08CB164C6862003E6A99 /* Debug */,
|
||||||
|
BBFC08CC164C6862003E6A99 /* Release */,
|
||||||
|
);
|
||||||
|
defaultConfigurationIsVisible = 0;
|
||||||
|
defaultConfigurationName = Debug;
|
||||||
|
};
|
||||||
/* End XCConfigurationList section */
|
/* End XCConfigurationList section */
|
||||||
};
|
};
|
||||||
rootObject = 08FB7793FE84155DC02AAC07 /* Project object */;
|
rootObject = 08FB7793FE84155DC02AAC07 /* Project object */;
|
||||||
|
|
32
Xcode/SDLTest/testgamecontroller-Info.plist
Normal file
32
Xcode/SDLTest/testgamecontroller-Info.plist
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
<plist version="1.0">
|
||||||
|
<dict>
|
||||||
|
<key>CFBundleDevelopmentRegion</key>
|
||||||
|
<string>English</string>
|
||||||
|
<key>CFBundleExecutable</key>
|
||||||
|
<string>testgamecontroller</string>
|
||||||
|
<key>CFBundleGetInfoString</key>
|
||||||
|
<string></string>
|
||||||
|
<key>CFBundleIconFile</key>
|
||||||
|
<string></string>
|
||||||
|
<key>CFBundleIdentifier</key>
|
||||||
|
<string></string>
|
||||||
|
<key>CFBundleInfoDictionaryVersion</key>
|
||||||
|
<string>6.0</string>
|
||||||
|
<key>CFBundleName</key>
|
||||||
|
<string></string>
|
||||||
|
<key>CFBundlePackageType</key>
|
||||||
|
<string>APPL</string>
|
||||||
|
<key>CFBundleShortVersionString</key>
|
||||||
|
<string></string>
|
||||||
|
<key>CFBundleSignature</key>
|
||||||
|
<string>????</string>
|
||||||
|
<key>CFBundleVersion</key>
|
||||||
|
<string>0.0.1d1</string>
|
||||||
|
<key>NSMainNibFile</key>
|
||||||
|
<string>SDLMain.nib</string>
|
||||||
|
<key>NSPrincipalClass</key>
|
||||||
|
<string>NSApplication</string>
|
||||||
|
</dict>
|
||||||
|
</plist>
|
|
@ -79,6 +79,7 @@
|
||||||
#include "SDL_endian.h"
|
#include "SDL_endian.h"
|
||||||
#include "SDL_error.h"
|
#include "SDL_error.h"
|
||||||
#include "SDL_events.h"
|
#include "SDL_events.h"
|
||||||
|
#include "SDL_gamecontroller.h"
|
||||||
#include "SDL_hints.h"
|
#include "SDL_hints.h"
|
||||||
#include "SDL_loadso.h"
|
#include "SDL_loadso.h"
|
||||||
#include "SDL_log.h"
|
#include "SDL_log.h"
|
||||||
|
@ -115,6 +116,7 @@ extern "C" {
|
||||||
#define SDL_INIT_VIDEO 0x00000020
|
#define SDL_INIT_VIDEO 0x00000020
|
||||||
#define SDL_INIT_JOYSTICK 0x00000200
|
#define SDL_INIT_JOYSTICK 0x00000200
|
||||||
#define SDL_INIT_HAPTIC 0x00001000
|
#define SDL_INIT_HAPTIC 0x00001000
|
||||||
|
#define SDL_INIT_GAMECONTROLLER 0x00002000 /**< turn on game controller also implicitly does JOYSTICK */
|
||||||
#define SDL_INIT_NOPARACHUTE 0x00100000 /**< Don't catch fatal signals */
|
#define SDL_INIT_NOPARACHUTE 0x00100000 /**< Don't catch fatal signals */
|
||||||
#define SDL_INIT_EVERYTHING 0x0000FFFF
|
#define SDL_INIT_EVERYTHING 0x0000FFFF
|
||||||
/*@}*/
|
/*@}*/
|
||||||
|
|
|
@ -34,6 +34,7 @@
|
||||||
#include "SDL_keyboard.h"
|
#include "SDL_keyboard.h"
|
||||||
#include "SDL_mouse.h"
|
#include "SDL_mouse.h"
|
||||||
#include "SDL_joystick.h"
|
#include "SDL_joystick.h"
|
||||||
|
#include "SDL_gamecontroller.h"
|
||||||
#include "SDL_quit.h"
|
#include "SDL_quit.h"
|
||||||
#include "SDL_gesture.h"
|
#include "SDL_gesture.h"
|
||||||
#include "SDL_touch.h"
|
#include "SDL_touch.h"
|
||||||
|
@ -90,6 +91,15 @@ typedef enum
|
||||||
SDL_JOYHATMOTION, /**< Joystick hat position change */
|
SDL_JOYHATMOTION, /**< Joystick hat position change */
|
||||||
SDL_JOYBUTTONDOWN, /**< Joystick button pressed */
|
SDL_JOYBUTTONDOWN, /**< Joystick button pressed */
|
||||||
SDL_JOYBUTTONUP, /**< Joystick button released */
|
SDL_JOYBUTTONUP, /**< Joystick button released */
|
||||||
|
SDL_JOYDEVICEADDED, /**< A new joystick has been inserted into the system */
|
||||||
|
SDL_JOYDEVICEREMOVED, /**< An opened joystick has been removed */
|
||||||
|
|
||||||
|
/* Game controller events */
|
||||||
|
SDL_CONTROLLERAXISMOTION = 0x650, /**< Game controller axis motion */
|
||||||
|
SDL_CONTROLLERBUTTONDOWN, /**< Game controller button pressed */
|
||||||
|
SDL_CONTROLLERBUTTONUP, /**< Game controller button released */
|
||||||
|
SDL_CONTROLLERDEVICEADDED, /**< A new Game controller has been inserted into the system */
|
||||||
|
SDL_CONTROLLERDEVICEREMOVED, /**< An opened Game controller has been removed */
|
||||||
|
|
||||||
/* Touch events */
|
/* Touch events */
|
||||||
SDL_FINGERDOWN = 0x700,
|
SDL_FINGERDOWN = 0x700,
|
||||||
|
@ -231,7 +241,7 @@ typedef struct SDL_JoyAxisEvent
|
||||||
{
|
{
|
||||||
Uint32 type; /**< ::SDL_JOYAXISMOTION */
|
Uint32 type; /**< ::SDL_JOYAXISMOTION */
|
||||||
Uint32 timestamp;
|
Uint32 timestamp;
|
||||||
Uint8 which; /**< The joystick device index */
|
Uint8 which; /**< The joystick instance id */
|
||||||
Uint8 axis; /**< The joystick axis index */
|
Uint8 axis; /**< The joystick axis index */
|
||||||
Uint8 padding1;
|
Uint8 padding1;
|
||||||
Uint8 padding2;
|
Uint8 padding2;
|
||||||
|
@ -245,7 +255,7 @@ typedef struct SDL_JoyBallEvent
|
||||||
{
|
{
|
||||||
Uint32 type; /**< ::SDL_JOYBALLMOTION */
|
Uint32 type; /**< ::SDL_JOYBALLMOTION */
|
||||||
Uint32 timestamp;
|
Uint32 timestamp;
|
||||||
Uint8 which; /**< The joystick device index */
|
Uint8 which; /**< The joystick instance id */
|
||||||
Uint8 ball; /**< The joystick trackball index */
|
Uint8 ball; /**< The joystick trackball index */
|
||||||
Uint8 padding1;
|
Uint8 padding1;
|
||||||
Uint8 padding2;
|
Uint8 padding2;
|
||||||
|
@ -260,7 +270,7 @@ typedef struct SDL_JoyHatEvent
|
||||||
{
|
{
|
||||||
Uint32 type; /**< ::SDL_JOYHATMOTION */
|
Uint32 type; /**< ::SDL_JOYHATMOTION */
|
||||||
Uint32 timestamp;
|
Uint32 timestamp;
|
||||||
Uint8 which; /**< The joystick device index */
|
Uint8 which; /**< The joystick instance id */
|
||||||
Uint8 hat; /**< The joystick hat index */
|
Uint8 hat; /**< The joystick hat index */
|
||||||
Uint8 value; /**< The hat position value.
|
Uint8 value; /**< The hat position value.
|
||||||
* \sa ::SDL_HAT_LEFTUP ::SDL_HAT_UP ::SDL_HAT_RIGHTUP
|
* \sa ::SDL_HAT_LEFTUP ::SDL_HAT_UP ::SDL_HAT_RIGHTUP
|
||||||
|
@ -279,12 +289,59 @@ typedef struct SDL_JoyButtonEvent
|
||||||
{
|
{
|
||||||
Uint32 type; /**< ::SDL_JOYBUTTONDOWN or ::SDL_JOYBUTTONUP */
|
Uint32 type; /**< ::SDL_JOYBUTTONDOWN or ::SDL_JOYBUTTONUP */
|
||||||
Uint32 timestamp;
|
Uint32 timestamp;
|
||||||
Uint8 which; /**< The joystick device index */
|
Uint8 which; /**< The joystick instance id */
|
||||||
Uint8 button; /**< The joystick button index */
|
Uint8 button; /**< The joystick button index */
|
||||||
Uint8 state; /**< ::SDL_PRESSED or ::SDL_RELEASED */
|
Uint8 state; /**< ::SDL_PRESSED or ::SDL_RELEASED */
|
||||||
Uint8 padding1;
|
Uint8 padding1;
|
||||||
} SDL_JoyButtonEvent;
|
} SDL_JoyButtonEvent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Joystick device event structure (event.jdevice.*)
|
||||||
|
*/
|
||||||
|
typedef struct SDL_JoyDeviceEvent
|
||||||
|
{
|
||||||
|
Uint32 type; /**< ::SDL_JOYDEVICEADDED or ::SDL_JOYDEVICEREMOVED */
|
||||||
|
Uint32 timestamp;
|
||||||
|
Uint32 which; /**< The joystick device index for ADD, instance_id for REMOVE*/
|
||||||
|
} SDL_JoyDeviceEvent;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Game controller axis motion event structure (event.caxis.*)
|
||||||
|
*/
|
||||||
|
typedef struct SDL_ControllerAxisEvent
|
||||||
|
{
|
||||||
|
Uint32 type; /**< ::SDL_CONTROLLERAXISMOTION */
|
||||||
|
Uint32 timestamp;
|
||||||
|
Uint8 which; /**< The joystick instance id */
|
||||||
|
SDL_CONTROLLER_AXIS axis; /**< The joystick axis index */
|
||||||
|
int value; /**< The axis value (range: -32768 to 32767) */
|
||||||
|
} SDL_ControllerAxisEvent;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Game controller button event structure (event.cbutton.*)
|
||||||
|
*/
|
||||||
|
typedef struct SDL_ControllerButtonEvent
|
||||||
|
{
|
||||||
|
Uint32 type; /**< ::SDL_CONTROLLERBUTTONDOWN or ::SDL_CONTROLLERBUTTONUP */
|
||||||
|
Uint32 timestamp;
|
||||||
|
Uint8 which; /**< The joystick instance id */
|
||||||
|
SDL_CONTROLLER_BUTTON button; /**< The joystick button index */
|
||||||
|
Uint8 state; /**< ::SDL_PRESSED or ::SDL_RELEASED */
|
||||||
|
} SDL_ControllerButtonEvent;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Controller device event structure (event.cdevice.*)
|
||||||
|
*/
|
||||||
|
typedef struct SDL_ControllerDeviceEvent
|
||||||
|
{
|
||||||
|
Uint32 type; /**< ::SDL_CONTROLLERDEVICEADDED or ::SDL_CONTROLLERDEVICEREMOVED */
|
||||||
|
Uint32 timestamp;
|
||||||
|
Uint32 which; /**< The joystick device index for ADD, instance_id for REMOVE*/
|
||||||
|
} SDL_ControllerDeviceEvent;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Touch finger motion/finger event structure (event.tfinger.*)
|
* \brief Touch finger motion/finger event structure (event.tfinger.*)
|
||||||
|
@ -430,6 +487,10 @@ typedef union SDL_Event
|
||||||
SDL_JoyBallEvent jball; /**< Joystick ball event data */
|
SDL_JoyBallEvent jball; /**< Joystick ball event data */
|
||||||
SDL_JoyHatEvent jhat; /**< Joystick hat event data */
|
SDL_JoyHatEvent jhat; /**< Joystick hat event data */
|
||||||
SDL_JoyButtonEvent jbutton; /**< Joystick button event data */
|
SDL_JoyButtonEvent jbutton; /**< Joystick button event data */
|
||||||
|
SDL_JoyDeviceEvent jdevice; /**< Joystick device change event data */
|
||||||
|
SDL_ControllerAxisEvent caxis; /**< Game Controller button event data */
|
||||||
|
SDL_ControllerButtonEvent cbutton; /**< Game Controller button event data */
|
||||||
|
SDL_ControllerDeviceEvent cdevice; /**< Game Controller device event data */
|
||||||
SDL_QuitEvent quit; /**< Quit request event data */
|
SDL_QuitEvent quit; /**< Quit request event data */
|
||||||
SDL_UserEvent user; /**< Custom event data */
|
SDL_UserEvent user; /**< Custom event data */
|
||||||
SDL_SysWMEvent syswm; /**< System dependent window event data */
|
SDL_SysWMEvent syswm; /**< System dependent window event data */
|
||||||
|
|
257
include/SDL_gamecontroller.h
Normal file
257
include/SDL_gamecontroller.h
Normal file
|
@ -0,0 +1,257 @@
|
||||||
|
/*
|
||||||
|
Simple DirectMedia Layer
|
||||||
|
Copyright (C) 1997-2012 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \file SDL_gamecontroller.h
|
||||||
|
*
|
||||||
|
* Include file for SDL game controller event handling
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _SDL_gamecontroller_h
|
||||||
|
#define _SDL_gamecontroller_h
|
||||||
|
|
||||||
|
#include "SDL_stdinc.h"
|
||||||
|
#include "SDL_error.h"
|
||||||
|
#include "SDL_joystick.h"
|
||||||
|
|
||||||
|
#include "begin_code.h"
|
||||||
|
/* Set up for C function definitions, even when using C++ */
|
||||||
|
#ifdef __cplusplus
|
||||||
|
/* *INDENT-OFF* */
|
||||||
|
extern "C" {
|
||||||
|
/* *INDENT-ON* */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \file SDL_gamecontroller.h
|
||||||
|
*
|
||||||
|
* In order to use these functions, SDL_Init() must have been called
|
||||||
|
* with the ::SDL_INIT_JOYSTICK flag. This causes SDL to scan the system
|
||||||
|
* for game controllers, and load appropriate drivers.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* The gamecontroller structure used to identify an SDL game controller */
|
||||||
|
struct _SDL_GameController;
|
||||||
|
typedef struct _SDL_GameController SDL_GameController;
|
||||||
|
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
SDL_CONTROLLER_BINDTYPE_NONE = 0,
|
||||||
|
SDL_CONTROLLER_BINDTYPE_BUTTON,
|
||||||
|
SDL_CONTROLLER_BINDTYPE_AXIS,
|
||||||
|
SDL_CONTROLLER_BINDTYPE_HAT,
|
||||||
|
} SDL_CONTROLLER_BINDTYPE;
|
||||||
|
/**
|
||||||
|
* get the sdl joystick layer binding for this controller button/axis mapping
|
||||||
|
*/
|
||||||
|
struct _SDL_GameControllerHatBind
|
||||||
|
{
|
||||||
|
int hat;
|
||||||
|
int hat_mask;
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef struct _SDL_GameControllerButtonBind
|
||||||
|
{
|
||||||
|
SDL_CONTROLLER_BINDTYPE m_eBindType;
|
||||||
|
union
|
||||||
|
{
|
||||||
|
int button;
|
||||||
|
int axis;
|
||||||
|
struct _SDL_GameControllerHatBind hat;
|
||||||
|
};
|
||||||
|
|
||||||
|
} SDL_GameControllerButtonBind;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To count the number of game controllers in the system for the following:
|
||||||
|
* int nJoysticks = SDL_NumJoysticks();
|
||||||
|
* int nGameControllers = 0;
|
||||||
|
* for ( int i = 0; i < nJoysticks; i++ ) {
|
||||||
|
* if ( SDL_IsGameController(i) ) {
|
||||||
|
* nGameControllers++;
|
||||||
|
* }
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
* Using the SDL_HINT_GAMECONTROLLERCONFIG hint you can add support for controllers SDL is unaware of or cause an existing controller to have a different binding. The format is:
|
||||||
|
* guid,name,mappings
|
||||||
|
*
|
||||||
|
* Where GUID is the string value from SDL_JoystickGetGUIDString(), name is the human readable string for the device and mappings are controller mappings to joystick ones.
|
||||||
|
* Under Windows there is a reserved GUID of "xinput" that covers any XInput devices.
|
||||||
|
* The mapping format for joystick is:
|
||||||
|
* bX - a joystick button, index X
|
||||||
|
* hX.Y - hat X with value Y
|
||||||
|
* aX - axis X of the joystick
|
||||||
|
* Buttons can be used as a controller axis and vice versa.
|
||||||
|
*
|
||||||
|
* This string shows an example of a valid mapping for a controller
|
||||||
|
* "341a3608000000000000504944564944,Aferglow PS3 Controller,a:b1,b:b2,y:b3,x:b0,start:b9,guide:b12,back:b8,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftshoulder:b4,rightshoulder:b5,leftstick:b10,rightstick:b11,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b6,righttrigger:b7",
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Is the joystick on this index supported by the game controller interface?
|
||||||
|
* returns 1 if supported, 0 otherwise.
|
||||||
|
*/
|
||||||
|
extern DECLSPEC int SDLCALL SDL_IsGameController(int joystick_index);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the implementation dependent name of a game controller.
|
||||||
|
* This can be called before any controllers are opened.
|
||||||
|
* If no name can be found, this function returns NULL.
|
||||||
|
*/
|
||||||
|
extern DECLSPEC const char *SDLCALL SDL_GameControllerNameForIndex(int joystick_index);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Open a game controller for use.
|
||||||
|
* The index passed as an argument refers to the N'th game controller on the system.
|
||||||
|
* This index is the value which will identify this controller in future controller
|
||||||
|
* events.
|
||||||
|
*
|
||||||
|
* \return A controller identifier, or NULL if an error occurred.
|
||||||
|
*/
|
||||||
|
extern DECLSPEC SDL_GameController *SDLCALL SDL_GameControllerOpen(int joystick_index);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the name for this currently opened controller
|
||||||
|
*/
|
||||||
|
extern DECLSPEC const char *SDLCALL SDL_GameControllerName(SDL_GameController * gamecontroller);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns 1 if the controller has been opened and currently connected, or 0 if it has not.
|
||||||
|
*/
|
||||||
|
extern DECLSPEC int SDLCALL SDL_GameControllerGetAttached(SDL_GameController * gamecontroller);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the underlying joystick object used by a controller
|
||||||
|
*/
|
||||||
|
extern DECLSPEC SDL_Joystick *SDLCALL SDL_GameControllerGetJoystick(SDL_GameController * gamecontroller);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enable/disable controller event polling.
|
||||||
|
*
|
||||||
|
* If controller events are disabled, you must call SDL_GameControllerUpdate()
|
||||||
|
* yourself and check the state of the controller when you want controller
|
||||||
|
* information.
|
||||||
|
*
|
||||||
|
* The state can be one of ::SDL_QUERY, ::SDL_ENABLE or ::SDL_IGNORE.
|
||||||
|
*/
|
||||||
|
extern DECLSPEC int SDLCALL SDL_GameControllerEventState(int state);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The list of axii available from a controller
|
||||||
|
*/
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
SDL_CONTROLLER_AXIS_INVALID = -1,
|
||||||
|
SDL_CONTROLLER_AXIS_LEFTX,
|
||||||
|
SDL_CONTROLLER_AXIS_LEFTY,
|
||||||
|
SDL_CONTROLLER_AXIS_RIGHTX,
|
||||||
|
SDL_CONTROLLER_AXIS_RIGHTY,
|
||||||
|
SDL_CONTROLLER_AXIS_TRIGGERLEFT,
|
||||||
|
SDL_CONTROLLER_AXIS_TRIGGERRIGHT,
|
||||||
|
SDL_CONTROLLER_AXIS_MAX
|
||||||
|
} SDL_CONTROLLER_AXIS;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* turn this string into a axis mapping
|
||||||
|
*/
|
||||||
|
extern DECLSPEC SDL_CONTROLLER_AXIS SDLCALL SDL_GameControllerGetAxisFromString(const char *pchString);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get the sdl joystick layer binding for this controller button mapping
|
||||||
|
*/
|
||||||
|
extern DECLSPEC SDL_GameControllerButtonBind SDLCALL SDL_GameControllerGetBindForAxis(SDL_GameController * gamecontroller, SDL_CONTROLLER_AXIS button);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the current state of an axis control on a game controller.
|
||||||
|
*
|
||||||
|
* The state is a value ranging from -32768 to 32767.
|
||||||
|
*
|
||||||
|
* The axis indices start at index 0.
|
||||||
|
*/
|
||||||
|
extern DECLSPEC Sint16 SDLCALL SDL_GameControllerGetAxis(SDL_GameController * gamecontroller,
|
||||||
|
SDL_CONTROLLER_AXIS axis);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The list of buttons available from a controller
|
||||||
|
*/
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
SDL_CONTROLLER_BUTTON_INVALID = -1,
|
||||||
|
SDL_CONTROLLER_BUTTON_A,
|
||||||
|
SDL_CONTROLLER_BUTTON_B,
|
||||||
|
SDL_CONTROLLER_BUTTON_X,
|
||||||
|
SDL_CONTROLLER_BUTTON_Y,
|
||||||
|
SDL_CONTROLLER_BUTTON_BACK,
|
||||||
|
SDL_CONTROLLER_BUTTON_GUIDE,
|
||||||
|
SDL_CONTROLLER_BUTTON_START,
|
||||||
|
SDL_CONTROLLER_BUTTON_LEFTSTICK,
|
||||||
|
SDL_CONTROLLER_BUTTON_RIGHTSTICK,
|
||||||
|
SDL_CONTROLLER_BUTTON_LEFTSHOULDER,
|
||||||
|
SDL_CONTROLLER_BUTTON_RIGHTSHOULDER,
|
||||||
|
SDL_CONTROLLER_BUTTON_DPAD_UP,
|
||||||
|
SDL_CONTROLLER_BUTTON_DPAD_DOWN,
|
||||||
|
SDL_CONTROLLER_BUTTON_DPAD_LEFT,
|
||||||
|
SDL_CONTROLLER_BUTTON_DPAD_RIGHT,
|
||||||
|
SDL_CONTROLLER_BUTTON_MAX
|
||||||
|
} SDL_CONTROLLER_BUTTON;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* turn this string into a button mapping
|
||||||
|
*/
|
||||||
|
extern DECLSPEC SDL_CONTROLLER_BUTTON SDLCALL SDL_GameControllerGetButtonFromString(const char *pchString);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get the sdl joystick layer binding for this controller button mapping
|
||||||
|
*/
|
||||||
|
extern DECLSPEC SDL_GameControllerButtonBind SDLCALL SDL_GameControllerGetBindForButton(SDL_GameController * gamecontroller, SDL_CONTROLLER_BUTTON button);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the current state of a button on a game controller.
|
||||||
|
*
|
||||||
|
* The button indices start at index 0.
|
||||||
|
*/
|
||||||
|
extern DECLSPEC Uint8 SDLCALL SDL_GameControllerGetButton(SDL_GameController * gamecontroller,
|
||||||
|
SDL_CONTROLLER_BUTTON button);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Close a controller previously opened with SDL_GameControllerOpen().
|
||||||
|
*/
|
||||||
|
extern DECLSPEC void SDLCALL SDL_GameControllerClose(SDL_GameController * gamecontrollerk);
|
||||||
|
|
||||||
|
|
||||||
|
/* Ends C function definitions when using C++ */
|
||||||
|
#ifdef __cplusplus
|
||||||
|
/* *INDENT-OFF* */
|
||||||
|
}
|
||||||
|
/* *INDENT-ON* */
|
||||||
|
#endif
|
||||||
|
#include "close_code.h"
|
||||||
|
|
||||||
|
#endif /* _SDL_gamecontroller_h */
|
||||||
|
|
||||||
|
/* vi: set ts=4 sw=4 expandtab: */
|
|
@ -189,6 +189,14 @@ extern "C" {
|
||||||
#define SDL_HINT_ORIENTATIONS "SDL_IOS_ORIENTATIONS"
|
#define SDL_HINT_ORIENTATIONS "SDL_IOS_ORIENTATIONS"
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief A variable that lets you manually hint extra gamecontroller db entries
|
||||||
|
*
|
||||||
|
* The variable expected newline delimited rows of gamecontroller config data, see SDL_gamecontroller.h
|
||||||
|
*/
|
||||||
|
#define SDL_HINT_GAMECONTROLLERCONFIG "SDL_GAMECONTROLLERCONFIG"
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief An enumeration of hint priorities
|
* \brief An enumeration of hint priorities
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -23,6 +23,17 @@
|
||||||
* \file SDL_joystick.h
|
* \file SDL_joystick.h
|
||||||
*
|
*
|
||||||
* Include file for SDL joystick event handling
|
* Include file for SDL joystick event handling
|
||||||
|
*
|
||||||
|
* The term "device_index" identifies currently plugged in joystick devices between 0 and SDL_NumJoysticks, with the exact joystick
|
||||||
|
* behind a device_index changing as joysticks are plugged and unplugged.
|
||||||
|
*
|
||||||
|
* The term "instance_id" is the current instantiation of a joystick device in the system, if the joystick is removed and then re-inserted
|
||||||
|
* then it will get a new instance_id, instance_id's are monotonically increasing identifiers of a joystick plugged in.
|
||||||
|
*
|
||||||
|
* The term JoystickGUID is a stable 128-bit identifier for a joystick device that does not change over time, it identifies class of
|
||||||
|
* the device (a X360 wired controller for example). This identifier is platform dependent.
|
||||||
|
*
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _SDL_joystick_h
|
#ifndef _SDL_joystick_h
|
||||||
|
@ -51,10 +62,11 @@ extern "C" {
|
||||||
struct _SDL_Joystick;
|
struct _SDL_Joystick;
|
||||||
typedef struct _SDL_Joystick SDL_Joystick;
|
typedef struct _SDL_Joystick SDL_Joystick;
|
||||||
|
|
||||||
|
typedef int SDL_JoystickID;
|
||||||
|
|
||||||
/* Function prototypes */
|
/* Function prototypes */
|
||||||
/**
|
/**
|
||||||
* Count the number of joysticks attached to the system
|
* Count the number of joysticks attached to the system right now
|
||||||
*/
|
*/
|
||||||
extern DECLSPEC int SDLCALL SDL_NumJoysticks(void);
|
extern DECLSPEC int SDLCALL SDL_NumJoysticks(void);
|
||||||
|
|
||||||
|
@ -63,7 +75,7 @@ extern DECLSPEC int SDLCALL SDL_NumJoysticks(void);
|
||||||
* This can be called before any joysticks are opened.
|
* This can be called before any joysticks are opened.
|
||||||
* If no name can be found, this function returns NULL.
|
* If no name can be found, this function returns NULL.
|
||||||
*/
|
*/
|
||||||
extern DECLSPEC const char *SDLCALL SDL_JoystickName(int device_index);
|
extern DECLSPEC const char *SDLCALL SDL_JoystickNameForIndex(int device_index);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Open a joystick for use.
|
* Open a joystick for use.
|
||||||
|
@ -76,14 +88,47 @@ extern DECLSPEC const char *SDLCALL SDL_JoystickName(int device_index);
|
||||||
extern DECLSPEC SDL_Joystick *SDLCALL SDL_JoystickOpen(int device_index);
|
extern DECLSPEC SDL_Joystick *SDLCALL SDL_JoystickOpen(int device_index);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns 1 if the joystick has been opened, or 0 if it has not.
|
* Return the name for this currently opened joystick.
|
||||||
|
* If no name can be found, this function returns NULL.
|
||||||
*/
|
*/
|
||||||
extern DECLSPEC int SDLCALL SDL_JoystickOpened(int device_index);
|
extern DECLSPEC const char *SDLCALL SDL_JoystickName(SDL_Joystick * joystick);
|
||||||
|
|
||||||
|
/* A structure that encodes the stable unique id for a joystick device */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
Uint8 data[16];
|
||||||
|
} JoystickGUID;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the GUID for the joystick at this index
|
||||||
|
*/
|
||||||
|
extern DECLSPEC JoystickGUID SDLCALL SDL_JoystickGetDeviceGUID(int device_index);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the GUID for this opened joystick
|
||||||
|
*/
|
||||||
|
extern DECLSPEC JoystickGUID SDLCALL SDL_JoystickGetGUID(SDL_Joystick * joystick);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return a string representation for this guid. You are responsible for freeing memory from this call
|
||||||
|
*/
|
||||||
|
extern DECLSPEC char *SDLCALL SDL_JoystickGetGUIDString(JoystickGUID guid);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* convert a string into a joystick formatted guid
|
||||||
|
*/
|
||||||
|
extern DECLSPEC JoystickGUID SDLCALL SDL_JoystickGetGUIDFromString(const char *pchGUID);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns 1 if the joystick has been opened and currently connected, or 0 if it has not.
|
||||||
|
*/
|
||||||
|
extern DECLSPEC int SDLCALL SDL_JoystickGetAttached(SDL_Joystick * joystick);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the device index of an opened joystick.
|
* Get the device index of an opened joystick.
|
||||||
*/
|
*/
|
||||||
extern DECLSPEC int SDLCALL SDL_JoystickIndex(SDL_Joystick * joystick);
|
extern DECLSPEC SDL_JoystickID SDLCALL SDL_JoystickInstanceID(SDL_Joystick * joystick);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the number of general axis controls on a joystick.
|
* Get the number of general axis controls on a joystick.
|
||||||
|
|
143
src/SDL.c
143
src/SDL.c
|
@ -44,7 +44,20 @@ extern int SDL_HelperWindowDestroy(void);
|
||||||
/* The initialized subsystems */
|
/* The initialized subsystems */
|
||||||
static Uint32 SDL_initialized = 0;
|
static Uint32 SDL_initialized = 0;
|
||||||
static Uint32 ticks_started = 0;
|
static Uint32 ticks_started = 0;
|
||||||
|
static SDL_bool SDL_bInMainQuit = SDL_FALSE;
|
||||||
|
static Uint8 SDL_SubsystemRefCount[ 32 ]; // keep a per subsystem init
|
||||||
|
|
||||||
|
/* helper func to return the index of the MSB in an int */
|
||||||
|
int msb32_idx( Uint32 n)
|
||||||
|
{
|
||||||
|
int b = 0;
|
||||||
|
if (!n) return -1;
|
||||||
|
|
||||||
|
#define step(x) if (n >= ((Uint32)1) << x) b += x, n >>= x
|
||||||
|
step(16); step(8); step(4); step(2); step(1);
|
||||||
|
#undef step
|
||||||
|
return b;
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
SDL_InitSubSystem(Uint32 flags)
|
SDL_InitSubSystem(Uint32 flags)
|
||||||
|
@ -55,11 +68,16 @@ SDL_InitSubSystem(Uint32 flags)
|
||||||
SDL_StartTicks();
|
SDL_StartTicks();
|
||||||
ticks_started = 1;
|
ticks_started = 1;
|
||||||
}
|
}
|
||||||
if ((flags & SDL_INIT_TIMER) && !(SDL_initialized & SDL_INIT_TIMER)) {
|
|
||||||
if (SDL_TimerInit() < 0) {
|
if ((flags & SDL_INIT_TIMER) ){
|
||||||
return (-1);
|
SDL_SubsystemRefCount[ msb32_idx(SDL_INIT_TIMER) ]++;
|
||||||
}
|
SDL_assert( SDL_SubsystemRefCount[ msb32_idx(SDL_INIT_TIMER) ] < 254 );
|
||||||
SDL_initialized |= SDL_INIT_TIMER;
|
if ( !(SDL_initialized & SDL_INIT_TIMER)) {
|
||||||
|
if (SDL_TimerInit() < 0) {
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
SDL_initialized |= SDL_INIT_TIMER;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
if (flags & SDL_INIT_TIMER) {
|
if (flags & SDL_INIT_TIMER) {
|
||||||
|
@ -70,11 +88,15 @@ SDL_InitSubSystem(Uint32 flags)
|
||||||
|
|
||||||
#if !SDL_VIDEO_DISABLED
|
#if !SDL_VIDEO_DISABLED
|
||||||
/* Initialize the video/event subsystem */
|
/* Initialize the video/event subsystem */
|
||||||
if ((flags & SDL_INIT_VIDEO) && !(SDL_initialized & SDL_INIT_VIDEO)) {
|
if ((flags & SDL_INIT_VIDEO) ) {
|
||||||
if (SDL_VideoInit(NULL) < 0) {
|
SDL_SubsystemRefCount[ msb32_idx(SDL_INIT_VIDEO) ]++;
|
||||||
return (-1);
|
SDL_assert( SDL_SubsystemRefCount[ msb32_idx(SDL_INIT_VIDEO) ] < 254 );
|
||||||
}
|
if ( !(SDL_initialized & SDL_INIT_VIDEO)) {
|
||||||
SDL_initialized |= SDL_INIT_VIDEO;
|
if (SDL_VideoInit(NULL) < 0) {
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
SDL_initialized |= SDL_INIT_VIDEO;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
if (flags & SDL_INIT_VIDEO) {
|
if (flags & SDL_INIT_VIDEO) {
|
||||||
|
@ -85,11 +107,15 @@ SDL_InitSubSystem(Uint32 flags)
|
||||||
|
|
||||||
#if !SDL_AUDIO_DISABLED
|
#if !SDL_AUDIO_DISABLED
|
||||||
/* Initialize the audio subsystem */
|
/* Initialize the audio subsystem */
|
||||||
if ((flags & SDL_INIT_AUDIO) && !(SDL_initialized & SDL_INIT_AUDIO)) {
|
if ((flags & SDL_INIT_AUDIO) ) {
|
||||||
if (SDL_AudioInit(NULL) < 0) {
|
SDL_SubsystemRefCount[ msb32_idx(SDL_INIT_AUDIO) ]++;
|
||||||
return (-1);
|
SDL_assert( SDL_SubsystemRefCount[ msb32_idx(SDL_INIT_AUDIO) ] < 254 );
|
||||||
}
|
if ( !(SDL_initialized & SDL_INIT_AUDIO)) {
|
||||||
SDL_initialized |= SDL_INIT_AUDIO;
|
if (SDL_AudioInit(NULL) < 0) {
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
SDL_initialized |= SDL_INIT_AUDIO;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
if (flags & SDL_INIT_AUDIO) {
|
if (flags & SDL_INIT_AUDIO) {
|
||||||
|
@ -100,10 +126,23 @@ SDL_InitSubSystem(Uint32 flags)
|
||||||
|
|
||||||
#if !SDL_JOYSTICK_DISABLED
|
#if !SDL_JOYSTICK_DISABLED
|
||||||
/* Initialize the joystick subsystem */
|
/* Initialize the joystick subsystem */
|
||||||
if ((flags & SDL_INIT_JOYSTICK) && !(SDL_initialized & SDL_INIT_JOYSTICK)) {
|
if ( ( (flags & SDL_INIT_JOYSTICK) ) || ((flags & SDL_INIT_GAMECONTROLLER) ) ) { // game controller implies joystick
|
||||||
if (SDL_JoystickInit() < 0) {
|
SDL_SubsystemRefCount[ msb32_idx(SDL_INIT_JOYSTICK) ]++;
|
||||||
|
SDL_assert( SDL_SubsystemRefCount[ msb32_idx(SDL_INIT_JOYSTICK) ] < 254 );
|
||||||
|
if ( !(SDL_initialized & SDL_INIT_JOYSTICK) && SDL_JoystickInit() < 0) {
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((flags & SDL_INIT_GAMECONTROLLER) ) {
|
||||||
|
SDL_SubsystemRefCount[ msb32_idx(SDL_INIT_GAMECONTROLLER) ]++;
|
||||||
|
SDL_assert( SDL_SubsystemRefCount[ msb32_idx(SDL_INIT_GAMECONTROLLER) ] < 254 );
|
||||||
|
if ( !(SDL_initialized & SDL_INIT_GAMECONTROLLER)) {
|
||||||
|
if (SDL_GameControllerInit() < 0) {
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
SDL_initialized |= SDL_INIT_GAMECONTROLLER;
|
||||||
|
}
|
||||||
|
}
|
||||||
SDL_initialized |= SDL_INIT_JOYSTICK;
|
SDL_initialized |= SDL_INIT_JOYSTICK;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
@ -115,11 +154,15 @@ SDL_InitSubSystem(Uint32 flags)
|
||||||
|
|
||||||
#if !SDL_HAPTIC_DISABLED
|
#if !SDL_HAPTIC_DISABLED
|
||||||
/* Initialize the haptic subsystem */
|
/* Initialize the haptic subsystem */
|
||||||
if ((flags & SDL_INIT_HAPTIC) && !(SDL_initialized & SDL_INIT_HAPTIC)) {
|
if ((flags & SDL_INIT_HAPTIC) ) {
|
||||||
if (SDL_HapticInit() < 0) {
|
SDL_SubsystemRefCount[ msb32_idx(SDL_INIT_HAPTIC) ]++;
|
||||||
return (-1);
|
SDL_assert( SDL_SubsystemRefCount[ msb32_idx(SDL_INIT_HAPTIC) ] < 254 );
|
||||||
}
|
if ( !(SDL_initialized & SDL_INIT_HAPTIC)) {
|
||||||
SDL_initialized |= SDL_INIT_HAPTIC;
|
if (SDL_HapticInit() < 0) {
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
SDL_initialized |= SDL_INIT_HAPTIC;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
if (flags & SDL_INIT_HAPTIC) {
|
if (flags & SDL_INIT_HAPTIC) {
|
||||||
|
@ -156,6 +199,7 @@ SDL_Init(Uint32 flags)
|
||||||
SDL_InstallParachute();
|
SDL_InstallParachute();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SDL_memset( SDL_SubsystemRefCount, 0x0, sizeof(SDL_SubsystemRefCount) );
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -164,33 +208,62 @@ SDL_QuitSubSystem(Uint32 flags)
|
||||||
{
|
{
|
||||||
/* Shut down requested initialized subsystems */
|
/* Shut down requested initialized subsystems */
|
||||||
#if !SDL_JOYSTICK_DISABLED
|
#if !SDL_JOYSTICK_DISABLED
|
||||||
if ((flags & SDL_initialized & SDL_INIT_JOYSTICK)) {
|
if ((flags & SDL_initialized & SDL_INIT_JOYSTICK) || (flags & SDL_initialized & SDL_INIT_GAMECONTROLLER)) {
|
||||||
SDL_JoystickQuit();
|
if ( (flags & SDL_initialized & SDL_INIT_GAMECONTROLLER) ) {
|
||||||
SDL_initialized &= ~SDL_INIT_JOYSTICK;
|
SDL_SubsystemRefCount[ msb32_idx(SDL_INIT_GAMECONTROLLER) ]--;
|
||||||
|
if ( SDL_bInMainQuit || SDL_SubsystemRefCount[ msb32_idx(SDL_INIT_GAMECONTROLLER) ] == 0 ) {
|
||||||
|
SDL_GameControllerQuit();
|
||||||
|
SDL_initialized &= ~SDL_INIT_GAMECONTROLLER;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SDL_SubsystemRefCount[ msb32_idx(SDL_INIT_JOYSTICK) ]--;
|
||||||
|
if ( SDL_bInMainQuit || SDL_SubsystemRefCount[ msb32_idx(SDL_INIT_JOYSTICK) ] == 0 )
|
||||||
|
{
|
||||||
|
SDL_JoystickQuit();
|
||||||
|
SDL_initialized &= ~SDL_INIT_JOYSTICK;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#if !SDL_HAPTIC_DISABLED
|
#if !SDL_HAPTIC_DISABLED
|
||||||
if ((flags & SDL_initialized & SDL_INIT_HAPTIC)) {
|
if ((flags & SDL_initialized & SDL_INIT_HAPTIC)) {
|
||||||
SDL_HapticQuit();
|
SDL_SubsystemRefCount[ msb32_idx(SDL_INIT_HAPTIC) ]--;
|
||||||
SDL_initialized &= ~SDL_INIT_HAPTIC;
|
if ( SDL_bInMainQuit || SDL_SubsystemRefCount[ msb32_idx(SDL_INIT_HAPTIC) ] == 0 )
|
||||||
|
{
|
||||||
|
SDL_HapticQuit();
|
||||||
|
SDL_initialized &= ~SDL_INIT_HAPTIC;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#if !SDL_AUDIO_DISABLED
|
#if !SDL_AUDIO_DISABLED
|
||||||
if ((flags & SDL_initialized & SDL_INIT_AUDIO)) {
|
if ((flags & SDL_initialized & SDL_INIT_AUDIO)) {
|
||||||
SDL_AudioQuit();
|
SDL_SubsystemRefCount[ msb32_idx(SDL_INIT_AUDIO) ]--;
|
||||||
SDL_initialized &= ~SDL_INIT_AUDIO;
|
if ( SDL_bInMainQuit || SDL_SubsystemRefCount[ msb32_idx(SDL_INIT_AUDIO) ] == 0 )
|
||||||
|
{
|
||||||
|
SDL_AudioQuit();
|
||||||
|
SDL_initialized &= ~SDL_INIT_AUDIO;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#if !SDL_VIDEO_DISABLED
|
#if !SDL_VIDEO_DISABLED
|
||||||
if ((flags & SDL_initialized & SDL_INIT_VIDEO)) {
|
if ((flags & SDL_initialized & SDL_INIT_VIDEO)) {
|
||||||
SDL_VideoQuit();
|
SDL_SubsystemRefCount[ msb32_idx(SDL_INIT_VIDEO) ]--;
|
||||||
SDL_initialized &= ~SDL_INIT_VIDEO;
|
if ( SDL_bInMainQuit || SDL_SubsystemRefCount[ msb32_idx(SDL_INIT_VIDEO) ] == 0 )
|
||||||
|
{
|
||||||
|
SDL_VideoQuit();
|
||||||
|
SDL_initialized &= ~SDL_INIT_VIDEO;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#if !SDL_TIMERS_DISABLED
|
#if !SDL_TIMERS_DISABLED
|
||||||
if ((flags & SDL_initialized & SDL_INIT_TIMER)) {
|
if ((flags & SDL_initialized & SDL_INIT_TIMER)) {
|
||||||
SDL_TimerQuit();
|
SDL_SubsystemRefCount[ msb32_idx(SDL_INIT_TIMER) ]--;
|
||||||
SDL_initialized &= ~SDL_INIT_TIMER;
|
if ( SDL_bInMainQuit || SDL_SubsystemRefCount[ msb32_idx(SDL_INIT_TIMER) ] == 0 )
|
||||||
|
{
|
||||||
|
SDL_TimerQuit();
|
||||||
|
SDL_initialized &= ~SDL_INIT_TIMER;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -207,6 +280,7 @@ SDL_WasInit(Uint32 flags)
|
||||||
void
|
void
|
||||||
SDL_Quit(void)
|
SDL_Quit(void)
|
||||||
{
|
{
|
||||||
|
SDL_bInMainQuit = SDL_TRUE;
|
||||||
/* Quit all subsystems */
|
/* Quit all subsystems */
|
||||||
#if defined(__WIN32__)
|
#if defined(__WIN32__)
|
||||||
SDL_HelperWindowDestroy();
|
SDL_HelperWindowDestroy();
|
||||||
|
@ -219,6 +293,9 @@ SDL_Quit(void)
|
||||||
SDL_ClearHints();
|
SDL_ClearHints();
|
||||||
SDL_AssertionsQuit();
|
SDL_AssertionsQuit();
|
||||||
SDL_LogResetPriorities();
|
SDL_LogResetPriorities();
|
||||||
|
|
||||||
|
SDL_memset( SDL_SubsystemRefCount, 0x0, sizeof(SDL_SubsystemRefCount) );
|
||||||
|
SDL_bInMainQuit = SDL_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get the library version number */
|
/* Get the library version number */
|
||||||
|
|
|
@ -70,7 +70,7 @@ static __inline__ SDL_bool
|
||||||
SDL_ShouldPollJoystick()
|
SDL_ShouldPollJoystick()
|
||||||
{
|
{
|
||||||
#if !SDL_JOYSTICK_DISABLED
|
#if !SDL_JOYSTICK_DISABLED
|
||||||
if (SDL_numjoysticks &&
|
if (SDL_PrivateJoystickNeedsPolling() &&
|
||||||
(!SDL_disabled_events[SDL_JOYAXISMOTION >> 8] ||
|
(!SDL_disabled_events[SDL_JOYAXISMOTION >> 8] ||
|
||||||
SDL_JoystickEventState(SDL_QUERY))) {
|
SDL_JoystickEventState(SDL_QUERY))) {
|
||||||
return SDL_TRUE;
|
return SDL_TRUE;
|
||||||
|
|
|
@ -238,7 +238,7 @@ SDL_JoystickIsHaptic(SDL_Joystick * joystick)
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
/* Must be a valid joystick */
|
/* Must be a valid joystick */
|
||||||
if (!SDL_PrivateJoystickValid(&joystick)) {
|
if (!SDL_PrivateJoystickValid(joystick)) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -263,7 +263,7 @@ SDL_HapticOpenFromJoystick(SDL_Joystick * joystick)
|
||||||
SDL_Haptic *haptic;
|
SDL_Haptic *haptic;
|
||||||
|
|
||||||
/* Must be a valid joystick */
|
/* Must be a valid joystick */
|
||||||
if (!SDL_PrivateJoystickValid(&joystick)) {
|
if (!SDL_PrivateJoystickValid(joystick)) {
|
||||||
SDL_SetError("Haptic: Joystick isn't valid.");
|
SDL_SetError("Haptic: Joystick isn't valid.");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -520,7 +520,7 @@ SDL_SYS_HapticMouse(void)
|
||||||
|
|
||||||
/* Grab the first mouse haptic device we find. */
|
/* Grab the first mouse haptic device we find. */
|
||||||
for (i = 0; i < SDL_numhaptics; i++) {
|
for (i = 0; i < SDL_numhaptics; i++) {
|
||||||
if (SDL_hapticlist[i].capabilities.dwDevType == DIDEVTYPE_MOUSE) {
|
if (SDL_hapticlist[i].capabilities.dwDevType == DI8DEVCLASS_POINTER ) {
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
1125
src/joystick/SDL_gamecontroller.c
Normal file
1125
src/joystick/SDL_gamecontroller.c
Normal file
File diff suppressed because it is too large
Load diff
|
@ -24,34 +24,22 @@
|
||||||
|
|
||||||
#include "SDL_events.h"
|
#include "SDL_events.h"
|
||||||
#include "SDL_sysjoystick.h"
|
#include "SDL_sysjoystick.h"
|
||||||
#include "SDL_joystick_c.h"
|
|
||||||
#include "SDL_assert.h"
|
#include "SDL_assert.h"
|
||||||
|
|
||||||
#if !SDL_EVENTS_DISABLED
|
#if !SDL_EVENTS_DISABLED
|
||||||
#include "../events/SDL_events_c.h"
|
#include "../events/SDL_events_c.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Uint8 SDL_numjoysticks = 0;
|
SDL_Joystick *SDL_joysticks = NULL;
|
||||||
SDL_Joystick **SDL_joysticks = NULL;
|
|
||||||
|
|
||||||
int
|
int
|
||||||
SDL_JoystickInit(void)
|
SDL_JoystickInit(void)
|
||||||
{
|
{
|
||||||
int arraylen;
|
|
||||||
int status;
|
int status;
|
||||||
|
|
||||||
SDL_numjoysticks = 0;
|
|
||||||
status = SDL_SYS_JoystickInit();
|
status = SDL_SYS_JoystickInit();
|
||||||
if (status >= 0) {
|
if (status >= 0) {
|
||||||
arraylen = (status + 1) * sizeof(*SDL_joysticks);
|
status = 0;
|
||||||
SDL_joysticks = (SDL_Joystick **) SDL_malloc(arraylen);
|
|
||||||
if (SDL_joysticks == NULL) {
|
|
||||||
SDL_numjoysticks = 0;
|
|
||||||
} else {
|
|
||||||
SDL_memset(SDL_joysticks, 0, arraylen);
|
|
||||||
SDL_numjoysticks = status;
|
|
||||||
}
|
|
||||||
status = 0;
|
|
||||||
}
|
}
|
||||||
return (status);
|
return (status);
|
||||||
}
|
}
|
||||||
|
@ -62,20 +50,20 @@ SDL_JoystickInit(void)
|
||||||
int
|
int
|
||||||
SDL_NumJoysticks(void)
|
SDL_NumJoysticks(void)
|
||||||
{
|
{
|
||||||
return SDL_numjoysticks;
|
return SDL_SYS_NumJoysticks();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Get the implementation dependent name of a joystick
|
* Get the implementation dependent name of a joystick
|
||||||
*/
|
*/
|
||||||
const char *
|
const char *
|
||||||
SDL_JoystickName(int device_index)
|
SDL_JoystickNameForIndex(int device_index)
|
||||||
{
|
{
|
||||||
if ((device_index < 0) || (device_index >= SDL_numjoysticks)) {
|
if ((device_index < 0) || (device_index >= SDL_NumJoysticks())) {
|
||||||
SDL_SetError("There are %d joysticks available", SDL_numjoysticks);
|
SDL_SetError("There are %d joysticks available", SDL_NumJoysticks());
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
return (SDL_SYS_JoystickName(device_index));
|
return (SDL_SYS_JoystickNameForIndex(device_index));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -88,21 +76,27 @@ SDL_JoystickName(int device_index)
|
||||||
SDL_Joystick *
|
SDL_Joystick *
|
||||||
SDL_JoystickOpen(int device_index)
|
SDL_JoystickOpen(int device_index)
|
||||||
{
|
{
|
||||||
int i;
|
|
||||||
SDL_Joystick *joystick;
|
SDL_Joystick *joystick;
|
||||||
|
SDL_Joystick *joysticklist;
|
||||||
|
const char *joystickname = NULL;
|
||||||
|
|
||||||
if ((device_index < 0) || (device_index >= SDL_numjoysticks)) {
|
if ((device_index < 0) || (device_index >= SDL_NumJoysticks())) {
|
||||||
SDL_SetError("There are %d joysticks available", SDL_numjoysticks);
|
SDL_SetError("There are %d joysticks available", SDL_NumJoysticks());
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If the joystick is already open, return it */
|
joysticklist = SDL_joysticks;
|
||||||
for (i = 0; SDL_joysticks[i]; ++i) {
|
/* If the joystick is already open, return it
|
||||||
if (device_index == SDL_joysticks[i]->index) {
|
* it is important that we have a single joystick * for each instance id
|
||||||
joystick = SDL_joysticks[i];
|
*/
|
||||||
++joystick->ref_count;
|
while ( joysticklist )
|
||||||
return (joystick);
|
{
|
||||||
}
|
if ( SDL_SYS_GetInstanceIdOfDeviceIndex(device_index) == joysticklist->instance_id ) {
|
||||||
|
joystick = joysticklist;
|
||||||
|
++joystick->ref_count;
|
||||||
|
return (joystick);
|
||||||
|
}
|
||||||
|
joysticklist = joysticklist->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Create and initialize the joystick */
|
/* Create and initialize the joystick */
|
||||||
|
@ -113,11 +107,17 @@ SDL_JoystickOpen(int device_index)
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_memset(joystick, 0, (sizeof *joystick));
|
SDL_memset(joystick, 0, (sizeof *joystick));
|
||||||
joystick->index = device_index;
|
if (SDL_SYS_JoystickOpen(joystick, device_index) < 0) {
|
||||||
if (SDL_SYS_JoystickOpen(joystick) < 0) {
|
|
||||||
SDL_free(joystick);
|
SDL_free(joystick);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
joystickname = SDL_SYS_JoystickNameForIndex( device_index );
|
||||||
|
if ( joystickname )
|
||||||
|
joystick->name = SDL_strdup( joystickname );
|
||||||
|
else
|
||||||
|
joystick->name = NULL;
|
||||||
|
|
||||||
if (joystick->naxes > 0) {
|
if (joystick->naxes > 0) {
|
||||||
joystick->axes = (Sint16 *) SDL_malloc
|
joystick->axes = (Sint16 *) SDL_malloc
|
||||||
(joystick->naxes * sizeof(Sint16));
|
(joystick->naxes * sizeof(Sint16));
|
||||||
|
@ -158,59 +158,37 @@ SDL_JoystickOpen(int device_index)
|
||||||
|
|
||||||
/* Add joystick to list */
|
/* Add joystick to list */
|
||||||
++joystick->ref_count;
|
++joystick->ref_count;
|
||||||
for (i = 0; SDL_joysticks[i]; ++i)
|
/* Link the joystick in the list */
|
||||||
/* Skip to next joystick */ ;
|
joystick->next = SDL_joysticks;
|
||||||
SDL_joysticks[i] = joystick;
|
SDL_joysticks = joystick;
|
||||||
|
|
||||||
|
SDL_SYS_JoystickUpdate( joystick );
|
||||||
|
|
||||||
return (joystick);
|
return (joystick);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Returns 1 if the joystick has been opened, or 0 if it has not.
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
SDL_JoystickOpened(int device_index)
|
|
||||||
{
|
|
||||||
int i, opened;
|
|
||||||
|
|
||||||
opened = 0;
|
|
||||||
for (i = 0; SDL_joysticks[i]; ++i) {
|
|
||||||
if (SDL_joysticks[i]->index == (Uint8) device_index) {
|
|
||||||
opened = 1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return (opened);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Checks to make sure the joystick is valid.
|
* Checks to make sure the joystick is valid.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
SDL_PrivateJoystickValid(SDL_Joystick ** joystick)
|
SDL_PrivateJoystickValid(SDL_Joystick * joystick)
|
||||||
{
|
{
|
||||||
int valid;
|
int valid;
|
||||||
|
|
||||||
if (*joystick == NULL) {
|
if ( joystick == NULL ) {
|
||||||
SDL_SetError("Joystick hasn't been opened yet");
|
SDL_SetError("Joystick hasn't been opened yet");
|
||||||
valid = 0;
|
valid = 0;
|
||||||
} else {
|
} else {
|
||||||
valid = 1;
|
valid = 1;
|
||||||
}
|
}
|
||||||
return valid;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
if ( joystick && joystick->closed )
|
||||||
* Get the device index of an opened joystick.
|
{
|
||||||
*/
|
valid = 0;
|
||||||
int
|
}
|
||||||
SDL_JoystickIndex(SDL_Joystick * joystick)
|
|
||||||
{
|
return valid;
|
||||||
if (!SDL_PrivateJoystickValid(&joystick)) {
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
return (joystick->index);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -219,7 +197,7 @@ SDL_JoystickIndex(SDL_Joystick * joystick)
|
||||||
int
|
int
|
||||||
SDL_JoystickNumAxes(SDL_Joystick * joystick)
|
SDL_JoystickNumAxes(SDL_Joystick * joystick)
|
||||||
{
|
{
|
||||||
if (!SDL_PrivateJoystickValid(&joystick)) {
|
if (!SDL_PrivateJoystickValid(joystick)) {
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
return (joystick->naxes);
|
return (joystick->naxes);
|
||||||
|
@ -231,7 +209,7 @@ SDL_JoystickNumAxes(SDL_Joystick * joystick)
|
||||||
int
|
int
|
||||||
SDL_JoystickNumHats(SDL_Joystick * joystick)
|
SDL_JoystickNumHats(SDL_Joystick * joystick)
|
||||||
{
|
{
|
||||||
if (!SDL_PrivateJoystickValid(&joystick)) {
|
if (!SDL_PrivateJoystickValid(joystick)) {
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
return (joystick->nhats);
|
return (joystick->nhats);
|
||||||
|
@ -243,7 +221,7 @@ SDL_JoystickNumHats(SDL_Joystick * joystick)
|
||||||
int
|
int
|
||||||
SDL_JoystickNumBalls(SDL_Joystick * joystick)
|
SDL_JoystickNumBalls(SDL_Joystick * joystick)
|
||||||
{
|
{
|
||||||
if (!SDL_PrivateJoystickValid(&joystick)) {
|
if (!SDL_PrivateJoystickValid(joystick)) {
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
return (joystick->nballs);
|
return (joystick->nballs);
|
||||||
|
@ -255,7 +233,7 @@ SDL_JoystickNumBalls(SDL_Joystick * joystick)
|
||||||
int
|
int
|
||||||
SDL_JoystickNumButtons(SDL_Joystick * joystick)
|
SDL_JoystickNumButtons(SDL_Joystick * joystick)
|
||||||
{
|
{
|
||||||
if (!SDL_PrivateJoystickValid(&joystick)) {
|
if (!SDL_PrivateJoystickValid(joystick)) {
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
return (joystick->nbuttons);
|
return (joystick->nbuttons);
|
||||||
|
@ -269,7 +247,7 @@ SDL_JoystickGetAxis(SDL_Joystick * joystick, int axis)
|
||||||
{
|
{
|
||||||
Sint16 state;
|
Sint16 state;
|
||||||
|
|
||||||
if (!SDL_PrivateJoystickValid(&joystick)) {
|
if (!SDL_PrivateJoystickValid(joystick)) {
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
if (axis < joystick->naxes) {
|
if (axis < joystick->naxes) {
|
||||||
|
@ -289,7 +267,7 @@ SDL_JoystickGetHat(SDL_Joystick * joystick, int hat)
|
||||||
{
|
{
|
||||||
Uint8 state;
|
Uint8 state;
|
||||||
|
|
||||||
if (!SDL_PrivateJoystickValid(&joystick)) {
|
if (!SDL_PrivateJoystickValid(joystick)) {
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
if (hat < joystick->nhats) {
|
if (hat < joystick->nhats) {
|
||||||
|
@ -309,7 +287,7 @@ SDL_JoystickGetBall(SDL_Joystick * joystick, int ball, int *dx, int *dy)
|
||||||
{
|
{
|
||||||
int retval;
|
int retval;
|
||||||
|
|
||||||
if (!SDL_PrivateJoystickValid(&joystick)) {
|
if (!SDL_PrivateJoystickValid(joystick)) {
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -338,7 +316,7 @@ SDL_JoystickGetButton(SDL_Joystick * joystick, int button)
|
||||||
{
|
{
|
||||||
Uint8 state;
|
Uint8 state;
|
||||||
|
|
||||||
if (!SDL_PrivateJoystickValid(&joystick)) {
|
if (!SDL_PrivateJoystickValid(joystick)) {
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
if (button < joystick->nbuttons) {
|
if (button < joystick->nbuttons) {
|
||||||
|
@ -350,15 +328,56 @@ SDL_JoystickGetButton(SDL_Joystick * joystick, int button)
|
||||||
return (state);
|
return (state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Return if the joystick in question is currently attached to the system,
|
||||||
|
* \return 0 if not plugged in, 1 if still present.
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
SDL_JoystickGetAttached( SDL_Joystick * joystick )
|
||||||
|
{
|
||||||
|
if (!SDL_PrivateJoystickValid(joystick)) {
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
return SDL_SYS_JoystickAttached(joystick);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Get the instance id for this opened joystick
|
||||||
|
*/
|
||||||
|
SDL_JoystickID
|
||||||
|
SDL_JoystickInstanceID( SDL_Joystick * joystick )
|
||||||
|
{
|
||||||
|
if (!SDL_PrivateJoystickValid(joystick)) {
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (joystick->instance_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Get the friendly name of this joystick
|
||||||
|
*/
|
||||||
|
const char *
|
||||||
|
SDL_JoystickName(SDL_Joystick * joystick)
|
||||||
|
{
|
||||||
|
if (!SDL_PrivateJoystickValid(joystick)) {
|
||||||
|
return (NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (joystick->name);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Close a joystick previously opened with SDL_JoystickOpen()
|
* Close a joystick previously opened with SDL_JoystickOpen()
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
SDL_JoystickClose(SDL_Joystick * joystick)
|
SDL_JoystickClose(SDL_Joystick * joystick)
|
||||||
{
|
{
|
||||||
int i;
|
SDL_Joystick *joysticklist;
|
||||||
|
SDL_Joystick *joysticklistprev;
|
||||||
|
|
||||||
if (!SDL_PrivateJoystickValid(&joystick)) {
|
if (!joystick) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -369,14 +388,30 @@ SDL_JoystickClose(SDL_Joystick * joystick)
|
||||||
|
|
||||||
SDL_SYS_JoystickClose(joystick);
|
SDL_SYS_JoystickClose(joystick);
|
||||||
|
|
||||||
/* Remove joystick from list */
|
joysticklist = SDL_joysticks;
|
||||||
for (i = 0; SDL_joysticks[i]; ++i) {
|
joysticklistprev = NULL;
|
||||||
if (joystick == SDL_joysticks[i]) {
|
while ( joysticklist )
|
||||||
SDL_memmove(&SDL_joysticks[i], &SDL_joysticks[i + 1],
|
{
|
||||||
(SDL_numjoysticks - i) * sizeof(joystick));
|
if (joystick == joysticklist)
|
||||||
break;
|
{
|
||||||
}
|
if ( joysticklistprev )
|
||||||
}
|
{
|
||||||
|
// unlink this entry
|
||||||
|
joysticklistprev->next = joysticklist->next;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SDL_joysticks = joystick->next;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
joysticklistprev = joysticklist;
|
||||||
|
joysticklist = joysticklist->next;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (joystick->name)
|
||||||
|
SDL_free(joystick->name);
|
||||||
|
|
||||||
/* Free the data associated with this joystick */
|
/* Free the data associated with this joystick */
|
||||||
if (joystick->axes) {
|
if (joystick->axes) {
|
||||||
|
@ -397,26 +432,15 @@ SDL_JoystickClose(SDL_Joystick * joystick)
|
||||||
void
|
void
|
||||||
SDL_JoystickQuit(void)
|
SDL_JoystickQuit(void)
|
||||||
{
|
{
|
||||||
const int numsticks = SDL_numjoysticks;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
/* Stop the event polling */
|
/* Stop the event polling */
|
||||||
SDL_numjoysticks = 0;
|
while ( SDL_joysticks )
|
||||||
|
{
|
||||||
for (i = numsticks; i--; ) {
|
SDL_joysticks->ref_count = 1;
|
||||||
SDL_Joystick *stick = SDL_joysticks[i];
|
SDL_JoystickClose(SDL_joysticks);
|
||||||
if (stick && (stick->ref_count >= 1)) {
|
}
|
||||||
stick->ref_count = 1;
|
|
||||||
SDL_JoystickClose(stick);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Quit the joystick setup */
|
/* Quit the joystick setup */
|
||||||
SDL_SYS_JoystickQuit();
|
SDL_SYS_JoystickQuit();
|
||||||
if (SDL_joysticks) {
|
|
||||||
SDL_free(SDL_joysticks);
|
|
||||||
SDL_joysticks = NULL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -441,14 +465,10 @@ SDL_PrivateJoystickAxis(SDL_Joystick * joystick, Uint8 axis, Sint16 value)
|
||||||
if (SDL_GetEventState(SDL_JOYAXISMOTION) == SDL_ENABLE) {
|
if (SDL_GetEventState(SDL_JOYAXISMOTION) == SDL_ENABLE) {
|
||||||
SDL_Event event;
|
SDL_Event event;
|
||||||
event.type = SDL_JOYAXISMOTION;
|
event.type = SDL_JOYAXISMOTION;
|
||||||
event.jaxis.which = joystick->index;
|
event.jaxis.which = joystick->instance_id;
|
||||||
event.jaxis.axis = axis;
|
event.jaxis.axis = axis;
|
||||||
event.jaxis.value = value;
|
event.jaxis.value = value;
|
||||||
if ((SDL_EventOK == NULL)
|
posted = SDL_PushEvent(&event) == 1;
|
||||||
|| (*SDL_EventOK) (SDL_EventOKParam, &event)) {
|
|
||||||
posted = 1;
|
|
||||||
SDL_PushEvent(&event);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#endif /* !SDL_EVENTS_DISABLED */
|
#endif /* !SDL_EVENTS_DISABLED */
|
||||||
return (posted);
|
return (posted);
|
||||||
|
@ -473,14 +493,10 @@ SDL_PrivateJoystickHat(SDL_Joystick * joystick, Uint8 hat, Uint8 value)
|
||||||
if (SDL_GetEventState(SDL_JOYHATMOTION) == SDL_ENABLE) {
|
if (SDL_GetEventState(SDL_JOYHATMOTION) == SDL_ENABLE) {
|
||||||
SDL_Event event;
|
SDL_Event event;
|
||||||
event.jhat.type = SDL_JOYHATMOTION;
|
event.jhat.type = SDL_JOYHATMOTION;
|
||||||
event.jhat.which = joystick->index;
|
event.jhat.which = joystick->instance_id;
|
||||||
event.jhat.hat = hat;
|
event.jhat.hat = hat;
|
||||||
event.jhat.value = value;
|
event.jhat.value = value;
|
||||||
if ((SDL_EventOK == NULL)
|
posted = SDL_PushEvent(&event) == 1;
|
||||||
|| (*SDL_EventOK) (SDL_EventOKParam, &event)) {
|
|
||||||
posted = 1;
|
|
||||||
SDL_PushEvent(&event);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#endif /* !SDL_EVENTS_DISABLED */
|
#endif /* !SDL_EVENTS_DISABLED */
|
||||||
return (posted);
|
return (posted);
|
||||||
|
@ -507,15 +523,11 @@ SDL_PrivateJoystickBall(SDL_Joystick * joystick, Uint8 ball,
|
||||||
if (SDL_GetEventState(SDL_JOYBALLMOTION) == SDL_ENABLE) {
|
if (SDL_GetEventState(SDL_JOYBALLMOTION) == SDL_ENABLE) {
|
||||||
SDL_Event event;
|
SDL_Event event;
|
||||||
event.jball.type = SDL_JOYBALLMOTION;
|
event.jball.type = SDL_JOYBALLMOTION;
|
||||||
event.jball.which = joystick->index;
|
event.jball.which = joystick->instance_id;
|
||||||
event.jball.ball = ball;
|
event.jball.ball = ball;
|
||||||
event.jball.xrel = xrel;
|
event.jball.xrel = xrel;
|
||||||
event.jball.yrel = yrel;
|
event.jball.yrel = yrel;
|
||||||
if ((SDL_EventOK == NULL)
|
posted = SDL_PushEvent(&event) == 1;
|
||||||
|| (*SDL_EventOK) (SDL_EventOKParam, &event)) {
|
|
||||||
posted = 1;
|
|
||||||
SDL_PushEvent(&event);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#endif /* !SDL_EVENTS_DISABLED */
|
#endif /* !SDL_EVENTS_DISABLED */
|
||||||
return (posted);
|
return (posted);
|
||||||
|
@ -553,14 +565,10 @@ SDL_PrivateJoystickButton(SDL_Joystick * joystick, Uint8 button, Uint8 state)
|
||||||
posted = 0;
|
posted = 0;
|
||||||
#if !SDL_EVENTS_DISABLED
|
#if !SDL_EVENTS_DISABLED
|
||||||
if (SDL_GetEventState(event.type) == SDL_ENABLE) {
|
if (SDL_GetEventState(event.type) == SDL_ENABLE) {
|
||||||
event.jbutton.which = joystick->index;
|
event.jbutton.which = joystick->instance_id;
|
||||||
event.jbutton.button = button;
|
event.jbutton.button = button;
|
||||||
event.jbutton.state = state;
|
event.jbutton.state = state;
|
||||||
if ((SDL_EventOK == NULL)
|
posted = SDL_PushEvent(&event) == 1;
|
||||||
|| (*SDL_EventOK) (SDL_EventOKParam, &event)) {
|
|
||||||
posted = 1;
|
|
||||||
SDL_PushEvent(&event);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#endif /* !SDL_EVENTS_DISABLED */
|
#endif /* !SDL_EVENTS_DISABLED */
|
||||||
return (posted);
|
return (posted);
|
||||||
|
@ -569,11 +577,39 @@ SDL_PrivateJoystickButton(SDL_Joystick * joystick, Uint8 button, Uint8 state)
|
||||||
void
|
void
|
||||||
SDL_JoystickUpdate(void)
|
SDL_JoystickUpdate(void)
|
||||||
{
|
{
|
||||||
int i;
|
SDL_Joystick *joystick;
|
||||||
|
|
||||||
for (i = 0; SDL_joysticks[i]; ++i) {
|
joystick = SDL_joysticks;
|
||||||
SDL_SYS_JoystickUpdate(SDL_joysticks[i]);
|
while ( joystick )
|
||||||
}
|
{
|
||||||
|
SDL_Joystick *joysticknext;
|
||||||
|
/* save off the next pointer, the Update call may cause a joystick removed event
|
||||||
|
* and cause our joystick pointer to be freed
|
||||||
|
*/
|
||||||
|
joysticknext = joystick->next;
|
||||||
|
|
||||||
|
SDL_SYS_JoystickUpdate( joystick );
|
||||||
|
|
||||||
|
if ( joystick->closed && joystick->uncentered )
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
joystick->uncentered = 0;
|
||||||
|
|
||||||
|
// Tell the app that everything is centered/unpressed...
|
||||||
|
for (i = 0; i < joystick->naxes; i++)
|
||||||
|
SDL_PrivateJoystickAxis(joystick, i, 0);
|
||||||
|
|
||||||
|
for (i = 0; i < joystick->nbuttons; i++)
|
||||||
|
SDL_PrivateJoystickButton(joystick, i, 0);
|
||||||
|
|
||||||
|
for (i = 0; i < joystick->nhats; i++)
|
||||||
|
SDL_PrivateJoystickHat(joystick, i, SDL_HAT_CENTERED);
|
||||||
|
}
|
||||||
|
|
||||||
|
joystick = joysticknext;
|
||||||
|
}
|
||||||
|
|
||||||
|
SDL_SYS_JoystickDetect();
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
@ -584,7 +620,7 @@ SDL_JoystickEventState(int state)
|
||||||
#else
|
#else
|
||||||
const Uint32 event_list[] = {
|
const Uint32 event_list[] = {
|
||||||
SDL_JOYAXISMOTION, SDL_JOYBALLMOTION, SDL_JOYHATMOTION,
|
SDL_JOYAXISMOTION, SDL_JOYBALLMOTION, SDL_JOYHATMOTION,
|
||||||
SDL_JOYBUTTONDOWN, SDL_JOYBUTTONUP,
|
SDL_JOYBUTTONDOWN, SDL_JOYBUTTONUP, SDL_JOYDEVICEADDED, SDL_JOYDEVICEREMOVED
|
||||||
};
|
};
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
|
@ -608,4 +644,121 @@ SDL_JoystickEventState(int state)
|
||||||
#endif /* SDL_EVENTS_DISABLED */
|
#endif /* SDL_EVENTS_DISABLED */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* return 1 if you want to run the joystick update loop this frame, used by hotplug support */
|
||||||
|
int
|
||||||
|
SDL_PrivateJoystickNeedsPolling()
|
||||||
|
{
|
||||||
|
if ( SDL_SYS_JoystickNeedsPolling() )
|
||||||
|
{
|
||||||
|
// sys layer needs us to think
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// otherwise only do it if a joystick is opened
|
||||||
|
return SDL_joysticks != NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* return the guid for this index*/
|
||||||
|
JoystickGUID SDL_JoystickGetDeviceGUID( int device_index )
|
||||||
|
{
|
||||||
|
return SDL_SYS_PrivateJoystickGetDeviceID( device_index );
|
||||||
|
}
|
||||||
|
|
||||||
|
/* return the guid for this openeded device*/
|
||||||
|
JoystickGUID SDL_JoystickGetGUID(SDL_Joystick * joystick)
|
||||||
|
{
|
||||||
|
return SDL_SYS_PrivateJoystickGetGUID( joystick );
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* convert the guid to a printable string */
|
||||||
|
char *SDL_JoystickGetGUIDString(JoystickGUID guid)
|
||||||
|
{
|
||||||
|
static const char k_rgchHexToASCII[] = "0123456789abcdef";
|
||||||
|
char *pchOut = NULL;
|
||||||
|
char *pchString = NULL;
|
||||||
|
int i;
|
||||||
|
pchString = SDL_malloc(33); // 16 bytes
|
||||||
|
if ( !pchString )
|
||||||
|
{
|
||||||
|
SDL_OutOfMemory();
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
pchOut = pchString;
|
||||||
|
|
||||||
|
for ( i = 0; i < sizeof(guid); i++ )
|
||||||
|
{
|
||||||
|
// each input byte writes 2 ascii chars, and might write a null byte.
|
||||||
|
// If we don't have room for next input byte, stop
|
||||||
|
unsigned char c = guid.data[i];
|
||||||
|
|
||||||
|
*pchOut++ = k_rgchHexToASCII[ c >> 4 ];
|
||||||
|
*pchOut++ = k_rgchHexToASCII[ c & 0x0F ];
|
||||||
|
}
|
||||||
|
*pchOut = '\0';
|
||||||
|
return pchString;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Purpose: Returns the 4 bit nibble for a hex character
|
||||||
|
// Input : c -
|
||||||
|
// Output : unsigned char
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
static unsigned char nibble( char c )
|
||||||
|
{
|
||||||
|
if ( ( c >= '0' ) &&
|
||||||
|
( c <= '9' ) )
|
||||||
|
{
|
||||||
|
return (unsigned char)(c - '0');
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( ( c >= 'A' ) &&
|
||||||
|
( c <= 'F' ) )
|
||||||
|
{
|
||||||
|
return (unsigned char)(c - 'A' + 0x0a);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( ( c >= 'a' ) &&
|
||||||
|
( c <= 'f' ) )
|
||||||
|
{
|
||||||
|
return (unsigned char)(c - 'a' + 0x0a);
|
||||||
|
}
|
||||||
|
|
||||||
|
// received an invalid character, and no real way to return an error
|
||||||
|
// AssertMsg1( false, "Q_nibble invalid hex character '%c' ", c );
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* convert the string version of a joystick guid to the struct */
|
||||||
|
JoystickGUID SDL_JoystickGetGUIDFromString(const char *pchGUID)
|
||||||
|
{
|
||||||
|
JoystickGUID guid;
|
||||||
|
int maxoutputbytes= sizeof(guid);
|
||||||
|
int len = SDL_strlen( pchGUID );
|
||||||
|
Uint8 *p;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
// Make sure it's even
|
||||||
|
len = ( len ) & ~0x1;
|
||||||
|
|
||||||
|
SDL_memset( &guid, 0x00, sizeof(guid) );
|
||||||
|
|
||||||
|
p = (Uint8 *)&guid;
|
||||||
|
for ( i = 0;
|
||||||
|
( i < len ) && ( ( p - (Uint8 *)&guid ) < maxoutputbytes );
|
||||||
|
i+=2, p++ )
|
||||||
|
{
|
||||||
|
*p = ( nibble( pchGUID[i] ) << 4 ) | nibble( pchGUID[i+1] );
|
||||||
|
}
|
||||||
|
|
||||||
|
return guid;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* vi: set ts=4 sw=4 expandtab: */
|
/* vi: set ts=4 sw=4 expandtab: */
|
||||||
|
|
|
@ -23,13 +23,15 @@
|
||||||
/* Useful functions and variables from SDL_joystick.c */
|
/* Useful functions and variables from SDL_joystick.c */
|
||||||
#include "SDL_joystick.h"
|
#include "SDL_joystick.h"
|
||||||
|
|
||||||
/* The number of available joysticks on the system */
|
|
||||||
extern Uint8 SDL_numjoysticks;
|
|
||||||
|
|
||||||
/* 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);
|
||||||
|
|
||||||
|
/* Initialization and shutdown functions */
|
||||||
|
extern int SDL_GameControllerInit(void);
|
||||||
|
extern void SDL_GameControllerQuit(void);
|
||||||
|
|
||||||
|
|
||||||
/* Internal event queueing functions */
|
/* Internal event queueing functions */
|
||||||
extern int SDL_PrivateJoystickAxis(SDL_Joystick * joystick,
|
extern int SDL_PrivateJoystickAxis(SDL_Joystick * joystick,
|
||||||
Uint8 axis, Sint16 value);
|
Uint8 axis, Sint16 value);
|
||||||
|
@ -40,7 +42,10 @@ extern int SDL_PrivateJoystickHat(SDL_Joystick * joystick,
|
||||||
extern int SDL_PrivateJoystickButton(SDL_Joystick * joystick,
|
extern int SDL_PrivateJoystickButton(SDL_Joystick * joystick,
|
||||||
Uint8 button, Uint8 state);
|
Uint8 button, Uint8 state);
|
||||||
|
|
||||||
|
/* Helper function to let lower sys layer tell the event system if the joystick code needs to think */
|
||||||
|
extern int SDL_PrivateJoystickNeedsPolling();
|
||||||
|
|
||||||
/* Internal sanity checking functions */
|
/* Internal sanity checking functions */
|
||||||
extern int SDL_PrivateJoystickValid(SDL_Joystick ** joystick);
|
extern int SDL_PrivateJoystickValid(SDL_Joystick * joystick);
|
||||||
|
|
||||||
/* vi: set ts=4 sw=4 expandtab: */
|
/* vi: set ts=4 sw=4 expandtab: */
|
||||||
|
|
|
@ -23,12 +23,13 @@
|
||||||
/* This is the system specific header for the SDL joystick API */
|
/* This is the system specific header for the SDL joystick API */
|
||||||
|
|
||||||
#include "SDL_joystick.h"
|
#include "SDL_joystick.h"
|
||||||
|
#include "SDL_joystick_c.h"
|
||||||
|
|
||||||
/* The SDL joystick structure */
|
/* The SDL joystick structure */
|
||||||
struct _SDL_Joystick
|
struct _SDL_Joystick
|
||||||
{
|
{
|
||||||
Uint8 index; /* Device index */
|
int instance_id; /* Device instance, monotonically increasing from 0 */
|
||||||
const char *name; /* Joystick name - system dependent */
|
char *name; /* Joystick name - system dependent */
|
||||||
|
|
||||||
int naxes; /* Number of axis controls on the joystick */
|
int naxes; /* Number of axis controls on the joystick */
|
||||||
Sint16 *axes; /* Current axis states */
|
Sint16 *axes; /* Current axis states */
|
||||||
|
@ -49,6 +50,10 @@ struct _SDL_Joystick
|
||||||
struct joystick_hwdata *hwdata; /* Driver dependent information */
|
struct joystick_hwdata *hwdata; /* Driver dependent information */
|
||||||
|
|
||||||
int ref_count; /* Reference count for multiple opens */
|
int ref_count; /* Reference count for multiple opens */
|
||||||
|
|
||||||
|
Uint8 closed; /* 1 if this device is no longer valid */
|
||||||
|
Uint8 uncentered; /* 1 if this device needs to have its state reset to 0 */
|
||||||
|
struct _SDL_Joystick *next; /* pointer to next joystick we have allocated */
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Function to scan the system for joysticks.
|
/* Function to scan the system for joysticks.
|
||||||
|
@ -59,14 +64,17 @@ struct _SDL_Joystick
|
||||||
extern int SDL_SYS_JoystickInit(void);
|
extern int SDL_SYS_JoystickInit(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_JoystickName(int index);
|
extern const char *SDL_SYS_JoystickNameForIndex(int index);
|
||||||
|
|
||||||
|
/* Function to get the current instance id of the joystick located at device_index */
|
||||||
|
extern SDL_JoystickID SDL_SYS_GetInstanceIdOfDeviceIndex( int device_index );
|
||||||
|
|
||||||
/* Function to open a joystick for use.
|
/* Function to open a joystick for use.
|
||||||
The joystick to open is specified by the index field of the joystick.
|
The joystick to open is specified by the index field of the joystick.
|
||||||
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.
|
||||||
*/
|
*/
|
||||||
extern int SDL_SYS_JoystickOpen(SDL_Joystick * joystick);
|
extern int SDL_SYS_JoystickOpen(SDL_Joystick * joystick, int device_index );
|
||||||
|
|
||||||
/* Function to update the state of a joystick - called as a device poll.
|
/* Function to update the state of a joystick - called as a device poll.
|
||||||
* This function shouldn't update the joystick structure directly,
|
* This function shouldn't update the joystick structure directly,
|
||||||
|
@ -81,4 +89,32 @@ extern void SDL_SYS_JoystickClose(SDL_Joystick * joystick);
|
||||||
/* Function to perform any system-specific joystick related cleanup */
|
/* Function to perform any system-specific joystick related cleanup */
|
||||||
extern void SDL_SYS_JoystickQuit(void);
|
extern void SDL_SYS_JoystickQuit(void);
|
||||||
|
|
||||||
|
/* Function to query if the joystick is currently attached
|
||||||
|
* It returns 1 if attached, 0 otherwise.
|
||||||
|
*/
|
||||||
|
extern int SDL_SYS_JoystickAttached(SDL_Joystick * joystick);
|
||||||
|
|
||||||
|
/* Function to return the number of joystick devices plugged in right now*/
|
||||||
|
extern int SDL_SYS_NumJoysticks();
|
||||||
|
|
||||||
|
/* Function to cause any queued joystick insertions to be processed
|
||||||
|
*/
|
||||||
|
extern void SDL_SYS_JoystickDetect();
|
||||||
|
|
||||||
|
/* Function to determine if the joystick loop needs to run right now
|
||||||
|
*/
|
||||||
|
extern int SDL_SYS_JoystickNeedsPolling();
|
||||||
|
|
||||||
|
/* Function to return the stable GUID for a plugged in device
|
||||||
|
*/
|
||||||
|
extern JoystickGUID SDL_SYS_PrivateJoystickGetDeviceID( int device_index );
|
||||||
|
|
||||||
|
/* Function to return the stable GUID for a opened joystick
|
||||||
|
*/
|
||||||
|
extern JoystickGUID SDL_SYS_PrivateJoystickGetGUID(SDL_Joystick * joystick);
|
||||||
|
|
||||||
|
#ifdef __WIN32__
|
||||||
|
/* Function to get the current instance id of the joystick located at device_index */
|
||||||
|
extern int SDL_SYS_IsXInputDeviceIndex( int device_index );
|
||||||
|
#endif
|
||||||
/* vi: set ts=4 sw=4 expandtab: */
|
/* vi: set ts=4 sw=4 expandtab: */
|
||||||
|
|
0
src/joystick/beos/SDL_bejoystick.cc
Normal file → Executable file
0
src/joystick/beos/SDL_bejoystick.cc
Normal file → Executable file
|
@ -42,6 +42,7 @@
|
||||||
#include <IOKit/hid/IOHIDKeys.h>
|
#include <IOKit/hid/IOHIDKeys.h>
|
||||||
#include <CoreFoundation/CoreFoundation.h>
|
#include <CoreFoundation/CoreFoundation.h>
|
||||||
#include <Carbon/Carbon.h> /* for NewPtrClear, DisposePtr */
|
#include <Carbon/Carbon.h> /* for NewPtrClear, DisposePtr */
|
||||||
|
#include <IOKit/IOMessage.h>
|
||||||
|
|
||||||
/* For force feedback testing. */
|
/* For force feedback testing. */
|
||||||
#include <ForceFeedback/ForceFeedback.h>
|
#include <ForceFeedback/ForceFeedback.h>
|
||||||
|
@ -51,11 +52,21 @@
|
||||||
#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"
|
||||||
|
#if !SDL_EVENTS_DISABLED
|
||||||
|
#include "../../events/SDL_events_c.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* Linked list of all available devices */
|
/* Linked list of all available devices */
|
||||||
static recDevice *gpDeviceList = NULL;
|
static recDevice *gpDeviceList = NULL;
|
||||||
|
/* OSX reference to the notification object that tells us about device insertion/removal */
|
||||||
|
IONotificationPortRef notificationPort = 0;
|
||||||
|
/* if 1 then a device was added since the last update call */
|
||||||
|
Uint8 s_bDeviceAdded = 0;
|
||||||
|
|
||||||
|
/* static incrementing counter for new joystick devices seen on the system. Devices should start with index 0 */
|
||||||
|
static int s_joystick_instance_id = -1;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
HIDReportErrorNum(char *strError, long numError)
|
HIDReportErrorNum(char *strError, long numError)
|
||||||
|
@ -115,10 +126,20 @@ HIDRemovalCallback(void *target, IOReturn result, void *refcon, void *sender)
|
||||||
{
|
{
|
||||||
recDevice *device = (recDevice *) refcon;
|
recDevice *device = (recDevice *) refcon;
|
||||||
device->removed = 1;
|
device->removed = 1;
|
||||||
device->uncentered = 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Called by the io port notifier on removal of this device
|
||||||
|
*/
|
||||||
|
void JoystickDeviceWasRemovedCallback( void * refcon, io_service_t service, natural_t messageType, void * messageArgument )
|
||||||
|
{
|
||||||
|
if( messageType == kIOMessageServiceIsTerminated && refcon )
|
||||||
|
{
|
||||||
|
recDevice *device = (recDevice *) refcon;
|
||||||
|
device->removed = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Create and open an interface to device, required prior to extracting values or building queues.
|
/* Create and open an interface to device, required prior to extracting values or building queues.
|
||||||
* Note: appliction now owns the device and must close and release it prior to exiting
|
* Note: appliction now owns the device and must close and release it prior to exiting
|
||||||
|
@ -162,10 +183,34 @@ HIDCreateOpenDeviceInterface(io_object_t hidDevice, recDevice * pDevice)
|
||||||
HIDReportErrorNum
|
HIDReportErrorNum
|
||||||
("Failed to open pDevice->interface via open.", result);
|
("Failed to open pDevice->interface via open.", result);
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
pDevice->portIterator = 0;
|
||||||
|
|
||||||
|
// It's okay if this fails, we have another detection method below
|
||||||
(*(pDevice->interface))->setRemovalCallback(pDevice->interface,
|
(*(pDevice->interface))->setRemovalCallback(pDevice->interface,
|
||||||
HIDRemovalCallback,
|
HIDRemovalCallback,
|
||||||
pDevice, pDevice);
|
pDevice, pDevice);
|
||||||
|
|
||||||
|
/* now connect notification for new devices */
|
||||||
|
pDevice->notificationPort = IONotificationPortCreate(kIOMasterPortDefault);
|
||||||
|
|
||||||
|
CFRunLoopAddSource(CFRunLoopGetCurrent(),
|
||||||
|
IONotificationPortGetRunLoopSource(pDevice->notificationPort),
|
||||||
|
kCFRunLoopDefaultMode);
|
||||||
|
|
||||||
|
// Register for notifications when a serial port is added to the system
|
||||||
|
result = IOServiceAddInterestNotification(pDevice->notificationPort,
|
||||||
|
hidDevice,
|
||||||
|
kIOGeneralInterest,
|
||||||
|
JoystickDeviceWasRemovedCallback,
|
||||||
|
pDevice,
|
||||||
|
&pDevice->portIterator);
|
||||||
|
if (kIOReturnSuccess != result) {
|
||||||
|
HIDReportErrorNum
|
||||||
|
("Failed to register for removal callback.", result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -195,6 +240,12 @@ HIDCloseReleaseInterface(recDevice * pDevice)
|
||||||
HIDReportErrorNum("Failed to release IOHIDDeviceInterface.",
|
HIDReportErrorNum("Failed to release IOHIDDeviceInterface.",
|
||||||
result);
|
result);
|
||||||
pDevice->interface = NULL;
|
pDevice->interface = NULL;
|
||||||
|
|
||||||
|
if ( pDevice->portIterator )
|
||||||
|
{
|
||||||
|
IOObjectRelease( pDevice->portIterator );
|
||||||
|
pDevice->portIterator = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -461,6 +512,26 @@ HIDGetDeviceInfo(io_object_t hidDevice, CFMutableDictionaryRef hidProperties,
|
||||||
("CFNumberGetValue error retrieving pDevice->usage.");
|
("CFNumberGetValue error retrieving pDevice->usage.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
refCF =
|
||||||
|
CFDictionaryGetValue(hidProperties,
|
||||||
|
CFSTR(kIOHIDVendorIDKey));
|
||||||
|
if (refCF) {
|
||||||
|
if (!CFNumberGetValue
|
||||||
|
(refCF, kCFNumberLongType, &pDevice->guid.data[0]))
|
||||||
|
SDL_SetError
|
||||||
|
("CFNumberGetValue error retrieving pDevice->guid.");
|
||||||
|
}
|
||||||
|
refCF =
|
||||||
|
CFDictionaryGetValue(hidProperties,
|
||||||
|
CFSTR(kIOHIDProductIDKey));
|
||||||
|
if (refCF) {
|
||||||
|
if (!CFNumberGetValue
|
||||||
|
(refCF, kCFNumberLongType, &pDevice->guid.data[8]))
|
||||||
|
SDL_SetError
|
||||||
|
("CFNumberGetValue error retrieving pDevice->guid[8].");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (NULL == refCF) { /* get top level element HID usage page or usage */
|
if (NULL == refCF) { /* get top level element HID usage page or usage */
|
||||||
/* use top level element instead */
|
/* use top level element instead */
|
||||||
CFTypeRef refCFTopElement = 0;
|
CFTypeRef refCFTopElement = 0;
|
||||||
|
@ -505,6 +576,7 @@ HIDBuildDevice(io_object_t hidDevice)
|
||||||
if (kIOReturnSuccess == result) {
|
if (kIOReturnSuccess == result) {
|
||||||
HIDGetDeviceInfo(hidDevice, hidProperties, pDevice); /* hidDevice used to find parents in registry tree */
|
HIDGetDeviceInfo(hidDevice, hidProperties, pDevice); /* hidDevice used to find parents in registry tree */
|
||||||
HIDGetCollectionElements(hidProperties, pDevice);
|
HIDGetCollectionElements(hidProperties, pDevice);
|
||||||
|
pDevice->instance_id = ++s_joystick_instance_id;
|
||||||
} else {
|
} else {
|
||||||
DisposePtr((Ptr) pDevice);
|
DisposePtr((Ptr) pDevice);
|
||||||
pDevice = NULL;
|
pDevice = NULL;
|
||||||
|
@ -569,6 +641,79 @@ HIDDisposeDevice(recDevice ** ppDevice)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Given an io_object_t from OSX adds a joystick device to our list if appropriate
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
AddDeviceHelper( io_object_t ioHIDDeviceObject )
|
||||||
|
{
|
||||||
|
recDevice *device;
|
||||||
|
|
||||||
|
/* build a device record */
|
||||||
|
device = HIDBuildDevice(ioHIDDeviceObject);
|
||||||
|
if (!device)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
/* Filter device list to non-keyboard/mouse stuff */
|
||||||
|
if ((device->usagePage != kHIDPage_GenericDesktop) ||
|
||||||
|
((device->usage != kHIDUsage_GD_Joystick &&
|
||||||
|
device->usage != kHIDUsage_GD_GamePad &&
|
||||||
|
device->usage != kHIDUsage_GD_MultiAxisController))) {
|
||||||
|
|
||||||
|
/* release memory for the device */
|
||||||
|
HIDDisposeDevice(&device);
|
||||||
|
DisposePtr((Ptr) device);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* We have to do some storage of the io_service_t for
|
||||||
|
* SDL_HapticOpenFromJoystick */
|
||||||
|
if (FFIsForceFeedback(ioHIDDeviceObject) == FF_OK) {
|
||||||
|
device->ffservice = ioHIDDeviceObject;
|
||||||
|
} else {
|
||||||
|
device->ffservice = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
device->send_open_event = 1;
|
||||||
|
s_bDeviceAdded = 1;
|
||||||
|
|
||||||
|
/* Add device to the end of the list */
|
||||||
|
if ( !gpDeviceList )
|
||||||
|
{
|
||||||
|
gpDeviceList = device;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
recDevice *curdevice;
|
||||||
|
|
||||||
|
curdevice = gpDeviceList;
|
||||||
|
while ( curdevice->pNext )
|
||||||
|
{
|
||||||
|
curdevice = curdevice->pNext;
|
||||||
|
}
|
||||||
|
curdevice->pNext = device;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Called by our IO port notifier on the master port when a HID device is inserted, we iterate
|
||||||
|
* and check for new joysticks
|
||||||
|
*/
|
||||||
|
void JoystickDeviceWasAddedCallback( void *refcon, io_iterator_t iterator )
|
||||||
|
{
|
||||||
|
io_object_t ioHIDDeviceObject = 0;
|
||||||
|
|
||||||
|
while ( ( ioHIDDeviceObject = IOIteratorNext(iterator) ) )
|
||||||
|
{
|
||||||
|
if ( ioHIDDeviceObject )
|
||||||
|
{
|
||||||
|
AddDeviceHelper( ioHIDDeviceObject );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* 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.
|
||||||
* This function should return the number of available joysticks, or -1
|
* This function should return the number of available joysticks, or -1
|
||||||
|
@ -581,10 +726,8 @@ SDL_SYS_JoystickInit(void)
|
||||||
mach_port_t masterPort = 0;
|
mach_port_t masterPort = 0;
|
||||||
io_iterator_t hidObjectIterator = 0;
|
io_iterator_t hidObjectIterator = 0;
|
||||||
CFMutableDictionaryRef hidMatchDictionary = NULL;
|
CFMutableDictionaryRef hidMatchDictionary = NULL;
|
||||||
recDevice *device, *lastDevice;
|
|
||||||
io_object_t ioHIDDeviceObject = 0;
|
io_object_t ioHIDDeviceObject = 0;
|
||||||
|
io_iterator_t portIterator = 0;
|
||||||
SDL_numjoysticks = 0;
|
|
||||||
|
|
||||||
if (gpDeviceList) {
|
if (gpDeviceList) {
|
||||||
SDL_SetError("Joystick: Device list already inited.");
|
SDL_SetError("Joystick: Device list already inited.");
|
||||||
|
@ -629,70 +772,49 @@ SDL_SYS_JoystickInit(void)
|
||||||
}
|
}
|
||||||
if (!hidObjectIterator) { /* there are no joysticks */
|
if (!hidObjectIterator) { /* there are no joysticks */
|
||||||
gpDeviceList = NULL;
|
gpDeviceList = NULL;
|
||||||
SDL_numjoysticks = 0;
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
/* IOServiceGetMatchingServices consumes a reference to the dictionary, so we don't need to release the dictionary ref. */
|
/* IOServiceGetMatchingServices consumes a reference to the dictionary, so we don't need to release the dictionary ref. */
|
||||||
|
|
||||||
/* build flat linked list of devices from device iterator */
|
/* build flat linked list of devices from device iterator */
|
||||||
|
|
||||||
gpDeviceList = lastDevice = NULL;
|
gpDeviceList = NULL;
|
||||||
|
|
||||||
while ((ioHIDDeviceObject = IOIteratorNext(hidObjectIterator))) {
|
while ((ioHIDDeviceObject = IOIteratorNext(hidObjectIterator))) {
|
||||||
/* build a device record */
|
AddDeviceHelper( ioHIDDeviceObject );
|
||||||
device = HIDBuildDevice(ioHIDDeviceObject);
|
|
||||||
if (!device)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
/* Filter device list to non-keyboard/mouse stuff */
|
|
||||||
if ((device->usagePage != kHIDPage_GenericDesktop) ||
|
|
||||||
((device->usage != kHIDUsage_GD_Joystick &&
|
|
||||||
device->usage != kHIDUsage_GD_GamePad &&
|
|
||||||
device->usage != kHIDUsage_GD_MultiAxisController))) {
|
|
||||||
|
|
||||||
/* release memory for the device */
|
|
||||||
HIDDisposeDevice(&device);
|
|
||||||
DisposePtr((Ptr) device);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* We have to do some storage of the io_service_t for
|
|
||||||
* SDL_HapticOpenFromJoystick */
|
|
||||||
if (FFIsForceFeedback(ioHIDDeviceObject) == FF_OK) {
|
|
||||||
device->ffservice = ioHIDDeviceObject;
|
|
||||||
} else {
|
|
||||||
device->ffservice = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Add device to the end of the list */
|
|
||||||
if (lastDevice)
|
|
||||||
lastDevice->pNext = device;
|
|
||||||
else
|
|
||||||
gpDeviceList = device;
|
|
||||||
lastDevice = device;
|
|
||||||
}
|
}
|
||||||
result = IOObjectRelease(hidObjectIterator); /* release the iterator */
|
result = IOObjectRelease(hidObjectIterator); /* release the iterator */
|
||||||
|
|
||||||
/* Count the total number of devices we found */
|
/* now connect notification for new devices */
|
||||||
device = gpDeviceList;
|
notificationPort = IONotificationPortCreate(masterPort);
|
||||||
while (device) {
|
hidMatchDictionary = IOServiceMatching(kIOHIDDeviceKey);
|
||||||
SDL_numjoysticks++;
|
|
||||||
device = device->pNext;
|
|
||||||
}
|
|
||||||
|
|
||||||
return SDL_numjoysticks;
|
CFRunLoopAddSource(CFRunLoopGetCurrent(),
|
||||||
|
IONotificationPortGetRunLoopSource(notificationPort),
|
||||||
|
kCFRunLoopDefaultMode);
|
||||||
|
|
||||||
|
// Register for notifications when a serial port is added to the system
|
||||||
|
result = IOServiceAddMatchingNotification(notificationPort,
|
||||||
|
kIOFirstMatchNotification,
|
||||||
|
hidMatchDictionary,
|
||||||
|
JoystickDeviceWasAddedCallback,
|
||||||
|
NULL,
|
||||||
|
&portIterator);
|
||||||
|
while (IOIteratorNext(portIterator)) {}; // Run out the iterator or notifications won't start (you can also use it to iterate the available devices).
|
||||||
|
|
||||||
|
return SDL_SYS_NumJoysticks();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 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_JoystickName(int index)
|
SDL_SYS_JoystickNameForIndex(int index)
|
||||||
{
|
{
|
||||||
recDevice *device = gpDeviceList;
|
recDevice *device = gpDeviceList;
|
||||||
|
|
||||||
for (; index > 0; index--)
|
for (; index > 0; index--)
|
||||||
device = device->pNext;
|
device = device->pNext;
|
||||||
|
|
||||||
return device->product;
|
return device->product;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Function to open a joystick for use.
|
/* Function to open a joystick for use.
|
||||||
|
@ -701,25 +823,77 @@ SDL_SYS_JoystickName(int index)
|
||||||
* It returns 0, or -1 if there is an error.
|
* It returns 0, or -1 if there is an error.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
SDL_SYS_JoystickOpen(SDL_Joystick * joystick)
|
SDL_SYS_JoystickOpen(SDL_Joystick * joystick, int device_index)
|
||||||
{
|
{
|
||||||
recDevice *device = gpDeviceList;
|
recDevice *device = gpDeviceList;
|
||||||
int index;
|
int index;
|
||||||
|
|
||||||
for (index = joystick->index; index > 0; index--)
|
for (index = device_index; index > 0; index--)
|
||||||
device = device->pNext;
|
device = device->pNext;
|
||||||
|
|
||||||
joystick->hwdata = device;
|
joystick->hwdata = device;
|
||||||
joystick->name = device->product;
|
joystick->instance_id = device->instance_id;
|
||||||
|
joystick->name = device->product;
|
||||||
joystick->naxes = device->axes;
|
|
||||||
joystick->nhats = device->hats;
|
|
||||||
joystick->nballs = 0;
|
|
||||||
joystick->nbuttons = device->buttons;
|
|
||||||
|
|
||||||
|
joystick->naxes = device->axes;
|
||||||
|
joystick->nhats = device->hats;
|
||||||
|
joystick->nballs = 0;
|
||||||
|
joystick->nbuttons = device->buttons;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Function to return the instance id of the joystick at device_index
|
||||||
|
*/
|
||||||
|
SDL_JoystickID
|
||||||
|
SDL_SYS_GetInstanceIdOfDeviceIndex( int device_index )
|
||||||
|
{
|
||||||
|
recDevice *device = gpDeviceList;
|
||||||
|
int index;
|
||||||
|
|
||||||
|
for (index = device_index; index > 0; index--)
|
||||||
|
device = device->pNext;
|
||||||
|
|
||||||
|
return device->instance_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Function to cause any queued joystick insertions to be processed
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
SDL_SYS_JoystickDetect()
|
||||||
|
{
|
||||||
|
if ( s_bDeviceAdded )
|
||||||
|
{
|
||||||
|
recDevice *device = gpDeviceList;
|
||||||
|
s_bDeviceAdded = 0;
|
||||||
|
int device_index = 0;
|
||||||
|
// send notifications
|
||||||
|
while ( device )
|
||||||
|
{
|
||||||
|
if ( device->send_open_event )
|
||||||
|
{
|
||||||
|
device->send_open_event = 0;
|
||||||
|
#if !SDL_EVENTS_DISABLED
|
||||||
|
SDL_Event event;
|
||||||
|
event.type = SDL_JOYDEVICEADDED;
|
||||||
|
|
||||||
|
if (SDL_GetEventState(event.type) == SDL_ENABLE) {
|
||||||
|
event.jdevice.which = device_index;
|
||||||
|
if ((SDL_EventOK == NULL)
|
||||||
|
|| (*SDL_EventOK) (SDL_EventOKParam, &event)) {
|
||||||
|
SDL_PushEvent(&event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif /* !SDL_EVENTS_DISABLED */
|
||||||
|
}
|
||||||
|
device_index++;
|
||||||
|
device = device->pNext;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Function to update the state of a joystick - called as a device poll.
|
/* Function to update the state of a joystick - called as a device poll.
|
||||||
* This function shouldn't update the joystick structure directly,
|
* This function shouldn't update the joystick structure directly,
|
||||||
* but instead should call SDL_PrivateJoystick*() to deliver events
|
* but instead should call SDL_PrivateJoystick*() to deliver events
|
||||||
|
@ -728,25 +902,48 @@ SDL_SYS_JoystickOpen(SDL_Joystick * joystick)
|
||||||
void
|
void
|
||||||
SDL_SYS_JoystickUpdate(SDL_Joystick * joystick)
|
SDL_SYS_JoystickUpdate(SDL_Joystick * joystick)
|
||||||
{
|
{
|
||||||
recDevice *device = joystick->hwdata;
|
recDevice *device = joystick->hwdata;
|
||||||
recElement *element;
|
recElement *element;
|
||||||
SInt32 value, range;
|
SInt32 value, range;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
if ( !device )
|
||||||
|
return;
|
||||||
|
|
||||||
if (device->removed) { /* device was unplugged; ignore it. */
|
if (device->removed) { /* device was unplugged; ignore it. */
|
||||||
if (device->uncentered) {
|
recDevice *devicelist = gpDeviceList;
|
||||||
device->uncentered = 0;
|
joystick->closed = 1;
|
||||||
|
joystick->uncentered = 1;
|
||||||
|
|
||||||
/* Tell the app that everything is centered/unpressed... */
|
if ( devicelist == device )
|
||||||
for (i = 0; i < device->axes; i++)
|
{
|
||||||
SDL_PrivateJoystickAxis(joystick, i, 0);
|
gpDeviceList = device->pNext;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
while ( devicelist->pNext != device )
|
||||||
|
{
|
||||||
|
devicelist = devicelist->pNext;
|
||||||
|
}
|
||||||
|
|
||||||
for (i = 0; i < device->buttons; i++)
|
devicelist->pNext = device->pNext;
|
||||||
SDL_PrivateJoystickButton(joystick, i, 0);
|
}
|
||||||
|
|
||||||
for (i = 0; i < device->hats; i++)
|
DisposePtr((Ptr) device);
|
||||||
SDL_PrivateJoystickHat(joystick, i, SDL_HAT_CENTERED);
|
joystick->hwdata = NULL;
|
||||||
}
|
|
||||||
|
#if !SDL_EVENTS_DISABLED
|
||||||
|
SDL_Event event;
|
||||||
|
event.type = SDL_JOYDEVICEREMOVED;
|
||||||
|
|
||||||
|
if (SDL_GetEventState(event.type) == SDL_ENABLE) {
|
||||||
|
event.jdevice.which = joystick->instance_id;
|
||||||
|
if ((SDL_EventOK == NULL)
|
||||||
|
|| (*SDL_EventOK) (SDL_EventOKParam, &event)) {
|
||||||
|
SDL_PushEvent(&event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif /* !SDL_EVENTS_DISABLED */
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -826,12 +1023,33 @@ SDL_SYS_JoystickUpdate(SDL_Joystick * joystick)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Function to query if the joystick is currently attached
|
||||||
|
* It returns 1 if attached, 0 otherwise.
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
SDL_SYS_JoystickAttached(SDL_Joystick * joystick)
|
||||||
|
{
|
||||||
|
recDevice *device = gpDeviceList;
|
||||||
|
int index;
|
||||||
|
|
||||||
|
while ( device )
|
||||||
|
{
|
||||||
|
if ( joystick->instance_id == device->instance_id )
|
||||||
|
return (1);
|
||||||
|
|
||||||
|
device = device->pNext;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Function to close a joystick after use */
|
/* Function to close a joystick after use */
|
||||||
void
|
void
|
||||||
SDL_SYS_JoystickClose(SDL_Joystick * joystick)
|
SDL_SYS_JoystickClose(SDL_Joystick * joystick)
|
||||||
{
|
{
|
||||||
/* Should we do anything here? */
|
joystick->closed = 1;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Function to perform any system-specific joystick related cleanup */
|
/* Function to perform any system-specific joystick related cleanup */
|
||||||
|
@ -840,6 +1058,51 @@ SDL_SYS_JoystickQuit(void)
|
||||||
{
|
{
|
||||||
while (NULL != gpDeviceList)
|
while (NULL != gpDeviceList)
|
||||||
gpDeviceList = HIDDisposeDevice(&gpDeviceList);
|
gpDeviceList = HIDDisposeDevice(&gpDeviceList);
|
||||||
|
|
||||||
|
if ( notificationPort )
|
||||||
|
{
|
||||||
|
IONotificationPortDestroy( notificationPort );
|
||||||
|
notificationPort = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Function to return the number of joystick devices plugged in right now*/
|
||||||
|
int
|
||||||
|
SDL_SYS_NumJoysticks()
|
||||||
|
{
|
||||||
|
recDevice *device = gpDeviceList;
|
||||||
|
int nJoySticks = 0;
|
||||||
|
|
||||||
|
while ( device )
|
||||||
|
{
|
||||||
|
nJoySticks++;
|
||||||
|
device = device->pNext;
|
||||||
|
}
|
||||||
|
|
||||||
|
return nJoySticks;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
SDL_SYS_JoystickNeedsPolling()
|
||||||
|
{
|
||||||
|
return s_bDeviceAdded;
|
||||||
|
}
|
||||||
|
|
||||||
|
JoystickGUID SDL_SYS_PrivateJoystickGetDeviceID( int device_index )
|
||||||
|
{
|
||||||
|
recDevice *device = gpDeviceList;
|
||||||
|
int index;
|
||||||
|
|
||||||
|
for (index = device_index; index > 0; index--)
|
||||||
|
device = device->pNext;
|
||||||
|
|
||||||
|
return device->guid;
|
||||||
|
}
|
||||||
|
|
||||||
|
JoystickGUID SDL_SYS_PrivateJoystickGetGUID(SDL_Joystick *joystick)
|
||||||
|
{
|
||||||
|
return joystick->hwdata->guid;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* SDL_JOYSTICK_IOKIT */
|
#endif /* SDL_JOYSTICK_IOKIT */
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
|
|
||||||
#include <IOKit/hid/IOHIDLib.h>
|
#include <IOKit/hid/IOHIDLib.h>
|
||||||
#include <IOKit/hid/IOHIDKeys.h>
|
#include <IOKit/hid/IOHIDKeys.h>
|
||||||
|
#include <IOKit/IOKitLib.h>
|
||||||
|
|
||||||
|
|
||||||
struct recElement
|
struct recElement
|
||||||
|
@ -58,6 +59,8 @@ struct joystick_hwdata
|
||||||
{
|
{
|
||||||
io_service_t ffservice; /* Interface for force feedback, 0 = no ff */
|
io_service_t ffservice; /* Interface for force feedback, 0 = no ff */
|
||||||
IOHIDDeviceInterface **interface; /* interface to device, NULL = no interface */
|
IOHIDDeviceInterface **interface; /* interface to device, NULL = no interface */
|
||||||
|
IONotificationPortRef notificationPort; /* port to be notified on joystick removal */
|
||||||
|
io_iterator_t portIterator; /* iterator for removal callback */
|
||||||
|
|
||||||
char product[256]; /* name of product */
|
char product[256]; /* name of product */
|
||||||
long usage; /* usage page from IOUSBHID Parser.h which defines general usage */
|
long usage; /* usage page from IOUSBHID Parser.h which defines general usage */
|
||||||
|
@ -75,6 +78,10 @@ struct joystick_hwdata
|
||||||
int removed;
|
int removed;
|
||||||
int uncentered;
|
int uncentered;
|
||||||
|
|
||||||
|
int instance_id;
|
||||||
|
JoystickGUID guid;
|
||||||
|
Uint8 send_open_event; /* 1 if we need to send an Added event for this device */
|
||||||
|
|
||||||
struct joystick_hwdata *pNext; /* next device */
|
struct joystick_hwdata *pNext; /* next device */
|
||||||
};
|
};
|
||||||
typedef struct joystick_hwdata recDevice;
|
typedef struct joystick_hwdata recDevice;
|
||||||
|
|
0
src/joystick/iphoneos/SDLUIAccelerationDelegate.m
Normal file → Executable file
0
src/joystick/iphoneos/SDLUIAccelerationDelegate.m
Normal file → Executable file
0
src/joystick/iphoneos/SDL_sysjoystick.m
Normal file → Executable file
0
src/joystick/iphoneos/SDL_sysjoystick.m
Normal file → Executable file
|
@ -298,7 +298,7 @@ CountLogicalJoysticks(int max)
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
for (i = 0; i < max; i++) {
|
for (i = 0; i < max; i++) {
|
||||||
name = SDL_SYS_JoystickName(i);
|
name = SDL_SYS_JoystickNameForIndex(i);
|
||||||
|
|
||||||
fd = open(SDL_joylist[i].fname, O_RDONLY, 0);
|
fd = open(SDL_joylist[i].fname, O_RDONLY, 0);
|
||||||
if (fd >= 0) {
|
if (fd >= 0) {
|
||||||
|
@ -390,6 +390,8 @@ EV_IsJoystick(int fd)
|
||||||
|
|
||||||
#endif /* SDL_INPUT_LINUXEV */
|
#endif /* SDL_INPUT_LINUXEV */
|
||||||
|
|
||||||
|
int SDL_SYS_numjoysticks = 0;
|
||||||
|
|
||||||
/* Function to scan the system for joysticks */
|
/* Function to scan the system for joysticks */
|
||||||
int
|
int
|
||||||
SDL_SYS_JoystickInit(void)
|
SDL_SYS_JoystickInit(void)
|
||||||
|
@ -491,7 +493,7 @@ SDL_SYS_JoystickInit(void)
|
||||||
will be duplicates but without extra information about their
|
will be duplicates but without extra information about their
|
||||||
hats or balls. Unfortunately, the event devices can't
|
hats or balls. Unfortunately, the event devices can't
|
||||||
currently be calibrated, so it's a win-lose situation.
|
currently be calibrated, so it's a win-lose situation.
|
||||||
So : /dev/input/eventX = /dev/input/jsY = /dev/jsY
|
So : /dev/input/eventX = /dev/input/jsY = /dev/js
|
||||||
*/
|
*/
|
||||||
if ((i == 0) && (numjoysticks > 0))
|
if ((i == 0) && (numjoysticks > 0))
|
||||||
break;
|
break;
|
||||||
|
@ -501,12 +503,13 @@ SDL_SYS_JoystickInit(void)
|
||||||
numjoysticks += CountLogicalJoysticks(numjoysticks);
|
numjoysticks += CountLogicalJoysticks(numjoysticks);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
SDL_SYS_numjoysticks = numjoysticks;
|
||||||
return (numjoysticks);
|
return (numjoysticks);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 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_JoystickName(int index)
|
SDL_SYS_JoystickNameForIndex(int index)
|
||||||
{
|
{
|
||||||
int fd;
|
int fd;
|
||||||
static char namebuf[128];
|
static char namebuf[128];
|
||||||
|
@ -601,7 +604,7 @@ JS_ConfigJoystick(SDL_Joystick * joystick, int fd)
|
||||||
joystick->nbuttons = n;
|
joystick->nbuttons = n;
|
||||||
}
|
}
|
||||||
|
|
||||||
name = SDL_SYS_JoystickName(joystick->index);
|
name = SDL_SYS_JoystickNameForIndex(joystick->instance_id);
|
||||||
|
|
||||||
/* Generic analog joystick support */
|
/* Generic analog joystick support */
|
||||||
if (SDL_strstr(name, "Analog") == name && SDL_strstr(name, "-hat")) {
|
if (SDL_strstr(name, "Analog") == name && SDL_strstr(name, "-hat")) {
|
||||||
|
@ -774,8 +777,8 @@ ConfigLogicalJoystick(SDL_Joystick * joystick)
|
||||||
{
|
{
|
||||||
struct joystick_logical_layout *layout;
|
struct joystick_logical_layout *layout;
|
||||||
|
|
||||||
layout = SDL_joylist[joystick->index].map->layout +
|
layout = SDL_joylist[joystick->instance_id].map->layout +
|
||||||
SDL_joylist[joystick->index].logicalno;
|
SDL_joylist[joystick->instance_id].logicalno;
|
||||||
|
|
||||||
joystick->nbuttons = layout->nbuttons;
|
joystick->nbuttons = layout->nbuttons;
|
||||||
joystick->nhats = layout->nhats;
|
joystick->nhats = layout->nhats;
|
||||||
|
@ -791,7 +794,7 @@ ConfigLogicalJoystick(SDL_Joystick * joystick)
|
||||||
It returns 0, or -1 if there is an error.
|
It returns 0, or -1 if there is an error.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
SDL_SYS_JoystickOpen(SDL_Joystick * joystick)
|
SDL_SYS_JoystickOpen(SDL_Joystick * joystick, int device_index)
|
||||||
{
|
{
|
||||||
int fd;
|
int fd;
|
||||||
char *fname;
|
char *fname;
|
||||||
|
@ -800,8 +803,8 @@ SDL_SYS_JoystickOpen(SDL_Joystick * joystick)
|
||||||
|
|
||||||
/* Open the joystick and set the joystick file descriptor */
|
/* Open the joystick and set the joystick file descriptor */
|
||||||
#ifndef NO_LOGICAL_JOYSTICKS
|
#ifndef NO_LOGICAL_JOYSTICKS
|
||||||
if (SDL_joylist[joystick->index].fname == NULL) {
|
if (SDL_joylist[joystick->instance_id].fname == NULL) {
|
||||||
SDL_joylist_head(realindex, joystick->index);
|
SDL_joylist_head(realindex, joystick->instance_id);
|
||||||
realjoy = SDL_JoystickOpen(realindex);
|
realjoy = SDL_JoystickOpen(realindex);
|
||||||
|
|
||||||
if (realjoy == NULL)
|
if (realjoy == NULL)
|
||||||
|
@ -811,17 +814,17 @@ SDL_SYS_JoystickOpen(SDL_Joystick * joystick)
|
||||||
fname = realjoy->hwdata->fname;
|
fname = realjoy->hwdata->fname;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
fd = open(SDL_joylist[joystick->index].fname, O_RDONLY, 0);
|
fd = open(SDL_joylist[joystick->instance_id].fname, O_RDONLY, 0);
|
||||||
fname = SDL_joylist[joystick->index].fname;
|
fname = SDL_joylist[joystick->instance_id].fname;
|
||||||
}
|
}
|
||||||
SDL_joylist[joystick->index].joy = joystick;
|
SDL_joylist[joystick->instance_id].joy = joystick;
|
||||||
#else
|
#else
|
||||||
fd = open(SDL_joylist[joystick->index].fname, O_RDONLY, 0);
|
fd = open(SDL_joylist[joystick->instance_id].fname, O_RDONLY, 0);
|
||||||
fname = SDL_joylist[joystick->index].fname;
|
fname = SDL_joylist[joystick->instance_id].fname;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
SDL_SetError("Unable to open %s\n", SDL_joylist[joystick->index]);
|
SDL_SetError("Unable to open %s\n", SDL_joylist[joystick->instance_id]);
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
joystick->hwdata = (struct joystick_hwdata *)
|
joystick->hwdata = (struct joystick_hwdata *)
|
||||||
|
@ -834,6 +837,7 @@ SDL_SYS_JoystickOpen(SDL_Joystick * joystick)
|
||||||
SDL_memset(joystick->hwdata, 0, sizeof(*joystick->hwdata));
|
SDL_memset(joystick->hwdata, 0, sizeof(*joystick->hwdata));
|
||||||
joystick->hwdata->fd = fd;
|
joystick->hwdata->fd = fd;
|
||||||
joystick->hwdata->fname = fname;
|
joystick->hwdata->fname = fname;
|
||||||
|
joystick->instance_id = device_index;
|
||||||
|
|
||||||
/* Set the joystick to non-blocking read mode */
|
/* Set the joystick to non-blocking read mode */
|
||||||
fcntl(fd, F_SETFL, O_NONBLOCK);
|
fcntl(fd, F_SETFL, O_NONBLOCK);
|
||||||
|
@ -861,7 +865,7 @@ FindLogicalJoystick(SDL_Joystick * joystick,
|
||||||
SDL_Joystick *logicaljoy;
|
SDL_Joystick *logicaljoy;
|
||||||
register int i;
|
register int i;
|
||||||
|
|
||||||
i = joystick->index;
|
i = joystick->instance_id;
|
||||||
logicaljoy = NULL;
|
logicaljoy = NULL;
|
||||||
|
|
||||||
/* get the fake joystick that will receive the event
|
/* get the fake joystick that will receive the event
|
||||||
|
@ -891,12 +895,12 @@ LogicalJoystickButton(SDL_Joystick * joystick, Uint8 button, Uint8 state)
|
||||||
|
|
||||||
/* if there's no map then this is just a regular joystick
|
/* if there's no map then this is just a regular joystick
|
||||||
*/
|
*/
|
||||||
if (SDL_joylist[joystick->index].map == NULL)
|
if (SDL_joylist[joystick->instance_id].map == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
/* get the logical joystick that will receive the event
|
/* get the logical joystick that will receive the event
|
||||||
*/
|
*/
|
||||||
buttons = SDL_joylist[joystick->index].map->buttonmap + button;
|
buttons = SDL_joylist[joystick->instance_id].map->buttonmap + button;
|
||||||
logicaljoy = FindLogicalJoystick(joystick, buttons);
|
logicaljoy = FindLogicalJoystick(joystick, buttons);
|
||||||
|
|
||||||
if (logicaljoy == NULL)
|
if (logicaljoy == NULL)
|
||||||
|
@ -915,12 +919,12 @@ LogicalJoystickAxis(SDL_Joystick * joystick, Uint8 axis, Sint16 value)
|
||||||
|
|
||||||
/* if there's no map then this is just a regular joystick
|
/* if there's no map then this is just a regular joystick
|
||||||
*/
|
*/
|
||||||
if (SDL_joylist[joystick->index].map == NULL)
|
if (SDL_joylist[joystick->instance_id].map == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
/* get the logical joystick that will receive the event
|
/* get the logical joystick that will receive the event
|
||||||
*/
|
*/
|
||||||
axes = SDL_joylist[joystick->index].map->axismap + axis;
|
axes = SDL_joylist[joystick->instance_id].map->axismap + axis;
|
||||||
logicaljoy = FindLogicalJoystick(joystick, axes);
|
logicaljoy = FindLogicalJoystick(joystick, axes);
|
||||||
|
|
||||||
if (logicaljoy == NULL)
|
if (logicaljoy == NULL)
|
||||||
|
@ -958,11 +962,11 @@ HandleHat(SDL_Joystick * stick, Uint8 hat, int axis, int value)
|
||||||
#ifndef NO_LOGICAL_JOYSTICKS
|
#ifndef NO_LOGICAL_JOYSTICKS
|
||||||
/* if there's no map then this is just a regular joystick
|
/* if there's no map then this is just a regular joystick
|
||||||
*/
|
*/
|
||||||
if (SDL_joylist[stick->index].map != NULL) {
|
if (SDL_joylist[stick->instance_id].map != NULL) {
|
||||||
|
|
||||||
/* get the fake joystick that will receive the event
|
/* get the fake joystick that will receive the event
|
||||||
*/
|
*/
|
||||||
hats = SDL_joylist[stick->index].map->hatmap + hat;
|
hats = SDL_joylist[stick->instance_id].map->hatmap + hat;
|
||||||
logicaljoy = FindLogicalJoystick(stick, hats);
|
logicaljoy = FindLogicalJoystick(stick, hats);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -997,8 +1001,8 @@ JS_HandleEvents(SDL_Joystick * joystick)
|
||||||
Uint8 other_axis;
|
Uint8 other_axis;
|
||||||
|
|
||||||
#ifndef NO_LOGICAL_JOYSTICKS
|
#ifndef NO_LOGICAL_JOYSTICKS
|
||||||
if (SDL_joylist[joystick->index].fname == NULL) {
|
if (SDL_joylist[joystick->instance_id].fname == NULL) {
|
||||||
SDL_joylist_head(i, joystick->index);
|
SDL_joylist_head(i, joystick->instance_id);
|
||||||
JS_HandleEvents(SDL_joylist[i].joy);
|
JS_HandleEvents(SDL_joylist[i].joy);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1089,8 +1093,8 @@ EV_HandleEvents(SDL_Joystick * joystick)
|
||||||
int code;
|
int code;
|
||||||
|
|
||||||
#ifndef NO_LOGICAL_JOYSTICKS
|
#ifndef NO_LOGICAL_JOYSTICKS
|
||||||
if (SDL_joylist[joystick->index].fname == NULL) {
|
if (SDL_joylist[joystick->instance_id].fname == NULL) {
|
||||||
SDL_joylist_head(i, joystick->index);
|
SDL_joylist_head(i, joystick->instance_id);
|
||||||
return EV_HandleEvents(SDL_joylist[i].joy);
|
return EV_HandleEvents(SDL_joylist[i].joy);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -1198,15 +1202,15 @@ SDL_SYS_JoystickClose(SDL_Joystick * joystick)
|
||||||
{
|
{
|
||||||
#ifndef NO_LOGICAL_JOYSTICKS
|
#ifndef NO_LOGICAL_JOYSTICKS
|
||||||
register int i;
|
register int i;
|
||||||
if (SDL_joylist[joystick->index].fname == NULL) {
|
if (SDL_joylist[joystick->instance_id].fname == NULL) {
|
||||||
SDL_joylist_head(i, joystick->index);
|
SDL_joylist_head(i, joystick->instance_id);
|
||||||
SDL_JoystickClose(SDL_joylist[i].joy);
|
SDL_JoystickClose(SDL_joylist[i].joy);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (joystick->hwdata) {
|
if (joystick->hwdata) {
|
||||||
#ifndef NO_LOGICAL_JOYSTICKS
|
#ifndef NO_LOGICAL_JOYSTICKS
|
||||||
if (SDL_joylist[joystick->index].fname != NULL)
|
if (SDL_joylist[joystick->instance_id].fname != NULL)
|
||||||
#endif
|
#endif
|
||||||
close(joystick->hwdata->fd);
|
close(joystick->hwdata->fd);
|
||||||
if (joystick->hwdata->hats) {
|
if (joystick->hwdata->hats) {
|
||||||
|
@ -1218,6 +1222,7 @@ SDL_SYS_JoystickClose(SDL_Joystick * joystick)
|
||||||
SDL_free(joystick->hwdata);
|
SDL_free(joystick->hwdata);
|
||||||
joystick->hwdata = NULL;
|
joystick->hwdata = NULL;
|
||||||
}
|
}
|
||||||
|
joystick->closed = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Function to perform any system-specific joystick related cleanup */
|
/* Function to perform any system-specific joystick related cleanup */
|
||||||
|
@ -1234,5 +1239,50 @@ SDL_SYS_JoystickQuit(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Function to perform the mapping from device index to the instance id for this index */
|
||||||
|
SDL_JoystickID SDL_SYS_GetInstanceIdOfDeviceIndex(int index)
|
||||||
|
{
|
||||||
|
return index;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Function to determine is this joystick is attached to the system right now */
|
||||||
|
int SDL_SYS_JoystickAttached(SDL_Joystick *joystick)
|
||||||
|
{
|
||||||
|
return joystick->closed;
|
||||||
|
}
|
||||||
|
|
||||||
|
int SDL_SYS_NumJoysticks()
|
||||||
|
{
|
||||||
|
return SDL_SYS_numjoysticks;
|
||||||
|
}
|
||||||
|
|
||||||
|
int SDL_SYS_JoystickNeedsPolling()
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SDL_SYS_JoystickDetect()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
JoystickGUID SDL_SYS_PrivateJoystickGetDeviceID( int device_index )
|
||||||
|
{
|
||||||
|
static JoystickGUID guid;
|
||||||
|
// the GUID is just the first 16 chars of the name for now
|
||||||
|
const char *name = SDL_SYS_JoystickNameForIndex( device_index );
|
||||||
|
SDL_memcpy( &guid, name, sizeof(guid) );
|
||||||
|
return guid;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
JoystickGUID SDL_SYS_PrivateJoystickGetGUID(SDL_Joystick * joystick)
|
||||||
|
{
|
||||||
|
static JoystickGUID guid;
|
||||||
|
// the GUID is just the first 16 chars of the name for now
|
||||||
|
const char *name = SDL_SYS_JoystickNameForIndex( joystick->name );
|
||||||
|
SDL_memcpy( &guid, name, sizeof(guid) );
|
||||||
|
return guid;
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* SDL_JOYSTICK_LINUX */
|
#endif /* SDL_JOYSTICK_LINUX */
|
||||||
/* vi: set ts=4 sw=4 expandtab: */
|
/* vi: set ts=4 sw=4 expandtab: */
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -34,9 +34,14 @@
|
||||||
|
|
||||||
#include "../../core/windows/SDL_windows.h"
|
#include "../../core/windows/SDL_windows.h"
|
||||||
|
|
||||||
#define DIRECTINPUT_VERSION 0x0700 /* Need version 7 for force feedback. */
|
#define DIRECTINPUT_VERSION 0x0800 /* Need version 7 for force feedback. Need verison 8 so IDirectInput8_EnumDevices doesn't leak like a sieve... */
|
||||||
#include <dinput.h>
|
#include <dinput.h>
|
||||||
|
#define COBJMACROS
|
||||||
|
#include <wbemcli.h>
|
||||||
|
#include <oleauto.h>
|
||||||
|
#include <xinput.h>
|
||||||
|
#include <devguid.h>
|
||||||
|
#include <dbt.h>
|
||||||
|
|
||||||
#define MAX_INPUTS 256 /* each joystick can have up to 256 inputs */
|
#define MAX_INPUTS 256 /* each joystick can have up to 256 inputs */
|
||||||
|
|
||||||
|
@ -57,15 +62,42 @@ typedef struct input_t
|
||||||
Uint8 num;
|
Uint8 num;
|
||||||
} input_t;
|
} input_t;
|
||||||
|
|
||||||
|
/* typedef's for XInput structs we use */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
WORD wButtons;
|
||||||
|
BYTE bLeftTrigger;
|
||||||
|
BYTE bRightTrigger;
|
||||||
|
SHORT sThumbLX;
|
||||||
|
SHORT sThumbLY;
|
||||||
|
SHORT sThumbRX;
|
||||||
|
SHORT sThumbRY;
|
||||||
|
DWORD dwPaddingReserved;
|
||||||
|
} XINPUT_GAMEPAD_EX;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
DWORD dwPacketNumber;
|
||||||
|
XINPUT_GAMEPAD_EX Gamepad;
|
||||||
|
} XINPUT_STATE_EX;
|
||||||
|
|
||||||
/* The private structure used to keep track of a joystick */
|
/* The private structure used to keep track of a joystick */
|
||||||
struct joystick_hwdata
|
struct joystick_hwdata
|
||||||
{
|
{
|
||||||
LPDIRECTINPUTDEVICE2 InputDevice;
|
LPDIRECTINPUTDEVICE2 InputDevice;
|
||||||
DIDEVCAPS Capabilities;
|
DIDEVCAPS Capabilities;
|
||||||
int buffered;
|
int buffered;
|
||||||
|
JoystickGUID guid;
|
||||||
|
|
||||||
input_t Inputs[MAX_INPUTS];
|
input_t Inputs[MAX_INPUTS];
|
||||||
int NumInputs;
|
int NumInputs;
|
||||||
|
int NumSliders;
|
||||||
|
Uint8 removed;
|
||||||
|
Uint8 send_remove_event;
|
||||||
|
Uint8 bXInputDevice; // 1 if this device supports using the xinput API rather than DirectInput
|
||||||
|
Uint8 userid; // XInput userid index for this joystick
|
||||||
|
Uint8 currentXInputSlot; // the current position to write to in XInputState below, used so we can compare old and new values
|
||||||
|
XINPUT_STATE_EX XInputState[2];
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* SDL_JOYSTICK_DINPUT_H */
|
#endif /* SDL_JOYSTICK_DINPUT_H */
|
||||||
|
|
|
@ -14,6 +14,7 @@ TARGETS = \
|
||||||
testdraw2$(EXE) \
|
testdraw2$(EXE) \
|
||||||
testerror$(EXE) \
|
testerror$(EXE) \
|
||||||
testfile$(EXE) \
|
testfile$(EXE) \
|
||||||
|
testgamecontroller$(EXE) \
|
||||||
testgesture$(EXE) \
|
testgesture$(EXE) \
|
||||||
testgl2$(EXE) \
|
testgl2$(EXE) \
|
||||||
testgles$(EXE) \
|
testgles$(EXE) \
|
||||||
|
@ -87,6 +88,9 @@ testerror$(EXE): $(srcdir)/testerror.c
|
||||||
testfile$(EXE): $(srcdir)/testfile.c
|
testfile$(EXE): $(srcdir)/testfile.c
|
||||||
$(CC) -o $@ $^ $(CFLAGS) $(LIBS)
|
$(CC) -o $@ $^ $(CFLAGS) $(LIBS)
|
||||||
|
|
||||||
|
testgamecontroller$(EXE): $(srcdir)/testgamecontroller.c
|
||||||
|
$(CC) -o $@ $^ $(CFLAGS) $(LIBS)
|
||||||
|
|
||||||
testgesture$(EXE): $(srcdir)/testgesture.c
|
testgesture$(EXE): $(srcdir)/testgesture.c
|
||||||
$(CC) -o $@ $^ $(CFLAGS) $(LIBS) @MATHLIB@
|
$(CC) -o $@ $^ $(CFLAGS) $(LIBS) @MATHLIB@
|
||||||
|
|
||||||
|
|
205
test/testgamecontroller.c
Normal file
205
test/testgamecontroller.c
Normal file
|
@ -0,0 +1,205 @@
|
||||||
|
/*
|
||||||
|
Copyright (C) 1997-2011 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Simple program to test the SDL game controller routines */
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "SDL.h"
|
||||||
|
|
||||||
|
#ifdef __IPHONEOS__
|
||||||
|
#define SCREEN_WIDTH 320
|
||||||
|
#define SCREEN_HEIGHT 480
|
||||||
|
#else
|
||||||
|
#define SCREEN_WIDTH 640
|
||||||
|
#define SCREEN_HEIGHT 480
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define MAX_NUM_AXES 6
|
||||||
|
#define MAX_NUM_HATS 2
|
||||||
|
|
||||||
|
static SDL_bool s_ForceQuit = SDL_FALSE;
|
||||||
|
|
||||||
|
static void
|
||||||
|
DrawRect(SDL_Renderer *r, const int x, const int y, const int w, const int h)
|
||||||
|
{
|
||||||
|
const SDL_Rect area = { x, y, w, h };
|
||||||
|
SDL_RenderFillRect(r, &area);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
WatchGameController(SDL_GameController * gamecontroller)
|
||||||
|
{
|
||||||
|
SDL_Window *window = NULL;
|
||||||
|
SDL_Renderer *screen = NULL;
|
||||||
|
const char *name = NULL;
|
||||||
|
int done = 0;
|
||||||
|
SDL_Event event;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
/* Create a window to display controller axis position */
|
||||||
|
window = SDL_CreateWindow("Game Controller Test", SDL_WINDOWPOS_CENTERED,
|
||||||
|
SDL_WINDOWPOS_CENTERED, SCREEN_WIDTH,
|
||||||
|
SCREEN_HEIGHT, SDL_WINDOW_SHOWN);
|
||||||
|
if (window == NULL) {
|
||||||
|
fprintf(stderr, "Couldn't create window: %s\n", SDL_GetError());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
screen = SDL_CreateRenderer(window, -1, 0);
|
||||||
|
if (screen == NULL) {
|
||||||
|
fprintf(stderr, "Couldn't create renderer: %s\n", SDL_GetError());
|
||||||
|
SDL_DestroyWindow(window);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
SDL_SetRenderDrawColor(screen, 0x00, 0x00, 0x00, SDL_ALPHA_OPAQUE);
|
||||||
|
SDL_RenderClear(screen);
|
||||||
|
SDL_RenderPresent(screen);
|
||||||
|
SDL_RaiseWindow(window);
|
||||||
|
|
||||||
|
/* Print info about the controller we are watching */
|
||||||
|
name = SDL_GameControllerName(gamecontroller);
|
||||||
|
printf("Watching controller %s\n", name ? name : "Unknown Controller");
|
||||||
|
|
||||||
|
/* Loop, getting controller events! */
|
||||||
|
while (!done) {
|
||||||
|
/* blank screen, set up for drawing this frame. */
|
||||||
|
SDL_SetRenderDrawColor(screen, 0x00, 0x00, 0x00, SDL_ALPHA_OPAQUE);
|
||||||
|
SDL_RenderClear(screen);
|
||||||
|
|
||||||
|
while (SDL_PollEvent(&event)) {
|
||||||
|
switch (event.type) {
|
||||||
|
case SDL_CONTROLLERAXISMOTION:
|
||||||
|
printf("Controller %d axis %d value: %d\n",
|
||||||
|
event.caxis.which,
|
||||||
|
event.caxis.axis, event.caxis.value);
|
||||||
|
break;
|
||||||
|
case SDL_CONTROLLERBUTTONDOWN:
|
||||||
|
printf("Controller %d button %d down\n",
|
||||||
|
event.cbutton.which, event.cbutton.button);
|
||||||
|
break;
|
||||||
|
case SDL_CONTROLLERBUTTONUP:
|
||||||
|
printf("Controller %d button %d up\n",
|
||||||
|
event.cbutton.which, event.cbutton.button);
|
||||||
|
break;
|
||||||
|
case SDL_KEYDOWN:
|
||||||
|
if (event.key.keysym.sym != SDLK_ESCAPE) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
/* Fall through to signal quit */
|
||||||
|
case SDL_QUIT:
|
||||||
|
done = 1;
|
||||||
|
s_ForceQuit = SDL_TRUE;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* Update visual controller state */
|
||||||
|
SDL_SetRenderDrawColor(screen, 0x00, 0xFF, 0x00, SDL_ALPHA_OPAQUE);
|
||||||
|
for (i = 0; i <SDL_CONTROLLER_BUTTON_MAX; ++i) {
|
||||||
|
if (SDL_GameControllerGetButton(gamecontroller, i) == SDL_PRESSED) {
|
||||||
|
DrawRect(screen, i * 34, SCREEN_HEIGHT - 34, 32, 32);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SDL_SetRenderDrawColor(screen, 0xFF, 0x00, 0x00, SDL_ALPHA_OPAQUE);
|
||||||
|
for (i = 0; i < SDL_CONTROLLER_AXIS_MAX / 2; ++i) {
|
||||||
|
/* Draw the X/Y axis */
|
||||||
|
int x, y;
|
||||||
|
x = (((int) SDL_GameControllerGetAxis(gamecontroller, i * 2 + 0)) + 32768);
|
||||||
|
x *= SCREEN_WIDTH;
|
||||||
|
x /= 65535;
|
||||||
|
if (x < 0) {
|
||||||
|
x = 0;
|
||||||
|
} else if (x > (SCREEN_WIDTH - 16)) {
|
||||||
|
x = SCREEN_WIDTH - 16;
|
||||||
|
}
|
||||||
|
y = (((int) SDL_GameControllerGetAxis(gamecontroller, i * 2 + 1)) + 32768);
|
||||||
|
y *= SCREEN_HEIGHT;
|
||||||
|
y /= 65535;
|
||||||
|
if (y < 0) {
|
||||||
|
y = 0;
|
||||||
|
} else if (y > (SCREEN_HEIGHT - 16)) {
|
||||||
|
y = SCREEN_HEIGHT - 16;
|
||||||
|
}
|
||||||
|
|
||||||
|
DrawRect(screen, x, y, 16, 16);
|
||||||
|
}
|
||||||
|
|
||||||
|
SDL_SetRenderDrawColor(screen, 0x00, 0x00, 0xFF, SDL_ALPHA_OPAQUE);
|
||||||
|
|
||||||
|
SDL_RenderPresent(screen);
|
||||||
|
|
||||||
|
if ( !done )
|
||||||
|
done = SDL_GameControllerGetAttached( gamecontroller ) == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
SDL_DestroyRenderer(screen);
|
||||||
|
SDL_DestroyWindow(window);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
const char *name;
|
||||||
|
int i;
|
||||||
|
int nController = 0;
|
||||||
|
SDL_GameController *gamecontroller;
|
||||||
|
|
||||||
|
SDL_SetHint( SDL_HINT_GAMECONTROLLERCONFIG, "341a3608000000000000504944564944,Aferglow PS3 Controller,a:b1,b:b2,y:b3,x:b0,start:b9,guide:b12,back:b8,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftshoulder:b4,rightshoulder:b5,leftstick:b10,rightstick:b11,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b6,righttrigger:b7" );
|
||||||
|
/* Initialize SDL (Note: video is required to start event loop) */
|
||||||
|
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK | SDL_INIT_GAMECONTROLLER ) < 0) {
|
||||||
|
fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError());
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Print information about the controller */
|
||||||
|
for (i = 0; i < SDL_NumJoysticks(); ++i) {
|
||||||
|
if ( SDL_IsGameController(i) )
|
||||||
|
{
|
||||||
|
nController++;
|
||||||
|
name = SDL_GameControllerNameForIndex(i);
|
||||||
|
printf("Game Controller %d: %s\n", i, name ? name : "Unknown Controller");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
printf("There are %d game controllers attached\n", nController);
|
||||||
|
|
||||||
|
if (argv[1]) {
|
||||||
|
int nreportederror = 0;
|
||||||
|
SDL_Event event;
|
||||||
|
gamecontroller = SDL_GameControllerOpen(atoi(argv[1]));
|
||||||
|
while ( s_ForceQuit == SDL_FALSE ) {
|
||||||
|
if (gamecontroller == NULL) {
|
||||||
|
if ( nreportederror == 0 ) {
|
||||||
|
printf("Couldn't open joystick %d: %s\n", atoi(argv[1]), SDL_GetError());
|
||||||
|
nreportederror = 1;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
nreportederror = 0;
|
||||||
|
WatchGameController(gamecontroller);
|
||||||
|
SDL_GameControllerClose(gamecontroller);
|
||||||
|
}
|
||||||
|
|
||||||
|
gamecontroller = NULL;
|
||||||
|
SDL_WaitEvent( &event );
|
||||||
|
if ( event.type == SDL_JOYDEVICEADDED )
|
||||||
|
gamecontroller = SDL_GameControllerOpen(atoi(argv[1]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
SDL_QuitSubSystem(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK | SDL_INIT_GAMECONTROLLER );
|
||||||
|
|
||||||
|
return (0);
|
||||||
|
}
|
|
@ -17,10 +17,14 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "SDL.h"
|
#include "SDL.h"
|
||||||
#include "common.h"
|
|
||||||
|
|
||||||
static CommonState *state;
|
#ifdef __IPHONEOS__
|
||||||
static SDL_BlendMode blendMode = SDL_BLENDMODE_NONE;
|
#define SCREEN_WIDTH 320
|
||||||
|
#define SCREEN_HEIGHT 480
|
||||||
|
#else
|
||||||
|
#define SCREEN_WIDTH 640
|
||||||
|
#define SCREEN_HEIGHT 480
|
||||||
|
#endif
|
||||||
|
|
||||||
#define MAX_NUM_AXES 6
|
#define MAX_NUM_AXES 6
|
||||||
#define MAX_NUM_HATS 2
|
#define MAX_NUM_HATS 2
|
||||||
|
@ -37,16 +41,35 @@ WatchJoystick(SDL_Joystick * joystick)
|
||||||
{
|
{
|
||||||
SDL_Window *window = NULL;
|
SDL_Window *window = NULL;
|
||||||
SDL_Renderer *screen = NULL;
|
SDL_Renderer *screen = NULL;
|
||||||
SDL_Rect viewport;
|
|
||||||
SDL_Event event;
|
|
||||||
|
|
||||||
const char *name = NULL;
|
const char *name = NULL;
|
||||||
int done = 0;
|
int done = 0;
|
||||||
|
SDL_Event event;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
/* Create a window to display joystick axis position */
|
||||||
|
window = SDL_CreateWindow("Joystick Test", SDL_WINDOWPOS_CENTERED,
|
||||||
|
SDL_WINDOWPOS_CENTERED, SCREEN_WIDTH,
|
||||||
|
SCREEN_HEIGHT, SDL_WINDOW_SHOWN);
|
||||||
|
if (window == NULL) {
|
||||||
|
fprintf(stderr, "Couldn't create window: %s\n", SDL_GetError());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
screen = SDL_CreateRenderer(window, -1, 0);
|
||||||
|
if (screen == NULL) {
|
||||||
|
fprintf(stderr, "Couldn't create renderer: %s\n", SDL_GetError());
|
||||||
|
SDL_DestroyWindow(window);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
SDL_SetRenderDrawColor(screen, 0x00, 0x00, 0x00, SDL_ALPHA_OPAQUE);
|
||||||
|
SDL_RenderClear(screen);
|
||||||
|
SDL_RenderPresent(screen);
|
||||||
|
SDL_RaiseWindow(window);
|
||||||
|
|
||||||
/* Print info about the joystick we are watching */
|
/* Print info about the joystick we are watching */
|
||||||
name = SDL_JoystickName(SDL_JoystickIndex(joystick));
|
name = SDL_JoystickName(joystick);
|
||||||
printf("Watching joystick %d: (%s)\n", SDL_JoystickIndex(joystick),
|
printf("Watching joystick %d: (%s)\n", SDL_JoystickInstanceID(joystick),
|
||||||
name ? name : "Unknown Joystick");
|
name ? name : "Unknown Joystick");
|
||||||
printf("Joystick has %d axes, %d hats, %d balls, and %d buttons\n",
|
printf("Joystick has %d axes, %d hats, %d balls, and %d buttons\n",
|
||||||
SDL_JoystickNumAxes(joystick), SDL_JoystickNumHats(joystick),
|
SDL_JoystickNumAxes(joystick), SDL_JoystickNumHats(joystick),
|
||||||
|
@ -54,6 +77,10 @@ WatchJoystick(SDL_Joystick * joystick)
|
||||||
|
|
||||||
/* Loop, getting joystick events! */
|
/* Loop, getting joystick events! */
|
||||||
while (!done) {
|
while (!done) {
|
||||||
|
/* blank screen, set up for drawing this frame. */
|
||||||
|
SDL_SetRenderDrawColor(screen, 0x00, 0x00, 0x00, SDL_ALPHA_OPAQUE);
|
||||||
|
SDL_RenderClear(screen);
|
||||||
|
|
||||||
while (SDL_PollEvent(&event)) {
|
while (SDL_PollEvent(&event)) {
|
||||||
switch (event.type) {
|
switch (event.type) {
|
||||||
case SDL_JOYAXISMOTION:
|
case SDL_JOYAXISMOTION:
|
||||||
|
@ -101,100 +128,86 @@ WatchJoystick(SDL_Joystick * joystick)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Update visual joystick state */
|
/* Update visual joystick state */
|
||||||
for (i = 0; i < state->num_windows; ++i) {
|
SDL_SetRenderDrawColor(screen, 0x00, 0xFF, 0x00, SDL_ALPHA_OPAQUE);
|
||||||
screen = state->renderers[i];
|
for (i = 0; i < SDL_JoystickNumButtons(joystick); ++i) {
|
||||||
|
if (SDL_JoystickGetButton(joystick, i) == SDL_PRESSED) {
|
||||||
/* Erase previous axes */
|
DrawRect(screen, i * 34, SCREEN_HEIGHT - 34, 32, 32);
|
||||||
SDL_SetRenderDrawColor(screen, 0x00, 0x00, 0x00, SDL_ALPHA_OPAQUE);
|
|
||||||
SDL_RenderClear(screen);
|
|
||||||
|
|
||||||
/* Query the sizes */
|
|
||||||
SDL_RenderGetViewport(screen, &viewport);
|
|
||||||
|
|
||||||
SDL_SetRenderDrawColor(screen, 0x00, 0xFF, 0x00, SDL_ALPHA_OPAQUE);
|
|
||||||
for (i = 0; i < SDL_JoystickNumButtons(joystick); ++i) {
|
|
||||||
if (SDL_JoystickGetButton(joystick, i) == SDL_PRESSED) {
|
|
||||||
DrawRect(screen, i * 34, viewport.h - 34, 32, 32);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_SetRenderDrawColor(screen, 0xFF, 0x00, 0x00, SDL_ALPHA_OPAQUE);
|
|
||||||
for (i = 0; i < SDL_JoystickNumAxes(joystick) / 2; ++i) {
|
|
||||||
/* Draw the X/Y axis */
|
|
||||||
int x, y;
|
|
||||||
x = (((int) SDL_JoystickGetAxis(joystick, i * 2 + 0)) + 32768);
|
|
||||||
x *= viewport.w ;
|
|
||||||
x /= 65535;
|
|
||||||
if (x < 0) {
|
|
||||||
x = 0;
|
|
||||||
} else if (x > (viewport.w - 16)) {
|
|
||||||
x = viewport.w - 16;
|
|
||||||
}
|
|
||||||
y = (((int) SDL_JoystickGetAxis(joystick, i * 2 + 1)) + 32768);
|
|
||||||
y *= viewport.h;
|
|
||||||
y /= 65535;
|
|
||||||
if (y < 0) {
|
|
||||||
y = 0;
|
|
||||||
} else if (y > (viewport.h - 16)) {
|
|
||||||
y = viewport.h - 16;
|
|
||||||
}
|
|
||||||
|
|
||||||
DrawRect(screen, x, y, 16, 16);
|
|
||||||
}
|
|
||||||
|
|
||||||
SDL_SetRenderDrawColor(screen, 0x00, 0x00, 0xFF, SDL_ALPHA_OPAQUE);
|
|
||||||
for (i = 0; i < SDL_JoystickNumHats(joystick); ++i) {
|
|
||||||
/* Derive the new position */
|
|
||||||
int x = viewport.w/2;
|
|
||||||
int y = viewport.h/2;
|
|
||||||
const Uint8 hat_pos = SDL_JoystickGetHat(joystick, i);
|
|
||||||
|
|
||||||
if (hat_pos & SDL_HAT_UP) {
|
|
||||||
y = 0;
|
|
||||||
} else if (hat_pos & SDL_HAT_DOWN) {
|
|
||||||
y = viewport.h-8;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (hat_pos & SDL_HAT_LEFT) {
|
|
||||||
x = 0;
|
|
||||||
} else if (hat_pos & SDL_HAT_RIGHT) {
|
|
||||||
x = viewport.w-8;
|
|
||||||
}
|
|
||||||
|
|
||||||
DrawRect(screen, x, y, 8, 8);
|
|
||||||
}
|
|
||||||
|
|
||||||
SDL_RenderPresent(screen);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SDL_SetRenderDrawColor(screen, 0xFF, 0x00, 0x00, SDL_ALPHA_OPAQUE);
|
||||||
|
for (i = 0; i < SDL_JoystickNumAxes(joystick) / 2; ++i) {
|
||||||
|
/* Draw the X/Y axis */
|
||||||
|
int x, y;
|
||||||
|
x = (((int) SDL_JoystickGetAxis(joystick, i * 2 + 0)) + 32768);
|
||||||
|
x *= SCREEN_WIDTH;
|
||||||
|
x /= 65535;
|
||||||
|
if (x < 0) {
|
||||||
|
x = 0;
|
||||||
|
} else if (x > (SCREEN_WIDTH - 16)) {
|
||||||
|
x = SCREEN_WIDTH - 16;
|
||||||
|
}
|
||||||
|
y = (((int) SDL_JoystickGetAxis(joystick, i * 2 + 1)) + 32768);
|
||||||
|
y *= SCREEN_HEIGHT;
|
||||||
|
y /= 65535;
|
||||||
|
if (y < 0) {
|
||||||
|
y = 0;
|
||||||
|
} else if (y > (SCREEN_HEIGHT - 16)) {
|
||||||
|
y = SCREEN_HEIGHT - 16;
|
||||||
|
}
|
||||||
|
|
||||||
|
DrawRect(screen, x, y, 16, 16);
|
||||||
|
}
|
||||||
|
|
||||||
|
SDL_SetRenderDrawColor(screen, 0x00, 0x00, 0xFF, SDL_ALPHA_OPAQUE);
|
||||||
|
for (i = 0; i < SDL_JoystickNumHats(joystick); ++i) {
|
||||||
|
/* Derive the new position */
|
||||||
|
int x = SCREEN_WIDTH/2;
|
||||||
|
int y = SCREEN_HEIGHT/2;
|
||||||
|
const Uint8 hat_pos = SDL_JoystickGetHat(joystick, i);
|
||||||
|
|
||||||
|
if (hat_pos & SDL_HAT_UP) {
|
||||||
|
y = 0;
|
||||||
|
} else if (hat_pos & SDL_HAT_DOWN) {
|
||||||
|
y = SCREEN_HEIGHT-8;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hat_pos & SDL_HAT_LEFT) {
|
||||||
|
x = 0;
|
||||||
|
} else if (hat_pos & SDL_HAT_RIGHT) {
|
||||||
|
x = SCREEN_WIDTH-8;
|
||||||
|
}
|
||||||
|
|
||||||
|
DrawRect(screen, x, y, 8, 8);
|
||||||
|
}
|
||||||
|
|
||||||
|
SDL_RenderPresent(screen);
|
||||||
|
|
||||||
|
done = SDL_JoystickGetAttached( joystick ) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SDL_DestroyRenderer(screen);
|
||||||
|
SDL_DestroyWindow(window);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
main(int argc, char *argv[])
|
main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
const char *name;
|
const char *name;
|
||||||
int i, joy=-1;
|
int i;
|
||||||
SDL_Joystick *joystick;
|
SDL_Joystick *joystick;
|
||||||
|
|
||||||
/* Initialize SDL (Note: video is required to start event loop) */
|
/* Initialize SDL (Note: video is required to start event loop) */
|
||||||
if (SDL_Init(SDL_INIT_JOYSTICK) < 0) {
|
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK) < 0) {
|
||||||
fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError());
|
fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError());
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Initialize test framework */
|
|
||||||
state = CommonCreateState(argv, SDL_INIT_VIDEO | SDL_INIT_JOYSTICK);
|
|
||||||
if (!state) {
|
|
||||||
fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError());
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Print information about the joysticks */
|
/* Print information about the joysticks */
|
||||||
printf("There are %d joysticks attached\n", SDL_NumJoysticks());
|
printf("There are %d joysticks attached\n", SDL_NumJoysticks());
|
||||||
for (i = 0; i < SDL_NumJoysticks(); ++i) {
|
for (i = 0; i < SDL_NumJoysticks(); ++i) {
|
||||||
name = SDL_JoystickName(i);
|
name = SDL_JoystickNameForIndex(i);
|
||||||
printf("Joystick %d: %s\n", i, name ? name : "Unknown Joystick");
|
printf("Joystick %d: %s\n", i, name ? name : "Unknown Joystick");
|
||||||
joystick = SDL_JoystickOpen(i);
|
joystick = SDL_JoystickOpen(i);
|
||||||
if (joystick == NULL) {
|
if (joystick == NULL) {
|
||||||
|
@ -205,42 +218,34 @@ main(int argc, char *argv[])
|
||||||
printf(" balls: %d\n", SDL_JoystickNumBalls(joystick));
|
printf(" balls: %d\n", SDL_JoystickNumBalls(joystick));
|
||||||
printf(" hats: %d\n", SDL_JoystickNumHats(joystick));
|
printf(" hats: %d\n", SDL_JoystickNumHats(joystick));
|
||||||
printf(" buttons: %d\n", SDL_JoystickNumButtons(joystick));
|
printf(" buttons: %d\n", SDL_JoystickNumButtons(joystick));
|
||||||
|
printf("instance id: %d\n", SDL_JoystickInstanceID(joystick));
|
||||||
SDL_JoystickClose(joystick);
|
SDL_JoystickClose(joystick);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 1; i < argc;) {
|
if (argv[1]) {
|
||||||
int consumed;
|
int nreportederror = 0;
|
||||||
|
SDL_Event event;
|
||||||
|
joystick = SDL_JoystickOpen(atoi(argv[1]));
|
||||||
|
while ( 1 ) {
|
||||||
|
if (joystick == NULL) {
|
||||||
|
if ( nreportederror == 0 ) {
|
||||||
|
printf("Couldn't open joystick %d: %s\n", atoi(argv[1]), SDL_GetError());
|
||||||
|
nreportederror = 1;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
nreportederror = 0;
|
||||||
|
WatchJoystick(joystick);
|
||||||
|
SDL_JoystickClose(joystick);
|
||||||
|
}
|
||||||
|
|
||||||
consumed = CommonArg(state, i);
|
joystick = NULL;
|
||||||
if (consumed == 0) {
|
SDL_WaitEvent( &event );
|
||||||
consumed = -1;
|
if ( event.type == SDL_JOYDEVICEADDED )
|
||||||
if (SDL_isdigit(*argv[i])) {
|
joystick = SDL_JoystickOpen(atoi(argv[1]));
|
||||||
joy = SDL_atoi(argv[i]);
|
}
|
||||||
consumed = 1;
|
}
|
||||||
}
|
SDL_QuitSubSystem(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK);
|
||||||
}
|
|
||||||
if (consumed < 0) {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
i += consumed;
|
|
||||||
}
|
|
||||||
if (!CommonInit(state)) {
|
|
||||||
return 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (joy > -1) {
|
|
||||||
joystick = SDL_JoystickOpen(joy);
|
|
||||||
if (joystick == NULL) {
|
|
||||||
printf("Couldn't open joystick %d: %s\n", joy,
|
|
||||||
SDL_GetError());
|
|
||||||
} else {
|
|
||||||
WatchJoystick(joystick);
|
|
||||||
SDL_JoystickClose(joystick);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
SDL_QuitSubSystem(SDL_INIT_JOYSTICK);
|
|
||||||
CommonQuit(state);
|
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue