mirror of https://github.com/libsdl-org/SDL
testcontroller replaces gamepadmap
This commit is contained in:
parent
8296242f2e
commit
505a8dfb15
|
@ -40,8 +40,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testcontroller", "tests\tes
|
|||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testgles2", "tests\testgles2\testgles2.vcxproj", "{E9558DFE-1961-4DD4-B09B-DD0EEFD5C315}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gamepadmap", "tests\gamepadmap\gamepadmap.vcxproj", "{55812185-D13C-4022-9C81-32E0F4A08306}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testvulkan", "tests\testvulkan\testvulkan.vcxproj", "{0D604DFD-AAB6-442C-9368-F91A344146AB}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testwm", "tests\testwm\testwm.vcxproj", "{C4E04D18-EF76-4B42-B4C2-16A1BACDC0A5}"
|
||||
|
@ -124,14 +122,6 @@ Global
|
|||
{8B5CFB38-CCBA-40A8-AD7A-89C57B070884}.Release|Win32.Build.0 = Release|Win32
|
||||
{8B5CFB38-CCBA-40A8-AD7A-89C57B070884}.Release|x64.ActiveCfg = Release|x64
|
||||
{8B5CFB38-CCBA-40A8-AD7A-89C57B070884}.Release|x64.Build.0 = Release|x64
|
||||
{55812185-D13C-4022-9C81-32E0F4A08304}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{55812185-D13C-4022-9C81-32E0F4A08304}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{55812185-D13C-4022-9C81-32E0F4A08304}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{55812185-D13C-4022-9C81-32E0F4A08304}.Debug|x64.Build.0 = Debug|x64
|
||||
{55812185-D13C-4022-9C81-32E0F4A08304}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{55812185-D13C-4022-9C81-32E0F4A08304}.Release|Win32.Build.0 = Release|Win32
|
||||
{55812185-D13C-4022-9C81-32E0F4A08304}.Release|x64.ActiveCfg = Release|x64
|
||||
{55812185-D13C-4022-9C81-32E0F4A08304}.Release|x64.Build.0 = Release|x64
|
||||
{B51E0D74-F0A2-45A2-BD2A-8B7D95B8204A}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{B51E0D74-F0A2-45A2-BD2A-8B7D95B8204A}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{B51E0D74-F0A2-45A2-BD2A-8B7D95B8204A}.Debug|x64.ActiveCfg = Debug|x64
|
||||
|
@ -220,14 +210,6 @@ Global
|
|||
{E9558DFE-1961-4DD4-B09B-DD0EEFD5C315}.Release|Win32.Build.0 = Release|Win32
|
||||
{E9558DFE-1961-4DD4-B09B-DD0EEFD5C315}.Release|x64.ActiveCfg = Release|x64
|
||||
{E9558DFE-1961-4DD4-B09B-DD0EEFD5C315}.Release|x64.Build.0 = Release|x64
|
||||
{55812185-D13C-4022-9C81-32E0F4A08306}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{55812185-D13C-4022-9C81-32E0F4A08306}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{55812185-D13C-4022-9C81-32E0F4A08306}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{55812185-D13C-4022-9C81-32E0F4A08306}.Debug|x64.Build.0 = Debug|x64
|
||||
{55812185-D13C-4022-9C81-32E0F4A08306}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{55812185-D13C-4022-9C81-32E0F4A08306}.Release|Win32.Build.0 = Release|Win32
|
||||
{55812185-D13C-4022-9C81-32E0F4A08306}.Release|x64.ActiveCfg = Release|x64
|
||||
{55812185-D13C-4022-9C81-32E0F4A08306}.Release|x64.Build.0 = Release|x64
|
||||
{0D604DFD-AAB6-442C-9368-F91A344146AB}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{0D604DFD-AAB6-442C-9368-F91A344146AB}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{0D604DFD-AAB6-442C-9368-F91A344146AB}.Debug|x64.ActiveCfg = Debug|x64
|
||||
|
@ -280,7 +262,6 @@ Global
|
|||
{8682FE1E-0CF6-4EDD-9BB5-1733D8C8B4DF} = {D69D5741-611F-4E14-8541-1FEE94F50B5A}
|
||||
{CAE4F1D0-314F-4B10-805B-0EFD670133A0} = {D69D5741-611F-4E14-8541-1FEE94F50B5A}
|
||||
{8B5CFB38-CCBA-40A8-AD7A-89C57B070884} = {D69D5741-611F-4E14-8541-1FEE94F50B5A}
|
||||
{55812185-D13C-4022-9C81-32E0F4A08304} = {D69D5741-611F-4E14-8541-1FEE94F50B5A}
|
||||
{B51E0D74-F0A2-45A2-BD2A-8B7D95B8204A} = {D69D5741-611F-4E14-8541-1FEE94F50B5A}
|
||||
{26932B24-EFC6-4E3A-B277-ED653DA37968} = {D69D5741-611F-4E14-8541-1FEE94F50B5A}
|
||||
{C4E04D18-EF76-4B42-B4C2-16A1BACDC0A3} = {D69D5741-611F-4E14-8541-1FEE94F50B5A}
|
||||
|
@ -291,7 +272,6 @@ Global
|
|||
{40FB7794-D3C3-4CFE-BCF4-A80C96635682} = {D69D5741-611F-4E14-8541-1FEE94F50B5A}
|
||||
{55812185-D13C-4022-9C81-32E0F4A08305} = {D69D5741-611F-4E14-8541-1FEE94F50B5A}
|
||||
{E9558DFE-1961-4DD4-B09B-DD0EEFD5C315} = {D69D5741-611F-4E14-8541-1FEE94F50B5A}
|
||||
{55812185-D13C-4022-9C81-32E0F4A08306} = {D69D5741-611F-4E14-8541-1FEE94F50B5A}
|
||||
{0D604DFD-AAB6-442C-9368-F91A344146AB} = {D69D5741-611F-4E14-8541-1FEE94F50B5A}
|
||||
{C4E04D18-EF76-4B42-B4C2-16A1BACDC0A5} = {D69D5741-611F-4E14-8541-1FEE94F50B5A}
|
||||
{40FB7794-D3C3-4CFE-BCF4-A80C97635682} = {D69D5741-611F-4E14-8541-1FEE94F50B5A}
|
||||
|
|
|
@ -1,206 +0,0 @@
|
|||
<?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">
|
||||
<ProjectGuid>{55812185-D13C-4022-9C81-32E0F4A08306}</ProjectGuid>
|
||||
<RootNamespace>gamepadmap</RootNamespace>
|
||||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<PlatformToolset Condition="'$(VisualStudioVersion)' != '10.0'">$(DefaultPlatformToolset)</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<PlatformToolset Condition="'$(VisualStudioVersion)' != '10.0'">$(DefaultPlatformToolset)</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<PlatformToolset Condition="'$(VisualStudioVersion)' != '10.0'">$(DefaultPlatformToolset)</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<PlatformToolset Condition="'$(VisualStudioVersion)' != '10.0'">$(DefaultPlatformToolset)</PlatformToolset>
|
||||
</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)'=='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)'=='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|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.40219.1</_ProjectFileVersion>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(Platform)\$(Configuration)\</IntDir>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(Platform)\$(Configuration)\</IntDir>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(Platform)\$(Configuration)\</IntDir>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(Platform)\$(Configuration)\</IntDir>
|
||||
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
|
||||
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
|
||||
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" />
|
||||
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" />
|
||||
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
|
||||
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
|
||||
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|x64'">AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|x64'" />
|
||||
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|x64'" />
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Midl>
|
||||
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<MkTypLibCompatible>true</MkTypLibCompatible>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
<TargetEnvironment>Win32</TargetEnvironment>
|
||||
<TypeLibraryName>.\Release/gamepadmap.tlb</TypeLibraryName>
|
||||
</Midl>
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)/../include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<AdditionalUsingDirectories>%(AdditionalUsingDirectories)</AdditionalUsingDirectories>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
</ClCompile>
|
||||
<ResourceCompile>
|
||||
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<Culture>0x0409</Culture>
|
||||
</ResourceCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Midl>
|
||||
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<MkTypLibCompatible>true</MkTypLibCompatible>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
<TargetEnvironment>X64</TargetEnvironment>
|
||||
<TypeLibraryName>.\Release/gamepadmap.tlb</TypeLibraryName>
|
||||
</Midl>
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)/../include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<AdditionalUsingDirectories>%(AdditionalUsingDirectories)</AdditionalUsingDirectories>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
</ClCompile>
|
||||
<ResourceCompile>
|
||||
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<Culture>0x0409</Culture>
|
||||
</ResourceCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Midl>
|
||||
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<MkTypLibCompatible>true</MkTypLibCompatible>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
<TargetEnvironment>Win32</TargetEnvironment>
|
||||
<TypeLibraryName>.\Debug/gamepadmap.tlb</TypeLibraryName>
|
||||
</Midl>
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)/../include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<AdditionalUsingDirectories>%(AdditionalUsingDirectories)</AdditionalUsingDirectories>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>OldStyle</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
<ResourceCompile>
|
||||
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<Culture>0x0409</Culture>
|
||||
</ResourceCompile>
|
||||
<Link>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Midl>
|
||||
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<MkTypLibCompatible>true</MkTypLibCompatible>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
<TargetEnvironment>X64</TargetEnvironment>
|
||||
<TypeLibraryName>.\Debug/gamepadmap.tlb</TypeLibraryName>
|
||||
</Midl>
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)/../include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<AdditionalUsingDirectories>%(AdditionalUsingDirectories)</AdditionalUsingDirectories>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>OldStyle</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
<ResourceCompile>
|
||||
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<Culture>0x0409</Culture>
|
||||
</ResourceCompile>
|
||||
<Link>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\SDL\SDL.vcxproj">
|
||||
<Project>{81ce8daf-ebb2-4761-8e45-b71abcca8c68}</Project>
|
||||
<Private>false</Private>
|
||||
<CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
|
||||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\SDL_test\SDL_test.vcxproj">
|
||||
<Project>{da956fd3-e143-46f2-9fe5-c77bebc56b1a}</Project>
|
||||
<Private>false</Private>
|
||||
<CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
|
||||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\..\test\gamepadmap.c" />
|
||||
<ClCompile Include="..\..\..\test\gamepadutils.c" />
|
||||
<ClCompile Include="..\..\..\test\testutils.c" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
|
@ -257,7 +257,6 @@ add_sdl_test_executable(testdisplayinfo SOURCES testdisplayinfo.c)
|
|||
add_sdl_test_executable(testqsort NONINTERACTIVE SOURCES testqsort.c)
|
||||
add_sdl_test_executable(testbounds NONINTERACTIVE SOURCES testbounds.c)
|
||||
add_sdl_test_executable(testcustomcursor SOURCES testcustomcursor.c)
|
||||
add_sdl_test_executable(gamepadmap TESTUTILS SOURCES gamepadmap.c gamepadutils.c)
|
||||
add_sdl_test_executable(testvulkan NO_C90 SOURCES testvulkan.c)
|
||||
add_sdl_test_executable(testoffscreen SOURCES testoffscreen.c)
|
||||
add_sdl_test_executable(testpopup SOURCES testpopup.c)
|
||||
|
|
|
@ -1,822 +0,0 @@
|
|||
/*
|
||||
Copyright (C) 1997-2023 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.
|
||||
*/
|
||||
|
||||
/* Gamepad mapping generator */
|
||||
/* Gabriel Jacobo <gabomdq@gmail.com> */
|
||||
|
||||
#include <SDL3/SDL.h>
|
||||
#include <SDL3/SDL_main.h>
|
||||
#include <SDL3/SDL_test.h>
|
||||
|
||||
#include "testutils.h"
|
||||
#include "gamepadutils.h"
|
||||
|
||||
/* Define this for verbose output while mapping gamepads */
|
||||
#define DEBUG_GAMEPADMAP
|
||||
|
||||
#define SCREEN_WIDTH 512
|
||||
#define SCREEN_HEIGHT 320
|
||||
|
||||
enum
|
||||
{
|
||||
SDL_GAMEPAD_BINDING_AXIS_LEFTX_NEGATIVE,
|
||||
SDL_GAMEPAD_BINDING_AXIS_LEFTX_POSITIVE,
|
||||
SDL_GAMEPAD_BINDING_AXIS_LEFTY_NEGATIVE,
|
||||
SDL_GAMEPAD_BINDING_AXIS_LEFTY_POSITIVE,
|
||||
SDL_GAMEPAD_BINDING_AXIS_RIGHTX_NEGATIVE,
|
||||
SDL_GAMEPAD_BINDING_AXIS_RIGHTX_POSITIVE,
|
||||
SDL_GAMEPAD_BINDING_AXIS_RIGHTY_NEGATIVE,
|
||||
SDL_GAMEPAD_BINDING_AXIS_RIGHTY_POSITIVE,
|
||||
SDL_GAMEPAD_BINDING_AXIS_TRIGGERLEFT,
|
||||
SDL_GAMEPAD_BINDING_AXIS_TRIGGERRIGHT,
|
||||
SDL_GAMEPAD_BINDING_AXIS_MAX,
|
||||
};
|
||||
|
||||
#define BINDING_COUNT (SDL_GAMEPAD_BUTTON_MAX + SDL_GAMEPAD_BINDING_AXIS_MAX)
|
||||
|
||||
static int s_arrBindingOrder[] = {
|
||||
SDL_GAMEPAD_BUTTON_A,
|
||||
SDL_GAMEPAD_BUTTON_B,
|
||||
SDL_GAMEPAD_BUTTON_Y,
|
||||
SDL_GAMEPAD_BUTTON_X,
|
||||
SDL_GAMEPAD_BUTTON_MAX + SDL_GAMEPAD_BINDING_AXIS_LEFTX_NEGATIVE,
|
||||
SDL_GAMEPAD_BUTTON_MAX + SDL_GAMEPAD_BINDING_AXIS_LEFTX_POSITIVE,
|
||||
SDL_GAMEPAD_BUTTON_MAX + SDL_GAMEPAD_BINDING_AXIS_LEFTY_NEGATIVE,
|
||||
SDL_GAMEPAD_BUTTON_MAX + SDL_GAMEPAD_BINDING_AXIS_LEFTY_POSITIVE,
|
||||
SDL_GAMEPAD_BUTTON_LEFT_STICK,
|
||||
SDL_GAMEPAD_BUTTON_MAX + SDL_GAMEPAD_BINDING_AXIS_RIGHTX_NEGATIVE,
|
||||
SDL_GAMEPAD_BUTTON_MAX + SDL_GAMEPAD_BINDING_AXIS_RIGHTX_POSITIVE,
|
||||
SDL_GAMEPAD_BUTTON_MAX + SDL_GAMEPAD_BINDING_AXIS_RIGHTY_NEGATIVE,
|
||||
SDL_GAMEPAD_BUTTON_MAX + SDL_GAMEPAD_BINDING_AXIS_RIGHTY_POSITIVE,
|
||||
SDL_GAMEPAD_BUTTON_RIGHT_STICK,
|
||||
SDL_GAMEPAD_BUTTON_LEFT_SHOULDER,
|
||||
SDL_GAMEPAD_BUTTON_MAX + SDL_GAMEPAD_BINDING_AXIS_TRIGGERLEFT,
|
||||
SDL_GAMEPAD_BUTTON_RIGHT_SHOULDER,
|
||||
SDL_GAMEPAD_BUTTON_MAX + SDL_GAMEPAD_BINDING_AXIS_TRIGGERRIGHT,
|
||||
SDL_GAMEPAD_BUTTON_DPAD_UP,
|
||||
SDL_GAMEPAD_BUTTON_DPAD_RIGHT,
|
||||
SDL_GAMEPAD_BUTTON_DPAD_DOWN,
|
||||
SDL_GAMEPAD_BUTTON_DPAD_LEFT,
|
||||
SDL_GAMEPAD_BUTTON_BACK,
|
||||
SDL_GAMEPAD_BUTTON_GUIDE,
|
||||
SDL_GAMEPAD_BUTTON_START,
|
||||
SDL_GAMEPAD_BUTTON_MISC1,
|
||||
SDL_GAMEPAD_BUTTON_PADDLE1,
|
||||
SDL_GAMEPAD_BUTTON_PADDLE2,
|
||||
SDL_GAMEPAD_BUTTON_PADDLE3,
|
||||
SDL_GAMEPAD_BUTTON_PADDLE4,
|
||||
SDL_GAMEPAD_BUTTON_TOUCHPAD,
|
||||
};
|
||||
SDL_COMPILE_TIME_ASSERT(s_arrBindingOrder, SDL_arraysize(s_arrBindingOrder) == BINDING_COUNT);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
SDL_GamepadBindingType bindType;
|
||||
union
|
||||
{
|
||||
int button;
|
||||
|
||||
struct
|
||||
{
|
||||
int axis;
|
||||
int axis_min;
|
||||
int axis_max;
|
||||
} axis;
|
||||
|
||||
struct
|
||||
{
|
||||
int hat;
|
||||
int hat_mask;
|
||||
} hat;
|
||||
|
||||
} value;
|
||||
|
||||
SDL_bool committed;
|
||||
|
||||
} SDL_GameControllerExtendedBind;
|
||||
|
||||
static SDL_GameControllerExtendedBind s_arrBindings[BINDING_COUNT];
|
||||
|
||||
typedef struct
|
||||
{
|
||||
SDL_bool m_bMoving;
|
||||
int m_nLastValue;
|
||||
int m_nStartingValue;
|
||||
int m_nFarthestValue;
|
||||
} AxisState;
|
||||
|
||||
static int s_nNumAxes;
|
||||
static AxisState *s_arrAxisState;
|
||||
|
||||
static int s_iCurrentBinding;
|
||||
static Uint64 s_unPendingAdvanceTime;
|
||||
static SDL_bool s_bBindingComplete;
|
||||
|
||||
static SDL_Window *window;
|
||||
static SDL_Renderer *screen;
|
||||
static GamepadImage *image;
|
||||
static SDL_bool done = SDL_FALSE;
|
||||
static SDL_bool bind_touchpad = SDL_FALSE;
|
||||
|
||||
static int
|
||||
StandardizeAxisValue(int nValue)
|
||||
{
|
||||
if (nValue > SDL_JOYSTICK_AXIS_MAX / 2) {
|
||||
return SDL_JOYSTICK_AXIS_MAX;
|
||||
} else if (nValue < SDL_JOYSTICK_AXIS_MIN / 2) {
|
||||
return SDL_JOYSTICK_AXIS_MIN;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
SetCurrentBinding(int iBinding)
|
||||
{
|
||||
int iIndex, iElement;
|
||||
SDL_GameControllerExtendedBind *pBinding;
|
||||
SDL_bool on_front;
|
||||
|
||||
if (iBinding < 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (iBinding == BINDING_COUNT) {
|
||||
s_bBindingComplete = SDL_TRUE;
|
||||
return;
|
||||
}
|
||||
|
||||
if (s_arrBindingOrder[iBinding] == -1) {
|
||||
SetCurrentBinding(iBinding + 1);
|
||||
return;
|
||||
}
|
||||
|
||||
if (s_arrBindingOrder[iBinding] == SDL_GAMEPAD_BUTTON_TOUCHPAD &&
|
||||
!bind_touchpad) {
|
||||
SetCurrentBinding(iBinding + 1);
|
||||
return;
|
||||
}
|
||||
|
||||
s_iCurrentBinding = iBinding;
|
||||
|
||||
pBinding = &s_arrBindings[s_arrBindingOrder[s_iCurrentBinding]];
|
||||
SDL_zerop(pBinding);
|
||||
|
||||
for (iIndex = 0; iIndex < s_nNumAxes; ++iIndex) {
|
||||
s_arrAxisState[iIndex].m_nFarthestValue = s_arrAxisState[iIndex].m_nStartingValue;
|
||||
}
|
||||
|
||||
iElement = s_arrBindingOrder[iBinding];
|
||||
on_front = SDL_TRUE;
|
||||
if (iElement >= SDL_GAMEPAD_BUTTON_PADDLE1 &&
|
||||
iElement <= SDL_GAMEPAD_BUTTON_PADDLE4) {
|
||||
on_front = SDL_FALSE;
|
||||
}
|
||||
SetGamepadImageShowingFront(image, on_front);
|
||||
|
||||
ClearGamepadImage(image);
|
||||
if (iElement < SDL_GAMEPAD_BUTTON_MAX) {
|
||||
SDL_GamepadButton eButton = (SDL_GamepadButton)iElement;
|
||||
SetGamepadImageButton(image, eButton, SDL_TRUE);
|
||||
} else {
|
||||
switch (iElement - SDL_GAMEPAD_BUTTON_MAX) {
|
||||
case SDL_GAMEPAD_BINDING_AXIS_LEFTX_NEGATIVE:
|
||||
SetGamepadImageAxis(image, SDL_GAMEPAD_AXIS_LEFTX, -1);
|
||||
break;
|
||||
case SDL_GAMEPAD_BINDING_AXIS_LEFTX_POSITIVE:
|
||||
SetGamepadImageAxis(image, SDL_GAMEPAD_AXIS_LEFTX, 1);
|
||||
break;
|
||||
case SDL_GAMEPAD_BINDING_AXIS_LEFTY_NEGATIVE:
|
||||
SetGamepadImageAxis(image, SDL_GAMEPAD_AXIS_LEFTY, -1);
|
||||
break;
|
||||
case SDL_GAMEPAD_BINDING_AXIS_LEFTY_POSITIVE:
|
||||
SetGamepadImageAxis(image, SDL_GAMEPAD_AXIS_LEFTY, 1);
|
||||
break;
|
||||
case SDL_GAMEPAD_BINDING_AXIS_RIGHTX_NEGATIVE:
|
||||
SetGamepadImageAxis(image, SDL_GAMEPAD_AXIS_RIGHTX, -1);
|
||||
break;
|
||||
case SDL_GAMEPAD_BINDING_AXIS_RIGHTX_POSITIVE:
|
||||
SetGamepadImageAxis(image, SDL_GAMEPAD_AXIS_RIGHTX, 1);
|
||||
break;
|
||||
case SDL_GAMEPAD_BINDING_AXIS_RIGHTY_NEGATIVE:
|
||||
SetGamepadImageAxis(image, SDL_GAMEPAD_AXIS_RIGHTY, -1);
|
||||
break;
|
||||
case SDL_GAMEPAD_BINDING_AXIS_RIGHTY_POSITIVE:
|
||||
SetGamepadImageAxis(image, SDL_GAMEPAD_AXIS_RIGHTY, 1);
|
||||
break;
|
||||
case SDL_GAMEPAD_BINDING_AXIS_TRIGGERLEFT:
|
||||
SetGamepadImageAxis(image, SDL_GAMEPAD_AXIS_LEFT_TRIGGER, 1);
|
||||
break;
|
||||
case SDL_GAMEPAD_BINDING_AXIS_TRIGGERRIGHT:
|
||||
SetGamepadImageAxis(image, SDL_GAMEPAD_AXIS_RIGHT_TRIGGER, 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
s_unPendingAdvanceTime = 0;
|
||||
}
|
||||
|
||||
static SDL_bool
|
||||
BBindingContainsBinding(const SDL_GameControllerExtendedBind *pBindingA, const SDL_GameControllerExtendedBind *pBindingB)
|
||||
{
|
||||
if (pBindingA->bindType != pBindingB->bindType) {
|
||||
return SDL_FALSE;
|
||||
}
|
||||
switch (pBindingA->bindType) {
|
||||
case SDL_GAMEPAD_BINDTYPE_AXIS:
|
||||
if (pBindingA->value.axis.axis != pBindingB->value.axis.axis) {
|
||||
return SDL_FALSE;
|
||||
}
|
||||
if (!pBindingA->committed) {
|
||||
return SDL_FALSE;
|
||||
}
|
||||
{
|
||||
int minA = SDL_min(pBindingA->value.axis.axis_min, pBindingA->value.axis.axis_max);
|
||||
int maxA = SDL_max(pBindingA->value.axis.axis_min, pBindingA->value.axis.axis_max);
|
||||
int minB = SDL_min(pBindingB->value.axis.axis_min, pBindingB->value.axis.axis_max);
|
||||
int maxB = SDL_max(pBindingB->value.axis.axis_min, pBindingB->value.axis.axis_max);
|
||||
return minA <= minB && maxA >= maxB;
|
||||
}
|
||||
/* Not reached */
|
||||
default:
|
||||
return SDL_memcmp(pBindingA, pBindingB, sizeof(*pBindingA)) == 0;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
ConfigureBinding(const SDL_GameControllerExtendedBind *pBinding)
|
||||
{
|
||||
SDL_GameControllerExtendedBind *pCurrent;
|
||||
int iIndex;
|
||||
int iCurrentElement = s_arrBindingOrder[s_iCurrentBinding];
|
||||
|
||||
/* Do we already have this binding? */
|
||||
for (iIndex = 0; iIndex < SDL_arraysize(s_arrBindings); ++iIndex) {
|
||||
pCurrent = &s_arrBindings[iIndex];
|
||||
if (BBindingContainsBinding(pCurrent, pBinding)) {
|
||||
if (iIndex == SDL_GAMEPAD_BUTTON_A && iCurrentElement != SDL_GAMEPAD_BUTTON_B) {
|
||||
/* Skip to the next binding */
|
||||
SetCurrentBinding(s_iCurrentBinding + 1);
|
||||
return;
|
||||
}
|
||||
|
||||
if (iIndex == SDL_GAMEPAD_BUTTON_B) {
|
||||
/* Go back to the previous binding */
|
||||
SetCurrentBinding(s_iCurrentBinding - 1);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Already have this binding, ignore it */
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef DEBUG_GAMEPADMAP
|
||||
switch (pBinding->bindType) {
|
||||
case SDL_GAMEPAD_BINDTYPE_NONE:
|
||||
break;
|
||||
case SDL_GAMEPAD_BINDTYPE_BUTTON:
|
||||
SDL_Log("Configuring button binding for button %d\n", pBinding->value.button);
|
||||
break;
|
||||
case SDL_GAMEPAD_BINDTYPE_AXIS:
|
||||
SDL_Log("Configuring axis binding for axis %d %d/%d committed = %s\n", pBinding->value.axis.axis, pBinding->value.axis.axis_min, pBinding->value.axis.axis_max, pBinding->committed ? "true" : "false");
|
||||
break;
|
||||
case SDL_GAMEPAD_BINDTYPE_HAT:
|
||||
SDL_Log("Configuring hat binding for hat %d %d\n", pBinding->value.hat.hat, pBinding->value.hat.hat_mask);
|
||||
break;
|
||||
}
|
||||
#endif /* DEBUG_GAMEPADMAP */
|
||||
|
||||
/* Should the new binding override the existing one? */
|
||||
pCurrent = &s_arrBindings[iCurrentElement];
|
||||
if (pCurrent->bindType != SDL_GAMEPAD_BINDTYPE_NONE) {
|
||||
SDL_bool bNativeDPad, bCurrentDPad;
|
||||
SDL_bool bNativeAxis, bCurrentAxis;
|
||||
|
||||
bNativeDPad = (iCurrentElement == SDL_GAMEPAD_BUTTON_DPAD_UP ||
|
||||
iCurrentElement == SDL_GAMEPAD_BUTTON_DPAD_DOWN ||
|
||||
iCurrentElement == SDL_GAMEPAD_BUTTON_DPAD_LEFT ||
|
||||
iCurrentElement == SDL_GAMEPAD_BUTTON_DPAD_RIGHT);
|
||||
bCurrentDPad = (pCurrent->bindType == SDL_GAMEPAD_BINDTYPE_HAT);
|
||||
if (bNativeDPad && bCurrentDPad) {
|
||||
/* We already have a binding of the type we want, ignore the new one */
|
||||
return;
|
||||
}
|
||||
|
||||
bNativeAxis = (iCurrentElement >= SDL_GAMEPAD_BUTTON_MAX);
|
||||
bCurrentAxis = (pCurrent->bindType == SDL_GAMEPAD_BINDTYPE_AXIS);
|
||||
if (bNativeAxis == bCurrentAxis &&
|
||||
(pBinding->bindType != SDL_GAMEPAD_BINDTYPE_AXIS ||
|
||||
pBinding->value.axis.axis != pCurrent->value.axis.axis)) {
|
||||
/* We already have a binding of the type we want, ignore the new one */
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
*pCurrent = *pBinding;
|
||||
|
||||
if (pBinding->committed) {
|
||||
s_unPendingAdvanceTime = SDL_GetTicks();
|
||||
} else {
|
||||
s_unPendingAdvanceTime = 0;
|
||||
}
|
||||
}
|
||||
|
||||
static SDL_bool
|
||||
BMergeAxisBindings(int iIndex)
|
||||
{
|
||||
SDL_GameControllerExtendedBind *pBindingA = &s_arrBindings[iIndex];
|
||||
SDL_GameControllerExtendedBind *pBindingB = &s_arrBindings[iIndex + 1];
|
||||
if (pBindingA->bindType == SDL_GAMEPAD_BINDTYPE_AXIS &&
|
||||
pBindingB->bindType == SDL_GAMEPAD_BINDTYPE_AXIS &&
|
||||
pBindingA->value.axis.axis == pBindingB->value.axis.axis) {
|
||||
if (pBindingA->value.axis.axis_min == pBindingB->value.axis.axis_min) {
|
||||
pBindingA->value.axis.axis_min = pBindingA->value.axis.axis_max;
|
||||
pBindingA->value.axis.axis_max = pBindingB->value.axis.axis_max;
|
||||
pBindingB->bindType = SDL_GAMEPAD_BINDTYPE_NONE;
|
||||
return SDL_TRUE;
|
||||
}
|
||||
}
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
WatchJoystick(SDL_Joystick *joystick)
|
||||
{
|
||||
const char *name = NULL;
|
||||
SDL_Event event;
|
||||
SDL_JoystickID nJoystickID;
|
||||
|
||||
image = CreateGamepadImage(screen);
|
||||
|
||||
SDL_RaiseWindow(window);
|
||||
|
||||
/* scale for platforms that don't give you the window size you asked for. */
|
||||
SDL_SetRenderLogicalPresentation(screen, SCREEN_WIDTH, SCREEN_HEIGHT,
|
||||
SDL_LOGICAL_PRESENTATION_LETTERBOX,
|
||||
SDL_SCALEMODE_LINEAR);
|
||||
|
||||
/* Print info about the joystick we are watching */
|
||||
name = SDL_GetJoystickName(joystick);
|
||||
SDL_Log("Watching joystick %" SDL_PRIs32 ": (%s)\n", SDL_GetJoystickInstanceID(joystick),
|
||||
name ? name : "Unknown Joystick");
|
||||
SDL_Log("Joystick has %d axes, %d hats, and %d buttons\n",
|
||||
SDL_GetNumJoystickAxes(joystick), SDL_GetNumJoystickHats(joystick), SDL_GetNumJoystickButtons(joystick));
|
||||
|
||||
SDL_Log("\n\n\
|
||||
====================================================================================\n\
|
||||
Press the buttons on your gamepad when indicated\n\
|
||||
(Your gamepad may look different than the picture)\n\
|
||||
If you want to correct a mistake, press backspace or the back button on your device\n\
|
||||
To skip a button, press SPACE or click/touch the screen\n\
|
||||
To exit, press ESC\n\
|
||||
====================================================================================\n");
|
||||
|
||||
nJoystickID = SDL_GetJoystickInstanceID(joystick);
|
||||
|
||||
s_nNumAxes = SDL_GetNumJoystickAxes(joystick);
|
||||
s_arrAxisState = (AxisState *)SDL_calloc(s_nNumAxes, sizeof(*s_arrAxisState));
|
||||
|
||||
/* Skip any spurious events at start */
|
||||
while (SDL_PollEvent(&event) > 0) {
|
||||
}
|
||||
|
||||
SetCurrentBinding(0);
|
||||
|
||||
/* Loop, getting joystick events! */
|
||||
while (!done && !s_bBindingComplete) {
|
||||
SDL_SetRenderDrawColor(screen, 0xFF, 0xFF, 0xFF, SDL_ALPHA_OPAQUE);
|
||||
SDL_RenderClear(screen);
|
||||
RenderGamepadImage(image);
|
||||
SDL_RenderPresent(screen);
|
||||
|
||||
while (SDL_PollEvent(&event) > 0) {
|
||||
switch (event.type) {
|
||||
case SDL_EVENT_JOYSTICK_REMOVED:
|
||||
if (event.jaxis.which == nJoystickID) {
|
||||
done = SDL_TRUE;
|
||||
}
|
||||
break;
|
||||
case SDL_EVENT_JOYSTICK_AXIS_MOTION:
|
||||
if (event.jaxis.which == nJoystickID) {
|
||||
const int MAX_ALLOWED_JITTER = SDL_JOYSTICK_AXIS_MAX / 80; /* ShanWan PS3 gamepad needed 96 */
|
||||
AxisState *pAxisState = &s_arrAxisState[event.jaxis.axis];
|
||||
int nValue = event.jaxis.value;
|
||||
int nCurrentDistance, nFarthestDistance;
|
||||
if (!pAxisState->m_bMoving) {
|
||||
Sint16 nInitialValue;
|
||||
pAxisState->m_bMoving = SDL_GetJoystickAxisInitialState(joystick, event.jaxis.axis, &nInitialValue);
|
||||
pAxisState->m_nLastValue = nValue;
|
||||
pAxisState->m_nStartingValue = nInitialValue;
|
||||
pAxisState->m_nFarthestValue = nInitialValue;
|
||||
} else if (SDL_abs(nValue - pAxisState->m_nLastValue) <= MAX_ALLOWED_JITTER) {
|
||||
break;
|
||||
} else {
|
||||
pAxisState->m_nLastValue = nValue;
|
||||
}
|
||||
nCurrentDistance = SDL_abs(nValue - pAxisState->m_nStartingValue);
|
||||
nFarthestDistance = SDL_abs(pAxisState->m_nFarthestValue - pAxisState->m_nStartingValue);
|
||||
if (nCurrentDistance > nFarthestDistance) {
|
||||
pAxisState->m_nFarthestValue = nValue;
|
||||
nFarthestDistance = SDL_abs(pAxisState->m_nFarthestValue - pAxisState->m_nStartingValue);
|
||||
}
|
||||
|
||||
#ifdef DEBUG_GAMEPADMAP
|
||||
SDL_Log("AXIS %d nValue %d nCurrentDistance %d nFarthestDistance %d\n", event.jaxis.axis, nValue, nCurrentDistance, nFarthestDistance);
|
||||
#endif
|
||||
if (nFarthestDistance >= 16000) {
|
||||
/* If we've gone out far enough and started to come back, let's bind this axis */
|
||||
SDL_bool bCommitBinding = (nCurrentDistance <= 10000) ? SDL_TRUE : SDL_FALSE;
|
||||
SDL_GameControllerExtendedBind binding;
|
||||
SDL_zero(binding);
|
||||
binding.bindType = SDL_GAMEPAD_BINDTYPE_AXIS;
|
||||
binding.value.axis.axis = event.jaxis.axis;
|
||||
binding.value.axis.axis_min = StandardizeAxisValue(pAxisState->m_nStartingValue);
|
||||
binding.value.axis.axis_max = StandardizeAxisValue(pAxisState->m_nFarthestValue);
|
||||
binding.committed = bCommitBinding;
|
||||
ConfigureBinding(&binding);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case SDL_EVENT_JOYSTICK_HAT_MOTION:
|
||||
if (event.jhat.which == nJoystickID) {
|
||||
if (event.jhat.value != SDL_HAT_CENTERED) {
|
||||
SDL_GameControllerExtendedBind binding;
|
||||
|
||||
#ifdef DEBUG_GAMEPADMAP
|
||||
SDL_Log("HAT %d %d\n", event.jhat.hat, event.jhat.value);
|
||||
#endif
|
||||
SDL_zero(binding);
|
||||
binding.bindType = SDL_GAMEPAD_BINDTYPE_HAT;
|
||||
binding.value.hat.hat = event.jhat.hat;
|
||||
binding.value.hat.hat_mask = event.jhat.value;
|
||||
binding.committed = SDL_TRUE;
|
||||
ConfigureBinding(&binding);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case SDL_EVENT_JOYSTICK_BUTTON_UP:
|
||||
if (event.jbutton.which == nJoystickID) {
|
||||
SDL_GameControllerExtendedBind binding;
|
||||
|
||||
#ifdef DEBUG_GAMEPADMAP
|
||||
SDL_Log("BUTTON %d\n", event.jbutton.button);
|
||||
#endif
|
||||
SDL_zero(binding);
|
||||
binding.bindType = SDL_GAMEPAD_BINDTYPE_BUTTON;
|
||||
binding.value.button = event.jbutton.button;
|
||||
binding.committed = SDL_TRUE;
|
||||
ConfigureBinding(&binding);
|
||||
}
|
||||
break;
|
||||
case SDL_EVENT_FINGER_DOWN:
|
||||
case SDL_EVENT_MOUSE_BUTTON_DOWN:
|
||||
/* Skip this step */
|
||||
SetCurrentBinding(s_iCurrentBinding + 1);
|
||||
break;
|
||||
case SDL_EVENT_KEY_DOWN:
|
||||
if (event.key.keysym.sym == SDLK_BACKSPACE || event.key.keysym.sym == SDLK_AC_BACK) {
|
||||
SetCurrentBinding(s_iCurrentBinding - 1);
|
||||
break;
|
||||
}
|
||||
if (event.key.keysym.sym == SDLK_SPACE) {
|
||||
SetCurrentBinding(s_iCurrentBinding + 1);
|
||||
break;
|
||||
}
|
||||
|
||||
if (event.key.keysym.sym != SDLK_ESCAPE) {
|
||||
break;
|
||||
}
|
||||
SDL_FALLTHROUGH;
|
||||
case SDL_EVENT_QUIT:
|
||||
done = SDL_TRUE;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
SDL_Delay(15);
|
||||
|
||||
/* Wait 30 ms for joystick events to stop coming in,
|
||||
in case a gamepad sends multiple events for a single control (e.g. axis and button for trigger)
|
||||
*/
|
||||
if (s_unPendingAdvanceTime && SDL_GetTicks() - s_unPendingAdvanceTime >= 30) {
|
||||
SetCurrentBinding(s_iCurrentBinding + 1);
|
||||
}
|
||||
}
|
||||
|
||||
if (s_bBindingComplete) {
|
||||
SDL_JoystickGUID guid;
|
||||
Uint16 crc;
|
||||
char mapping[1024];
|
||||
char trimmed_name[128];
|
||||
char *spot;
|
||||
int iIndex;
|
||||
char pszElement[12];
|
||||
|
||||
SDL_strlcpy(trimmed_name, name, SDL_arraysize(trimmed_name));
|
||||
while (SDL_isspace(trimmed_name[0])) {
|
||||
SDL_memmove(&trimmed_name[0], &trimmed_name[1], SDL_strlen(trimmed_name));
|
||||
}
|
||||
while (trimmed_name[0] && SDL_isspace(trimmed_name[SDL_strlen(trimmed_name) - 1])) {
|
||||
trimmed_name[SDL_strlen(trimmed_name) - 1] = '\0';
|
||||
}
|
||||
while ((spot = SDL_strchr(trimmed_name, ',')) != NULL) {
|
||||
SDL_memmove(spot, spot + 1, SDL_strlen(spot));
|
||||
}
|
||||
|
||||
/* Initialize mapping with GUID and name */
|
||||
guid = SDL_GetJoystickGUID(joystick);
|
||||
SDL_GetJoystickGUIDInfo(guid, NULL, NULL, NULL, &crc);
|
||||
if (crc) {
|
||||
/* Clear the CRC from the GUID for the mapping */
|
||||
guid.data[2] = 0;
|
||||
guid.data[3] = 0;
|
||||
}
|
||||
SDL_GetJoystickGUIDString(guid, mapping, SDL_arraysize(mapping));
|
||||
SDL_strlcat(mapping, ",", SDL_arraysize(mapping));
|
||||
SDL_strlcat(mapping, trimmed_name, SDL_arraysize(mapping));
|
||||
SDL_strlcat(mapping, ",", SDL_arraysize(mapping));
|
||||
SDL_strlcat(mapping, "platform:", SDL_arraysize(mapping));
|
||||
SDL_strlcat(mapping, SDL_GetPlatform(), SDL_arraysize(mapping));
|
||||
SDL_strlcat(mapping, ",", SDL_arraysize(mapping));
|
||||
if (crc) {
|
||||
char crc_string[5];
|
||||
|
||||
SDL_strlcat(mapping, "crc:", SDL_arraysize(mapping));
|
||||
(void)SDL_snprintf(crc_string, sizeof(crc_string), "%.4x", crc);
|
||||
SDL_strlcat(mapping, crc_string, SDL_arraysize(mapping));
|
||||
SDL_strlcat(mapping, ",", SDL_arraysize(mapping));
|
||||
}
|
||||
|
||||
for (iIndex = 0; iIndex < SDL_arraysize(s_arrBindings); ++iIndex) {
|
||||
SDL_GameControllerExtendedBind *pBinding = &s_arrBindings[iIndex];
|
||||
if (pBinding->bindType == SDL_GAMEPAD_BINDTYPE_NONE) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (iIndex < SDL_GAMEPAD_BUTTON_MAX) {
|
||||
SDL_GamepadButton eButton = (SDL_GamepadButton)iIndex;
|
||||
SDL_strlcat(mapping, SDL_GetGamepadStringForButton(eButton), SDL_arraysize(mapping));
|
||||
} else {
|
||||
const char *pszAxisName = NULL;
|
||||
switch (iIndex - SDL_GAMEPAD_BUTTON_MAX) {
|
||||
case SDL_GAMEPAD_BINDING_AXIS_LEFTX_NEGATIVE:
|
||||
if (!BMergeAxisBindings(iIndex)) {
|
||||
SDL_strlcat(mapping, "-", SDL_arraysize(mapping));
|
||||
}
|
||||
pszAxisName = SDL_GetGamepadStringForAxis(SDL_GAMEPAD_AXIS_LEFTX);
|
||||
break;
|
||||
case SDL_GAMEPAD_BINDING_AXIS_LEFTX_POSITIVE:
|
||||
SDL_strlcat(mapping, "+", SDL_arraysize(mapping));
|
||||
pszAxisName = SDL_GetGamepadStringForAxis(SDL_GAMEPAD_AXIS_LEFTX);
|
||||
break;
|
||||
case SDL_GAMEPAD_BINDING_AXIS_LEFTY_NEGATIVE:
|
||||
if (!BMergeAxisBindings(iIndex)) {
|
||||
SDL_strlcat(mapping, "-", SDL_arraysize(mapping));
|
||||
}
|
||||
pszAxisName = SDL_GetGamepadStringForAxis(SDL_GAMEPAD_AXIS_LEFTY);
|
||||
break;
|
||||
case SDL_GAMEPAD_BINDING_AXIS_LEFTY_POSITIVE:
|
||||
SDL_strlcat(mapping, "+", SDL_arraysize(mapping));
|
||||
pszAxisName = SDL_GetGamepadStringForAxis(SDL_GAMEPAD_AXIS_LEFTY);
|
||||
break;
|
||||
case SDL_GAMEPAD_BINDING_AXIS_RIGHTX_NEGATIVE:
|
||||
if (!BMergeAxisBindings(iIndex)) {
|
||||
SDL_strlcat(mapping, "-", SDL_arraysize(mapping));
|
||||
}
|
||||
pszAxisName = SDL_GetGamepadStringForAxis(SDL_GAMEPAD_AXIS_RIGHTX);
|
||||
break;
|
||||
case SDL_GAMEPAD_BINDING_AXIS_RIGHTX_POSITIVE:
|
||||
SDL_strlcat(mapping, "+", SDL_arraysize(mapping));
|
||||
pszAxisName = SDL_GetGamepadStringForAxis(SDL_GAMEPAD_AXIS_RIGHTX);
|
||||
break;
|
||||
case SDL_GAMEPAD_BINDING_AXIS_RIGHTY_NEGATIVE:
|
||||
if (!BMergeAxisBindings(iIndex)) {
|
||||
SDL_strlcat(mapping, "-", SDL_arraysize(mapping));
|
||||
}
|
||||
pszAxisName = SDL_GetGamepadStringForAxis(SDL_GAMEPAD_AXIS_RIGHTY);
|
||||
break;
|
||||
case SDL_GAMEPAD_BINDING_AXIS_RIGHTY_POSITIVE:
|
||||
SDL_strlcat(mapping, "+", SDL_arraysize(mapping));
|
||||
pszAxisName = SDL_GetGamepadStringForAxis(SDL_GAMEPAD_AXIS_RIGHTY);
|
||||
break;
|
||||
case SDL_GAMEPAD_BINDING_AXIS_TRIGGERLEFT:
|
||||
pszAxisName = SDL_GetGamepadStringForAxis(SDL_GAMEPAD_AXIS_LEFT_TRIGGER);
|
||||
break;
|
||||
case SDL_GAMEPAD_BINDING_AXIS_TRIGGERRIGHT:
|
||||
pszAxisName = SDL_GetGamepadStringForAxis(SDL_GAMEPAD_AXIS_RIGHT_TRIGGER);
|
||||
break;
|
||||
}
|
||||
if (pszAxisName) {
|
||||
SDL_strlcat(mapping, pszAxisName, SDL_arraysize(mapping));
|
||||
}
|
||||
}
|
||||
SDL_strlcat(mapping, ":", SDL_arraysize(mapping));
|
||||
|
||||
pszElement[0] = '\0';
|
||||
switch (pBinding->bindType) {
|
||||
case SDL_GAMEPAD_BINDTYPE_BUTTON:
|
||||
(void)SDL_snprintf(pszElement, sizeof(pszElement), "b%d", pBinding->value.button);
|
||||
break;
|
||||
case SDL_GAMEPAD_BINDTYPE_AXIS:
|
||||
if (pBinding->value.axis.axis_min == 0 && pBinding->value.axis.axis_max == SDL_JOYSTICK_AXIS_MIN) {
|
||||
/* The negative half axis */
|
||||
(void)SDL_snprintf(pszElement, sizeof(pszElement), "-a%d", pBinding->value.axis.axis);
|
||||
} else if (pBinding->value.axis.axis_min == 0 && pBinding->value.axis.axis_max == SDL_JOYSTICK_AXIS_MAX) {
|
||||
/* The positive half axis */
|
||||
(void)SDL_snprintf(pszElement, sizeof(pszElement), "+a%d", pBinding->value.axis.axis);
|
||||
} else {
|
||||
(void)SDL_snprintf(pszElement, sizeof(pszElement), "a%d", pBinding->value.axis.axis);
|
||||
if (pBinding->value.axis.axis_min > pBinding->value.axis.axis_max) {
|
||||
/* Invert the axis */
|
||||
SDL_strlcat(pszElement, "~", SDL_arraysize(pszElement));
|
||||
}
|
||||
}
|
||||
break;
|
||||
case SDL_GAMEPAD_BINDTYPE_HAT:
|
||||
(void)SDL_snprintf(pszElement, sizeof(pszElement), "h%d.%d", pBinding->value.hat.hat, pBinding->value.hat.hat_mask);
|
||||
break;
|
||||
default:
|
||||
SDL_assert(!"Unknown bind type");
|
||||
break;
|
||||
}
|
||||
SDL_strlcat(mapping, pszElement, SDL_arraysize(mapping));
|
||||
SDL_strlcat(mapping, ",", SDL_arraysize(mapping));
|
||||
}
|
||||
|
||||
SDL_Log("Mapping:\n\n%s\n\n", mapping);
|
||||
}
|
||||
|
||||
SDL_free(s_arrAxisState);
|
||||
s_arrAxisState = NULL;
|
||||
|
||||
SDL_DestroyRenderer(screen);
|
||||
}
|
||||
|
||||
static SDL_bool HasJoysticks(void)
|
||||
{
|
||||
int num_joysticks = 0;
|
||||
SDL_JoystickID *joysticks;
|
||||
|
||||
joysticks = SDL_GetJoysticks(&num_joysticks);
|
||||
if (joysticks) {
|
||||
SDL_free(joysticks);
|
||||
}
|
||||
if (num_joysticks > 0) {
|
||||
return SDL_TRUE;
|
||||
} else {
|
||||
return SDL_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
const char *name;
|
||||
int i;
|
||||
int num_joysticks = 0;
|
||||
SDL_JoystickID *joysticks;
|
||||
int joystick_index;
|
||||
SDL_Joystick *joystick = NULL;
|
||||
SDLTest_CommonState *state;
|
||||
|
||||
SDL_SetHint(SDL_HINT_ACCELEROMETER_AS_JOYSTICK, "0");
|
||||
|
||||
/* Initialize test framework */
|
||||
state = SDLTest_CommonCreateState(argv, 0);
|
||||
if (state == NULL) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Enable standard application logging */
|
||||
SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
|
||||
|
||||
/* Parse commandline */
|
||||
for (i = 1; i < argc;) {
|
||||
int consumed;
|
||||
|
||||
consumed = SDLTest_CommonArg(state, i);
|
||||
if (!consumed) {
|
||||
if (SDL_strcmp(argv[i], "--bind-touchpad") == 0) {
|
||||
bind_touchpad = SDL_TRUE;
|
||||
consumed = 1;
|
||||
}
|
||||
}
|
||||
if (consumed <= 0) {
|
||||
if (argv[i][0] == '-') {
|
||||
static const char *options[] = { "[--bind-touchpad]", NULL };
|
||||
SDLTest_CommonLogUsage(state, argv[0], options);
|
||||
return 1;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
i += consumed;
|
||||
}
|
||||
|
||||
/* Initialize SDL (Note: video is required to start event loop) */
|
||||
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK) < 0) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Create a window to display joystick axis position */
|
||||
window = SDL_CreateWindow("Game Controller Map", SCREEN_WIDTH, SCREEN_HEIGHT, 0);
|
||||
if (window == NULL) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create window: %s\n", SDL_GetError());
|
||||
return 2;
|
||||
}
|
||||
|
||||
screen = SDL_CreateRenderer(window, NULL, 0);
|
||||
if (screen == NULL) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create renderer: %s\n", SDL_GetError());
|
||||
return 2;
|
||||
}
|
||||
|
||||
while (!done && !HasJoysticks()) {
|
||||
SDL_Event event;
|
||||
|
||||
while (SDL_PollEvent(&event) > 0) {
|
||||
switch (event.type) {
|
||||
case SDL_EVENT_KEY_DOWN:
|
||||
if (event.key.keysym.sym != SDLK_ESCAPE) {
|
||||
break;
|
||||
}
|
||||
SDL_FALLTHROUGH;
|
||||
case SDL_EVENT_QUIT:
|
||||
done = SDL_TRUE;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
SDL_RenderPresent(screen);
|
||||
}
|
||||
|
||||
/* Print information about the joysticks */
|
||||
joysticks = SDL_GetJoysticks(&num_joysticks);
|
||||
if (joysticks) {
|
||||
SDL_Log("There are %d joysticks attached\n", num_joysticks);
|
||||
for (i = 0; joysticks[i]; ++i) {
|
||||
SDL_JoystickID instance_id = joysticks[i];
|
||||
|
||||
name = SDL_GetJoystickInstanceName(instance_id);
|
||||
SDL_Log("Joystick %" SDL_PRIu32 ": %s\n", instance_id, name ? name : "Unknown Joystick");
|
||||
joystick = SDL_OpenJoystick(instance_id);
|
||||
if (joystick == NULL) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_OpenJoystick(%" SDL_PRIu32 ") failed: %s\n", instance_id,
|
||||
SDL_GetError());
|
||||
} else {
|
||||
char guid[64];
|
||||
SDL_GetJoystickGUIDString(SDL_GetJoystickGUID(joystick),
|
||||
guid, sizeof(guid));
|
||||
SDL_Log(" axes: %d\n", SDL_GetNumJoystickAxes(joystick));
|
||||
SDL_Log(" hats: %d\n", SDL_GetNumJoystickHats(joystick));
|
||||
SDL_Log(" buttons: %d\n", SDL_GetNumJoystickButtons(joystick));
|
||||
SDL_Log("instance id: %" SDL_PRIu32 "\n", instance_id);
|
||||
SDL_Log(" guid: %s\n", guid);
|
||||
SDL_Log(" VID/PID: 0x%.4x/0x%.4x\n", SDL_GetJoystickVendor(joystick), SDL_GetJoystickProduct(joystick));
|
||||
SDL_CloseJoystick(joystick);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
joystick_index = 0;
|
||||
for (i = 1; i < argc; ++i) {
|
||||
if (argv[i] && *argv[i] != '-') {
|
||||
joystick_index = SDL_atoi(argv[i]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (joysticks && joystick_index < num_joysticks) {
|
||||
joystick = SDL_OpenJoystick(joysticks[joystick_index]);
|
||||
if (joystick == NULL) {
|
||||
SDL_Log("Couldn't open joystick %d: %s\n", joystick_index, SDL_GetError());
|
||||
}
|
||||
}
|
||||
if (joystick != NULL) {
|
||||
WatchJoystick(joystick);
|
||||
SDL_CloseJoystick(joystick);
|
||||
}
|
||||
|
||||
SDL_free(joysticks);
|
||||
|
||||
SDL_DestroyWindow(window);
|
||||
|
||||
SDL_QuitSubSystem(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK);
|
||||
|
||||
SDLTest_CommonDestroyState(state);
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue