WinRT: merged with the latest official SDL source

This commit is contained in:
David Ludwig 2012-12-16 22:02:01 -05:00
commit 643b3f0a30
92 changed files with 20142 additions and 15373 deletions

View file

@ -205,7 +205,6 @@ dep_option(ARTS_SHARED "Dynamically load aRts audio support" ON "ARTS" O
set_option(NAS "Support the NAS audio API" ${UNIX_SYS}) set_option(NAS "Support the NAS audio API" ${UNIX_SYS})
set_option(RPATH "Use an rpath when linking SDL" ${UNIX_SYS}) set_option(RPATH "Use an rpath when linking SDL" ${UNIX_SYS})
set_option(CLOCK_GETTIME "Use clock_gettime() instead of gettimeofday()" OFF) set_option(CLOCK_GETTIME "Use clock_gettime() instead of gettimeofday()" OFF)
set_option(INPUT_EVENTS "Use Linux 2.4 unified input interface" ${LINUX})
set_option(INPUT_TSLIB "Use the Touchscreen library for input" ${UNIX_SYS}) set_option(INPUT_TSLIB "Use the Touchscreen library for input" ${UNIX_SYS})
set_option(VIDEO_X11 "Use X11 video driver" ${UNIX_SYS}) set_option(VIDEO_X11 "Use X11 video driver" ${UNIX_SYS})
dep_option(X11_SHARED "Dynamically load X11 support" ON "VIDEO_X11" OFF) dep_option(X11_SHARED "Dynamically load X11 support" ON "VIDEO_X11" OFF)
@ -632,7 +631,7 @@ if(UNIX AND NOT APPLE)
CheckOpenGLESX11() CheckOpenGLESX11()
endif(SDL_VIDEO) endif(SDL_VIDEO)
if(INPUT_EVENTS) if(LINUX)
check_c_source_compiles(" check_c_source_compiles("
#include <linux/input.h> #include <linux/input.h>
#ifndef EVIOCGNAME #ifndef EVIOCGNAME
@ -642,16 +641,16 @@ if(UNIX AND NOT APPLE)
if(HAVE_INPUT_EVENTS) if(HAVE_INPUT_EVENTS)
set(SDL_INPUT_LINUXEV 1) set(SDL_INPUT_LINUXEV 1)
endif(HAVE_INPUT_EVENTS) endif(HAVE_INPUT_EVENTS)
endif(INPUT_EVENTS)
if(SDL_HAPTIC AND HAVE_INPUT_EVENTS) if(SDL_HAPTIC AND HAVE_INPUT_EVENTS)
if(LINUX)
set(SDL_HAPTIC_LINUX 1) set(SDL_HAPTIC_LINUX 1)
file(GLOB HAPTIC_SOURCES ${SDL2_SOURCE_DIR}/src/haptic/linux/*.c) file(GLOB HAPTIC_SOURCES ${SDL2_SOURCE_DIR}/src/haptic/linux/*.c)
set(SOURCE_FILES ${SOURCE_FILES} ${HAPTIC_SOURCES}) set(SOURCE_FILES ${SOURCE_FILES} ${HAPTIC_SOURCES})
set(HAVE_SDL_HAPTIC TRUE) set(HAVE_SDL_HAPTIC TRUE)
endif(LINUX) endif(SDL_HAPTIC AND HAVE_INPUT_EVENTS)
endif(SDL_HAPTIC AND HAVE_INPUT_EVENTS)
check_include_file("libudev.h" HAVE_LIBUDEV_H)
endif(LINUX)
if(INPUT_TSLIB) if(INPUT_TSLIB)
check_c_source_compiles(" check_c_source_compiles("

View file

@ -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 \
@ -92,8 +93,7 @@ HDRS = \
begin_code.h \ begin_code.h \
close_code.h close_code.h
SDLTEST_HDRS = \ SDLTEST_HDRS = $(shell ls $(srcdir)/include | fgrep SDL_test)
SDL_test.h
LT_AGE = @LT_AGE@ LT_AGE = @LT_AGE@
LT_CURRENT = @LT_CURRENT@ LT_CURRENT = @LT_CURRENT@

View file

@ -411,6 +411,10 @@
RelativePath="..\..\include\SDL_events.h" RelativePath="..\..\include\SDL_events.h"
> >
</File> </File>
<File
RelativePath="..\..\include\SDL_gamecontroller.h"
>
</File>
<File <File
RelativePath="..\..\include\SDL_gesture.h" RelativePath="..\..\include\SDL_gesture.h"
> >
@ -451,6 +455,10 @@
RelativePath="..\..\include\SDL_main.h" RelativePath="..\..\include\SDL_main.h"
> >
</File> </File>
<File
RelativePath="..\..\include\SDL_messagebox.h"
>
</File>
<File <File
RelativePath="..\..\include\SDL_mouse.h" RelativePath="..\..\include\SDL_mouse.h"
> >
@ -856,6 +864,10 @@
RelativePath="..\..\src\video\SDL_fillrect.c" RelativePath="..\..\src\video\SDL_fillrect.c"
> >
</File> </File>
<File
RelativePath="..\..\src\joystick\SDL_gamecontroller.c"
>
</File>
<File <File
RelativePath="..\..\src\events\SDL_gesture.c" RelativePath="..\..\src\events\SDL_gesture.c"
> >

View file

@ -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" />

View file

@ -255,6 +255,7 @@
<ClInclude Include="..\..\include\SDL_types.h" /> <ClInclude Include="..\..\include\SDL_types.h" />
<ClInclude Include="..\..\include\SDL_version.h" /> <ClInclude Include="..\..\include\SDL_version.h" />
<ClInclude Include="..\..\include\SDL_video.h" /> <ClInclude Include="..\..\include\SDL_video.h" />
<ClInclude Include="..\..\include\SDL_gamecontroller.h" />
<ClInclude Include="..\..\src\core\windows\SDL_windows.h" /> <ClInclude Include="..\..\src\core\windows\SDL_windows.h" />
<ClInclude Include="..\..\src\events\blank_cursor.h" /> <ClInclude Include="..\..\src\events\blank_cursor.h" />
<ClInclude Include="..\..\src\events\default_cursor.h" /> <ClInclude Include="..\..\src\events\default_cursor.h" />
@ -445,6 +446,7 @@
<ClCompile Include="..\..\src\video\windows\SDL_windowsvideo.c" /> <ClCompile Include="..\..\src\video\windows\SDL_windowsvideo.c" />
<ClCompile Include="..\..\src\video\windows\SDL_windowswindow.c" /> <ClCompile Include="..\..\src\video\windows\SDL_windowswindow.c" />
<ClCompile Include="..\..\src\events\SDL_windowevents.c" /> <ClCompile Include="..\..\src\events\SDL_windowevents.c" />
<ClCompile Include="..\..\src\joystick\SDL_gamecontroller.c" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ResourceCompile Include="..\..\src\main\windows\version.rc" /> <ResourceCompile Include="..\..\src\main\windows\version.rc" />

View file

@ -67,6 +67,11 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testpower", "tests\testpowe
{DA956FD3-E142-46F2-9DD5-C78BEBB56B7A} = {DA956FD3-E142-46F2-9DD5-C78BEBB56B7A} {DA956FD3-E142-46F2-9DD5-C78BEBB56B7A} = {DA956FD3-E142-46F2-9DD5-C78BEBB56B7A}
EndProjectSection EndProjectSection
EndProject EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SDLtest", "SDLtest\SDLtest_VS2010.vcxproj", "{DA956FD3-E143-46F2-9FE5-C77BEBC56B1A}"
ProjectSection(ProjectDependencies) = postProject
{81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68} = {81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68}
EndProjectSection
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32 Debug|Win32 = Debug|Win32
@ -160,6 +165,14 @@ Global
{C4E04D18-EF76-4B42-B4C2-16A1BACDC0A3}.Release|Win32.ActiveCfg = Release|Win32 {C4E04D18-EF76-4B42-B4C2-16A1BACDC0A3}.Release|Win32.ActiveCfg = Release|Win32
{C4E04D18-EF76-4B42-B4C2-16A1BACDC0A3}.Release|Win32.Build.0 = Release|Win32 {C4E04D18-EF76-4B42-B4C2-16A1BACDC0A3}.Release|Win32.Build.0 = Release|Win32
{C4E04D18-EF76-4B42-B4C2-16A1BACDC0A3}.Release|x64.ActiveCfg = Release|Win32 {C4E04D18-EF76-4B42-B4C2-16A1BACDC0A3}.Release|x64.ActiveCfg = Release|Win32
{DA956FD3-E143-46F2-9FE5-C77BEBC56B1A}.Debug|Win32.ActiveCfg = Debug|Win32
{DA956FD3-E143-46F2-9FE5-C77BEBC56B1A}.Debug|Win32.Build.0 = Debug|Win32
{DA956FD3-E143-46F2-9FE5-C77BEBC56B1A}.Debug|x64.ActiveCfg = Debug|x64
{DA956FD3-E143-46F2-9FE5-C77BEBC56B1A}.Debug|x64.Build.0 = Debug|x64
{DA956FD3-E143-46F2-9FE5-C77BEBC56B1A}.Release|Win32.ActiveCfg = Release|Win32
{DA956FD3-E143-46F2-9FE5-C77BEBC56B1A}.Release|Win32.Build.0 = Release|Win32
{DA956FD3-E143-46F2-9FE5-C77BEBC56B1A}.Release|x64.ActiveCfg = Release|x64
{DA956FD3-E143-46F2-9FE5-C77BEBC56B1A}.Release|x64.Build.0 = Release|x64
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE

View file

@ -7,7 +7,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SDLmain", "SDLmain\SDLmain_
EndProject EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{CE748C1F-3C21-4825-AA6A-F895A023F7E7}" Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{CE748C1F-3C21-4825-AA6A-F895A023F7E7}"
EndProject EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "automated", "tests\automated\automated_VS2010.vcxproj", "{DDD710DB-EC7B-4CCB-BD75-535D401A2FE0}" Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "automated", "tests\automated\automated_VS2012.vcxproj", "{DDD710DB-EC7B-4CCB-BD75-535D401A2FE0}"
ProjectSection(ProjectDependencies) = postProject ProjectSection(ProjectDependencies) = postProject
{81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68} = {81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68} {81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68} = {81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68}
{DA956FD3-E142-46F2-9DD5-C78BEBB56B7A} = {DA956FD3-E142-46F2-9DD5-C78BEBB56B7A} {DA956FD3-E142-46F2-9DD5-C78BEBB56B7A} = {DA956FD3-E142-46F2-9DD5-C78BEBB56B7A}
@ -67,6 +67,11 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testpower", "tests\testpowe
{DA956FD3-E142-46F2-9DD5-C78BEBB56B7A} = {DA956FD3-E142-46F2-9DD5-C78BEBB56B7A} {DA956FD3-E142-46F2-9DD5-C78BEBB56B7A} = {DA956FD3-E142-46F2-9DD5-C78BEBB56B7A}
EndProjectSection EndProjectSection
EndProject EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SDLtest", "SDLtest\SDLtest_VS2012.vcxproj", "{DA956FD3-E143-46F2-9FE5-C77BEBC56B1A}"
ProjectSection(ProjectDependencies) = postProject
{81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68} = {81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68}
EndProjectSection
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32 Debug|Win32 = Debug|Win32
@ -160,6 +165,14 @@ Global
{C4E04D18-EF76-4B42-B4C2-16A1BACDC0A3}.Release|Win32.ActiveCfg = Release|Win32 {C4E04D18-EF76-4B42-B4C2-16A1BACDC0A3}.Release|Win32.ActiveCfg = Release|Win32
{C4E04D18-EF76-4B42-B4C2-16A1BACDC0A3}.Release|Win32.Build.0 = Release|Win32 {C4E04D18-EF76-4B42-B4C2-16A1BACDC0A3}.Release|Win32.Build.0 = Release|Win32
{C4E04D18-EF76-4B42-B4C2-16A1BACDC0A3}.Release|x64.ActiveCfg = Release|Win32 {C4E04D18-EF76-4B42-B4C2-16A1BACDC0A3}.Release|x64.ActiveCfg = Release|Win32
{DA956FD3-E143-46F2-9FE5-C77BEBC56B1A}.Debug|Win32.ActiveCfg = Debug|Win32
{DA956FD3-E143-46F2-9FE5-C77BEBC56B1A}.Debug|Win32.Build.0 = Debug|Win32
{DA956FD3-E143-46F2-9FE5-C77BEBC56B1A}.Debug|x64.ActiveCfg = Debug|x64
{DA956FD3-E143-46F2-9FE5-C77BEBC56B1A}.Debug|x64.Build.0 = Debug|x64
{DA956FD3-E143-46F2-9FE5-C77BEBC56B1A}.Release|Win32.ActiveCfg = Release|Win32
{DA956FD3-E143-46F2-9FE5-C77BEBC56B1A}.Release|Win32.Build.0 = Release|Win32
{DA956FD3-E143-46F2-9FE5-C77BEBC56B1A}.Release|x64.ActiveCfg = Release|x64
{DA956FD3-E143-46F2-9FE5-C77BEBC56B1A}.Release|x64.Build.0 = Release|x64
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE

View file

@ -0,0 +1,179 @@
<?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>SDLtest</ProjectName>
<ProjectGuid>{DA956FD3-E143-46F2-9FE5-C77BEBC56B1A}</ProjectGuid>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseOfMfc>false</UseOfMfc>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseOfMfc>false</UseOfMfc>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseOfMfc>false</UseOfMfc>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</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)'=='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.30319.1</_ProjectFileVersion>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(Platform)\$(Configuration)\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(Platform)\$(Configuration)\</IntDir>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(Platform)\$(Configuration)\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(Platform)\$(Configuration)\</IntDir>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(Platform)\$(Configuration)\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(Platform)\$(Configuration)\</IntDir>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(Platform)\$(Configuration)\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(Platform)\$(Configuration)\</IntDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<PreBuildEvent />
<ClCompile>
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
<AdditionalIncludeDirectories>..\..\include;..\..\include\SDL;%(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>
<Lib>
<SuppressStartupBanner>true</SuppressStartupBanner>
</Lib>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Midl>
<TargetEnvironment>X64</TargetEnvironment>
</Midl>
<ClCompile>
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
<AdditionalIncludeDirectories>..\..\include;..\..\include\SDL;%(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>
<Lib>
<SuppressStartupBanner>true</SuppressStartupBanner>
</Lib>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<PreBuildEvent />
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>..\..\include;..\..\include\SDL;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<SuppressStartupBanner>true</SuppressStartupBanner>
<DebugInformationFormat>OldStyle</DebugInformationFormat>
<CompileAs>Default</CompileAs>
</ClCompile>
<Lib>
<SuppressStartupBanner>true</SuppressStartupBanner>
</Lib>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Midl>
<TargetEnvironment>X64</TargetEnvironment>
</Midl>
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>..\..\include;..\..\include\SDL;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<PrecompiledHeader>
</PrecompiledHeader>
<PrecompiledHeaderOutputFile>.\Debug/SDLtest.pch</PrecompiledHeaderOutputFile>
<WarningLevel>Level3</WarningLevel>
<SuppressStartupBanner>true</SuppressStartupBanner>
<DebugInformationFormat>OldStyle</DebugInformationFormat>
<CompileAs>Default</CompileAs>
</ClCompile>
<Lib>
<SuppressStartupBanner>true</SuppressStartupBanner>
</Lib>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="..\..\include\SDL_test.h" />
<ClInclude Include="..\..\include\SDL_test_assert.h" />
<ClInclude Include="..\..\include\SDL_test_common.h" />
<ClInclude Include="..\..\include\SDL_test_crc32.h" />
<ClInclude Include="..\..\include\SDL_test_font.h" />
<ClInclude Include="..\..\include\SDL_test_fuzzer.h" />
<ClInclude Include="..\..\include\SDL_test_harness.h" />
<ClInclude Include="..\..\include\SDL_test_log.h" />
<ClInclude Include="..\..\include\SDL_test_md5.h" />
<ClInclude Include="..\..\include\SDL_test_random.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\src\test\SDL_test_assert.c" />
<ClCompile Include="..\..\src\test\SDL_test_common.c" />
<ClCompile Include="..\..\src\test\SDL_test_crc32.c" />
<ClCompile Include="..\..\src\test\SDL_test_font.c" />
<ClCompile Include="..\..\src\test\SDL_test_fuzzer.c" />
<ClCompile Include="..\..\src\test\SDL_test_harness.c" />
<ClCompile Include="..\..\src\test\SDL_test_log.c" />
<ClCompile Include="..\..\src\test\SDL_test_md5.c" />
<ClCompile Include="..\..\src\test\SDL_test_random.c" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View file

@ -0,0 +1,183 @@
<?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>SDLtest</ProjectName>
<ProjectGuid>{DA956FD3-E143-46F2-9FE5-C77BEBC56B1A}</ProjectGuid>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseOfMfc>false</UseOfMfc>
<PlatformToolset>v110</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseOfMfc>false</UseOfMfc>
<PlatformToolset>v110</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseOfMfc>false</UseOfMfc>
<CharacterSet>MultiByte</CharacterSet>
<PlatformToolset>v110</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseOfMfc>false</UseOfMfc>
<PlatformToolset>v110</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.30319.1</_ProjectFileVersion>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(Platform)\$(Configuration)\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(Platform)\$(Configuration)\</IntDir>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(Platform)\$(Configuration)\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(Platform)\$(Configuration)\</IntDir>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(Platform)\$(Configuration)\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(Platform)\$(Configuration)\</IntDir>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(Platform)\$(Configuration)\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(Platform)\$(Configuration)\</IntDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<PreBuildEvent />
<ClCompile>
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
<AdditionalIncludeDirectories>..\..\include;..\..\include\SDL;%(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>
<Lib>
<SuppressStartupBanner>true</SuppressStartupBanner>
</Lib>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Midl>
<TargetEnvironment>X64</TargetEnvironment>
</Midl>
<ClCompile>
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
<AdditionalIncludeDirectories>..\..\include;..\..\include\SDL;%(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>
<Lib>
<SuppressStartupBanner>true</SuppressStartupBanner>
</Lib>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<PreBuildEvent />
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>..\..\include;..\..\include\SDL;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<SuppressStartupBanner>true</SuppressStartupBanner>
<DebugInformationFormat>OldStyle</DebugInformationFormat>
<CompileAs>Default</CompileAs>
</ClCompile>
<Lib>
<SuppressStartupBanner>true</SuppressStartupBanner>
</Lib>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Midl>
<TargetEnvironment>X64</TargetEnvironment>
</Midl>
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>..\..\include;..\..\include\SDL;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<PrecompiledHeader>
</PrecompiledHeader>
<PrecompiledHeaderOutputFile>.\Debug/SDLtest.pch</PrecompiledHeaderOutputFile>
<WarningLevel>Level3</WarningLevel>
<SuppressStartupBanner>true</SuppressStartupBanner>
<DebugInformationFormat>OldStyle</DebugInformationFormat>
<CompileAs>Default</CompileAs>
</ClCompile>
<Lib>
<SuppressStartupBanner>true</SuppressStartupBanner>
</Lib>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="..\..\include\SDL_test.h" />
<ClInclude Include="..\..\include\SDL_test_assert.h" />
<ClInclude Include="..\..\include\SDL_test_common.h" />
<ClInclude Include="..\..\include\SDL_test_crc32.h" />
<ClInclude Include="..\..\include\SDL_test_font.h" />
<ClInclude Include="..\..\include\SDL_test_fuzzer.h" />
<ClInclude Include="..\..\include\SDL_test_harness.h" />
<ClInclude Include="..\..\include\SDL_test_log.h" />
<ClInclude Include="..\..\include\SDL_test_md5.h" />
<ClInclude Include="..\..\include\SDL_test_random.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\src\test\SDL_test_assert.c" />
<ClCompile Include="..\..\src\test\SDL_test_common.c" />
<ClCompile Include="..\..\src\test\SDL_test_crc32.c" />
<ClCompile Include="..\..\src\test\SDL_test_font.c" />
<ClCompile Include="..\..\src\test\SDL_test_fuzzer.c" />
<ClCompile Include="..\..\src\test\SDL_test_harness.c" />
<ClCompile Include="..\..\src\test\SDL_test_log.c" />
<ClCompile Include="..\..\src\test\SDL_test_md5.c" />
<ClCompile Include="..\..\src\test\SDL_test_random.c" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View file

@ -29,23 +29,19 @@
<ConfigurationType>Application</ConfigurationType> <ConfigurationType>Application</ConfigurationType>
<CharacterSet>Unicode</CharacterSet> <CharacterSet>Unicode</CharacterSet>
<WholeProgramOptimization>true</WholeProgramOptimization> <WholeProgramOptimization>true</WholeProgramOptimization>
<PlatformToolset>v110</PlatformToolset>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType> <ConfigurationType>Application</ConfigurationType>
<CharacterSet>Unicode</CharacterSet> <CharacterSet>Unicode</CharacterSet>
<WholeProgramOptimization>true</WholeProgramOptimization> <WholeProgramOptimization>true</WholeProgramOptimization>
<PlatformToolset>v110</PlatformToolset>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType> <ConfigurationType>Application</ConfigurationType>
<CharacterSet>Unicode</CharacterSet> <CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v110</PlatformToolset>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType> <ConfigurationType>Application</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet> <CharacterSet>MultiByte</CharacterSet>
<PlatformToolset>v110</PlatformToolset>
</PropertyGroup> </PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings"> <ImportGroup Label="ExtensionSettings">

View file

@ -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>

View file

@ -98,6 +98,8 @@
56ED04E3118A8EFD00A56AA6 /* SDL_syspower.m in Sources */ = {isa = PBXBuildFile; fileRef = 56ED04E2118A8EFD00A56AA6 /* SDL_syspower.m */; }; 56ED04E3118A8EFD00A56AA6 /* SDL_syspower.m in Sources */ = {isa = PBXBuildFile; fileRef = 56ED04E2118A8EFD00A56AA6 /* SDL_syspower.m */; };
93CB792313FC5E5200BD3E05 /* SDL_uikitviewcontroller.h in Headers */ = {isa = PBXBuildFile; fileRef = 93CB792213FC5E5200BD3E05 /* SDL_uikitviewcontroller.h */; }; 93CB792313FC5E5200BD3E05 /* SDL_uikitviewcontroller.h in Headers */ = {isa = PBXBuildFile; fileRef = 93CB792213FC5E5200BD3E05 /* SDL_uikitviewcontroller.h */; };
93CB792613FC5F5300BD3E05 /* SDL_uikitviewcontroller.m in Sources */ = {isa = PBXBuildFile; fileRef = 93CB792513FC5F5300BD3E05 /* SDL_uikitviewcontroller.m */; }; 93CB792613FC5F5300BD3E05 /* SDL_uikitviewcontroller.m in Sources */ = {isa = PBXBuildFile; fileRef = 93CB792513FC5F5300BD3E05 /* SDL_uikitviewcontroller.m */; };
AA0AD06216647BBB00CE5896 /* SDL_gamecontroller.c in Sources */ = {isa = PBXBuildFile; fileRef = AA0AD06116647BBB00CE5896 /* SDL_gamecontroller.c */; };
AA0AD06516647BD400CE5896 /* SDL_gamecontroller.h in Headers */ = {isa = PBXBuildFile; fileRef = AA0AD06416647BD400CE5896 /* SDL_gamecontroller.h */; };
AA126AD41617C5E7005ABC8F /* SDL_uikitmodes.h in Headers */ = {isa = PBXBuildFile; fileRef = AA126AD21617C5E6005ABC8F /* SDL_uikitmodes.h */; }; AA126AD41617C5E7005ABC8F /* SDL_uikitmodes.h in Headers */ = {isa = PBXBuildFile; fileRef = AA126AD21617C5E6005ABC8F /* SDL_uikitmodes.h */; };
AA126AD51617C5E7005ABC8F /* SDL_uikitmodes.m in Sources */ = {isa = PBXBuildFile; fileRef = AA126AD31617C5E6005ABC8F /* SDL_uikitmodes.m */; }; AA126AD51617C5E7005ABC8F /* SDL_uikitmodes.m in Sources */ = {isa = PBXBuildFile; fileRef = AA126AD31617C5E6005ABC8F /* SDL_uikitmodes.m */; };
AA628ADB159369E3005138DD /* SDL_rotate.c in Sources */ = {isa = PBXBuildFile; fileRef = AA628AD9159369E3005138DD /* SDL_rotate.c */; }; AA628ADB159369E3005138DD /* SDL_rotate.c in Sources */ = {isa = PBXBuildFile; fileRef = AA628AD9159369E3005138DD /* SDL_rotate.c */; };
@ -356,6 +358,8 @@
56ED04E2118A8EFD00A56AA6 /* SDL_syspower.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SDL_syspower.m; path = ../../src/power/uikit/SDL_syspower.m; sourceTree = SOURCE_ROOT; }; 56ED04E2118A8EFD00A56AA6 /* SDL_syspower.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SDL_syspower.m; path = ../../src/power/uikit/SDL_syspower.m; sourceTree = SOURCE_ROOT; };
93CB792213FC5E5200BD3E05 /* SDL_uikitviewcontroller.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_uikitviewcontroller.h; sourceTree = "<group>"; }; 93CB792213FC5E5200BD3E05 /* SDL_uikitviewcontroller.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_uikitviewcontroller.h; sourceTree = "<group>"; };
93CB792513FC5F5300BD3E05 /* SDL_uikitviewcontroller.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDL_uikitviewcontroller.m; sourceTree = "<group>"; }; 93CB792513FC5F5300BD3E05 /* SDL_uikitviewcontroller.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDL_uikitviewcontroller.m; sourceTree = "<group>"; };
AA0AD06116647BBB00CE5896 /* SDL_gamecontroller.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_gamecontroller.c; sourceTree = "<group>"; };
AA0AD06416647BD400CE5896 /* SDL_gamecontroller.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_gamecontroller.h; sourceTree = "<group>"; };
AA126AD21617C5E6005ABC8F /* SDL_uikitmodes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_uikitmodes.h; sourceTree = "<group>"; }; AA126AD21617C5E6005ABC8F /* SDL_uikitmodes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_uikitmodes.h; sourceTree = "<group>"; };
AA126AD31617C5E6005ABC8F /* SDL_uikitmodes.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDL_uikitmodes.m; sourceTree = "<group>"; }; AA126AD31617C5E6005ABC8F /* SDL_uikitmodes.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDL_uikitmodes.m; sourceTree = "<group>"; };
AA628AD9159369E3005138DD /* SDL_rotate.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_rotate.c; sourceTree = "<group>"; }; AA628AD9159369E3005138DD /* SDL_rotate.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_rotate.c; sourceTree = "<group>"; };
@ -831,6 +835,7 @@
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
FD689EFF0E26E5B600F90B21 /* iphoneos */, FD689EFF0E26E5B600F90B21 /* iphoneos */,
AA0AD06116647BBB00CE5896 /* SDL_gamecontroller.c */,
FD5F9D1E0E0E08B3008E885B /* SDL_joystick.c */, FD5F9D1E0E0E08B3008E885B /* SDL_joystick.c */,
FD5F9D1F0E0E08B3008E885B /* SDL_joystick_c.h */, FD5F9D1F0E0E08B3008E885B /* SDL_joystick_c.h */,
FD5F9D200E0E08B3008E885B /* SDL_sysjoystick.h */, FD5F9D200E0E08B3008E885B /* SDL_sysjoystick.h */,
@ -915,6 +920,7 @@
AA7558701595D55500BBD41B /* SDL_endian.h */, AA7558701595D55500BBD41B /* SDL_endian.h */,
AA7558711595D55500BBD41B /* SDL_error.h */, AA7558711595D55500BBD41B /* SDL_error.h */,
AA7558721595D55500BBD41B /* SDL_events.h */, AA7558721595D55500BBD41B /* SDL_events.h */,
AA0AD06416647BD400CE5896 /* SDL_gamecontroller.h */,
AA7558731595D55500BBD41B /* SDL_gesture.h */, AA7558731595D55500BBD41B /* SDL_gesture.h */,
AA7558741595D55500BBD41B /* SDL_haptic.h */, AA7558741595D55500BBD41B /* SDL_haptic.h */,
AA7558751595D55500BBD41B /* SDL_hints.h */, AA7558751595D55500BBD41B /* SDL_hints.h */,
@ -1260,6 +1266,7 @@
AA704DD6162AA90A0076D1C1 /* SDL_dropevents_c.h in Headers */, AA704DD6162AA90A0076D1C1 /* SDL_dropevents_c.h in Headers */,
AA9FF9511637C6E5000DF050 /* SDL_messagebox.h in Headers */, AA9FF9511637C6E5000DF050 /* SDL_messagebox.h in Headers */,
AABCC3941640643D00AB8930 /* SDL_uikitmessagebox.h in Headers */, AABCC3941640643D00AB8930 /* SDL_uikitmessagebox.h in Headers */,
AA0AD06516647BD400CE5896 /* SDL_gamecontroller.h in Headers */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };
@ -1479,6 +1486,7 @@
AA126AD51617C5E7005ABC8F /* SDL_uikitmodes.m in Sources */, AA126AD51617C5E7005ABC8F /* SDL_uikitmodes.m in Sources */,
AA704DD7162AA90A0076D1C1 /* SDL_dropevents.c in Sources */, AA704DD7162AA90A0076D1C1 /* SDL_dropevents.c in Sources */,
AABCC3951640643D00AB8930 /* SDL_uikitmessagebox.m in Sources */, AABCC3951640643D00AB8930 /* SDL_uikitmessagebox.m in Sources */,
AA0AD06216647BBB00CE5896 /* SDL_gamecontroller.c in Sources */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };

View file

@ -428,6 +428,9 @@
04F7805F12FB74A200FC43C0 /* SDL_drawpoint.h in Headers */ = {isa = PBXBuildFile; fileRef = 04F7804712FB74A200FC43C0 /* SDL_drawpoint.h */; }; 04F7805F12FB74A200FC43C0 /* SDL_drawpoint.h in Headers */ = {isa = PBXBuildFile; fileRef = 04F7804712FB74A200FC43C0 /* SDL_drawpoint.h */; };
566CDE8F148F0AC200C5A9BB /* SDL_dropevents_c.h in Headers */ = {isa = PBXBuildFile; fileRef = 566CDE8D148F0AC200C5A9BB /* SDL_dropevents_c.h */; }; 566CDE8F148F0AC200C5A9BB /* SDL_dropevents_c.h in Headers */ = {isa = PBXBuildFile; fileRef = 566CDE8D148F0AC200C5A9BB /* SDL_dropevents_c.h */; };
566CDE90148F0AC200C5A9BB /* SDL_dropevents.c in Sources */ = {isa = PBXBuildFile; fileRef = 566CDE8E148F0AC200C5A9BB /* SDL_dropevents.c */; }; 566CDE90148F0AC200C5A9BB /* SDL_dropevents.c in Sources */ = {isa = PBXBuildFile; fileRef = 566CDE8E148F0AC200C5A9BB /* SDL_dropevents.c */; };
A77E6EB4167AB0A90010E40B /* SDL_gamecontroller.h in Headers */ = {isa = PBXBuildFile; fileRef = A77E6EB3167AB0A90010E40B /* SDL_gamecontroller.h */; settings = {ATTRIBUTES = (Public, ); }; };
A77E6EB5167AB0A90010E40B /* SDL_gamecontroller.h in Headers */ = {isa = PBXBuildFile; fileRef = A77E6EB3167AB0A90010E40B /* SDL_gamecontroller.h */; };
AA0AD09D16648D1700CE5896 /* SDL_gamecontroller.c in Sources */ = {isa = PBXBuildFile; fileRef = BBFC088A164C6514003E6A99 /* SDL_gamecontroller.c */; };
AA41F88014B8F1F500993C4F /* SDL_dropevents.c in Sources */ = {isa = PBXBuildFile; fileRef = 566CDE8E148F0AC200C5A9BB /* SDL_dropevents.c */; }; AA41F88014B8F1F500993C4F /* SDL_dropevents.c in Sources */ = {isa = PBXBuildFile; fileRef = 566CDE8E148F0AC200C5A9BB /* SDL_dropevents.c */; };
AA628ACA159367B7005138DD /* SDL_rotate.c in Sources */ = {isa = PBXBuildFile; fileRef = AA628AC8159367B7005138DD /* SDL_rotate.c */; }; AA628ACA159367B7005138DD /* SDL_rotate.c in Sources */ = {isa = PBXBuildFile; fileRef = AA628AC8159367B7005138DD /* SDL_rotate.c */; };
AA628ACB159367B7005138DD /* SDL_rotate.c in Sources */ = {isa = PBXBuildFile; fileRef = AA628AC8159367B7005138DD /* SDL_rotate.c */; }; AA628ACB159367B7005138DD /* SDL_rotate.c in Sources */ = {isa = PBXBuildFile; fileRef = AA628AC8159367B7005138DD /* SDL_rotate.c */; };
@ -546,6 +549,7 @@
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 */; };
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 */
@ -832,6 +836,7 @@
04F7804712FB74A200FC43C0 /* SDL_drawpoint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_drawpoint.h; sourceTree = "<group>"; }; 04F7804712FB74A200FC43C0 /* SDL_drawpoint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_drawpoint.h; sourceTree = "<group>"; };
566CDE8D148F0AC200C5A9BB /* SDL_dropevents_c.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_dropevents_c.h; sourceTree = "<group>"; }; 566CDE8D148F0AC200C5A9BB /* SDL_dropevents_c.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_dropevents_c.h; sourceTree = "<group>"; };
566CDE8E148F0AC200C5A9BB /* SDL_dropevents.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_dropevents.c; sourceTree = "<group>"; }; 566CDE8E148F0AC200C5A9BB /* SDL_dropevents.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_dropevents.c; sourceTree = "<group>"; };
A77E6EB3167AB0A90010E40B /* SDL_gamecontroller.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_gamecontroller.h; sourceTree = "<group>"; };
AA628AC8159367B7005138DD /* SDL_rotate.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_rotate.c; sourceTree = "<group>"; }; AA628AC8159367B7005138DD /* SDL_rotate.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_rotate.c; sourceTree = "<group>"; };
AA628AC9159367B7005138DD /* SDL_rotate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_rotate.h; sourceTree = "<group>"; }; AA628AC9159367B7005138DD /* SDL_rotate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_rotate.h; sourceTree = "<group>"; };
AA628ACF159367F2005138DD /* SDL_x11xinput2.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_x11xinput2.c; sourceTree = "<group>"; }; AA628ACF159367F2005138DD /* SDL_x11xinput2.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_x11xinput2.c; sourceTree = "<group>"; };
@ -891,6 +896,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; };
@ -1077,6 +1083,7 @@
AA7557D21595D4D800BBD41B /* SDL_endian.h */, AA7557D21595D4D800BBD41B /* SDL_endian.h */,
AA7557D31595D4D800BBD41B /* SDL_error.h */, AA7557D31595D4D800BBD41B /* SDL_error.h */,
AA7557D41595D4D800BBD41B /* SDL_events.h */, AA7557D41595D4D800BBD41B /* SDL_events.h */,
A77E6EB3167AB0A90010E40B /* SDL_gamecontroller.h */,
AA7557D51595D4D800BBD41B /* SDL_gesture.h */, AA7557D51595D4D800BBD41B /* SDL_gesture.h */,
AA7557D61595D4D800BBD41B /* SDL_haptic.h */, AA7557D61595D4D800BBD41B /* SDL_haptic.h */,
AA7557D71595D4D800BBD41B /* SDL_hints.h */, AA7557D71595D4D800BBD41B /* SDL_hints.h */,
@ -1325,6 +1332,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;
@ -1675,6 +1683,7 @@
AA7558101595D4D800BBD41B /* SDL_endian.h in Headers */, AA7558101595D4D800BBD41B /* SDL_endian.h in Headers */,
AA7558121595D4D800BBD41B /* SDL_error.h in Headers */, AA7558121595D4D800BBD41B /* SDL_error.h in Headers */,
AA7558141595D4D800BBD41B /* SDL_events.h in Headers */, AA7558141595D4D800BBD41B /* SDL_events.h in Headers */,
A77E6EB4167AB0A90010E40B /* SDL_gamecontroller.h in Headers */,
AA7558161595D4D800BBD41B /* SDL_gesture.h in Headers */, AA7558161595D4D800BBD41B /* SDL_gesture.h in Headers */,
AA7558181595D4D800BBD41B /* SDL_haptic.h in Headers */, AA7558181595D4D800BBD41B /* SDL_haptic.h in Headers */,
AA75581A1595D4D800BBD41B /* SDL_hints.h in Headers */, AA75581A1595D4D800BBD41B /* SDL_hints.h in Headers */,
@ -1942,6 +1951,7 @@
AA75585D1595D4D800BBD41B /* SDL_video.h in Headers */, AA75585D1595D4D800BBD41B /* SDL_video.h in Headers */,
AA75585F1595D4D800BBD41B /* SDL.h in Headers */, AA75585F1595D4D800BBD41B /* SDL.h in Headers */,
AABCC38E164063D200AB8930 /* SDL_cocoamessagebox.h in Headers */, AABCC38E164063D200AB8930 /* SDL_cocoamessagebox.h in Headers */,
A77E6EB5167AB0A90010E40B /* SDL_gamecontroller.h in Headers */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };
@ -2273,6 +2283,7 @@
AA628AD1159367F2005138DD /* SDL_x11xinput2.c in Sources */, AA628AD1159367F2005138DD /* SDL_x11xinput2.c in Sources */,
AA9E4093163BE51E007A2AD0 /* SDL_x11messagebox.c in Sources */, AA9E4093163BE51E007A2AD0 /* SDL_x11messagebox.c in Sources */,
AABCC38F164063D200AB8930 /* SDL_cocoamessagebox.m in Sources */, AABCC38F164063D200AB8930 /* SDL_cocoamessagebox.m in Sources */,
AA0AD09D16648D1700CE5896 /* SDL_gamecontroller.c in Sources */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };
@ -2306,6 +2317,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 */,

View file

@ -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 */;

View 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>

16704
configure vendored

File diff suppressed because it is too large Load diff

View file

@ -1650,10 +1650,6 @@ dnl See if we can use the new unified event interface in Linux 2.4
CheckInputEvents() CheckInputEvents()
{ {
dnl Check for Linux 2.4 unified input event interface support dnl Check for Linux 2.4 unified input event interface support
AC_ARG_ENABLE(input-events,
AC_HELP_STRING([--enable-input-events], [use Linux 2.4 unified input interface [[default=yes]]]),
, enable_input_events=yes)
if test x$enable_input_events = xyes; then
AC_MSG_CHECKING(for Linux 2.4 unified input interface) AC_MSG_CHECKING(for Linux 2.4 unified input interface)
use_input_events=no use_input_events=no
AC_TRY_COMPILE([ AC_TRY_COMPILE([
@ -1669,6 +1665,21 @@ AC_HELP_STRING([--enable-input-events], [use Linux 2.4 unified input interface [
if test x$use_input_events = xyes; then if test x$use_input_events = xyes; then
AC_DEFINE(SDL_INPUT_LINUXEV, 1, [ ]) AC_DEFINE(SDL_INPUT_LINUXEV, 1, [ ])
fi fi
}
dnl See if the platform offers libudev for device enumeration and hotplugging.
CheckLibUDev()
{
AC_ARG_ENABLE(libudev,
AC_HELP_STRING([--enable-libudev], [enable libudev support [[default=yes]]]),
, enable_libudev=yes)
if test x$enable_libudev = xyes; then
AC_CHECK_HEADER(libudev.h,
have_libudev_h_hdr=yes,
have_libudev_h_hdr=no)
if test x$have_libudev_h_hdr = xyes; then
AC_DEFINE(HAVE_LIBUDEV_H, 1, [ ])
fi
fi fi
} }
@ -2196,6 +2207,7 @@ case "$host" in
CheckFusionSound CheckFusionSound
CheckOpenGLX11 CheckOpenGLX11
CheckOpenGLESX11 CheckOpenGLESX11
CheckLibUDev
CheckInputEvents CheckInputEvents
CheckTslib CheckTslib
CheckUSBHID CheckUSBHID

View file

@ -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
/*@}*/ /*@}*/

View file

@ -65,6 +65,7 @@
#cmakedefine HAVE_SIGNAL_H 1 #cmakedefine HAVE_SIGNAL_H 1
#cmakedefine HAVE_ALTIVEC_H 1 #cmakedefine HAVE_ALTIVEC_H 1
#cmakedefine HAVE_PTHREAD_NP_H 1 #cmakedefine HAVE_PTHREAD_NP_H 1
#cmakedefine HAVE_LIBUDEV_H 1
/* C library functions */ /* C library functions */
#cmakedefine HAVE_MALLOC 1 #cmakedefine HAVE_MALLOC 1

View file

@ -70,6 +70,7 @@
#undef HAVE_SIGNAL_H #undef HAVE_SIGNAL_H
#undef HAVE_ALTIVEC_H #undef HAVE_ALTIVEC_H
#undef HAVE_PTHREAD_NP_H #undef HAVE_PTHREAD_NP_H
#undef HAVE_LIBUDEV_H
/* C library functions */ /* C library functions */
#undef HAVE_MALLOC #undef HAVE_MALLOC

View file

@ -130,7 +130,7 @@
/* Enable various video drivers */ /* Enable various video drivers */
#define SDL_VIDEO_DRIVER_COCOA 1 #define SDL_VIDEO_DRIVER_COCOA 1
#define SDL_VIDEO_DRIVER_DUMMY 1 #define SDL_VIDEO_DRIVER_DUMMY 1
#define SDL_VIDEO_DRIVER_X11 1 #define SDL_VIDEO_DRIVER_X11 0
#define SDL_VIDEO_DRIVER_X11_DYNAMIC "/usr/X11R6/lib/libX11.6.dylib" #define SDL_VIDEO_DRIVER_X11_DYNAMIC "/usr/X11R6/lib/libX11.6.dylib"
#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT "/usr/X11R6/lib/libXext.6.dylib" #define SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT "/usr/X11R6/lib/libXext.6.dylib"
#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XINERAMA "/usr/X11R6/lib/libXinerama.1.dylib" #define SDL_VIDEO_DRIVER_X11_DYNAMIC_XINERAMA "/usr/X11R6/lib/libXinerama.1.dylib"

View file

@ -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 */

View 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: */

View file

@ -163,6 +163,13 @@ extern "C" {
*/ */
#define SDL_HINT_GRAB_KEYBOARD "SDL_GRAB_KEYBOARD" #define SDL_HINT_GRAB_KEYBOARD "SDL_GRAB_KEYBOARD"
/**
* \brief Minimize your SDL_Window if it loses key focus when in Fullscreen mode. Defaults to true.
*
*/
#define SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS "SDL_VIDEO_MINIMIZE_ON_FOCUS_LOSS"
/** /**
* \brief A variable controlling whether the idle timer is disabled on iOS. * \brief A variable controlling whether the idle timer is disabled on iOS.
* *
@ -189,6 +196,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
*/ */

View file

@ -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,17 @@ extern "C" {
struct _SDL_Joystick; struct _SDL_Joystick;
typedef struct _SDL_Joystick SDL_Joystick; typedef struct _SDL_Joystick SDL_Joystick;
/* A structure that encodes the stable unique id for a joystick device */
typedef struct {
Uint8 data[16];
} SDL_JoystickGUID;
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 +81,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 +94,41 @@ 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);
/**
* Return the GUID for the joystick at this index
*/
extern DECLSPEC SDL_JoystickGUID SDLCALL SDL_JoystickGetDeviceGUID(int device_index);
/** /**
* Get the device index of an opened joystick. * Return the GUID for this opened joystick
*/ */
extern DECLSPEC int SDLCALL SDL_JoystickIndex(SDL_Joystick * joystick); extern DECLSPEC SDL_JoystickGUID SDLCALL SDL_JoystickGetGUID(SDL_Joystick * joystick);
/**
* Return a string representation for this guid. pszGUID must point to at least 33 bytes
* (32 for the string plus a NULL terminator).
*/
extern DECLSPEC void SDL_JoystickGetGUIDString(SDL_JoystickGUID guid, char *pszGUID, int cbGUID);
/**
* convert a string into a joystick formatted guid
*/
extern DECLSPEC SDL_JoystickGUID SDLCALL SDL_JoystickGetGUIDFromString(const char *pchGUID);
/**
* Returns SDL_TRUE if the joystick has been opened and currently connected, or SDL_FALSE if it has not.
*/
extern DECLSPEC SDL_bool SDLCALL SDL_JoystickGetAttached(SDL_Joystick * joystick);
/**
* Get the instance ID of an opened 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.

View file

@ -59,8 +59,9 @@ extern "C" {
* \brief The predefined log categories * \brief The predefined log categories
* *
* By default the application category is enabled at the INFO level, * By default the application category is enabled at the INFO level,
* the assert category is enabled at the WARN level, and all other * the assert category is enabled at the WARN level, test is enabled
* categories are enabled at the CRITICAL level. * at the VERBOSE level and all other categories are enabled at the
* CRITICAL level.
*/ */
enum enum
{ {
@ -72,6 +73,7 @@ enum
SDL_LOG_CATEGORY_VIDEO, SDL_LOG_CATEGORY_VIDEO,
SDL_LOG_CATEGORY_RENDER, SDL_LOG_CATEGORY_RENDER,
SDL_LOG_CATEGORY_INPUT, SDL_LOG_CATEGORY_INPUT,
SDL_LOG_CATEGORY_TEST,
/* Reserved for future SDL library use */ /* Reserved for future SDL library use */
SDL_LOG_CATEGORY_RESERVED1, SDL_LOG_CATEGORY_RESERVED1,

View file

@ -20,18 +20,26 @@
*/ */
/** /**
* \file SDLTest.h * \file SDL_test.h
* *
* Include file for SDL test framework. * Include file for SDL test framework.
* *
* This code is a part of the SDL2_test library, not the main SDL library. * This code is a part of the SDL2_test library, not the main SDL library.
*/ */
#ifndef _SDLTest_h #ifndef _SDL_test_h
#define _SDLTest_h #define _SDL_test_h
#include "SDL.h" #include "SDL.h"
#include "SDL_test_common.h"
#include "SDL_test_font.h" #include "SDL_test_font.h"
#include "SDL_test_random.h"
#include "SDL_test_fuzzer.h"
#include "SDL_test_crc32.h"
#include "SDL_test_md5.h"
#include "SDL_test_log.h"
#include "SDL_test_assert.h"
#include "SDL_test_harness.h"
#include "begin_code.h" #include "begin_code.h"
/* Set up for C function definitions, even when using C++ */ /* Set up for C function definitions, even when using C++ */
@ -41,9 +49,13 @@ extern "C" {
/* *INDENT-ON* */ /* *INDENT-ON* */
#endif #endif
/* Function prototypes */ /* Global definitions */
/* ADD STUFF HERE */ /*
* Note: Maximum size of SDLTest log message is less than SDLs limit
* to ensure we can fit additional information such as the timestamp.
*/
#define SDLTEST_MAX_LOGMESSAGE_LENGTH 3584
/* Ends C function definitions when using C++ */ /* Ends C function definitions when using C++ */
#ifdef __cplusplus #ifdef __cplusplus
@ -53,6 +65,6 @@ extern "C" {
#endif #endif
#include "close_code.h" #include "close_code.h"
#endif /* _SDLTest_h */ #endif /* _SDL_test_h */
/* vi: set ts=4 sw=4 expandtab: */ /* vi: set ts=4 sw=4 expandtab: */

109
include/SDL_test_assert.h Normal file
View file

@ -0,0 +1,109 @@
/*
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_test_assert.h
*
* Include file for SDL test framework.
*
* This code is a part of the SDL2_test library, not the main SDL library.
*/
/*
*
* Assert API for test code and test cases
*
*/
#ifndef _SDL_test_assert_h
#define _SDL_test_assert_h
#include "begin_code.h"
/* Set up for C function definitions, even when using C++ */
#ifdef __cplusplus
/* *INDENT-OFF* */
extern "C" {
/* *INDENT-ON* */
#endif
/**
* \brief Fails the assert.
*/
#define ASSERT_FAIL 0
/**
* \brief Passes the assert.
*/
#define ASSERT_PASS 1
/**
* \brief Assert that logs and break execution flow on failures.
*
* \param assertCondition Evaluated condition or variable to assert; fail (==0) or pass (!=0).
* \param assertDescription Message to log with the assert describing it.
*/
void SDLTest_Assert(int assertCondition, char *assertDescription, ...);
/**
* \brief Assert for test cases that logs but does not break execution flow on failures. Updates assertion counters.
*
* \param assertCondition Evaluated condition or variable to assert; fail (==0) or pass (!=0).
* \param assertDescription Message to log with the assert describing it.
*
* \returns Returns the assertCondition so it can be used to externally to break execution flow if desired.
*/
int SDLTest_AssertCheck(int assertCondition, char *assertDescription, ...);
/**
* \brief Explicitely pass without checking an assertion condition. Updates assertion counter.
*
* \param assertDescription Message to log with the assert describing it.
*/
void SDLTest_AssertPass(char *assertDescription, ...);
/**
* \brief Resets the assert summary counters to zero.
*/
void SDLTest_ResetAssertSummary();
/**
* \brief Logs summary of all assertions (total, pass, fail) since last reset as INFO or ERROR.
*/
void SDLTest_LogAssertSummary();
/**
* \brief Converts the current assert summary state to a test result.
*
* \returns TEST_RESULT_PASSED, TEST_RESULT_FAILED, or TEST_RESULT_NO_ASSERT
*/
int SDLTest_AssertSummaryToTestResult();
#ifdef __cplusplus
/* *INDENT-OFF* */
}
/* *INDENT-ON* */
#endif
#include "close_code.h"
#endif /* _SDL_test_assert_h */
/* vi: set ts=4 sw=4 expandtab: */

182
include/SDL_test_common.h Normal file
View file

@ -0,0 +1,182 @@
/*
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_test_common.h
*
* Include file for SDL test framework.
*
* This code is a part of the SDL2_test library, not the main SDL library.
*/
/* Ported from original test\common.h file. */
#ifndef _SDL_test_common_h
#define _SDL_test_common_h
#include "SDL.h"
#ifdef __NDS__
#define DEFAULT_WINDOW_WIDTH 256
#define DEFAULT_WINDOW_HEIGHT (2*192)
#else
#define DEFAULT_WINDOW_WIDTH 640
#define DEFAULT_WINDOW_HEIGHT 480
#endif
#define VERBOSE_VIDEO 0x00000001
#define VERBOSE_MODES 0x00000002
#define VERBOSE_RENDER 0x00000004
#define VERBOSE_EVENT 0x00000008
#define VERBOSE_AUDIO 0x00000010
typedef struct
{
/* SDL init flags */
char **argv;
Uint32 flags;
Uint32 verbose;
/* Video info */
const char *videodriver;
int display;
const char *window_title;
const char *window_icon;
Uint32 window_flags;
int window_x;
int window_y;
int window_w;
int window_h;
int depth;
int refresh_rate;
int num_windows;
SDL_Window **windows;
/* Renderer info */
const char *renderdriver;
Uint32 render_flags;
SDL_bool skip_renderer;
SDL_Renderer **renderers;
/* Audio info */
const char *audiodriver;
SDL_AudioSpec audiospec;
/* GL settings */
int gl_red_size;
int gl_green_size;
int gl_blue_size;
int gl_alpha_size;
int gl_buffer_size;
int gl_depth_size;
int gl_stencil_size;
int gl_double_buffer;
int gl_accum_red_size;
int gl_accum_green_size;
int gl_accum_blue_size;
int gl_accum_alpha_size;
int gl_stereo;
int gl_multisamplebuffers;
int gl_multisamplesamples;
int gl_retained_backing;
int gl_accelerated;
int gl_major_version;
int gl_minor_version;
} SDLTest_CommonState;
#include "begin_code.h"
/* Set up for C function definitions, even when using C++ */
#ifdef __cplusplus
/* *INDENT-OFF* */
extern "C" {
/* *INDENT-ON* */
#endif
/* Function prototypes */
/**
* \brief Parse command line parameters and create common state.
*
* \param argv Array of command line parameters
* \param flags Flags indicating which subsystem to initialize (i.e. SDL_INIT_VIDEO | SDL_INIT_AUDIO)
*
* \returns Returns a newly allocated common state object.
*/
SDLTest_CommonState *SDLTest_CommonCreateState(char **argv, Uint32 flags);
/**
* \brief Process one common argument.
*
* \param state The common state describing the test window to create.
* \param index The index of the argument to process in argv[].
*
* \returns The number of arguments processed (i.e. 1 for --fullscreen, 2 for --video [videodriver], or -1 on error.
*/
int SDLTest_CommonArg(SDLTest_CommonState * state, int index);
/**
* \brief Returns common usage information
*
* \param state The common state describing the test window to create.
*
* \returns String with usage information
*/
const char *SDLTest_CommonUsage(SDLTest_CommonState * state);
/**
* \brief Open test window.
*
* \param state The common state describing the test window to create.
*
* \returns True if initialization succeeded, false otherwise
*/
SDL_bool SDLTest_CommonInit(SDLTest_CommonState * state);
/**
* \brief Common event handler for test windows.
*
* \param state The common state used to create test window.
* \param event The event to handle.
* \param done Flag indicating we are done.
*
*/
void SDLTest_CommonEvent(SDLTest_CommonState * state, SDL_Event * event, int *done);
/**
* \brief Close test window.
*
* \param state The common state used to create test window.
*
*/
void SDLTest_CommonQuit(SDLTest_CommonState * state);
/* Ends C function definitions when using C++ */
#ifdef __cplusplus
/* *INDENT-OFF* */
}
/* *INDENT-ON* */
#endif
#include "close_code.h"
#endif /* _SDL_test_common_h */
/* vi: set ts=4 sw=4 expandtab: */

128
include/SDL_test_crc32.h Normal file
View file

@ -0,0 +1,128 @@
/*
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_test_crc32.h
*
* Include file for SDL test framework.
*
* This code is a part of the SDL2_test library, not the main SDL library.
*/
/*
Implements CRC32 calculations (default output is Perl String::CRC32 compatible).
*/
#ifndef _SDL_test_crc32_h
#define _SDL_test_crc32_h
#include "begin_code.h"
/* Set up for C function definitions, even when using C++ */
#ifdef __cplusplus
/* *INDENT-OFF* */
extern "C" {
/* *INDENT-ON* */
#endif
/* ------------ Definitions --------- */
/* Definition shared by all CRC routines */
#ifndef CrcUint32
#define CrcUint32 unsigned int
#endif
#ifndef CrcUint8
#define CrcUint8 unsigned char
#endif
#ifdef ORIGINAL_METHOD
#define CRC32_POLY 0x04c11db7 /* AUTODIN II, Ethernet, & FDDI */
#else
#define CRC32_POLY 0xEDB88320 /* Perl String::CRC32 compatible */
#endif
/**
* Data structure for CRC32 (checksum) computation
*/
typedef struct {
CrcUint32 crc32_table[256]; /* CRC table */
} SDLTest_Crc32Context;
/* ---------- Function Prototypes ------------- */
/**
* /brief Initialize the CRC context
*
* Note: The function initializes the crc table required for all crc calculations.
*
* /param crcContext pointer to context variable
*
* /returns 0 for OK, -1 on error
*
*/
int SDLTest_Crc32Init(SDLTest_Crc32Context * crcContext);
/**
* /brief calculate a crc32 from a data block
*
* /param crcContext pointer to context variable
* /param inBuf input buffer to checksum
* /param inLen length of input buffer
* /param crc32 pointer to Uint32 to store the final CRC into
*
* /returns 0 for OK, -1 on error
*
*/
int SDLTest_crc32Calc(SDLTest_Crc32Context * crcContext, CrcUint8 *inBuf, CrcUint32 inLen, CrcUint32 *crc32);
/* Same routine broken down into three steps */
int SDLTest_Crc32CalcStart(SDLTest_Crc32Context * crcContext, CrcUint32 *crc32);
int SDLTest_Crc32CalcEnd(SDLTest_Crc32Context * crcContext, CrcUint32 *crc32);
int SDLTest_Crc32CalcBuffer(SDLTest_Crc32Context * crcContext, CrcUint8 *inBuf, CrcUint32 inLen, CrcUint32 *crc32);
/**
* /brief clean up CRC context
*
* /param crcContext pointer to context variable
*
* /returns 0 for OK, -1 on error
*
*/
int SDLTest_Crc32Done(SDLTest_Crc32Context * crcContext);
/* Ends C function definitions when using C++ */
#ifdef __cplusplus
/* *INDENT-OFF* */
}
/* *INDENT-ON* */
#endif
#include "close_code.h"
#endif /* _SDL_test_crc32_h */
/* vi: set ts=4 sw=4 expandtab: */

371
include/SDL_test_fuzzer.h Normal file
View file

@ -0,0 +1,371 @@
/*
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_test_fuzzer.h
*
* Include file for SDL test framework.
*
* This code is a part of the SDL2_test library, not the main SDL library.
*/
/*
Data generators for fuzzing test data in a reproducible way.
*/
#ifndef _SDL_test_fuzzer_h
#define _SDL_test_fuzzer_h
#include "begin_code.h"
/* Set up for C function definitions, even when using C++ */
#ifdef __cplusplus
/* *INDENT-OFF* */
extern "C" {
/* *INDENT-ON* */
#endif
/*
Based on GSOC code by Markus Kauppila <markus.kauppila@gmail.com>
*/
/**
* \file
* Note: The fuzzer implementation uses a static instance of random context
* internally which makes it thread-UNsafe.
*/
/**
* Initializes the fuzzer for a test
*
* /param execKey Execution "Key" that initializes the random number generator uniquely for the test.
*
*/
void SDLTest_FuzzerInit(Uint64 execKey);
/**
* Returns a random Uint8
*
* \returns Generated integer
*/
Uint8 SDLTest_RandomUint8();
/**
* Returns a random Sint8
*
* \returns Generated signed integer
*/
Sint8 SDLTest_RandomSint8();
/**
* Returns a random Uint16
*
* \returns Generated integer
*/
Uint16 SDLTest_RandomUint16();
/**
* Returns a random Sint16
*
* \returns Generated signed integer
*/
Sint16 SDLTest_RandomSint16();
/**
* Returns a random integer
*
* \returns Generated integer
*/
Sint32 SDLTest_RandomSint32();
/**
* Returns a random positive integer
*
* \returns Generated integer
*/
Uint32 SDLTest_RandomUint32();
/**
* Returns random Uint64.
*
* \returns Generated integer
*/
Uint64 SDLTest_RandomUint64();
/**
* Returns random Sint64.
*
* \returns Generated signed integer
*/
Sint64 SDLTest_RandomSint64();
/**
* \returns random float in range [0.0 - 1.0[
*/
float SDLTest_RandomUnitFloat();
/**
* \returns random double in range [0.0 - 1.0[
*/
double SDLTest_RandomUnitDouble();
/**
* \returns random float.
*
*/
float SDLTest_RandomFloat();
/**
* \returns random double.
*
*/
double SDLTest_RandomDouble();
/**
* Returns a random boundary value for Uint8 within the given boundaries.
* Boundaries are inclusive, see the usage examples below. If validDomain
* is true, the function will only return valid boundaries, otherwise non-valid
* boundaries are also possible.
* If boundary1 > boundary2, the values are swapped
*
* Usage examples:
* RandomUint8BoundaryValue(10, 20, SDL_TRUE) returns 10, 11, 19 or 20
* RandomUint8BoundaryValue(1, 20, SDL_FALSE) returns 0 or 21
* RandomUint8BoundaryValue(0, 99, SDL_FALSE) returns 100
* RandomUint8BoundaryValue(0, 255, SDL_FALSE) returns -1 (== error value)
*
* \param boundary1 Lower boundary limit
* \param boundary2 Upper boundary limit
* \param validDomain Should the generated boundary be valid or not?
*
* \returns Boundary value in given range or error value (-1)
*/
Uint8 SDLTest_RandomUint8BoundaryValue(Uint8 boundary1, Uint8 boundary2, SDL_bool validDomain);
/**
* Returns a random boundary value for Uint16 within the given boundaries.
* Boundaries are inclusive, see the usage examples below. If validDomain
* is true, the function will only return valid boundaries, otherwise non-valid
* boundaries are also possible.
* If boundary1 > boundary2, the values are swapped
*
* Usage examples:
* RandomUint16BoundaryValue(10, 20, SDL_TRUE) returns 10, 11, 19 or 20
* RandomUint16BoundaryValue(1, 20, SDL_FALSE) returns 0 or 21
* RandomUint16BoundaryValue(0, 99, SDL_FALSE) returns 100
* RandomUint16BoundaryValue(0, 0xFFFF, SDL_FALSE) returns -1 (== error value)
*
* \param boundary1 Lower boundary limit
* \param boundary2 Upper boundary limit
* \param validDomain Should the generated boundary be valid or not?
*
* \returns Boundary value in given range or error value (-1)
*/
Uint16 SDLTest_RandomUint16BoundaryValue(Uint16 boundary1, Uint16 boundary2, SDL_bool validDomain);
/**
* Returns a random boundary value for Uint32 within the given boundaries.
* Boundaries are inclusive, see the usage examples below. If validDomain
* is true, the function will only return valid boundaries, otherwise non-valid
* boundaries are also possible.
* If boundary1 > boundary2, the values are swapped
*
* Usage examples:
* RandomUint32BoundaryValue(10, 20, SDL_TRUE) returns 10, 11, 19 or 20
* RandomUint32BoundaryValue(1, 20, SDL_FALSE) returns 0 or 21
* RandomUint32BoundaryValue(0, 99, SDL_FALSE) returns 100
* RandomUint32BoundaryValue(0, 0xFFFFFFFF, SDL_FALSE) returns -1 (== error value)
*
* \param boundary1 Lower boundary limit
* \param boundary2 Upper boundary limit
* \param validDomain Should the generated boundary be valid or not?
*
* \returns Boundary value in given range or error value (-1)
*/
Uint32 SDLTest_RandomUint32BoundaryValue(Uint32 boundary1, Uint32 boundary2, SDL_bool validDomain);
/**
* Returns a random boundary value for Uint64 within the given boundaries.
* Boundaries are inclusive, see the usage examples below. If validDomain
* is true, the function will only return valid boundaries, otherwise non-valid
* boundaries are also possible.
* If boundary1 > boundary2, the values are swapped
*
* Usage examples:
* RandomUint64BoundaryValue(10, 20, SDL_TRUE) returns 10, 11, 19 or 20
* RandomUint64BoundaryValue(1, 20, SDL_FALSE) returns 0 or 21
* RandomUint64BoundaryValue(0, 99, SDL_FALSE) returns 100
* RandomUint64BoundaryValue(0, 0xFFFFFFFFFFFFFFFF, SDL_FALSE) returns -1 (== error value)
*
* \param boundary1 Lower boundary limit
* \param boundary2 Upper boundary limit
* \param validDomain Should the generated boundary be valid or not?
*
* \returns Boundary value in given range or error value (-1)
*/
Uint64 SDLTest_RandomUint64BoundaryValue(Uint64 boundary1, Uint64 boundary2, SDL_bool validDomain);
/**
* Returns a random boundary value for Sint8 within the given boundaries.
* Boundaries are inclusive, see the usage examples below. If validDomain
* is true, the function will only return valid boundaries, otherwise non-valid
* boundaries are also possible.
* If boundary1 > boundary2, the values are swapped
*
* Usage examples:
* RandomSint8BoundaryValue(-10, 20, SDL_TRUE) returns -11, -10, 19 or 20
* RandomSint8BoundaryValue(-100, -10, SDL_FALSE) returns -101 or -9
* RandomSint8BoundaryValue(-128, 99, SDL_FALSE) returns 100
* RandomSint8BoundaryValue(-128, 127, SDL_FALSE) returns SINT8_MIN (== error value)
*
* \param boundary1 Lower boundary limit
* \param boundary2 Upper boundary limit
* \param validDomain Should the generated boundary be valid or not?
*
* \returns Boundary value in given range or error value (-1)
*/
Sint8 SDLTest_RandomSint8BoundaryValue(Sint8 boundary1, Sint8 boundary2, SDL_bool validDomain);
/**
* Returns a random boundary value for Sint16 within the given boundaries.
* Boundaries are inclusive, see the usage examples below. If validDomain
* is true, the function will only return valid boundaries, otherwise non-valid
* boundaries are also possible.
* If boundary1 > boundary2, the values are swapped
*
* Usage examples:
* RandomSint16BoundaryValue(-10, 20, SDL_TRUE) returns -11, -10, 19 or 20
* RandomSint16BoundaryValue(-100, -10, SDL_FALSE) returns -101 or -9
* RandomSint16BoundaryValue(SINT8_MIN, 99, SDL_FALSE) returns 100
* RandomSint16BoundaryValue(SINT8_MIN, SINT8_MAX, SDL_FALSE) returns SINT16_MIN (== error value)
*
* \param boundary1 Lower boundary limit
* \param boundary2 Upper boundary limit
* \param validDomain Should the generated boundary be valid or not?
*
* \returns Boundary value in given range or error value (-1)
*/
Sint16 SDLTest_RandomSint16BoundaryValue(Sint16 boundary1, Sint16 boundary2, SDL_bool validDomain);
/**
* Returns a random boundary value for Sint32 within the given boundaries.
* Boundaries are inclusive, see the usage examples below. If validDomain
* is true, the function will only return valid boundaries, otherwise non-valid
* boundaries are also possible.
* If boundary1 > boundary2, the values are swapped
*
* Usage examples:
* RandomSint32BoundaryValue(-10, 20, SDL_TRUE) returns -11, -10, 19 or 20
* RandomSint32BoundaryValue(-100, -10, SDL_FALSE) returns -101 or -9
* RandomSint32BoundaryValue(SINT32_MIN, 99, SDL_FALSE) returns 100
* RandomSint32BoundaryValue(SINT32_MIN, SINT32_MAX, SDL_FALSE) returns SINT32_MIN (== error value)
*
* \param boundary1 Lower boundary limit
* \param boundary2 Upper boundary limit
* \param validDomain Should the generated boundary be valid or not?
*
* \returns Boundary value in given range or error value (-1)
*/
Sint32 SDLTest_RandomSint32BoundaryValue(Sint32 boundary1, Sint32 boundary2, SDL_bool validDomain);
/**
* Returns a random boundary value for Sint64 within the given boundaries.
* Boundaries are inclusive, see the usage examples below. If validDomain
* is true, the function will only return valid boundaries, otherwise non-valid
* boundaries are also possible.
* If boundary1 > boundary2, the values are swapped
*
* Usage examples:
* RandomSint64BoundaryValue(-10, 20, SDL_TRUE) returns -11, -10, 19 or 20
* RandomSint64BoundaryValue(-100, -10, SDL_FALSE) returns -101 or -9
* RandomSint64BoundaryValue(SINT64_MIN, 99, SDL_FALSE) returns 100
* RandomSint64BoundaryValue(SINT64_MIN, SINT32_MAX, SDL_FALSE) returns SINT64_MIN (== error value)
*
* \param boundary1 Lower boundary limit
* \param boundary2 Upper boundary limit
* \param validDomain Should the generated boundary be valid or not?
*
* \returns Boundary value in given range or error value (-1)
*/
Sint64 SDLTest_RandomSint64BoundaryValue(Sint64 boundary1, Sint64 boundary2, SDL_bool validDomain);
/**
* Returns integer in range [min, max] (inclusive).
* Min and max values can be negative values.
* If Max in smaller tham min, then the values are swapped.
* Min and max are the same value, that value will be returned.
*
* \returns Generated integer
*/
Sint32 SDLTest_RandomIntegerInRange(Sint32 min, Sint32 max);
/**
* Generates random null-terminated string. The maximum length for
* the string is 255 characters and it can contain ASCII characters
* from 1 to 127.
*
* Note: Returned string needs to be deallocated.
*
* \returns newly allocated random string
*/
char * SDLTest_RandomAsciiString();
/**
* Generates random null-terminated string. The maximum length for
* the string is defined by maxLenght parameter.
* String can contain ASCII characters from 1 to 127.
*
* Note: Returned string needs to be deallocated.
*
* \param maxLength Maximum length of the generated string
*
* \returns newly allocated random string
*/
char * SDLTest_RandomAsciiStringWithMaximumLength(int maxLength);
/**
* Returns the invocation count for the fuzzer since last ...FuzzerInit.
*/
int SDLTest_GetFuzzerInvocationCount();
/* Ends C function definitions when using C++ */
#ifdef __cplusplus
/* *INDENT-OFF* */
}
/* *INDENT-ON* */
#endif
#include "close_code.h"
#endif /* _SDL_test_fuzzer_h */
/* vi: set ts=4 sw=4 expandtab: */

125
include/SDL_test_harness.h Normal file
View file

@ -0,0 +1,125 @@
/*
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_test_harness.h
*
* Include file for SDL test framework.
*
* This code is a part of the SDL2_test library, not the main SDL library.
*/
/*
Defines types for test case definitions and the test execution harness API.
Based on original GSOC code by Markus Kauppila <markus.kauppila@gmail.com>
*/
#ifndef _SDL_test_harness_h
#define _SDL_test_harness_h
#include "begin_code.h"
/* Set up for C function definitions, even when using C++ */
#ifdef __cplusplus
/* *INDENT-OFF* */
extern "C" {
/* *INDENT-ON* */
#endif
//! Definitions for test case structures
#define TEST_ENABLED 1
#define TEST_DISABLED 0
//! Definition of all the possible test return values of the test case method
#define TEST_ABORTED -1
#define TEST_COMPLETED 0
#define TEST_SKIPPED 1
//! Definition of all the possible test results for the harness
#define TEST_RESULT_PASSED 0
#define TEST_RESULT_FAILED 1
#define TEST_RESULT_NO_ASSERT 2
#define TEST_RESULT_SKIPPED 3
#define TEST_RESULT_SETUP_FAILURE 4
//!< Function pointer to a test case setup function (run before every test)
typedef void (*SDLTest_TestCaseSetUpFp)(void *arg);
//!< Function pointer to a test case function
typedef void (*SDLTest_TestCaseFp)(void *arg);
//!< Function pointer to a test case teardown function (run after every test)
typedef void (*SDLTest_TestCaseTearDownFp)(void *arg);
/**
* Holds information about a single test case.
*/
typedef struct SDLTest_TestCaseReference {
/*!< Func2Stress */
SDLTest_TestCaseFp testCase;
/*!< Short name (or function name) "Func2Stress" */
char *name;
/*!< Long name or full description "This test pushes func2() to the limit." */
char *description;
/*!< Set to TEST_ENABLED or TEST_DISABLED (test won't be run) */
int enabled;
} SDLTest_TestCaseReference;
/**
* Holds information about a test suite (multiple test cases).
*/
typedef struct SDLTest_TestSuiteReference {
/*!< "PlatformSuite" */
char *name;
/*!< The function that is run before each test. NULL skips. */
SDLTest_TestCaseSetUpFp testSetUp;
/*!< The test cases that are run as part of the suite. Last item should be NULL. */
const SDLTest_TestCaseReference **testCases;
/*!< The function that is run after each test. NULL skips. */
SDLTest_TestCaseTearDownFp testTearDown;
} SDLTest_TestSuiteReference;
/**
* \brief Execute a test suite using the given run seed and execution key.
*
* \param testSuites Suites containing the test case.
* \param userRunSeed Custom run seed provided by user, or NULL to autogenerate one.
* \param userExecKey Custom execution key provided by user, or 0 to autogenerate one.
* \param testIterations Number of iterations to run each test case.
*
* \returns Test run result; 0 when all tests passed, 1 if any tests failed.
*/
int SDLTest_RunSuites(SDLTest_TestSuiteReference *testSuites[], char *userRunSeed, Uint64 userExecKey, int testIterations);
/* Ends C function definitions when using C++ */
#ifdef __cplusplus
/* *INDENT-OFF* */
}
/* *INDENT-ON* */
#endif
#include "close_code.h"
#endif /* _SDL_test_harness_h */
/* vi: set ts=4 sw=4 expandtab: */

71
include/SDL_test_log.h Normal file
View file

@ -0,0 +1,71 @@
/*
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_test_log.h
*
* Include file for SDL test framework.
*
* This code is a part of the SDL2_test library, not the main SDL library.
*/
/*
*
* Wrapper to log in the TEST category
*
*/
#ifndef _SDL_test_log_h
#define _SDL_test_log_h
#include "begin_code.h"
/* Set up for C function definitions, even when using C++ */
#ifdef __cplusplus
/* *INDENT-OFF* */
extern "C" {
/* *INDENT-ON* */
#endif
/**
* \brief Prints given message with a timestamp in the TEST category and INFO priority.
*
* \param fmt Message to be logged
*/
void SDLTest_Log(char *fmt, ...);
/**
* \brief Prints given message with a timestamp in the TEST category and the ERROR priority.
*
* \param fmt Message to be logged
*/
void SDLTest_LogError(char *fmt, ...);
/* Ends C function definitions when using C++ */
#ifdef __cplusplus
/* *INDENT-OFF* */
}
/* *INDENT-ON* */
#endif
#include "close_code.h"
#endif /* _SDL_test_log_h */
/* vi: set ts=4 sw=4 expandtab: */

133
include/SDL_test_md5.h Normal file
View file

@ -0,0 +1,133 @@
/*
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_test_md5.h
*
* Include file for SDL test framework.
*
* This code is a part of the SDL2_test library, not the main SDL library.
*/
/*
***********************************************************************
** Header file for implementation of MD5 **
** RSA Data Security, Inc. MD5 Message-Digest Algorithm **
** Created: 2/17/90 RLR **
** Revised: 12/27/90 SRD,AJ,BSK,JT Reference C version **
** Revised (for MD5): RLR 4/27/91 **
** -- G modified to have y&~z instead of y&z **
** -- FF, GG, HH modified to add in last register done **
** -- Access pattern: round 2 works mod 5, round 3 works mod 3 **
** -- distinct additive constant for each step **
** -- round 4 added, working mod 7 **
***********************************************************************
*/
/*
***********************************************************************
** Message-digest routines: **
** To form the message digest for a message M **
** (1) Initialize a context buffer mdContext using MD5Init **
** (2) Call MD5Update on mdContext and M **
** (3) Call MD5Final on mdContext **
** The message digest is now in mdContext->digest[0...15] **
***********************************************************************
*/
#ifndef _SDL_test_md5_h
#define _SDL_test_md5_h
#include "begin_code.h"
/* Set up for C function definitions, even when using C++ */
#ifdef __cplusplus
/* *INDENT-OFF* */
extern "C" {
/* *INDENT-ON* */
#endif
/* ------------ Definitions --------- */
/* typedef a 32-bit type */
typedef unsigned long int MD5UINT4;
/* Data structure for MD5 (Message-Digest) computation */
typedef struct {
MD5UINT4 i[2]; /* number of _bits_ handled mod 2^64 */
MD5UINT4 buf[4]; /* scratch buffer */
unsigned char in[64]; /* input buffer */
unsigned char digest[16]; /* actual digest after Md5Final call */
} SDLTest_Md5Context;
/* ---------- Function Prototypes ------------- */
/**
* /brief initialize the context
*
* /param mdContext pointer to context variable
*
* Note: The function initializes the message-digest context
* mdContext. Call before each new use of the context -
* all fields are set to zero.
*/
void SDLTest_Md5Init(SDLTest_Md5Context * mdContext);
/**
* /brief update digest from variable length data
*
* /param mdContext pointer to context variable
* /param inBuf pointer to data array/string
* /param inLen length of data array/string
*
* Note: The function updates the message-digest context to account
* for the presence of each of the characters inBuf[0..inLen-1]
* in the message whose digest is being computed.
*/
void SDLTest_Md5Update(SDLTest_Md5Context * mdContext, unsigned char *inBuf,
unsigned int inLen);
/*
* /brief complete digest computation
*
* /param mdContext pointer to context variable
*
* Note: The function terminates the message-digest computation and
* ends with the desired message digest in mdContext.digest[0..15].
* Always call before using the digest[] variable.
*/
void SDLTest_Md5Final(SDLTest_Md5Context * mdContext);
/* Ends C function definitions when using C++ */
#ifdef __cplusplus
/* *INDENT-OFF* */
}
/* *INDENT-ON* */
#endif
#include "close_code.h"
#endif /* _SDL_test_md5_h */
/* vi: set ts=4 sw=4 expandtab: */

119
include/SDL_test_random.h Normal file
View file

@ -0,0 +1,119 @@
/*
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_test_random.h
*
* Include file for SDL test framework.
*
* This code is a part of the SDL2_test library, not the main SDL library.
*/
/*
A "32-bit Multiply with carry random number generator. Very fast.
Includes a list of recommended multipliers.
multiply-with-carry generator: x(n) = a*x(n-1) + carry mod 2^32.
period: (a*2^31)-1
*/
#ifndef _SDL_test_random_h
#define _SDL_test_random_h
#include "begin_code.h"
/* Set up for C function definitions, even when using C++ */
#ifdef __cplusplus
/* *INDENT-OFF* */
extern "C" {
/* *INDENT-ON* */
#endif
/* --- Definitions */
/*
* Macros that return a random number in a specific format.
*/
#define SDLTest_RandomInt(c) ((int)SDLTest_Random(c))
/*
* Context structure for the random number generator state.
*/
typedef struct {
unsigned int a;
unsigned int x;
unsigned int c;
unsigned int ah;
unsigned int al;
} SDLTest_RandomContext;
/* --- Function prototypes */
/**
* \brief Initialize random number generator with two integers.
*
* Note: The random sequence of numbers returned by ...Random() is the
* same for the same two integers and has a period of 2^31.
*
* \param rndContext pointer to context structure
* \param xi integer that defines the random sequence
* \param ci integer that defines the random sequence
*
*/
void SDLTest_RandomInit(SDLTest_RandomContext * rndContext, unsigned int xi,
unsigned int ci);
/**
* \brief Initialize random number generator based on current system time.
*
* \param rndContext pointer to context structure
*
*/
void SDLTest_RandomInitTime(SDLTest_RandomContext *rndContext);
/**
* \brief Initialize random number generator based on current system time.
*
* Note: ...RandomInit() or ...RandomInitTime() must have been called
* before using this function.
*
* \param rndContext pointer to context structure
*
* \returns A random number (32bit unsigned integer)
*
*/
unsigned int SDLTest_Random(SDLTest_RandomContext *rndContext);
/* Ends C function definitions when using C++ */
#ifdef __cplusplus
/* *INDENT-OFF* */
}
/* *INDENT-ON* */
#endif
#include "close_code.h"
#endif /* _SDL_test_random_h */
/* vi: set ts=4 sw=4 expandtab: */

View file

@ -108,6 +108,7 @@ typedef enum
SDL_WINDOW_INPUT_GRABBED = 0x00000100, /**< window has grabbed input focus */ SDL_WINDOW_INPUT_GRABBED = 0x00000100, /**< window has grabbed input focus */
SDL_WINDOW_INPUT_FOCUS = 0x00000200, /**< window has input focus */ SDL_WINDOW_INPUT_FOCUS = 0x00000200, /**< window has input focus */
SDL_WINDOW_MOUSE_FOCUS = 0x00000400, /**< window has mouse focus */ SDL_WINDOW_MOUSE_FOCUS = 0x00000400, /**< window has mouse focus */
SDL_WINDOW_FULLSCREEN_DESKTOP = ( SDL_WINDOW_FULLSCREEN | 0x00001000 ),
SDL_WINDOW_FOREIGN = 0x00000800 /**< window not created by SDL */ SDL_WINDOW_FOREIGN = 0x00000800 /**< window not created by SDL */
} SDL_WindowFlags; } SDL_WindowFlags;
@ -604,7 +605,7 @@ extern DECLSPEC void SDLCALL SDL_RestoreWindow(SDL_Window * window);
* \sa SDL_GetWindowDisplayMode() * \sa SDL_GetWindowDisplayMode()
*/ */
extern DECLSPEC int SDLCALL SDL_SetWindowFullscreen(SDL_Window * window, extern DECLSPEC int SDLCALL SDL_SetWindowFullscreen(SDL_Window * window,
SDL_bool fullscreen); Uint32 flags);
/** /**
* \brief Get the SDL surface associated with the window. * \brief Get the SDL surface associated with the window.

143
src/SDL.c
View file

@ -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 */

View file

@ -128,6 +128,12 @@ static void SDL_AbortAssertion(void)
static SDL_assert_state static SDL_assert_state
SDL_PromptAssertion(const SDL_assert_data *data, void *userdata) SDL_PromptAssertion(const SDL_assert_data *data, void *userdata)
{ {
#ifdef __WIN32__
#define ENDLINE "\r\n"
#else
#define ENDLINE "\n"
#endif
const char *envr; const char *envr;
SDL_assert_state state = SDL_ASSERTION_ABORT; SDL_assert_state state = SDL_ASSERTION_ABORT;
SDL_Window *window; SDL_Window *window;
@ -152,7 +158,8 @@ SDL_PromptAssertion(const SDL_assert_data *data, void *userdata)
return SDL_ASSERTION_ABORT; return SDL_ASSERTION_ABORT;
} }
SDL_snprintf(message, SDL_MAX_LOG_MESSAGE, SDL_snprintf(message, SDL_MAX_LOG_MESSAGE,
"Assertion failure at %s (%s:%d), triggered %u %s:\r\n '%s'", "Assertion failure at %s (%s:%d), triggered %u %s:" ENDLINE
" '%s'",
data->function, data->filename, data->linenum, data->function, data->filename, data->linenum,
data->trigger_count, (data->trigger_count == 1) ? "time" : "times", data->trigger_count, (data->trigger_count == 1) ? "time" : "times",
data->condition); data->condition);

View file

@ -37,6 +37,7 @@
#define DEFAULT_PRIORITY SDL_LOG_PRIORITY_CRITICAL #define DEFAULT_PRIORITY SDL_LOG_PRIORITY_CRITICAL
#define DEFAULT_ASSERT_PRIORITY SDL_LOG_PRIORITY_WARN #define DEFAULT_ASSERT_PRIORITY SDL_LOG_PRIORITY_WARN
#define DEFAULT_APPLICATION_PRIORITY SDL_LOG_PRIORITY_INFO #define DEFAULT_APPLICATION_PRIORITY SDL_LOG_PRIORITY_INFO
#define DEFAULT_TEST_PRIORITY SDL_LOG_PRIORITY_VERBOSE
typedef struct SDL_LogLevel typedef struct SDL_LogLevel
{ {
@ -54,6 +55,7 @@ static SDL_LogLevel *SDL_loglevels;
static SDL_LogPriority SDL_default_priority = DEFAULT_PRIORITY; static SDL_LogPriority SDL_default_priority = DEFAULT_PRIORITY;
static SDL_LogPriority SDL_assert_priority = DEFAULT_ASSERT_PRIORITY; static SDL_LogPriority SDL_assert_priority = DEFAULT_ASSERT_PRIORITY;
static SDL_LogPriority SDL_application_priority = DEFAULT_APPLICATION_PRIORITY; static SDL_LogPriority SDL_application_priority = DEFAULT_APPLICATION_PRIORITY;
static SDL_LogPriority SDL_test_priority = DEFAULT_TEST_PRIORITY;
static SDL_LogOutputFunction SDL_log_function = SDL_LogOutput; static SDL_LogOutputFunction SDL_log_function = SDL_LogOutput;
static void *SDL_log_userdata = NULL; static void *SDL_log_userdata = NULL;
@ -135,7 +137,9 @@ SDL_LogGetPriority(int category)
} }
} }
if (category == SDL_LOG_CATEGORY_APPLICATION) { if (category == SDL_LOG_CATEGORY_TEST) {
return SDL_test_priority;
} else if (category == SDL_LOG_CATEGORY_APPLICATION) {
return SDL_application_priority; return SDL_application_priority;
} else if (category == SDL_LOG_CATEGORY_ASSERT) { } else if (category == SDL_LOG_CATEGORY_ASSERT) {
return SDL_assert_priority; return SDL_assert_priority;
@ -158,6 +162,7 @@ SDL_LogResetPriorities(void)
SDL_default_priority = DEFAULT_PRIORITY; SDL_default_priority = DEFAULT_PRIORITY;
SDL_assert_priority = DEFAULT_ASSERT_PRIORITY; SDL_assert_priority = DEFAULT_ASSERT_PRIORITY;
SDL_application_priority = DEFAULT_APPLICATION_PRIORITY; SDL_application_priority = DEFAULT_APPLICATION_PRIORITY;
SDL_test_priority = DEFAULT_TEST_PRIORITY;
} }
void void

0
src/audio/sdlgenaudiocvt.pl Normal file → Executable file
View file

View file

@ -70,9 +70,9 @@ static __inline__ SDL_bool
SDL_ShouldPollJoystick() SDL_ShouldPollJoystick()
{ {
#if !SDL_JOYSTICK_DISABLED #if !SDL_JOYSTICK_DISABLED
if (SDL_numjoysticks && if ((!SDL_disabled_events[SDL_JOYAXISMOTION >> 8] ||
(!SDL_disabled_events[SDL_JOYAXISMOTION >> 8] || SDL_JoystickEventState(SDL_QUERY)) &&
SDL_JoystickEventState(SDL_QUERY))) { SDL_PrivateJoystickNeedsPolling()) {
return SDL_TRUE; return SDL_TRUE;
} }
#endif #endif

View file

@ -379,6 +379,12 @@ void
SDL_WarpMouseInWindow(SDL_Window * window, int x, int y) SDL_WarpMouseInWindow(SDL_Window * window, int x, int y)
{ {
SDL_Mouse *mouse = SDL_GetMouse(); SDL_Mouse *mouse = SDL_GetMouse();
if ( window == NULL )
window = mouse->focus;
if ( window == NULL )
return;
if (mouse->WarpMouse) { if (mouse->WarpMouse) {
mouse->WarpMouse(window, x, y); mouse->WarpMouse(window, x, y);

View file

@ -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;
} }

View file

@ -49,7 +49,7 @@ static struct
*/ */
struct haptic_hwdata struct haptic_hwdata
{ {
LPDIRECTINPUTDEVICE2 device; LPDIRECTINPUTDEVICE8 device;
DWORD axes[3]; /* Axes to use. */ DWORD axes[3]; /* Axes to use. */
int is_joystick; /* Device is loaded as joystick. */ int is_joystick; /* Device is loaded as joystick. */
}; };
@ -69,7 +69,7 @@ struct haptic_hweffect
* Internal stuff. * Internal stuff.
*/ */
static SDL_bool coinitialized = SDL_FALSE; static SDL_bool coinitialized = SDL_FALSE;
static LPDIRECTINPUT dinput = NULL; static LPDIRECTINPUT8 dinput = NULL;
/* /*
@ -85,8 +85,8 @@ static void DI_SetError(const char *str, HRESULT err);
static int DI_GUIDIsSame(const GUID * a, const GUID * b); static int DI_GUIDIsSame(const GUID * a, const GUID * b);
static int SDL_SYS_HapticOpenFromInstance(SDL_Haptic * haptic, static int SDL_SYS_HapticOpenFromInstance(SDL_Haptic * haptic,
DIDEVICEINSTANCE instance); DIDEVICEINSTANCE instance);
static int SDL_SYS_HapticOpenFromDevice2(SDL_Haptic * haptic, static int SDL_SYS_HapticOpenFromDevice8(SDL_Haptic * haptic,
LPDIRECTINPUTDEVICE2 device2); LPDIRECTINPUTDEVICE8 device8);
static DWORD DIGetTriggerButton(Uint16 button); static DWORD DIGetTriggerButton(Uint16 button);
static int SDL_SYS_SetDirection(DIEFFECT * effect, SDL_HapticDirection * dir, static int SDL_SYS_SetDirection(DIEFFECT * effect, SDL_HapticDirection * dir,
int naxes); int naxes);
@ -151,8 +151,8 @@ SDL_SYS_HapticInit(void)
coinitialized = SDL_TRUE; coinitialized = SDL_TRUE;
ret = CoCreateInstance(&CLSID_DirectInput, NULL, CLSCTX_INPROC_SERVER, ret = CoCreateInstance(&CLSID_DirectInput8, NULL, CLSCTX_INPROC_SERVER,
&IID_IDirectInput, (LPVOID) & dinput); &IID_IDirectInput8, (LPVOID) & dinput);
if (FAILED(ret)) { if (FAILED(ret)) {
SDL_SYS_HapticQuit(); SDL_SYS_HapticQuit();
DI_SetError("CoCreateInstance", ret); DI_SetError("CoCreateInstance", ret);
@ -167,7 +167,7 @@ SDL_SYS_HapticInit(void)
GetLastError()); GetLastError());
return -1; return -1;
} }
ret = IDirectInput_Initialize(dinput, instance, DIRECTINPUT_VERSION); ret = IDirectInput8_Initialize(dinput, instance, DIRECTINPUT_VERSION);
if (FAILED(ret)) { if (FAILED(ret)) {
SDL_SYS_HapticQuit(); SDL_SYS_HapticQuit();
DI_SetError("Initializing DirectInput device", ret); DI_SetError("Initializing DirectInput device", ret);
@ -175,7 +175,7 @@ SDL_SYS_HapticInit(void)
} }
/* Look for haptic devices. */ /* Look for haptic devices. */
ret = IDirectInput_EnumDevices(dinput, ret = IDirectInput8_EnumDevices(dinput,
0, 0,
EnumHapticsCallback, EnumHapticsCallback,
NULL, NULL,
@ -197,14 +197,14 @@ static BOOL CALLBACK
EnumHapticsCallback(const DIDEVICEINSTANCE * pdidInstance, VOID * pContext) EnumHapticsCallback(const DIDEVICEINSTANCE * pdidInstance, VOID * pContext)
{ {
HRESULT ret; HRESULT ret;
LPDIRECTINPUTDEVICE device; LPDIRECTINPUTDEVICE8 device;
/* Copy the instance over, useful for creating devices. */ /* Copy the instance over, useful for creating devices. */
SDL_memcpy(&SDL_hapticlist[SDL_numhaptics].instance, pdidInstance, SDL_memcpy(&SDL_hapticlist[SDL_numhaptics].instance, pdidInstance,
sizeof(DIDEVICEINSTANCE)); sizeof(DIDEVICEINSTANCE));
/* Open the device */ /* Open the device */
ret = IDirectInput_CreateDevice(dinput, &pdidInstance->guidInstance, ret = IDirectInput8_CreateDevice(dinput, &pdidInstance->guidInstance,
&device, NULL); &device, NULL);
if (FAILED(ret)) { if (FAILED(ret)) {
/* DI_SetError("Creating DirectInput device",ret); */ /* DI_SetError("Creating DirectInput device",ret); */
@ -213,12 +213,12 @@ EnumHapticsCallback(const DIDEVICEINSTANCE * pdidInstance, VOID * pContext)
/* Get capabilities. */ /* Get capabilities. */
SDL_hapticlist[SDL_numhaptics].capabilities.dwSize = sizeof(DIDEVCAPS); SDL_hapticlist[SDL_numhaptics].capabilities.dwSize = sizeof(DIDEVCAPS);
ret = IDirectInputDevice_GetCapabilities(device, ret = IDirectInputDevice8_GetCapabilities(device,
&SDL_hapticlist[SDL_numhaptics]. &SDL_hapticlist[SDL_numhaptics].
capabilities); capabilities);
if (FAILED(ret)) { if (FAILED(ret)) {
/* DI_SetError("Getting device capabilities",ret); */ /* DI_SetError("Getting device capabilities",ret); */
IDirectInputDevice_Release(device); IDirectInputDevice8_Release(device);
return DIENUM_CONTINUE; return DIENUM_CONTINUE;
} }
@ -226,7 +226,7 @@ EnumHapticsCallback(const DIDEVICEINSTANCE * pdidInstance, VOID * pContext)
SDL_hapticlist[SDL_numhaptics].name = WIN_StringToUTF8(SDL_hapticlist[SDL_numhaptics].instance.tszProductName); SDL_hapticlist[SDL_numhaptics].name = WIN_StringToUTF8(SDL_hapticlist[SDL_numhaptics].instance.tszProductName);
/* Close up device and count it. */ /* Close up device and count it. */
IDirectInputDevice_Release(device); IDirectInputDevice8_Release(device);
SDL_numhaptics++; SDL_numhaptics++;
/* Watch out for hard limit. */ /* Watch out for hard limit. */
@ -306,16 +306,16 @@ DI_DeviceObjectCallback(LPCDIDEVICEOBJECTINSTANCE dev, LPVOID pvRef)
* *
* Steps: * Steps:
* - Open temporary DirectInputDevice interface. * - Open temporary DirectInputDevice interface.
* - Create DirectInputDevice2 interface. * - Create DirectInputDevice8 interface.
* - Release DirectInputDevice interface. * - Release DirectInputDevice interface.
* - Call SDL_SYS_HapticOpenFromDevice2 * - Call SDL_SYS_HapticOpenFromDevice8
*/ */
static int static int
SDL_SYS_HapticOpenFromInstance(SDL_Haptic * haptic, DIDEVICEINSTANCE instance) SDL_SYS_HapticOpenFromInstance(SDL_Haptic * haptic, DIDEVICEINSTANCE instance)
{ {
HRESULT ret; HRESULT ret;
int ret2; int ret2;
LPDIRECTINPUTDEVICE device; LPDIRECTINPUTDEVICE8 device;
/* Allocate the hwdata */ /* Allocate the hwdata */
haptic->hwdata = (struct haptic_hwdata *) haptic->hwdata = (struct haptic_hwdata *)
@ -327,26 +327,26 @@ SDL_SYS_HapticOpenFromInstance(SDL_Haptic * haptic, DIDEVICEINSTANCE instance)
SDL_memset(haptic->hwdata, 0, sizeof(*haptic->hwdata)); SDL_memset(haptic->hwdata, 0, sizeof(*haptic->hwdata));
/* Open the device */ /* Open the device */
ret = IDirectInput_CreateDevice(dinput, &instance.guidInstance, ret = IDirectInput8_CreateDevice(dinput, &instance.guidInstance,
&device, NULL); &device, NULL);
if (FAILED(ret)) { if (FAILED(ret)) {
DI_SetError("Creating DirectInput device", ret); DI_SetError("Creating DirectInput device", ret);
goto creat_err; goto creat_err;
} }
/* Now get the IDirectInputDevice2 interface, instead. */ /* Now get the IDirectInputDevice8 interface, instead. */
ret = IDirectInputDevice_QueryInterface(device, ret = IDirectInputDevice8_QueryInterface(device,
&IID_IDirectInputDevice2, &IID_IDirectInputDevice8,
(LPVOID *) & haptic->hwdata-> (LPVOID *) & haptic->hwdata->
device); device);
/* Done with the temporary one now. */ /* Done with the temporary one now. */
IDirectInputDevice_Release(device); IDirectInputDevice8_Release(device);
if (FAILED(ret)) { if (FAILED(ret)) {
DI_SetError("Querying DirectInput interface", ret); DI_SetError("Querying DirectInput interface", ret);
goto creat_err; goto creat_err;
} }
ret2 = SDL_SYS_HapticOpenFromDevice2(haptic, haptic->hwdata->device); ret2 = SDL_SYS_HapticOpenFromDevice8(haptic, haptic->hwdata->device);
if (ret2 < 0) { if (ret2 < 0) {
goto query_err; goto query_err;
} }
@ -354,7 +354,7 @@ SDL_SYS_HapticOpenFromInstance(SDL_Haptic * haptic, DIDEVICEINSTANCE instance)
return 0; return 0;
query_err: query_err:
IDirectInputDevice2_Release(haptic->hwdata->device); IDirectInputDevice8_Release(haptic->hwdata->device);
creat_err: creat_err:
if (haptic->hwdata != NULL) { if (haptic->hwdata != NULL) {
SDL_free(haptic->hwdata); SDL_free(haptic->hwdata);
@ -375,17 +375,17 @@ SDL_SYS_HapticOpenFromInstance(SDL_Haptic * haptic, DIDEVICEINSTANCE instance)
* - Get supported featuers. * - Get supported featuers.
*/ */
static int static int
SDL_SYS_HapticOpenFromDevice2(SDL_Haptic * haptic, SDL_SYS_HapticOpenFromDevice8(SDL_Haptic * haptic,
LPDIRECTINPUTDEVICE2 device2) LPDIRECTINPUTDEVICE8 device8)
{ {
HRESULT ret; HRESULT ret;
DIPROPDWORD dipdw; DIPROPDWORD dipdw;
/* We'll use the device2 from now on. */ /* We'll use the device8 from now on. */
haptic->hwdata->device = device2; haptic->hwdata->device = device8;
/* Grab it exclusively to use force feedback stuff. */ /* Grab it exclusively to use force feedback stuff. */
ret = IDirectInputDevice2_SetCooperativeLevel(haptic->hwdata->device, ret = IDirectInputDevice8_SetCooperativeLevel(haptic->hwdata->device,
SDL_HelperWindow, SDL_HelperWindow,
DISCL_EXCLUSIVE | DISCL_EXCLUSIVE |
DISCL_BACKGROUND); DISCL_BACKGROUND);
@ -395,7 +395,7 @@ SDL_SYS_HapticOpenFromDevice2(SDL_Haptic * haptic,
} }
/* Set data format. */ /* Set data format. */
ret = IDirectInputDevice2_SetDataFormat(haptic->hwdata->device, ret = IDirectInputDevice8_SetDataFormat(haptic->hwdata->device,
&c_dfDIJoystick2); &c_dfDIJoystick2);
if (FAILED(ret)) { if (FAILED(ret)) {
DI_SetError("Setting data format", ret); DI_SetError("Setting data format", ret);
@ -403,7 +403,7 @@ SDL_SYS_HapticOpenFromDevice2(SDL_Haptic * haptic,
} }
/* Get number of axes. */ /* Get number of axes. */
ret = IDirectInputDevice2_EnumObjects(haptic->hwdata->device, ret = IDirectInputDevice8_EnumObjects(haptic->hwdata->device,
DI_DeviceObjectCallback, DI_DeviceObjectCallback,
haptic, DIDFT_AXIS); haptic, DIDFT_AXIS);
if (FAILED(ret)) { if (FAILED(ret)) {
@ -412,14 +412,14 @@ SDL_SYS_HapticOpenFromDevice2(SDL_Haptic * haptic,
} }
/* Acquire the device. */ /* Acquire the device. */
ret = IDirectInputDevice2_Acquire(haptic->hwdata->device); ret = IDirectInputDevice8_Acquire(haptic->hwdata->device);
if (FAILED(ret)) { if (FAILED(ret)) {
DI_SetError("Acquiring DirectInput device", ret); DI_SetError("Acquiring DirectInput device", ret);
goto acquire_err; goto acquire_err;
} }
/* Reset all actuators - just in case. */ /* Reset all actuators - just in case. */
ret = IDirectInputDevice2_SendForceFeedbackCommand(haptic->hwdata->device, ret = IDirectInputDevice8_SendForceFeedbackCommand(haptic->hwdata->device,
DISFFC_RESET); DISFFC_RESET);
if (FAILED(ret)) { if (FAILED(ret)) {
DI_SetError("Resetting device", ret); DI_SetError("Resetting device", ret);
@ -427,7 +427,7 @@ SDL_SYS_HapticOpenFromDevice2(SDL_Haptic * haptic,
} }
/* Enabling actuators. */ /* Enabling actuators. */
ret = IDirectInputDevice2_SendForceFeedbackCommand(haptic->hwdata->device, ret = IDirectInputDevice8_SendForceFeedbackCommand(haptic->hwdata->device,
DISFFC_SETACTUATORSON); DISFFC_SETACTUATORSON);
if (FAILED(ret)) { if (FAILED(ret)) {
DI_SetError("Enabling actuators", ret); DI_SetError("Enabling actuators", ret);
@ -435,7 +435,7 @@ SDL_SYS_HapticOpenFromDevice2(SDL_Haptic * haptic,
} }
/* Get supported effects. */ /* Get supported effects. */
ret = IDirectInputDevice2_EnumEffects(haptic->hwdata->device, ret = IDirectInputDevice8_EnumEffects(haptic->hwdata->device,
DI_EffectCallback, haptic, DI_EffectCallback, haptic,
DIEFT_ALL); DIEFT_ALL);
if (FAILED(ret)) { if (FAILED(ret)) {
@ -453,7 +453,7 @@ SDL_SYS_HapticOpenFromDevice2(SDL_Haptic * haptic,
dipdw.diph.dwObj = 0; dipdw.diph.dwObj = 0;
dipdw.diph.dwHow = DIPH_DEVICE; dipdw.diph.dwHow = DIPH_DEVICE;
dipdw.dwData = 10000; dipdw.dwData = 10000;
ret = IDirectInputDevice2_SetProperty(haptic->hwdata->device, ret = IDirectInputDevice8_SetProperty(haptic->hwdata->device,
DIPROP_FFGAIN, &dipdw.diph); DIPROP_FFGAIN, &dipdw.diph);
if (!FAILED(ret)) { /* Gain is supported. */ if (!FAILED(ret)) { /* Gain is supported. */
haptic->supported |= SDL_HAPTIC_GAIN; haptic->supported |= SDL_HAPTIC_GAIN;
@ -461,7 +461,7 @@ SDL_SYS_HapticOpenFromDevice2(SDL_Haptic * haptic,
dipdw.diph.dwObj = 0; dipdw.diph.dwObj = 0;
dipdw.diph.dwHow = DIPH_DEVICE; dipdw.diph.dwHow = DIPH_DEVICE;
dipdw.dwData = DIPROPAUTOCENTER_OFF; dipdw.dwData = DIPROPAUTOCENTER_OFF;
ret = IDirectInputDevice2_SetProperty(haptic->hwdata->device, ret = IDirectInputDevice8_SetProperty(haptic->hwdata->device,
DIPROP_AUTOCENTER, &dipdw.diph); DIPROP_AUTOCENTER, &dipdw.diph);
if (!FAILED(ret)) { /* Autocenter is supported. */ if (!FAILED(ret)) { /* Autocenter is supported. */
haptic->supported |= SDL_HAPTIC_AUTOCENTER; haptic->supported |= SDL_HAPTIC_AUTOCENTER;
@ -492,7 +492,7 @@ SDL_SYS_HapticOpenFromDevice2(SDL_Haptic * haptic,
/* Error handling */ /* Error handling */
acquire_err: acquire_err:
IDirectInputDevice2_Unacquire(haptic->hwdata->device); IDirectInputDevice8_Unacquire(haptic->hwdata->device);
return -1; return -1;
} }
@ -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;
} }
} }
@ -555,12 +555,12 @@ SDL_SYS_JoystickSameHaptic(SDL_Haptic * haptic, SDL_Joystick * joystick)
joy_instance.dwSize = sizeof(DIDEVICEINSTANCE); joy_instance.dwSize = sizeof(DIDEVICEINSTANCE);
/* Get the device instances. */ /* Get the device instances. */
ret = IDirectInputDevice2_GetDeviceInfo(haptic->hwdata->device, ret = IDirectInputDevice8_GetDeviceInfo(haptic->hwdata->device,
&hap_instance); &hap_instance);
if (FAILED(ret)) { if (FAILED(ret)) {
return 0; return 0;
} }
ret = IDirectInputDevice2_GetDeviceInfo(joystick->hwdata->InputDevice, ret = IDirectInputDevice8_GetDeviceInfo(joystick->hwdata->InputDevice,
&joy_instance); &joy_instance);
if (FAILED(ret)) { if (FAILED(ret)) {
return 0; return 0;
@ -586,7 +586,7 @@ SDL_SYS_HapticOpenFromJoystick(SDL_Haptic * haptic, SDL_Joystick * joystick)
/* Since it comes from a joystick we have to try to match it with a haptic device on our haptic list. */ /* Since it comes from a joystick we have to try to match it with a haptic device on our haptic list. */
for (i=0; i<SDL_numhaptics; i++) { for (i=0; i<SDL_numhaptics; i++) {
idret = IDirectInputDevice2_GetDeviceInfo(joystick->hwdata->InputDevice, idret = IDirectInputDevice8_GetDeviceInfo(joystick->hwdata->InputDevice,
&joy_instance); &joy_instance);
if (FAILED(idret)) { if (FAILED(idret)) {
return -1; return -1;
@ -612,7 +612,7 @@ SDL_SYS_HapticOpenFromJoystick(SDL_Haptic * haptic, SDL_Joystick * joystick)
/* Now open the device. */ /* Now open the device. */
ret = ret =
SDL_SYS_HapticOpenFromDevice2(haptic, joystick->hwdata->InputDevice); SDL_SYS_HapticOpenFromDevice8(haptic, joystick->hwdata->InputDevice);
if (ret < 0) { if (ret < 0) {
return -1; return -1;
} }
@ -638,10 +638,10 @@ SDL_SYS_HapticClose(SDL_Haptic * haptic)
haptic->neffects = 0; haptic->neffects = 0;
/* Clean up */ /* Clean up */
IDirectInputDevice2_Unacquire(haptic->hwdata->device); IDirectInputDevice8_Unacquire(haptic->hwdata->device);
/* Only release if isn't grabbed by a joystick. */ /* Only release if isn't grabbed by a joystick. */
if (haptic->hwdata->is_joystick == 0) { if (haptic->hwdata->is_joystick == 0) {
IDirectInputDevice2_Release(haptic->hwdata->device); IDirectInputDevice8_Release(haptic->hwdata->device);
} }
/* Free */ /* Free */
@ -667,7 +667,7 @@ SDL_SYS_HapticQuit(void)
} }
if (dinput != NULL) { if (dinput != NULL) {
IDirectInput_Release(dinput); IDirectInput8_Release(dinput);
dinput = NULL; dinput = NULL;
} }
@ -1148,7 +1148,7 @@ SDL_SYS_HapticNewEffect(SDL_Haptic * haptic, struct haptic_effect *effect,
} }
/* Create the actual effect. */ /* Create the actual effect. */
ret = IDirectInputDevice2_CreateEffect(haptic->hwdata->device, type, ret = IDirectInputDevice8_CreateEffect(haptic->hwdata->device, type,
&effect->hweffect->effect, &effect->hweffect->effect,
&effect->hweffect->ref, NULL); &effect->hweffect->ref, NULL);
if (FAILED(ret)) { if (FAILED(ret)) {
@ -1319,7 +1319,7 @@ SDL_SYS_HapticSetGain(SDL_Haptic * haptic, int gain)
dipdw.dwData = gain * 100; /* 0 to 10,000 */ dipdw.dwData = gain * 100; /* 0 to 10,000 */
/* Try to set the autocenter. */ /* Try to set the autocenter. */
ret = IDirectInputDevice2_SetProperty(haptic->hwdata->device, ret = IDirectInputDevice8_SetProperty(haptic->hwdata->device,
DIPROP_FFGAIN, &dipdw.diph); DIPROP_FFGAIN, &dipdw.diph);
if (FAILED(ret)) { if (FAILED(ret)) {
DI_SetError("Setting gain", ret); DI_SetError("Setting gain", ret);
@ -1348,7 +1348,7 @@ SDL_SYS_HapticSetAutocenter(SDL_Haptic * haptic, int autocenter)
DIPROPAUTOCENTER_ON; DIPROPAUTOCENTER_ON;
/* Try to set the autocenter. */ /* Try to set the autocenter. */
ret = IDirectInputDevice2_SetProperty(haptic->hwdata->device, ret = IDirectInputDevice8_SetProperty(haptic->hwdata->device,
DIPROP_AUTOCENTER, &dipdw.diph); DIPROP_AUTOCENTER, &dipdw.diph);
if (FAILED(ret)) { if (FAILED(ret)) {
DI_SetError("Setting autocenter", ret); DI_SetError("Setting autocenter", ret);
@ -1368,7 +1368,7 @@ SDL_SYS_HapticPause(SDL_Haptic * haptic)
HRESULT ret; HRESULT ret;
/* Pause the device. */ /* Pause the device. */
ret = IDirectInputDevice2_SendForceFeedbackCommand(haptic->hwdata->device, ret = IDirectInputDevice8_SendForceFeedbackCommand(haptic->hwdata->device,
DISFFC_PAUSE); DISFFC_PAUSE);
if (FAILED(ret)) { if (FAILED(ret)) {
DI_SetError("Pausing the device", ret); DI_SetError("Pausing the device", ret);
@ -1388,7 +1388,7 @@ SDL_SYS_HapticUnpause(SDL_Haptic * haptic)
HRESULT ret; HRESULT ret;
/* Unpause the device. */ /* Unpause the device. */
ret = IDirectInputDevice2_SendForceFeedbackCommand(haptic->hwdata->device, ret = IDirectInputDevice8_SendForceFeedbackCommand(haptic->hwdata->device,
DISFFC_CONTINUE); DISFFC_CONTINUE);
if (FAILED(ret)) { if (FAILED(ret)) {
DI_SetError("Pausing the device", ret); DI_SetError("Pausing the device", ret);
@ -1408,7 +1408,7 @@ SDL_SYS_HapticStopAll(SDL_Haptic * haptic)
HRESULT ret; HRESULT ret;
/* Try to stop the effects. */ /* Try to stop the effects. */
ret = IDirectInputDevice2_SendForceFeedbackCommand(haptic->hwdata->device, ret = IDirectInputDevice8_SendForceFeedbackCommand(haptic->hwdata->device,
DISFFC_STOPALL); DISFFC_STOPALL);
if (FAILED(ret)) { if (FAILED(ret)) {
DI_SetError("Stopping the device", ret); DI_SetError("Stopping the device", ret);

File diff suppressed because it is too large Load diff

View file

@ -24,34 +24,23 @@
#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; static SDL_Joystick *SDL_joysticks = NULL;
SDL_Joystick **SDL_joysticks = NULL; static SDL_Joystick *SDL_updating_joystick = 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 +51,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_JoystickNameForDeviceIndex(device_index));
} }
/* /*
@ -88,21 +77,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 +108,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_JoystickNameForDeviceIndex( 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,68 +159,46 @@ 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;
} }
if ( joystick && joystick->closed )
{
valid = 0;
}
return valid; return valid;
} }
/*
* Get the device index of an opened joystick.
*/
int
SDL_JoystickIndex(SDL_Joystick * joystick)
{
if (!SDL_PrivateJoystickValid(&joystick)) {
return (-1);
}
return (joystick->index);
}
/* /*
* Get the number of multi-dimensional axis controls on a joystick * Get the number of multi-dimensional axis controls on a 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 +210,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 +222,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 +234,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 +248,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 +268,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 +288,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 +317,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 +329,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.
*/
SDL_bool
SDL_JoystickGetAttached(SDL_Joystick * joystick)
{
if (!SDL_PrivateJoystickValid(joystick)) {
return SDL_FALSE;
}
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;
} }
@ -367,17 +387,37 @@ SDL_JoystickClose(SDL_Joystick * joystick)
return; return;
} }
SDL_SYS_JoystickClose(joystick); if (joystick == SDL_updating_joystick) {
return;
/* Remove joystick from list */
for (i = 0; SDL_joysticks[i]; ++i) {
if (joystick == SDL_joysticks[i]) {
SDL_memmove(&SDL_joysticks[i], &SDL_joysticks[i + 1],
(SDL_numjoysticks - i) * sizeof(joystick));
break;
}
} }
SDL_SYS_JoystickClose(joystick);
joysticklist = SDL_joysticks;
joysticklistprev = NULL;
while ( joysticklist )
{
if (joystick == joysticklist)
{
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) {
SDL_free(joystick->axes); SDL_free(joystick->axes);
@ -397,26 +437,18 @@ SDL_JoystickClose(SDL_Joystick * joystick)
void void
SDL_JoystickQuit(void) SDL_JoystickQuit(void)
{ {
const int numsticks = SDL_numjoysticks; /* Make sure we're not getting called in the middle of updating joysticks */
int i; SDL_assert(!SDL_updating_joystick);
/* 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;
}
} }
@ -433,6 +465,9 @@ SDL_PrivateJoystickAxis(SDL_Joystick * joystick, Uint8 axis, Sint16 value)
} }
/* Update internal joystick state */ /* Update internal joystick state */
if (value == joystick->axes[axis]) {
return 0;
}
joystick->axes[axis] = value; joystick->axes[axis] = value;
/* Post the event, if desired */ /* Post the event, if desired */
@ -441,14 +476,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 +504,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 +534,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 +576,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,28 +588,66 @@ SDL_PrivateJoystickButton(SDL_Joystick * joystick, Uint8 button, Uint8 state)
void void
SDL_JoystickUpdate(void) SDL_JoystickUpdate(void)
{ {
int i; SDL_Joystick *joystick;
joystick = SDL_joysticks;
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;
for (i = 0; SDL_joysticks[i]; ++i) { SDL_updating_joystick = joystick;
SDL_SYS_JoystickUpdate(SDL_joysticks[i]);
} 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);
}
SDL_updating_joystick = NULL;
/* If the joystick was closed while updating, free it here */
if ( joystick->ref_count <= 0 ) {
SDL_JoystickClose(joystick);
}
joystick = joysticknext;
}
SDL_SYS_JoystickDetect();
} }
int int
SDL_JoystickEventState(int state) SDL_JoystickEventState(int state)
{ {
#if SDL_EVENTS_DISABLED #if SDL_EVENTS_DISABLED
return SDL_IGNORE; return SDL_DISABLE;
#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;
switch (state) { switch (state) {
case SDL_QUERY: case SDL_QUERY:
state = SDL_IGNORE; state = SDL_DISABLE;
for (i = 0; i < SDL_arraysize(event_list); ++i) { for (i = 0; i < SDL_arraysize(event_list); ++i) {
state = SDL_EventState(event_list[i], SDL_QUERY); state = SDL_EventState(event_list[i], SDL_QUERY);
if (state == SDL_ENABLE) { if (state == SDL_ENABLE) {
@ -608,4 +665,108 @@ 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 */
SDL_bool
SDL_PrivateJoystickNeedsPolling()
{
if (SDL_joysticks != NULL) {
return SDL_TRUE;
} else {
return SDL_SYS_JoystickNeedsPolling();
}
}
/* return the guid for this index */
SDL_JoystickGUID SDL_JoystickGetDeviceGUID(int device_index)
{
return SDL_SYS_JoystickGetDeviceGUID( device_index );
}
/* return the guid for this opened device */
SDL_JoystickGUID SDL_JoystickGetGUID(SDL_Joystick * joystick)
{
return SDL_SYS_JoystickGetGUID( joystick );
}
/* convert the guid to a printable string */
void SDL_JoystickGetGUIDString( SDL_JoystickGUID guid, char *pszGUID, int cbGUID )
{
static const char k_rgchHexToASCII[] = "0123456789abcdef";
int i;
if ((pszGUID == NULL) || (cbGUID <= 0)) {
return;
}
for ( i = 0; i < sizeof(guid.data) && i < (cbGUID-1); 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];
*pszGUID++ = k_rgchHexToASCII[ c >> 4 ];
*pszGUID++ = k_rgchHexToASCII[ c & 0x0F ];
}
*pszGUID = '\0';
}
//-----------------------------------------------------------------------------
// 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 */
SDL_JoystickGUID SDL_JoystickGetGUIDFromString(const char *pchGUID)
{
SDL_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: */

View file

@ -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);
@ -39,8 +41,11 @@ extern int SDL_PrivateJoystickHat(SDL_Joystick * joystick,
Uint8 hat, Uint8 value); Uint8 hat, Uint8 value);
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 SDL_bool 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: */

View file

@ -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.
@ -58,15 +63,32 @@ struct _SDL_Joystick
*/ */
extern int SDL_SYS_JoystickInit(void); extern int SDL_SYS_JoystickInit(void);
/* 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 SDL_bool SDL_SYS_JoystickNeedsPolling();
/* 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_JoystickNameForDeviceIndex(int device_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 query if the joystick is currently attached
* It returns 1 if attached, 0 otherwise.
*/
extern SDL_bool SDL_SYS_JoystickAttached(SDL_Joystick * joystick);
/* 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 +103,15 @@ 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 return the stable GUID for a plugged in device */
extern SDL_JoystickGUID SDL_SYS_JoystickGetDeviceGUID(int device_index);
/* Function to return the stable GUID for a opened joystick */
extern SDL_JoystickGUID SDL_SYS_JoystickGetGUID(SDL_Joystick * joystick);
#ifdef SDL_JOYSTICK_DINPUT
/* Function to get the current instance id of the joystick located at device_index */
extern SDL_bool SDL_SYS_IsXInputDeviceIndex( int device_index );
#endif
/* vi: set ts=4 sw=4 expandtab: */ /* vi: set ts=4 sw=4 expandtab: */

View file

@ -43,21 +43,34 @@ static const char *accelerometerName = "Android accelerometer";
int int
SDL_SYS_JoystickInit(void) SDL_SYS_JoystickInit(void)
{ {
SDL_numjoysticks = 1;
return (1); return (1);
} }
int SDL_SYS_NumJoysticks()
{
return 1;
}
void SDL_SYS_JoystickDetect()
{
}
SDL_bool SDL_SYS_JoystickNeedsPolling()
{
return SDL_FALSE;
}
/* 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_JoystickNameForDeviceIndex(int device_index)
{ {
if (index == 0) { return accelerometerName;
return accelerometerName; }
} else {
SDL_SetError("No joystick available with that index"); /* Function to perform the mapping from device index to the instance id for this index */
return (NULL); SDL_JoystickID SDL_SYS_GetInstanceIdOfDeviceIndex(int device_index)
} {
return device_index;
} }
/* Function to open a joystick for use. /* Function to open a joystick for use.
@ -66,16 +79,25 @@ 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)
{ {
joystick->nbuttons = 0; if (device_index == 0) {
joystick->nhats = 0; joystick->nbuttons = 0;
joystick->nballs = 0; joystick->nhats = 0;
joystick->naxes = 3; joystick->nballs = 0;
joystick->name = accelerometerName; joystick->naxes = 3;
return 0; return 0;
} else {
SDL_SetError("No joystick available with that index");
return (-1);
}
} }
/* Function to determine is this joystick is attached to the system right now */
SDL_bool SDL_SYS_JoystickAttached(SDL_Joystick *joystick)
{
return SDL_TRUE;
}
/* 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,
@ -109,6 +131,26 @@ SDL_SYS_JoystickQuit(void)
{ {
} }
#endif /* SDL_JOYSTICK_NDS */ SDL_JoystickGUID SDL_SYS_JoystickGetDeviceGUID( int device_index )
{
SDL_JoystickGUID guid;
// the GUID is just the first 16 chars of the name for now
const char *name = SDL_SYS_JoystickNameForDeviceIndex( device_index );
SDL_zero( guid );
SDL_memcpy( &guid, name, SDL_min( sizeof(guid), SDL_strlen( name ) ) );
return guid;
}
SDL_JoystickGUID SDL_SYS_JoystickGetGUID(SDL_Joystick * joystick)
{
SDL_JoystickGUID guid;
// the GUID is just the first 16 chars of the name for now
const char *name = joystick->name;
SDL_zero( guid );
SDL_memcpy( &guid, name, SDL_min( sizeof(guid), SDL_strlen( name ) ) );
return guid;
}
#endif /* SDL_JOYSTICK_ANDROID */
/* vi: set ts=4 sw=4 expandtab: */ /* vi: set ts=4 sw=4 expandtab: */

View file

@ -50,6 +50,8 @@ extern "C"
int16 *new_axes; int16 *new_axes;
}; };
static int SDL_SYS_numjoysticks = 0;
/* Function to scan the system for joysticks. /* Function to scan the system for joysticks.
* This function should set SDL_numjoysticks to the number of available * This function should set SDL_numjoysticks to the number of available
* joysticks. Joystick 0 should be the system default joystick. * joysticks. Joystick 0 should be the system default joystick.
@ -58,36 +60,55 @@ extern "C"
int SDL_SYS_JoystickInit(void) int SDL_SYS_JoystickInit(void)
{ {
BJoystick joystick; BJoystick joystick;
int numjoysticks;
int i; int i;
int32 nports; int32 nports;
char name[B_OS_NAME_LENGTH]; char name[B_OS_NAME_LENGTH];
/* Search for attached joysticks */ /* Search for attached joysticks */
nports = joystick.CountDevices(); nports = joystick.CountDevices();
numjoysticks = 0; SDL_SYS_numjoysticks = 0;
SDL_memset(SDL_joyport, 0, (sizeof SDL_joyport)); SDL_memset(SDL_joyport, 0, (sizeof SDL_joyport));
SDL_memset(SDL_joyname, 0, (sizeof SDL_joyname)); SDL_memset(SDL_joyname, 0, (sizeof SDL_joyname));
for (i = 0; (SDL_numjoysticks < MAX_JOYSTICKS) && (i < nports); ++i) for (i = 0; (SDL_SYS_numjoysticks < MAX_JOYSTICKS) && (i < nports); ++i)
{ {
if (joystick.GetDeviceName(i, name) == B_OK) { if (joystick.GetDeviceName(i, name) == B_OK) {
if (joystick.Open(name) != B_ERROR) { if (joystick.Open(name) != B_ERROR) {
BString stick_name; BString stick_name;
joystick.GetControllerName(&stick_name); joystick.GetControllerName(&stick_name);
SDL_joyport[numjoysticks] = strdup(name); SDL_joyport[SDL_SYS_numjoysticks] = strdup(name);
SDL_joyname[numjoysticks] = strdup(stick_name.String()); SDL_joyname[SDL_SYS_numjoysticks] = strdup(stick_name.String());
numjoysticks++; SDL_SYS_numjoysticks++;
joystick.Close(); joystick.Close();
} }
} }
} }
return (numjoysticks); return (SDL_SYS_numjoysticks);
}
int SDL_SYS_NumJoysticks()
{
return SDL_SYS_numjoysticks;
}
void SDL_SYS_JoystickDetect()
{
}
SDL_bool SDL_SYS_JoystickNeedsPolling()
{
return SDL_FALSE;
} }
/* Function to get the device-dependent name of a joystick */ /* Function to get the device-dependent name of a joystick */
const char *SDL_SYS_JoystickName(int index) const char *SDL_SYS_JoystickNameForDeviceIndex(int device_index)
{ {
return SDL_joyname[index]; return SDL_joyname[device_index];
}
/* Function to perform the mapping from device index to the instance id for this index */
SDL_JoystickID SDL_SYS_GetInstanceIdOfDeviceIndex(int device_index)
{
return device_index;
} }
/* Function to open a joystick for use. /* Function to open a joystick for use.
@ -95,11 +116,12 @@ extern "C"
This should fill the nbuttons and naxes fields of the joystick structure. This should fill the nbuttons and naxes fields of the joystick structure.
It returns 0, or -1 if there is an error. It returns 0, or -1 if there is an error.
*/ */
int SDL_SYS_JoystickOpen(SDL_Joystick * joystick) int SDL_SYS_JoystickOpen(SDL_Joystick * joystick, int device_index)
{ {
BJoystick *stick; BJoystick *stick;
/* Create the joystick data structure */ /* Create the joystick data structure */
joystick->instance_id = device_index;
joystick->hwdata = (struct joystick_hwdata *) joystick->hwdata = (struct joystick_hwdata *)
SDL_malloc(sizeof(*joystick->hwdata)); SDL_malloc(sizeof(*joystick->hwdata));
if (joystick->hwdata == NULL) { if (joystick->hwdata == NULL) {
@ -111,7 +133,7 @@ extern "C"
joystick->hwdata->stick = stick; joystick->hwdata->stick = stick;
/* Open the requested joystick for use */ /* Open the requested joystick for use */
if (stick->Open(SDL_joyport[joystick->index]) == B_ERROR) { if (stick->Open(SDL_joyport[device_index]) == B_ERROR) {
SDL_SetError("Unable to open joystick"); SDL_SetError("Unable to open joystick");
SDL_SYS_JoystickClose(joystick); SDL_SYS_JoystickClose(joystick);
return (-1); return (-1);
@ -139,6 +161,12 @@ extern "C"
return (0); return (0);
} }
/* Function to determine is this joystick is attached to the system right now */
SDL_bool SDL_SYS_JoystickAttached(SDL_Joystick *joystick)
{
return SDL_TRUE;
}
/* 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
@ -233,6 +261,26 @@ extern "C"
SDL_joyname[0] = NULL; SDL_joyname[0] = NULL;
} }
SDL_JoystickGUID SDL_SYS_JoystickGetDeviceGUID( int device_index )
{
SDL_JoystickGUID guid;
// the GUID is just the first 16 chars of the name for now
const char *name = SDL_SYS_JoystickNameForDeviceIndex( device_index );
SDL_zero( guid );
SDL_memcpy( &guid, name, SDL_min( sizeof(guid), SDL_strlen( name ) ) );
return guid;
}
SDL_JoystickGUID SDL_SYS_JoystickGetGUID(SDL_Joystick * joystick)
{
SDL_JoystickGUID guid;
// the GUID is just the first 16 chars of the name for now
const char *name = joystick->name;
SDL_zero( guid );
SDL_memcpy( &guid, name, SDL_min( sizeof(guid), SDL_strlen( name ) ) );
return guid;
}
}; // extern "C" }; // extern "C"
#endif /* SDL_JOYSTICK_BEOS */ #endif /* SDL_JOYSTICK_BEOS */

View file

@ -157,13 +157,15 @@ static void report_free(struct report *);
#define REP_BUF_DATA(rep) ((rep)->buf->data) #define REP_BUF_DATA(rep) ((rep)->buf->data)
#endif #endif
static int SDL_SYS_numjoysticks = 0;
int int
SDL_SYS_JoystickInit(void) SDL_SYS_JoystickInit(void)
{ {
char s[16]; char s[16];
int i, fd; int i, fd;
SDL_numjoysticks = 0; SDL_SYS_numjoysticks = 0;
SDL_memset(joynames, 0, sizeof(joynames)); SDL_memset(joynames, 0, sizeof(joynames));
SDL_memset(joydevnames, 0, sizeof(joydevnames)); SDL_memset(joydevnames, 0, sizeof(joydevnames));
@ -173,22 +175,21 @@ SDL_SYS_JoystickInit(void)
SDL_snprintf(s, SDL_arraysize(s), "/dev/uhid%d", i); SDL_snprintf(s, SDL_arraysize(s), "/dev/uhid%d", i);
nj.index = SDL_numjoysticks; joynames[SDL_SYS_numjoysticks] = strdup(s);
joynames[nj.index] = strdup(s);
if (SDL_SYS_JoystickOpen(&nj) == 0) { if (SDL_SYS_JoystickOpen(&nj, SDL_SYS_numjoysticks) == 0) {
SDL_SYS_JoystickClose(&nj); SDL_SYS_JoystickClose(&nj);
SDL_numjoysticks++; SDL_SYS_numjoysticks++;
} else { } else {
SDL_free(joynames[nj.index]); SDL_free(joynames[SDL_SYS_numjoysticks]);
joynames[nj.index] = NULL; joynames[SDL_SYS_numjoysticks] = NULL;
} }
} }
for (i = 0; i < MAX_JOY_JOYS; i++) { for (i = 0; i < MAX_JOY_JOYS; i++) {
SDL_snprintf(s, SDL_arraysize(s), "/dev/joy%d", i); SDL_snprintf(s, SDL_arraysize(s), "/dev/joy%d", i);
fd = open(s, O_RDONLY); fd = open(s, O_RDONLY);
if (fd != -1) { if (fd != -1) {
joynames[SDL_numjoysticks++] = strdup(s); joynames[SDL_SYS_numjoysticks++] = strdup(s);
close(fd); close(fd);
} }
} }
@ -196,16 +197,36 @@ SDL_SYS_JoystickInit(void)
/* Read the default USB HID usage table. */ /* Read the default USB HID usage table. */
hid_init(NULL); hid_init(NULL);
return (SDL_numjoysticks); return (SDL_SYS_numjoysticks);
}
int SDL_SYS_NumJoysticks()
{
return SDL_SYS_numjoysticks;
}
void SDL_SYS_JoystickDetect()
{
}
SDL_bool SDL_SYS_JoystickNeedsPolling()
{
return SDL_FALSE;
} }
const char * const char *
SDL_SYS_JoystickName(int index) SDL_SYS_JoystickNameForDeviceIndex(int device_index)
{ {
if (joydevnames[index] != NULL) { if (joydevnames[device_index] != NULL) {
return (joydevnames[index]); return (joydevnames[device_index]);
} }
return (joynames[index]); return (joynames[device_index]);
}
/* Function to perform the mapping from device index to the instance id for this index */
SDL_JoystickID SDL_SYS_GetInstanceIdOfDeviceIndex(int device_index)
{
return device_index;
} }
static int static int
@ -260,9 +281,9 @@ hatval_to_sdl(Sint32 hatval)
int int
SDL_SYS_JoystickOpen(SDL_Joystick * joy) SDL_SYS_JoystickOpen(SDL_Joystick * joy, int device_index)
{ {
char *path = joynames[joy->index]; char *path = joynames[device_index];
struct joystick_hwdata *hw; struct joystick_hwdata *hw;
struct hid_item hitem; struct hid_item hitem;
struct hid_data *hdata; struct hid_data *hdata;
@ -276,6 +297,7 @@ SDL_SYS_JoystickOpen(SDL_Joystick * joy)
return (-1); return (-1);
} }
joy->instance_id = device_index;
hw = (struct joystick_hwdata *) hw = (struct joystick_hwdata *)
SDL_malloc(sizeof(struct joystick_hwdata)); SDL_malloc(sizeof(struct joystick_hwdata));
if (hw == NULL) { if (hw == NULL) {
@ -292,7 +314,7 @@ SDL_SYS_JoystickOpen(SDL_Joystick * joy)
joy->nbuttons = 2; joy->nbuttons = 2;
joy->nhats = 0; joy->nhats = 0;
joy->nballs = 0; joy->nballs = 0;
joydevnames[joy->index] = strdup("Gameport joystick"); joydevnames[device_index] = strdup("Gameport joystick");
goto usbend; goto usbend;
} else { } else {
hw->type = BSDJOY_UHID; hw->type = BSDJOY_UHID;
@ -356,8 +378,8 @@ SDL_SYS_JoystickOpen(SDL_Joystick * joy)
s = hid_usage_in_page(hitem.usage); s = hid_usage_in_page(hitem.usage);
sp = SDL_malloc(SDL_strlen(s) + 5); sp = SDL_malloc(SDL_strlen(s) + 5);
SDL_snprintf(sp, SDL_strlen(s) + 5, "%s (%d)", SDL_snprintf(sp, SDL_strlen(s) + 5, "%s (%d)",
s, joy->index); s, device_index);
joydevnames[joy->index] = sp; joydevnames[device_index] = sp;
} }
} }
break; break;
@ -402,6 +424,12 @@ SDL_SYS_JoystickOpen(SDL_Joystick * joy)
return (-1); return (-1);
} }
/* Function to determine is this joystick is attached to the system right now */
SDL_bool SDL_SYS_JoystickAttached(SDL_Joystick *joystick)
{
return SDL_TRUE;
}
void void
SDL_SYS_JoystickUpdate(SDL_Joystick * joy) SDL_SYS_JoystickUpdate(SDL_Joystick * joy)
{ {
@ -556,6 +584,26 @@ SDL_SYS_JoystickQuit(void)
return; return;
} }
SDL_JoystickGUID SDL_SYS_JoystickGetDeviceGUID( int device_index )
{
SDL_JoystickGUID guid;
// the GUID is just the first 16 chars of the name for now
const char *name = SDL_SYS_JoystickNameForDeviceIndex( device_index );
SDL_zero( guid );
SDL_memcpy( &guid, name, SDL_min( sizeof(guid), SDL_strlen( name ) ) );
return guid;
}
SDL_JoystickGUID SDL_SYS_JoystickGetGUID(SDL_Joystick * joystick)
{
SDL_JoystickGUID guid;
// the GUID is just the first 16 chars of the name for now
const char *name = joystick->name;
SDL_zero( guid );
SDL_memcpy( &guid, name, SDL_min( sizeof(guid), SDL_strlen( name ) ) );
return guid;
}
static int static int
report_alloc(struct report *r, struct report_desc *rd, int repind) report_alloc(struct report *r, struct report_desc *rd, int repind)
{ {
@ -612,4 +660,5 @@ report_free(struct report *r)
} }
#endif /* SDL_JOYSTICK_USBHID */ #endif /* SDL_JOYSTICK_USBHID */
/* vi: set ts=4 sw=4 expandtab: */ /* vi: set ts=4 sw=4 expandtab: */

View 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 */
static SDL_bool s_bDeviceAdded = SDL_FALSE;
/* 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,9 +183,33 @@ 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 = SDL_TRUE;
/* 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,120 @@ 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 */
/* now connect notification for new devices */
notificationPort = IONotificationPortCreate(masterPort);
hidMatchDictionary = IOServiceMatching(kIOHIDDeviceKey);
/* Count the total number of devices we found */ CFRunLoopAddSource(CFRunLoopGetCurrent(),
device = gpDeviceList; IONotificationPortGetRunLoopSource(notificationPort),
while (device) { kCFRunLoopDefaultMode);
SDL_numjoysticks++;
// 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 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; device = device->pNext;
} }
return SDL_numjoysticks; return nJoySticks;
}
/* Function to cause any queued joystick insertions to be processed
*/
void
SDL_SYS_JoystickDetect()
{
if ( s_bDeviceAdded )
{
recDevice *device = gpDeviceList;
s_bDeviceAdded = SDL_FALSE;
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;
}
}
}
SDL_bool
SDL_SYS_JoystickNeedsPolling()
{
return s_bDeviceAdded;
} }
/* 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_JoystickNameForDeviceIndex(int device_index)
{ {
recDevice *device = gpDeviceList; recDevice *device = gpDeviceList;
for (; index > 0; index--) for (; device_index > 0; device_index--)
device = device->pNext; device = device->pNext;
return device->product; return device->product;
}
/* 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 open a joystick for use. /* Function to open a joystick for use.
@ -701,25 +894,44 @@ 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->instance_id = device->instance_id;
joystick->hwdata = device; joystick->hwdata = device;
joystick->name = device->product; 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 query if the joystick is currently attached
* It returns 1 if attached, 0 otherwise.
*/
SDL_bool
SDL_SYS_JoystickAttached(SDL_Joystick * joystick)
{
recDevice *device = gpDeviceList;
while ( device )
{
if ( joystick->instance_id == device->instance_id )
return SDL_TRUE;
device = device->pNext;
}
return SDL_FALSE;
}
/* 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,26 +940,49 @@ 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... */
for (i = 0; i < device->axes; i++) if ( devicelist == device )
SDL_PrivateJoystickAxis(joystick, i, 0); {
gpDeviceList = device->pNext;
for (i = 0; i < device->buttons; i++) }
SDL_PrivateJoystickButton(joystick, i, 0); else
{
for (i = 0; i < device->hats; i++) while ( devicelist->pNext != device )
SDL_PrivateJoystickHat(joystick, i, SDL_HAT_CENTERED); {
} devicelist = devicelist->pNext;
}
devicelist->pNext = device->pNext;
}
DisposePtr((Ptr) device);
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;
} }
@ -829,9 +1064,8 @@ SDL_SYS_JoystickUpdate(SDL_Joystick * joystick)
/* 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 +1074,29 @@ SDL_SYS_JoystickQuit(void)
{ {
while (NULL != gpDeviceList) while (NULL != gpDeviceList)
gpDeviceList = HIDDisposeDevice(&gpDeviceList); gpDeviceList = HIDDisposeDevice(&gpDeviceList);
if ( notificationPort )
{
IONotificationPortDestroy( notificationPort );
notificationPort = 0;
}
}
SDL_JoystickGUID SDL_SYS_JoystickGetDeviceGUID( int device_index )
{
recDevice *device = gpDeviceList;
int index;
for (index = device_index; index > 0; index--)
device = device->pNext;
return device->guid;
}
SDL_JoystickGUID SDL_SYS_JoystickGetGUID(SDL_Joystick *joystick)
{
return joystick->hwdata->guid;
} }
#endif /* SDL_JOYSTICK_IOKIT */ #endif /* SDL_JOYSTICK_IOKIT */

View file

@ -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,7 +59,9 @@ 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 */
long usagePage; /* usage within above page from IOUSBHID Parser.h which defines specific usage */ long usagePage; /* usage within above page from IOUSBHID Parser.h which defines specific usage */
@ -74,6 +77,10 @@ struct joystick_hwdata
int removed; int removed;
int uncentered; int uncentered;
int instance_id;
SDL_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 */
}; };

View file

@ -29,37 +29,60 @@
#include "../SDL_joystick_c.h" #include "../SDL_joystick_c.h"
/* Function to scan the system for joysticks. /* Function to scan the system for joysticks.
* This function should set SDL_numjoysticks to the number of available
* joysticks. Joystick 0 should be the system default joystick.
* It should return 0, or -1 on an unrecoverable fatal error. * It should return 0, or -1 on an unrecoverable fatal error.
*/ */
int int
SDL_SYS_JoystickInit(void) SDL_SYS_JoystickInit(void)
{ {
SDL_numjoysticks = 0;
return (0); return (0);
} }
int SDL_SYS_NumJoysticks()
{
return 0;
}
void SDL_SYS_JoystickDetect()
{
}
SDL_bool SDL_SYS_JoystickNeedsPolling()
{
return SDL_FALSE;
}
/* 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_JoystickNameForDeviceIndex(int device_index)
{ {
SDL_SetError("Logic error: No joysticks available"); SDL_SetError("Logic error: No joysticks available");
return (NULL); return (NULL);
} }
/* Function to perform the mapping from device index to the instance id for this index */
SDL_JoystickID SDL_SYS_GetInstanceIdOfDeviceIndex(int device_index)
{
return 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.
*/ */
int int
SDL_SYS_JoystickOpen(SDL_Joystick * joystick) SDL_SYS_JoystickOpen(SDL_Joystick * joystick, int device_index)
{ {
SDL_SetError("Logic error: No joysticks available"); SDL_SetError("Logic error: No joysticks available");
return (-1); return (-1);
} }
/* Function to determine is this joystick is attached to the system right now */
SDL_bool SDL_SYS_JoystickAttached(SDL_Joystick *joystick)
{
return SDL_TRUE;
}
/* 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
@ -85,6 +108,27 @@ SDL_SYS_JoystickQuit(void)
return; return;
} }
SDL_JoystickGUID SDL_SYS_JoystickGetDeviceGUID( int device_index )
{
SDL_JoystickGUID guid;
// the GUID is just the first 16 chars of the name for now
const char *name = SDL_SYS_JoystickNameForDeviceIndex( device_index );
SDL_zero( guid );
SDL_memcpy( &guid, name, SDL_min( sizeof(guid), SDL_strlen( name ) ) );
return guid;
}
SDL_JoystickGUID SDL_SYS_JoystickGetGUID(SDL_Joystick * joystick)
{
SDL_JoystickGUID guid;
// the GUID is just the first 16 chars of the name for now
const char *name = joystick->name;
SDL_zero( guid );
SDL_memcpy( &guid, name, SDL_min( sizeof(guid), SDL_strlen( name ) ) );
return guid;
}
#endif /* SDL_JOYSTICK_DUMMY || SDL_JOYSTICK_DISABLED */ #endif /* SDL_JOYSTICK_DUMMY || SDL_JOYSTICK_DISABLED */
/* vi: set ts=4 sw=4 expandtab: */ /* vi: set ts=4 sw=4 expandtab: */

View file

@ -37,21 +37,34 @@ const char *accelerometerName = "iPhone accelerometer";
int int
SDL_SYS_JoystickInit(void) SDL_SYS_JoystickInit(void)
{ {
SDL_numjoysticks = 1;
return (1); return (1);
} }
int SDL_SYS_NumJoysticks()
{
return 1;
}
void SDL_SYS_JoystickDetect()
{
}
SDL_bool SDL_SYS_JoystickNeedsPolling()
{
return SDL_FALSE;
}
/* 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_JoystickNameForDeviceIndex(int device_index)
{ {
switch(index) { return accelerometerName;
case 0: }
return accelerometerName;
default: /* Function to perform the mapping from device index to the instance id for this index */
SDL_SetError("No joystick available with that index"); SDL_JoystickID SDL_SYS_GetInstanceIdOfDeviceIndex(int device_index)
return NULL; {
} return device_index;
} }
/* Function to open a joystick for use. /* Function to open a joystick for use.
@ -60,22 +73,20 @@ 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)
{ {
if (joystick->index == 0) { joystick->naxes = 3;
joystick->naxes = 3; joystick->nhats = 0;
joystick->nhats = 0; joystick->nballs = 0;
joystick->nballs = 0; joystick->nbuttons = 0;
joystick->nbuttons = 0; [[SDLUIAccelerationDelegate sharedDelegate] startup];
joystick->name = accelerometerName; return 0;
[[SDLUIAccelerationDelegate sharedDelegate] startup]; }
return 0;
} /* Function to determine is this joystick is attached to the system right now */
else { SDL_bool SDL_SYS_JoystickAttached(SDL_Joystick *joystick)
SDL_SetError("No joystick available with that index"); {
return (-1); return SDL_TRUE;
}
} }
/* 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.
@ -107,7 +118,7 @@ SDL_SYS_JoystickUpdate(SDL_Joystick * joystick)
void void
SDL_SYS_JoystickClose(SDL_Joystick * joystick) SDL_SYS_JoystickClose(SDL_Joystick * joystick)
{ {
if (joystick->index == 0 && [[SDLUIAccelerationDelegate sharedDelegate] isRunning]) { if ([[SDLUIAccelerationDelegate sharedDelegate] isRunning]) {
[[SDLUIAccelerationDelegate sharedDelegate] shutdown]; [[SDLUIAccelerationDelegate sharedDelegate] shutdown];
} }
SDL_SetError("No joystick open with that index"); SDL_SetError("No joystick open with that index");
@ -121,4 +132,25 @@ SDL_SYS_JoystickQuit(void)
{ {
return; return;
} }
SDL_JoystickGUID SDL_SYS_JoystickGetDeviceGUID( int device_index )
{
SDL_JoystickGUID guid;
// the GUID is just the first 16 chars of the name for now
const char *name = SDL_SYS_JoystickNameForDeviceIndex( device_index );
SDL_zero( guid );
SDL_memcpy( &guid, name, SDL_min( sizeof(guid), SDL_strlen( name ) ) );
return guid;
}
SDL_JoystickGUID SDL_SYS_JoystickGetGUID(SDL_Joystick * joystick)
{
SDL_JoystickGUID guid;
// the GUID is just the first 16 chars of the name for now
const char *name = joystick->name;
SDL_zero( guid );
SDL_memcpy( &guid, name, SDL_min( sizeof(guid), SDL_strlen( name ) ) );
return guid;
}
/* vi: set ts=4 sw=4 expandtab: */ /* vi: set ts=4 sw=4 expandtab: */

File diff suppressed because it is too large Load diff

View file

@ -19,14 +19,16 @@
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
*/ */
#if SDL_INPUT_LINUXEV
#include <linux/input.h> #include <linux/input.h>
#endif
struct SDL_joylist_item;
/* 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
{ {
int fd; int fd;
struct SDL_joylist_item *item;
SDL_JoystickGUID guid;
char *fname; /* Used in haptic subsystem */ char *fname; /* Used in haptic subsystem */
/* The current linux joystick driver maps hats to two axes */ /* The current linux joystick driver maps hats to two axes */
@ -41,8 +43,6 @@ struct joystick_hwdata
} *balls; } *balls;
/* Support for the Linux 2.4 unified input interface */ /* Support for the Linux 2.4 unified input interface */
#if SDL_INPUT_LINUXEV
SDL_bool is_hid;
Uint8 key_map[KEY_MAX - BTN_MISC]; Uint8 key_map[KEY_MAX - BTN_MISC];
Uint8 abs_map[ABS_MAX]; Uint8 abs_map[ABS_MAX];
struct axis_correct struct axis_correct
@ -50,5 +50,4 @@ struct joystick_hwdata
int used; int used;
int coef[3]; int coef[3];
} abs_correct[ABS_MAX]; } abs_correct[ABS_MAX];
#endif
}; };

View file

@ -36,25 +36,38 @@
#include "../../video/nds/SDL_ndsevents_c.h" #include "../../video/nds/SDL_ndsevents_c.h"
/* Function to scan the system for joysticks. /* Function to scan the system for joysticks.
* This function should set SDL_numjoysticks to the number of available
* joysticks. Joystick 0 should be the system default joystick.
* It should return 0, or -1 on an unrecoverable fatal error.
*/ */
int int
SDL_SYS_JoystickInit(void) SDL_SYS_JoystickInit(void)
{ {
SDL_numjoysticks = 1;
return (1); return (1);
} }
int SDL_SYS_NumJoysticks()
{
return 1;
}
void SDL_SYS_JoystickDetect()
{
}
SDL_bool SDL_SYS_JoystickNeedsPolling()
{
return SDL_FALSE;
}
/* 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_JoystickNameForDeviceIndex(int device_index)
{ {
if (!index) return "NDS builtin joypad";
return "NDS builtin joypad"; }
SDL_SetError("No joystick available with that index");
return (NULL); /* Function to perform the mapping from device index to the instance id for this index */
SDL_JoystickID SDL_SYS_GetInstanceIdOfDeviceIndex(int device_index)
{
return device_index;
} }
/* Function to open a joystick for use. /* Function to open a joystick for use.
@ -63,7 +76,7 @@ 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)
{ {
joystick->nbuttons = 8; joystick->nbuttons = 8;
joystick->nhats = 0; joystick->nhats = 0;
@ -72,6 +85,11 @@ SDL_SYS_JoystickOpen(SDL_Joystick * joystick)
return 0; return 0;
} }
/* Function to determine is this joystick is attached to the system right now */
SDL_bool SDL_SYS_JoystickAttached(SDL_Joystick *joystick)
{
return SDL_TRUE;
}
/* 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,
@ -168,4 +186,24 @@ SDL_SYS_JoystickQuit(void)
{ {
} }
SDL_JoystickGUID SDL_SYS_JoystickGetDeviceGUID( int device_index )
{
SDL_JoystickGUID guid;
// the GUID is just the first 16 chars of the name for now
const char *name = SDL_SYS_JoystickNameForDeviceIndex( device_index );
SDL_zero( guid );
SDL_memcpy( &guid, name, SDL_min( sizeof(guid), SDL_strlen( name ) ) );
return guid;
}
SDL_JoystickGUID SDL_SYS_JoystickGetGUID(SDL_Joystick * joystick)
{
SDL_JoystickGUID guid;
// the GUID is just the first 16 chars of the name for now
const char *name = joystick->name;
SDL_zero( guid );
SDL_memcpy( &guid, name, SDL_min( sizeof(guid), SDL_strlen( name ) ) );
return guid;
}
#endif /* SDL_JOYSTICK_NDS */ #endif /* SDL_JOYSTICK_NDS */

File diff suppressed because it is too large Load diff

View file

@ -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; LPDIRECTINPUTDEVICE8 InputDevice;
DIDEVCAPS Capabilities; DIDEVCAPS Capabilities;
int buffered; int buffered;
SDL_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 */

View file

@ -135,6 +135,8 @@ GetJoystickName(int index, const char *szRegKey)
return (name); return (name);
} }
static int SDL_SYS_numjoysticks = 0;
/* Function to scan the system for joysticks. /* Function to scan the system for joysticks.
* This function should set SDL_numjoysticks to the number of available * This function should set SDL_numjoysticks to the number of available
* joysticks. Joystick 0 should be the system default joystick. * joysticks. Joystick 0 should be the system default joystick.
@ -145,7 +147,6 @@ SDL_SYS_JoystickInit(void)
{ {
int i; int i;
int maxdevs; int maxdevs;
int numdevs;
JOYINFOEX joyinfo; JOYINFOEX joyinfo;
JOYCAPS joycaps; JOYCAPS joycaps;
MMRESULT result; MMRESULT result;
@ -157,9 +158,9 @@ SDL_SYS_JoystickInit(void)
} }
/* Loop over all potential joystick devices */ /* Loop over all potential joystick devices */
numdevs = 0; SDL_SYS_numjoysticks = 0;
maxdevs = joyGetNumDevs(); maxdevs = joyGetNumDevs();
for (i = JOYSTICKID1; i < maxdevs && numdevs < MAX_JOYSTICKS; ++i) { for (i = JOYSTICKID1; i < maxdevs && SDL_SYS_numjoysticks < MAX_JOYSTICKS; ++i) {
joyinfo.dwSize = sizeof(joyinfo); joyinfo.dwSize = sizeof(joyinfo);
joyinfo.dwFlags = JOY_RETURNALL; joyinfo.dwFlags = JOY_RETURNALL;
@ -167,35 +168,55 @@ SDL_SYS_JoystickInit(void)
if (result == JOYERR_NOERROR) { if (result == JOYERR_NOERROR) {
result = joyGetDevCaps(i, &joycaps, sizeof(joycaps)); result = joyGetDevCaps(i, &joycaps, sizeof(joycaps));
if (result == JOYERR_NOERROR) { if (result == JOYERR_NOERROR) {
SYS_JoystickID[numdevs] = i; SYS_JoystickID[SDL_SYS_numjoysticks] = i;
SYS_Joystick[numdevs] = joycaps; SYS_Joystick[SDL_SYS_numjoysticks] = joycaps;
SYS_JoystickName[numdevs] = SYS_JoystickName[SDL_SYS_numjoysticks] =
GetJoystickName(i, joycaps.szRegKey); GetJoystickName(i, joycaps.szRegKey);
numdevs++; SDL_SYS_numjoysticks++;
} }
} }
} }
return (numdevs); return (SDL_SYS_numjoysticks);
}
int SDL_SYS_NumJoysticks()
{
return SDL_SYS_numjoysticks;
}
void SDL_SYS_JoystickDetect()
{
}
SDL_bool SDL_SYS_JoystickNeedsPolling()
{
return SDL_FALSE;
} }
/* 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_JoystickNameForDeviceIndex(int device_index)
{ {
if (SYS_JoystickName[index] != NULL) { if (SYS_JoystickName[device_index] != NULL) {
return (SYS_JoystickName[index]); return (SYS_JoystickName[device_index]);
} else { } else {
return (SYS_Joystick[index].szPname); return (SYS_Joystick[device_index].szPname);
} }
} }
/* Function to perform the mapping from device index to the instance id for this index */
SDL_JoystickID SDL_SYS_GetInstanceIdOfDeviceIndex(int device_index)
{
return 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.
*/ */
int int
SDL_SYS_JoystickOpen(SDL_Joystick * joystick) SDL_SYS_JoystickOpen(SDL_Joystick * joystick, int device_index)
{ {
int index, i; int index, i;
int caps_flags[MAX_AXES - 2] = int caps_flags[MAX_AXES - 2] =
@ -204,7 +225,7 @@ SDL_SYS_JoystickOpen(SDL_Joystick * joystick)
/* shortcut */ /* shortcut */
index = joystick->index; index = device_index;
axis_min[0] = SYS_Joystick[index].wXmin; axis_min[0] = SYS_Joystick[index].wXmin;
axis_max[0] = SYS_Joystick[index].wXmax; axis_max[0] = SYS_Joystick[index].wXmax;
axis_min[1] = SYS_Joystick[index].wYmin; axis_min[1] = SYS_Joystick[index].wYmin;
@ -219,6 +240,7 @@ SDL_SYS_JoystickOpen(SDL_Joystick * joystick)
axis_max[5] = SYS_Joystick[index].wVmax; axis_max[5] = SYS_Joystick[index].wVmax;
/* allocate memory for system specific hardware data */ /* allocate memory for system specific hardware data */
joystick->instance_id = device_index;
joystick->hwdata = joystick->hwdata =
(struct joystick_hwdata *) SDL_malloc(sizeof(*joystick->hwdata)); (struct joystick_hwdata *) SDL_malloc(sizeof(*joystick->hwdata));
if (joystick->hwdata == NULL) { if (joystick->hwdata == NULL) {
@ -251,6 +273,12 @@ SDL_SYS_JoystickOpen(SDL_Joystick * joystick)
return (0); return (0);
} }
/* Function to determine is this joystick is attached to the system right now */
SDL_bool SDL_SYS_JoystickAttached(SDL_Joystick *joystick)
{
return SDL_TRUE;
}
static Uint8 static Uint8
TranslatePOV(DWORD value) TranslatePOV(DWORD value)
{ {
@ -377,6 +405,26 @@ SDL_SYS_JoystickQuit(void)
} }
} }
SDL_JoystickGUID SDL_SYS_JoystickGetDeviceGUID( int device_index )
{
SDL_JoystickGUID guid;
// the GUID is just the first 16 chars of the name for now
const char *name = SDL_SYS_JoystickNameForDeviceIndex( device_index );
SDL_zero( guid );
SDL_memcpy( &guid, name, SDL_min( sizeof(guid), SDL_strlen( name ) ) );
return guid;
}
SDL_JoystickGUID SDL_SYS_JoystickGetGUID(SDL_Joystick * joystick)
{
SDL_JoystickGUID guid;
// the GUID is just the first 16 chars of the name for now
const char *name = joystick->name;
SDL_zero( guid );
SDL_memcpy( &guid, name, SDL_min( sizeof(guid), SDL_strlen( name ) ) );
return guid;
}
/* implementation functions */ /* implementation functions */
void void
@ -423,4 +471,5 @@ SetMMerror(char *function, int code)
} }
#endif /* SDL_JOYSTICK_WINMM */ #endif /* SDL_JOYSTICK_WINMM */
/* vi: set ts=4 sw=4 expandtab: */ /* vi: set ts=4 sw=4 expandtab: */

View file

@ -27,7 +27,7 @@ UnEscapeQuotes(char *arg)
char *last = NULL; char *last = NULL;
while (*arg) { while (*arg) {
if (*arg == '"' && *last == '\\') { if (*arg == '"' && (last != NULL && *last == '\\')) {
char *c_curr = arg; char *c_curr = arg;
char *c_last = last; char *c_last = last;

153
src/test/SDL_test_assert.c Normal file
View file

@ -0,0 +1,153 @@
/*
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.
*/
/*
Used by the test framework and test cases.
*/
#include "SDL_config.h"
#include "SDL_test.h"
/* Assert check message format */
const char *SDLTest_AssertCheckFormat = "Assert '%s': %s";
/* Assert summary message format */
const char *SDLTest_AssertSummaryFormat = "Assert Summary: Total=%d Passed=%d Failed=%d";
/*! \brief counts the failed asserts */
static Uint32 SDLTest_AssertsFailed = 0;
/*! \brief counts the passed asserts */
static Uint32 SDLTest_AssertsPassed = 0;
/*
* Assert that logs and break execution flow on failures (i.e. for harness errors).
*/
void SDLTest_Assert(int assertCondition, char *assertDescription, ...)
{
va_list list;
char logMessage[SDLTEST_MAX_LOGMESSAGE_LENGTH];
// Print assert description into a buffer
memset(logMessage, 0, SDLTEST_MAX_LOGMESSAGE_LENGTH);
va_start(list, assertDescription);
SDL_vsnprintf(logMessage, SDLTEST_MAX_LOGMESSAGE_LENGTH - 1, assertDescription, list);
va_end(list);
// Log, then assert and break on failure
SDL_assert((SDLTest_AssertCheck(assertCondition, logMessage)));
}
/*
* Assert that logs but does not break execution flow on failures (i.e. for test cases).
*/
int SDLTest_AssertCheck(int assertCondition, char *assertDescription, ...)
{
va_list list;
char logMessage[SDLTEST_MAX_LOGMESSAGE_LENGTH];
char *logFormat = (char *)SDLTest_AssertCheckFormat;
// Print assert description into a buffer
memset(logMessage, 0, SDLTEST_MAX_LOGMESSAGE_LENGTH);
va_start(list, assertDescription);
SDL_vsnprintf(logMessage, SDLTEST_MAX_LOGMESSAGE_LENGTH - 1, assertDescription, list);
va_end(list);
// Log pass or fail message
if (assertCondition == ASSERT_FAIL)
{
SDLTest_AssertsFailed++;
SDLTest_LogError(logFormat, logMessage, "Failed");
}
else
{
SDLTest_AssertsPassed++;
SDLTest_Log(logFormat, logMessage, "Passed");
}
return assertCondition;
}
/*
* Explicitly passing Assert that logs (i.e. for test cases).
*/
void SDLTest_AssertPass(char *assertDescription, ...)
{
va_list list;
char logMessage[SDLTEST_MAX_LOGMESSAGE_LENGTH];
char *logFormat = (char *)SDLTest_AssertCheckFormat;
// Print assert description into a buffer
memset(logMessage, 0, SDLTEST_MAX_LOGMESSAGE_LENGTH);
va_start(list, assertDescription);
SDL_vsnprintf(logMessage, SDLTEST_MAX_LOGMESSAGE_LENGTH - 1, assertDescription, list);
va_end(list);
// Log pass message
SDLTest_AssertsPassed++;
SDLTest_Log(logFormat, logMessage, "Pass");
}
/*
* Resets the assert summary counters to zero.
*/
void SDLTest_ResetAssertSummary()
{
SDLTest_AssertsPassed = 0;
SDLTest_AssertsFailed = 0;
}
/*
* Logs summary of all assertions (total, pass, fail) since last reset
* as INFO (failed==0) or ERROR (failed > 0).
*/
void SDLTest_LogAssertSummary()
{
char *logFormat = (char *)SDLTest_AssertSummaryFormat;
Uint32 totalAsserts = SDLTest_AssertsPassed + SDLTest_AssertsFailed;
if (SDLTest_AssertsFailed == 0)
{
SDLTest_Log(logFormat, totalAsserts, SDLTest_AssertsPassed, SDLTest_AssertsFailed);
}
else
{
SDLTest_LogError(logFormat, totalAsserts, SDLTest_AssertsPassed, SDLTest_AssertsFailed);
}
}
/*
* Converts the current assert state into a test result
*/
int SDLTest_AssertSummaryToTestResult()
{
if (SDLTest_AssertsFailed > 0) {
return TEST_RESULT_FAILED;
} else {
if (SDLTest_AssertsPassed > 0) {
return TEST_RESULT_PASSED;
} else {
return TEST_RESULT_NO_ASSERT;
}
}
}

1261
src/test/SDL_test_common.c Normal file

File diff suppressed because it is too large Load diff

165
src/test/SDL_test_crc32.c Normal file
View file

@ -0,0 +1,165 @@
/*
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.
*/
/*
Used by the test execution component.
Original source code contributed by A. Schiffler for GSOC project.
*/
#include "SDL_config.h"
#include "SDL_test.h"
int SDLTest_Crc32Init(SDLTest_Crc32Context *crcContext)
{
int i,j;
CrcUint32 c;
/* Sanity check context pointer */
if (crcContext==NULL) {
return -1;
}
/*
* Build auxiliary table for parallel byte-at-a-time CRC-32
*/
#ifdef ORIGINAL_METHOD
for (i = 0; i < 256; ++i) {
for (c = i << 24, j = 8; j > 0; --j) {
c = c & 0x80000000 ? (c << 1) ^ CRC32_POLY : (c << 1);
}
crcContext->crc32_table[i] = c;
}
#else
for (i=0; i<256; i++) {
c = i;
for (j=8; j>0; j--) {
if (c & 1) {
c = (c >> 1) ^ CRC32_POLY;
} else {
c >>= 1;
}
}
crcContext->crc32_table[i] = c;
}
#endif
return 0;
}
/* Complete CRC32 calculation on a memory block */
int SDLTest_Crc32Calc(SDLTest_Crc32Context * crcContext, CrcUint8 *inBuf, CrcUint32 inLen, CrcUint32 *crc32)
{
if (SDLTest_Crc32CalcStart(crcContext,crc32)) {
return -1;
}
if (SDLTest_Crc32CalcBuffer(crcContext, inBuf, inLen, crc32)) {
return -1;
}
if (SDLTest_Crc32CalcEnd(crcContext, crc32)) {
return -1;
}
return 0;
}
/* Start crc calculation */
int SDLTest_Crc32CalcStart(SDLTest_Crc32Context * crcContext, CrcUint32 *crc32)
{
/* Sanity check pointers */
if (crcContext==NULL) {
*crc32=0;
return -1;
}
/*
* Preload shift register, per CRC-32 spec
*/
*crc32 = 0xffffffff;
return 0;
}
/* Finish crc calculation */
int SDLTest_Crc32CalcEnd(SDLTest_Crc32Context * crcContext, CrcUint32 *crc32)
{
/* Sanity check pointers */
if (crcContext==NULL) {
*crc32=0;
return -1;
}
/*
* Return complement, per CRC-32 spec
*/
*crc32 = (~(*crc32));
return 0;
}
/* Include memory block in crc */
int SDLTest_Crc32CalcBuffer(SDLTest_Crc32Context * crcContext, CrcUint8 *inBuf, CrcUint32 inLen, CrcUint32 *crc32)
{
CrcUint8 *p;
register CrcUint32 crc;
if (crcContext==NULL) {
*crc32=0;
return -1;
}
if (inBuf==NULL) {
return -1;
}
/*
* Calculate CRC from data
*/
crc = *crc32;
for (p = inBuf; inLen > 0; ++p, --inLen) {
#ifdef ORIGINAL_METHOD
crc = (crc << 8) ^ crcContext->crc32_table[(crc >> 24) ^ *p];
#else
crc = ((crc >> 8) & 0x00FFFFFF) ^ crcContext->crc32_table[ (crc ^ *p) & 0xFF ];
#endif
}
*crc32 = crc;
return 0;
}
int SDLTest_Crc32Done(SDLTest_Crc32Context * crcContext)
{
if (crcContext==NULL) {
return -1;
}
return 0;
}

639
src/test/SDL_test_fuzzer.c Normal file
View file

@ -0,0 +1,639 @@
/*
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.
*/
/*
Data generators for fuzzing test data in a reproducible way.
*/
#include "SDL_config.h"
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
#include <float.h>
#include "SDL_test.h"
/**
*Counter for fuzzer invocations
*/
static int fuzzerInvocationCounter = 0;
/**
* Context for shared random number generator
*/
static SDLTest_RandomContext rndContext;
/*
* Note: doxygen documentation markup for functions is in the header file.
*/
void
SDLTest_FuzzerInit(Uint64 execKey)
{
Uint32 a = (execKey >> 32) & 0x00000000FFFFFFFF;
Uint32 b = execKey & 0x00000000FFFFFFFF;
SDL_memset((void *)&rndContext, 0, sizeof(SDLTest_RandomContext));
SDLTest_RandomInit(&rndContext, a, b);
fuzzerInvocationCounter = 0;
}
int
SDLTest_GetFuzzerInvocationCount()
{
return fuzzerInvocationCounter;
}
Uint8
SDLTest_RandomUint8()
{
fuzzerInvocationCounter++;
return (Uint8) SDLTest_RandomInt(&rndContext) & 0x000000FF;
}
Sint8
SDLTest_RandomSint8()
{
fuzzerInvocationCounter++;
return (Sint8) SDLTest_RandomInt(&rndContext) & 0x000000FF;
}
Uint16
SDLTest_RandomUint16()
{
fuzzerInvocationCounter++;
return (Uint16) SDLTest_RandomInt(&rndContext) & 0x0000FFFF;
}
Sint16
SDLTest_RandomSint16()
{
fuzzerInvocationCounter++;
return (Sint16) SDLTest_RandomInt(&rndContext) & 0x0000FFFF;
}
Sint32
SDLTest_RandomSint32()
{
fuzzerInvocationCounter++;
return (Sint32) SDLTest_RandomInt(&rndContext);
}
Uint32
SDLTest_RandomUint32()
{
fuzzerInvocationCounter++;
return (Uint32) SDLTest_RandomInt(&rndContext);
}
Uint64
SDLTest_RandomUint64()
{
Uint64 value;
Uint32 *vp = (void*)&value;
fuzzerInvocationCounter++;
vp[0] = SDLTest_RandomSint32();
vp[1] = SDLTest_RandomSint32();
return value;
}
Sint64
SDLTest_RandomSint64()
{
Uint64 value;
Uint32 *vp = (void*)&value;
fuzzerInvocationCounter++;
vp[0] = SDLTest_RandomSint32();
vp[1] = SDLTest_RandomSint32();
return value;
}
Sint32
SDLTest_RandomIntegerInRange(Sint32 pMin, Sint32 pMax)
{
Sint64 min = pMin;
Sint64 max = pMax;
Sint64 temp;
Sint64 number;
if(pMin > pMax) {
temp = min;
min = max;
max = temp;
} else if(pMin == pMax) {
return (Sint32)min;
}
number = SDLTest_RandomUint32(); // invocation count increment in there
return (Sint32)((number % ((max + 1) - min)) + min);
}
/*!
* Generates boundary values between the given boundaries.
* Boundary values are inclusive. See the examples below.
* If boundary2 < boundary1, the values are swapped.
* If boundary1 == boundary2, value of boundary1 will be returned
*
* Generating boundary values for Uint8:
* BoundaryValues(sizeof(Uint8), 10, 20, True) -> [10,11,19,20]
* BoundaryValues(sizeof(Uint8), 10, 20, False) -> [9,21]
* BoundaryValues(sizeof(Uint8), 0, 15, True) -> [0, 1, 14, 15]
* BoundaryValues(sizeof(Uint8), 0, 15, False) -> [16]
* BoundaryValues(sizeof(Uint8), 0, 255, False) -> NULL
*
* Generator works the same for other types of unsigned integers.
*
* Note: outBuffer will be allocated and needs to be freed later.
* If outbuffer != NULL, it'll be freed.
*
* \param maxValue The biggest value that is acceptable for this data type.
* For instance, for Uint8 -> 255, Uint16 -> 65536 etc.
* \param pBoundary1 defines lower boundary
* \param pBoundary2 defines upper boundary
* \param validDomain Generate only for valid domain (for the data type)
*
* \param outBuffer The generated boundary values are put here
*
* \returns Returns the number of elements in outBuffer or -1 in case of error
*/
Uint32
SDLTest_GenerateUnsignedBoundaryValues(const Uint64 maxValue,
Uint64 pBoundary1, Uint64 pBoundary2, SDL_bool validDomain,
Uint64 *outBuffer)
{
Uint64 boundary1 = pBoundary1, boundary2 = pBoundary2;
Uint64 temp;
Uint64 tempBuf[4];
int index;
if(outBuffer != NULL) {
SDL_free(outBuffer);
}
if(boundary1 > boundary2) {
temp = boundary1;
boundary1 = boundary2;
boundary2 = temp;
}
index = 0;
if(boundary1 == boundary2) {
tempBuf[index++] = boundary1;
}
else if(validDomain) {
tempBuf[index++] = boundary1;
if(boundary1 < UINT64_MAX)
tempBuf[index++] = boundary1 + 1;
tempBuf[index++] = boundary2 - 1;
tempBuf[index++] = boundary2;
}
else {
if(boundary1 > 0) {
tempBuf[index++] = boundary1 - 1;
}
if(boundary2 < maxValue && boundary2 < UINT64_MAX) {
tempBuf[index++] = boundary2 + 1;
}
}
if(index == 0) {
// There are no valid boundaries
return 0;
}
// Create the return buffer
outBuffer = (Uint64 *)SDL_malloc(index * sizeof(Uint64));
if(outBuffer == NULL) {
return 0;
}
SDL_memcpy(outBuffer, tempBuf, index * sizeof(Uint64));
return index;
}
Uint8
SDLTest_RandomUint8BoundaryValue(Uint8 boundary1, Uint8 boundary2, SDL_bool validDomain)
{
Uint64 *buffer = NULL;
Uint32 size;
Uint32 index;
Uint8 retVal;
// max value for Uint8
const Uint64 maxValue = UINT8_MAX;
size = SDLTest_GenerateUnsignedBoundaryValues(maxValue,
(Uint64) boundary1, (Uint64) boundary2,
validDomain, buffer);
if (buffer == NULL || size == 0) {
return 0;
}
index = SDLTest_RandomSint32() % size;
retVal = (Uint8)buffer[index];
SDL_free(buffer);
fuzzerInvocationCounter++;
return retVal;
}
Uint16
SDLTest_RandomUint16BoundaryValue(Uint16 boundary1, Uint16 boundary2, SDL_bool validDomain)
{
Uint64 *buffer = NULL;
Uint32 size;
Uint32 index;
Uint16 retVal;
// max value for Uint16
const Uint64 maxValue = UINT16_MAX;
size = SDLTest_GenerateUnsignedBoundaryValues(maxValue,
(Uint64) boundary1, (Uint64) boundary2,
validDomain, buffer);
if (buffer == NULL || size == 0) {
return 0;
}
index = SDLTest_RandomSint32() % size;
retVal = (Uint16) buffer[index];
SDL_free(buffer);
fuzzerInvocationCounter++;
return retVal;
}
Uint32
SDLTest_RandomUint32BoundaryValue(Uint32 boundary1, Uint32 boundary2, SDL_bool validDomain)
{
Uint64 *buffer = NULL;
Uint32 size;
Uint32 index;
Uint32 retVal;
// max value for Uint32
const Uint64 maxValue = UINT32_MAX;
size = SDLTest_GenerateUnsignedBoundaryValues(maxValue,
(Uint64) boundary1, (Uint64) boundary2,
validDomain, buffer);
if (buffer == NULL || size == 0) {
return 0;
}
index = SDLTest_RandomSint32() % size;
retVal = (Uint32) buffer[index];
SDL_free(buffer);
fuzzerInvocationCounter++;
return retVal;
}
Uint64
SDLTest_RandomUint64BoundaryValue(Uint64 boundary1, Uint64 boundary2, SDL_bool validDomain)
{
Uint64 *buffer = NULL;
Uint32 size;
Uint32 index;
Uint64 retVal;
// max value for Uint64
const Uint64 maxValue = UINT64_MAX;
size = SDLTest_GenerateUnsignedBoundaryValues(maxValue,
(Uint64) boundary1, (Uint64) boundary2,
validDomain, buffer);
if (buffer == NULL || size == 0) {
return 0;
}
index = SDLTest_RandomSint32() % size;
retVal = (Uint64) buffer[index];
SDL_free(buffer);
fuzzerInvocationCounter++;
return retVal;
}
/*!
* Generates boundary values between the given boundaries.
* Boundary values are inclusive. See the examples below.
* If boundary2 < boundary1, the values are swapped.
* If boundary1 == boundary2, value of boundary1 will be returned
*
* Generating boundary values for Sint8:
* SignedBoundaryValues(sizeof(Sint8), -10, 20, True) -> [-11,-10,19,20]
* SignedBoundaryValues(sizeof(Sint8), -10, 20, False) -> [-11,21]
* SignedBoundaryValues(sizeof(Sint8), -30, -15, True) -> [-30, -29, -16, -15]
* SignedBoundaryValues(sizeof(Sint8), -128, 15, False) -> [16]
* SignedBoundaryValues(sizeof(Sint8), -128, 127, False) -> NULL
*
* Generator works the same for other types of signed integers.
*
* Note: outBuffer will be allocated and needs to be freed later.
* If outbuffer != NULL, it'll be freed.
*
*
* \param minValue The smallest value that is acceptable for this data type.
* For instance, for Uint8 -> -128, Uint16 -> -32,768 etc.
* \param maxValue The biggest value that is acceptable for this data type.
* For instance, for Uint8 -> 127, Uint16 -> 32767 etc.
* \param pBoundary1 defines lower boundary
* \param pBoundary2 defines upper boundary
* \param validDomain Generate only for valid domain (for the data type)
*
* \param outBuffer The generated boundary values are put here
*
* \returns Returns the number of elements in outBuffer or -1 in case of error
*/
Uint32
SDLTest_GenerateSignedBoundaryValues(const Sint64 minValue, const Sint64 maxValue,
Sint64 pBoundary1, Sint64 pBoundary2, SDL_bool validDomain,
Sint64 *outBuffer)
{
int index;
Sint64 tempBuf[4];
Sint64 boundary1 = pBoundary1, boundary2 = pBoundary2;
if(outBuffer != NULL) {
SDL_free(outBuffer);
}
if(boundary1 > boundary2) {
Sint64 temp = boundary1;
boundary1 = boundary2;
boundary2 = temp;
}
index = 0;
if(boundary1 == boundary2) {
tempBuf[index++] = boundary1;
}
else if(validDomain) {
tempBuf[index++] = boundary1;
if(boundary1 < LLONG_MAX)
tempBuf[index++] = boundary1 + 1;
if(boundary2 > LLONG_MIN)
tempBuf[index++] = boundary2 - 1;
tempBuf[index++] = boundary2;
}
else {
if(boundary1 > minValue && boundary1 > LLONG_MIN) {
tempBuf[index++] = boundary1 - 1;
}
if(boundary2 < maxValue && boundary2 < UINT64_MAX) {
tempBuf[index++] = boundary2 + 1;
}
}
if(index == 0) {
// There are no valid boundaries
return 0;
}
// Create the return buffer
outBuffer = (Sint64 *)SDL_malloc(index * sizeof(Sint64));
if(outBuffer == NULL) {
return 0;
}
SDL_memcpy((void *)outBuffer, (void *)tempBuf, index * sizeof(Sint64));
return (Uint32)index;
}
Sint8
SDLTest_RandomSint8BoundaryValue(Sint8 boundary1, Sint8 boundary2, SDL_bool validDomain)
{
// min & max values for Sint8
const Sint64 maxValue = CHAR_MAX;
const Sint64 minValue = CHAR_MIN;
Sint64 *buffer = NULL;
Uint32 size;
Uint32 index;
Sint8 retVal;
size = SDLTest_GenerateSignedBoundaryValues(minValue, maxValue,
(Sint64) boundary1, (Sint64) boundary2,
validDomain, buffer);
if (buffer == NULL || size == 0) {
return CHAR_MIN;
}
index = SDLTest_RandomSint32() % size;
retVal = (Sint8) buffer[index];
SDL_free(buffer);
fuzzerInvocationCounter++;
return retVal;
}
Sint16
SDLTest_RandomSint16BoundaryValue(Sint16 boundary1, Sint16 boundary2, SDL_bool validDomain)
{
// min & max values for Sint16
const Sint64 maxValue = SHRT_MAX;
const Sint64 minValue = SHRT_MIN;
Sint64 *buffer = NULL;
Uint32 size;
Uint32 index;
Sint16 retVal;
size = SDLTest_GenerateSignedBoundaryValues(minValue, maxValue,
(Sint64) boundary1, (Sint64) boundary2,
validDomain, buffer);
if (buffer == NULL || size == 0) {
return SHRT_MIN;
}
index = SDLTest_RandomSint32() % size;
retVal = (Sint16) buffer[index];
SDL_free(buffer);
fuzzerInvocationCounter++;
return retVal;
}
Sint32
SDLTest_RandomSint32BoundaryValue(Sint32 boundary1, Sint32 boundary2, SDL_bool validDomain)
{
// min & max values for Sint32
const Sint64 maxValue = INT_MAX;
const Sint64 minValue = INT_MIN;
Sint64 *buffer = NULL;
Uint32 size;
Uint32 index;
Sint32 retVal;
size = SDLTest_GenerateSignedBoundaryValues(minValue, maxValue,
(Sint64) boundary1, (Sint64) boundary2,
validDomain, buffer);
if (buffer == NULL || size == 0) {
return INT_MIN;
}
index = SDLTest_RandomSint32() % size;
retVal = (Sint32) buffer[index];
SDL_free(buffer);
fuzzerInvocationCounter++;
return retVal;
}
Sint64
SDLTest_RandomSint64BoundaryValue(Sint64 boundary1, Sint64 boundary2, SDL_bool validDomain)
{
Sint64 *buffer = NULL;
Uint32 size;
Uint32 index;
Sint64 retVal;
// min & max values for Sint64
const Sint64 maxValue = LLONG_MAX;
const Sint64 minValue = LLONG_MIN;
size = SDLTest_GenerateSignedBoundaryValues(minValue, maxValue,
(Sint64) boundary1, (Sint64) boundary2,
validDomain, buffer);
if (buffer == NULL || size == 0) {
return LLONG_MIN;
}
index = SDLTest_RandomSint32() % size;
retVal = (Sint64) buffer[index];
SDL_free(buffer);
fuzzerInvocationCounter++;
return retVal;
}
float
SDLTest_RandomUnitFloat()
{
return (float) SDLTest_RandomUint32() / UINT_MAX;
}
float
SDLTest_RandomFloat()
{
return (float) (FLT_MIN + SDLTest_RandomUnitDouble() * (FLT_MAX - FLT_MIN));
}
double
SDLTest_RandomUnitDouble()
{
return (double) (SDLTest_RandomUint64() >> 11) * (1.0/9007199254740992.0);
}
double
SDLTest_RandomDouble()
{
double r = 0.0;
double s = 1.0;
do {
s /= UINT_MAX + 1.0;
r += (double)SDLTest_RandomInt(&rndContext) * s;
} while (s > DBL_EPSILON);
fuzzerInvocationCounter++;
return r;
}
char *
SDLTest_RandomAsciiString()
{
// note: fuzzerInvocationCounter is increment in the RandomAsciiStringWithMaximumLenght
return SDLTest_RandomAsciiStringWithMaximumLength(255);
}
char *
SDLTest_RandomAsciiStringWithMaximumLength(int maxSize)
{
int size;
char *string;
int counter;
fuzzerInvocationCounter++;
if(maxSize < 1) {
return NULL;
}
size = (SDLTest_RandomUint32() % (maxSize + 1)) + 1;
string = (char *)SDL_malloc(size * sizeof(char));
if (string==NULL) {
return NULL;
}
for(counter = 0; counter < size; ++counter) {
string[counter] = (char)SDLTest_RandomIntegerInRange(1, 127);
}
string[counter] = '\0';
return string;
}

520
src/test/SDL_test_harness.c Normal file
View file

@ -0,0 +1,520 @@
/*
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.
*/
#include "SDL_config.h"
#include "SDL_test.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
/* Invalid test name/description message format */
const char *SDLTest_InvalidNameFormat = "(Invalid)";
/* Log summary message format */
const char *SDLTest_LogSummaryFormat = "%s Summary: Total=%d Passed=%d Failed=%d Skipped=%d";
/* Final result message format */
const char *SDLTest_FinalResultFormat = ">>> %s '%s': %s\n";
/*! \brief Timeout for single test case execution */
static Uint32 SDLTest_TestCaseTimeout = 3600;
/**
* Generates a random run seed string for the harness. The generated seed
* will contain alphanumeric characters (0-9A-Z).
*
* Note: The returned string needs to be deallocated by the caller.
*
* \param length The length of the seed string to generate
*
* \returns The generated seed string
*/
char *
SDLTest_GenerateRunSeed(const int length)
{
char *seed = NULL;
SDLTest_RandomContext randomContext;
int counter;
// Sanity check input
if (length <= 0) {
SDLTest_LogError("The length of the harness seed must be >0.");
return NULL;
}
// Allocate output buffer
seed = (char *)SDL_malloc((length + 1) * sizeof(char));
if (seed == NULL) {
SDLTest_LogError("SDL_malloc for run seed output buffer failed.");
return NULL;
}
// Generate a random string of alphanumeric characters
SDLTest_RandomInitTime(&randomContext);
for (counter = 0; counter < length - 1; ++counter) {
unsigned int number = SDLTest_Random(&randomContext);
char ch = (char) (number % (91 - 48)) + 48;
if (ch >= 58 && ch <= 64) {
ch = 65;
}
seed[counter] = ch;
}
seed[counter] = '\0';
return seed;
}
/**
* Generates an execution key for the fuzzer.
*
* \param runSeed The run seed to use
* \param suiteName The name of the test suite
* \param testName The name of the test
* \param iteration The iteration count
*
* \returns The generated execution key to initialize the fuzzer with.
*
*/
Uint64
SDLTest_GenerateExecKey(char *runSeed, char *suiteName, char *testName, int iteration)
{
SDLTest_Md5Context md5Context;
Uint64 *keys;
char iterationString[16];
Uint32 runSeedLength;
Uint32 suiteNameLength;
Uint32 testNameLength;
Uint32 iterationStringLength;
Uint32 entireStringLength;
char *buffer;
if (runSeed == NULL || strlen(runSeed)==0) {
SDLTest_LogError("Invalid runSeed string.");
return -1;
}
if (suiteName == NULL || strlen(suiteName)==0) {
SDLTest_LogError("Invalid suiteName string.");
return -1;
}
if (testName == NULL || strlen(testName)==0) {
SDLTest_LogError("Invalid testName string.");
return -1;
}
if (iteration <= 0) {
SDLTest_LogError("Invalid iteration count.");
return -1;
}
// Convert iteration number into a string
memset(iterationString, 0, sizeof(iterationString));
SDL_snprintf(iterationString, sizeof(iterationString) - 1, "%d", iteration);
// Combine the parameters into single string
runSeedLength = strlen(runSeed);
suiteNameLength = strlen(suiteName);
testNameLength = strlen(testName);
iterationStringLength = strlen(iterationString);
entireStringLength = runSeedLength + suiteNameLength + testNameLength + iterationStringLength + 1;
buffer = (char *)SDL_malloc(entireStringLength);
if (buffer == NULL) {
SDLTest_LogError("SDL_malloc failed to allocate buffer for execKey generation.");
return 0;
}
SDL_snprintf(buffer, entireStringLength, "%s%s%s%d", runSeed, suiteName, testName, iteration);
// Hash string and use half of the digest as 64bit exec key
SDLTest_Md5Init(&md5Context);
SDLTest_Md5Update(&md5Context, (unsigned char *)buffer, entireStringLength);
SDLTest_Md5Final(&md5Context);
SDL_free(buffer);
keys = (Uint64 *)md5Context.digest;
return keys[0];
}
/**
* \brief Set timeout handler for test.
*
* Note: SDL_Init(SDL_INIT_TIMER) will be called if it wasn't done so before.
*
* \param timeout Timeout interval in seconds.
* \param callback Function that will be called after timeout has elapsed.
*
* \return Timer id or -1 on failure.
*/
SDL_TimerID
SDLTest_SetTestTimeout(int timeout, void (*callback)())
{
Uint32 timeoutInMilliseconds;
SDL_TimerID timerID;
if (callback == NULL) {
SDLTest_LogError("Timeout callback can't be NULL");
return -1;
}
if (timeout < 0) {
SDLTest_LogError("Timeout value must be bigger than zero.");
return -1;
}
/* Init SDL timer if not initialized before */
if (SDL_WasInit(SDL_INIT_TIMER) == 0) {
if (SDL_InitSubSystem(SDL_INIT_TIMER)) {
SDLTest_LogError("Failed to init timer subsystem: %s", SDL_GetError());
return -1;
}
}
/* Set timer */
timeoutInMilliseconds = timeout * 1000;
timerID = SDL_AddTimer(timeoutInMilliseconds, (SDL_TimerCallback)callback, 0x0);
if (timerID == 0) {
SDLTest_LogError("Creation of SDL timer failed: %s", SDL_GetError());
return -1;
}
return timerID;
}
void
SDLTest_BailOut()
{
SDLTest_LogError("TestCaseTimeout timer expired. Aborting test run.");
exit(TEST_ABORTED); // bail out from the test
}
/**
* \brief Execute a test using the given execution key.
*
* \param testSuite Suite containing the test case.
* \param testCase Case to execute.
* \param execKey Execution key for the fuzzer.
*
* \returns Test case result.
*/
int
SDLTest_RunTest(SDLTest_TestSuiteReference *testSuite, SDLTest_TestCaseReference *testCase, Uint64 execKey)
{
SDL_TimerID timer = 0;
int testResult = 0;
int fuzzerCount;
if (testSuite==NULL || testCase==NULL || testSuite->name==NULL || testCase->name==NULL)
{
SDLTest_LogError("Setup failure: testSuite or testCase references NULL");
return TEST_RESULT_SETUP_FAILURE;
}
if (!testCase->enabled)
{
SDLTest_Log((char *)SDLTest_FinalResultFormat, "Test", testCase->name, "Skipped");
return TEST_RESULT_SKIPPED;
}
// Initialize fuzzer
SDLTest_FuzzerInit(execKey);
// Reset assert tracker
SDLTest_ResetAssertSummary();
// Set timeout timer
timer = SDLTest_SetTestTimeout(SDLTest_TestCaseTimeout, SDLTest_BailOut);
// Maybe run suite initalizer function
if (testSuite->testSetUp) {
testSuite->testSetUp(0x0);
if (SDLTest_AssertSummaryToTestResult() == TEST_RESULT_FAILED) {
SDLTest_LogError((char *)SDLTest_FinalResultFormat, "Suite Setup", testSuite->name, "Failed");
return TEST_RESULT_SETUP_FAILURE;
}
}
// Run test case function
testCase->testCase(0x0);
testResult = SDLTest_AssertSummaryToTestResult();
// Maybe run suite cleanup function (ignore failed asserts)
if (testSuite->testTearDown) {
testSuite->testTearDown(0x0);
}
// Cancel timeout timer
if (timer) {
SDL_RemoveTimer(timer);
}
// Report on asserts and fuzzer usage
fuzzerCount = SDLTest_GetFuzzerInvocationCount();
if (fuzzerCount > 0) {
SDLTest_Log("Fuzzer invocations: %d", fuzzerCount);
}
SDLTest_LogAssertSummary();
return testResult;
}
/* Prints summary of all suites/tests contained in the given reference */
void SDLTest_LogTestSuiteSummary(SDLTest_TestSuiteReference *testSuites)
{
int suiteCounter;
int testCounter;
SDLTest_TestSuiteReference *testSuite;
SDLTest_TestCaseReference *testCase;
// Loop over all suites
suiteCounter = 0;
while(&testSuites[suiteCounter]) {
testSuite=&testSuites[suiteCounter];
suiteCounter++;
SDLTest_Log("Test Suite %i - %s\n", suiteCounter,
(testSuite->name) ? testSuite->name : SDLTest_InvalidNameFormat);
// Loop over all test cases
testCounter = 0;
while(testSuite->testCases[testCounter])
{
testCase=(SDLTest_TestCaseReference *)testSuite->testCases[testCounter];
testCounter++;
SDLTest_Log(" Test Case %i - %s: %s", testCounter,
(testCase->name) ? testCase->name : SDLTest_InvalidNameFormat,
(testCase->description) ? testCase->description : SDLTest_InvalidNameFormat);
}
}
}
/* Gets a timer value in seconds */
float GetClock()
{
float currentClock = (float)clock();
return currentClock / (float)CLOCKS_PER_SEC;
}
/**
* \brief Execute a test suite using the given run seend and execution key.
*
* \param testSuites Suites containing the test case.
* \param userRunSeed Custom run seed provided by user, or NULL to autogenerate one.
* \param userExecKey Custom execution key provided by user, or 0 to autogenerate one.
* \param testIterations Number of iterations to run each test case.
*
* \returns Test run result; 0 when all tests passed, 1 if any tests failed.
*/
int
SDLTest_RunSuites(SDLTest_TestSuiteReference *testSuites[], char *userRunSeed, Uint64 userExecKey, int testIterations)
{
int suiteCounter;
int testCounter;
int iterationCounter;
SDLTest_TestSuiteReference *testSuite;
SDLTest_TestCaseReference *testCase;
char *runSeed = NULL;
char *currentSuiteName;
char *currentTestName;
Uint64 execKey;
float runStartSeconds;
float suiteStartSeconds;
float testStartSeconds;
float runEndSeconds;
float suiteEndSeconds;
float testEndSeconds;
int testResult = 0;
int runResult = 0;
Uint32 totalTestFailedCount = 0;
Uint32 totalTestPassedCount = 0;
Uint32 totalTestSkippedCount = 0;
Uint32 testFailedCount = 0;
Uint32 testPassedCount = 0;
Uint32 testSkippedCount = 0;
Uint32 countSum = 0;
char *logFormat = (char *)SDLTest_LogSummaryFormat;
// Sanitize test iterations
if (testIterations < 1) {
testIterations = 1;
}
// Generate run see if we don't have one already
if (userRunSeed == NULL || strlen(userRunSeed) == 0) {
runSeed = SDLTest_GenerateRunSeed(16);
if (runSeed == NULL) {
SDLTest_LogError("Generating a random seed failed");
return 2;
}
} else {
runSeed = userRunSeed;
}
// Reset per-run counters
totalTestFailedCount = 0;
totalTestPassedCount = 0;
totalTestSkippedCount = 0;
// Take time - run start
runStartSeconds = GetClock();
// Log run with fuzzer parameters
SDLTest_Log("::::: Test Run /w seed '%s' started\n", runSeed);
// Loop over all suites
suiteCounter = 0;
while(testSuites[suiteCounter]) {
testSuite=(SDLTest_TestSuiteReference *)testSuites[suiteCounter];
suiteCounter++;
// Reset per-suite counters
testFailedCount = 0;
testPassedCount = 0;
testSkippedCount = 0;
// Take time - suite start
suiteStartSeconds = GetClock();
// Log suite started
currentSuiteName = (char *)((testSuite->name) ? testSuite->name : SDLTest_InvalidNameFormat);
SDLTest_Log("===== Test Suite %i: '%s' started\n",
suiteCounter,
currentSuiteName);
// Loop over all test cases
testCounter = 0;
while(testSuite->testCases[testCounter])
{
testCase=(SDLTest_TestCaseReference *)testSuite->testCases[testCounter];
testCounter++;
// Take time - test start
testStartSeconds = GetClock();
// Log test started
currentTestName = (char *)((testCase->name) ? testCase->name : SDLTest_InvalidNameFormat);
SDLTest_Log("----- Test Case %i.%i: '%s' started",
suiteCounter,
testCounter,
currentTestName);
if (testCase->description != NULL && strlen(testCase->description)>0) {
SDLTest_Log("Test Description: '%s'",
(testCase->description) ? testCase->description : SDLTest_InvalidNameFormat);
}
// Loop over all iterations
iterationCounter = 0;
while(iterationCounter < testIterations)
{
iterationCounter++;
if (userExecKey != 0) {
execKey = userExecKey;
} else {
execKey = SDLTest_GenerateExecKey(runSeed, testSuite->name, testCase->name, iterationCounter);
}
SDLTest_Log("Test Iteration %i: execKey %llu", iterationCounter, execKey);
testResult = SDLTest_RunTest(testSuite, testCase, execKey);
if (testResult == TEST_RESULT_PASSED) {
testPassedCount++;
totalTestPassedCount++;
} else if (testResult == TEST_RESULT_SKIPPED) {
testSkippedCount++;
totalTestSkippedCount++;
} else {
testFailedCount++;
totalTestFailedCount++;
}
}
// Take time - test end
testEndSeconds = GetClock();
if (testIterations > 1) {
// Log test runtime
SDLTest_Log("Runtime of %i iterations: %.1f sec", testIterations, testEndSeconds - testStartSeconds);
SDLTest_Log("Test runtime: %.5f sec", (testEndSeconds - testStartSeconds) / (float)testIterations);
} else {
// Log test runtime
SDLTest_Log("Test runtime: %.1f sec", testEndSeconds - testStartSeconds);
}
// Log final test result
switch (testResult) {
case TEST_RESULT_PASSED:
SDLTest_Log((char *)SDLTest_FinalResultFormat, "Test", currentTestName, "Passed");
break;
case TEST_RESULT_FAILED:
SDLTest_LogError((char *)SDLTest_FinalResultFormat, "Test", currentTestName, "Failed");
break;
case TEST_RESULT_NO_ASSERT:
SDLTest_LogError((char *)SDLTest_FinalResultFormat,"Test", currentTestName, "No Asserts");
break;
}
}
// Take time - suite end
suiteEndSeconds = GetClock();
// Log suite runtime
SDLTest_Log("Suite runtime: %.1f sec", suiteEndSeconds - suiteStartSeconds);
// Log summary and final Suite result
countSum = testPassedCount + testFailedCount + testSkippedCount;
if (testFailedCount == 0)
{
SDLTest_Log(logFormat, "Suite", countSum, testPassedCount, testFailedCount, testSkippedCount);
SDLTest_Log((char *)SDLTest_FinalResultFormat, "Suite", currentSuiteName, "Passed");
}
else
{
SDLTest_LogError(logFormat, "Suite", countSum, testPassedCount, testFailedCount, testSkippedCount);
SDLTest_LogError((char *)SDLTest_FinalResultFormat, "Suite", currentSuiteName, "Failed");
}
}
// Take time - run end
runEndSeconds = GetClock();
// Log total runtime
SDLTest_Log("Total runtime: %.1f sec", runEndSeconds - runStartSeconds);
// Log summary and final run result
countSum = totalTestPassedCount + totalTestFailedCount + totalTestSkippedCount;
if (testFailedCount == 0)
{
runResult = 0;
SDLTest_Log(logFormat, "Run", countSum, totalTestPassedCount, totalTestFailedCount, totalTestSkippedCount);
SDLTest_Log((char *)SDLTest_FinalResultFormat, "Run /w seed", runSeed, "Passed");
}
else
{
runResult = 1;
SDLTest_LogError(logFormat, "Run", countSum, totalTestPassedCount, totalTestFailedCount, totalTestSkippedCount);
SDLTest_LogError((char *)SDLTest_FinalResultFormat, "Run /w seed", runSeed, "Failed");
}
SDLTest_Log("Exit code: %d", runResult);
return runResult;
}

99
src/test/SDL_test_log.c Normal file
View file

@ -0,0 +1,99 @@
/*
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.
*/
/*
Used by the test framework and test cases.
*/
// quiet windows compiler warnings
#define _CRT_SECURE_NO_WARNINGS
#include "SDL_config.h"
#include <stdarg.h> /* va_list */
#include <stdio.h>
#include <string.h>
#include <time.h>
#include "SDL_test.h"
/*!
* Converts unix timestamp to its ascii representation in localtime
*
* Note: Uses a static buffer internally, so the return value
* isn't valid after the next call of this function. If you
* want to retain the return value, make a copy of it.
*
* \param timestamp A Timestamp, i.e. time(0)
*
* \return Ascii representation of the timestamp in localtime in the format '08/23/01 14:55:02'
*/
char *SDLTest_TimestampToString(const time_t timestamp)
{
time_t copy;
static char buffer[64];
struct tm *local;
memset(buffer, 0, sizeof(buffer));\
copy = timestamp;
local = localtime(&copy);
strftime(buffer, sizeof(buffer), "%x %X", local);
return buffer;
}
/*
* Prints given message with a timestamp in the TEST category and INFO priority.
*/
void SDLTest_Log(char *fmt, ...)
{
va_list list;
char logMessage[SDLTEST_MAX_LOGMESSAGE_LENGTH];
// Print log message into a buffer
memset(logMessage, 0, SDLTEST_MAX_LOGMESSAGE_LENGTH);
va_start(list, fmt);
SDL_vsnprintf(logMessage, SDLTEST_MAX_LOGMESSAGE_LENGTH - 1, fmt, list);
va_end(list);
// Log with timestamp and newline
SDL_LogMessage(SDL_LOG_CATEGORY_TEST, SDL_LOG_PRIORITY_INFO, " %s: %s", SDLTest_TimestampToString(time(0)), logMessage);
}
/*
* Prints given message with a timestamp in the TEST category and the ERROR priority.
*/
void SDLTest_LogError(char *fmt, ...)
{
va_list list;
char logMessage[SDLTEST_MAX_LOGMESSAGE_LENGTH];
// Print log message into a buffer
memset(logMessage, 0, SDLTEST_MAX_LOGMESSAGE_LENGTH);
va_start(list, fmt);
SDL_vsnprintf(logMessage, SDLTEST_MAX_LOGMESSAGE_LENGTH - 1, fmt, list);
va_end(list);
// Log with timestamp and newline
SDL_LogMessage(SDL_LOG_CATEGORY_TEST, SDL_LOG_PRIORITY_ERROR, "%s: %s", SDLTest_TimestampToString(time(0)), logMessage);
}

336
src/test/SDL_test_md5.c Normal file
View file

@ -0,0 +1,336 @@
/*
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.
*/
/*
***********************************************************************
** RSA Data Security, Inc. MD5 Message-Digest Algorithm **
** Created: 2/17/90 RLR **
** Revised: 1/91 SRD,AJ,BSK,JT Reference C ver., 7/10 constant corr. **
***********************************************************************
*/
/*
***********************************************************************
** Copyright (C) 1990, RSA Data Security, Inc. All rights reserved. **
** **
** License to copy and use this software is granted provided that **
** it is identified as the "RSA Data Security, Inc. MD5 Message- **
** Digest Algorithm" in all material mentioning or referencing this **
** software or this function. **
** **
** License is also granted to make and use derivative works **
** provided that such works are identified as "derived from the RSA **
** Data Security, Inc. MD5 Message-Digest Algorithm" in all **
** material mentioning or referencing the derived work. **
** **
** RSA Data Security, Inc. makes no representations concerning **
** either the merchantability of this software or the suitability **
** of this software for any particular purpose. It is provided "as **
** is" without express or implied warranty of any kind. **
** **
** These notices must be retained in any copies of any part of this **
** documentation and/or software. **
***********************************************************************
*/
#include "SDL_config.h"
#include "SDL_test.h"
/* Forward declaration of static helper function */
static void SDLTest_Md5Transform(MD5UINT4 * buf, MD5UINT4 * in);
static unsigned char MD5PADDING[64] = {
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
/* F, G, H and I are basic MD5 functions */
#define F(x, y, z) (((x) & (y)) | ((~x) & (z)))
#define G(x, y, z) (((x) & (z)) | ((y) & (~z)))
#define H(x, y, z) ((x) ^ (y) ^ (z))
#define I(x, y, z) ((y) ^ ((x) | (~z)))
/* ROTATE_LEFT rotates x left n bits */
#define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32-(n))))
/* FF, GG, HH, and II transformations for rounds 1, 2, 3, and 4 */
/* Rotation is separate from addition to prevent recomputation */
#define FF(a, b, c, d, x, s, ac) \
{(a) += F ((b), (c), (d)) + (x) + (MD5UINT4)(ac); \
(a) = ROTATE_LEFT ((a), (s)); \
(a) += (b); \
}
#define GG(a, b, c, d, x, s, ac) \
{(a) += G ((b), (c), (d)) + (x) + (MD5UINT4)(ac); \
(a) = ROTATE_LEFT ((a), (s)); \
(a) += (b); \
}
#define HH(a, b, c, d, x, s, ac) \
{(a) += H ((b), (c), (d)) + (x) + (MD5UINT4)(ac); \
(a) = ROTATE_LEFT ((a), (s)); \
(a) += (b); \
}
#define II(a, b, c, d, x, s, ac) \
{(a) += I ((b), (c), (d)) + (x) + (MD5UINT4)(ac); \
(a) = ROTATE_LEFT ((a), (s)); \
(a) += (b); \
}
/*
The routine MD5Init initializes the message-digest context
mdContext. All fields are set to zero.
*/
void SDLTest_Md5Init(SDLTest_Md5Context * mdContext)
{
if (mdContext==NULL) return;
mdContext->i[0] = mdContext->i[1] = (MD5UINT4) 0;
/*
* Load magic initialization constants.
*/
mdContext->buf[0] = (MD5UINT4) 0x67452301;
mdContext->buf[1] = (MD5UINT4) 0xefcdab89;
mdContext->buf[2] = (MD5UINT4) 0x98badcfe;
mdContext->buf[3] = (MD5UINT4) 0x10325476;
}
/*
The routine MD5Update updates the message-digest context to
account for the presence of each of the characters inBuf[0..inLen-1]
in the message whose digest is being computed.
*/
void SDLTest_Md5Update(SDLTest_Md5Context * mdContext, unsigned char *inBuf,
unsigned int inLen)
{
MD5UINT4 in[16];
int mdi;
unsigned int i, ii;
if (mdContext == NULL) return;
if (inBuf == NULL || inLen < 1) return;
/*
* compute number of bytes mod 64
*/
mdi = (int) ((mdContext->i[0] >> 3) & 0x3F);
/*
* update number of bits
*/
if ((mdContext->i[0] + ((MD5UINT4) inLen << 3)) < mdContext->i[0])
mdContext->i[1]++;
mdContext->i[0] += ((MD5UINT4) inLen << 3);
mdContext->i[1] += ((MD5UINT4) inLen >> 29);
while (inLen--) {
/*
* add new character to buffer, increment mdi
*/
mdContext->in[mdi++] = *inBuf++;
/*
* transform if necessary
*/
if (mdi == 0x40) {
for (i = 0, ii = 0; i < 16; i++, ii += 4)
in[i] = (((MD5UINT4) mdContext->in[ii + 3]) << 24) |
(((MD5UINT4) mdContext->in[ii + 2]) << 16) |
(((MD5UINT4) mdContext->in[ii + 1]) << 8) |
((MD5UINT4) mdContext->in[ii]);
SDLTest_Md5Transform(mdContext->buf, in);
mdi = 0;
}
}
}
/*
The routine MD5Final terminates the message-digest computation and
ends with the desired message digest in mdContext->digest[0...15].
*/
void SDLTest_Md5Final(SDLTest_Md5Context * mdContext)
{
MD5UINT4 in[16];
int mdi;
unsigned int i, ii;
unsigned int padLen;
if (mdContext == NULL) return;
/*
* save number of bits
*/
in[14] = mdContext->i[0];
in[15] = mdContext->i[1];
/*
* compute number of bytes mod 64
*/
mdi = (int) ((mdContext->i[0] >> 3) & 0x3F);
/*
* pad out to 56 mod 64
*/
padLen = (mdi < 56) ? (56 - mdi) : (120 - mdi);
SDLTest_Md5Update(mdContext, MD5PADDING, padLen);
/*
* append length in bits and transform
*/
for (i = 0, ii = 0; i < 14; i++, ii += 4)
in[i] = (((MD5UINT4) mdContext->in[ii + 3]) << 24) |
(((MD5UINT4) mdContext->in[ii + 2]) << 16) |
(((MD5UINT4) mdContext->in[ii + 1]) << 8) |
((MD5UINT4) mdContext->in[ii]);
SDLTest_Md5Transform(mdContext->buf, in);
/*
* store buffer in digest
*/
for (i = 0, ii = 0; i < 4; i++, ii += 4) {
mdContext->digest[ii] = (unsigned char) (mdContext->buf[i] & 0xFF);
mdContext->digest[ii + 1] =
(unsigned char) ((mdContext->buf[i] >> 8) & 0xFF);
mdContext->digest[ii + 2] =
(unsigned char) ((mdContext->buf[i] >> 16) & 0xFF);
mdContext->digest[ii + 3] =
(unsigned char) ((mdContext->buf[i] >> 24) & 0xFF);
}
}
/* Basic MD5 step. Transforms buf based on in.
*/
static void SDLTest_Md5Transform(MD5UINT4 * buf, MD5UINT4 * in)
{
MD5UINT4 a = buf[0], b = buf[1], c = buf[2], d = buf[3];
/*
* Round 1
*/
#define S11 7
#define S12 12
#define S13 17
#define S14 22
FF(a, b, c, d, in[0], S11, 3614090360u); /* 1 */
FF(d, a, b, c, in[1], S12, 3905402710u); /* 2 */
FF(c, d, a, b, in[2], S13, 606105819u); /* 3 */
FF(b, c, d, a, in[3], S14, 3250441966u); /* 4 */
FF(a, b, c, d, in[4], S11, 4118548399u); /* 5 */
FF(d, a, b, c, in[5], S12, 1200080426u); /* 6 */
FF(c, d, a, b, in[6], S13, 2821735955u); /* 7 */
FF(b, c, d, a, in[7], S14, 4249261313u); /* 8 */
FF(a, b, c, d, in[8], S11, 1770035416u); /* 9 */
FF(d, a, b, c, in[9], S12, 2336552879u); /* 10 */
FF(c, d, a, b, in[10], S13, 4294925233u); /* 11 */
FF(b, c, d, a, in[11], S14, 2304563134u); /* 12 */
FF(a, b, c, d, in[12], S11, 1804603682u); /* 13 */
FF(d, a, b, c, in[13], S12, 4254626195u); /* 14 */
FF(c, d, a, b, in[14], S13, 2792965006u); /* 15 */
FF(b, c, d, a, in[15], S14, 1236535329u); /* 16 */
/*
* Round 2
*/
#define S21 5
#define S22 9
#define S23 14
#define S24 20
GG(a, b, c, d, in[1], S21, 4129170786u); /* 17 */
GG(d, a, b, c, in[6], S22, 3225465664u); /* 18 */
GG(c, d, a, b, in[11], S23, 643717713u); /* 19 */
GG(b, c, d, a, in[0], S24, 3921069994u); /* 20 */
GG(a, b, c, d, in[5], S21, 3593408605u); /* 21 */
GG(d, a, b, c, in[10], S22, 38016083u); /* 22 */
GG(c, d, a, b, in[15], S23, 3634488961u); /* 23 */
GG(b, c, d, a, in[4], S24, 3889429448u); /* 24 */
GG(a, b, c, d, in[9], S21, 568446438u); /* 25 */
GG(d, a, b, c, in[14], S22, 3275163606u); /* 26 */
GG(c, d, a, b, in[3], S23, 4107603335u); /* 27 */
GG(b, c, d, a, in[8], S24, 1163531501u); /* 28 */
GG(a, b, c, d, in[13], S21, 2850285829u); /* 29 */
GG(d, a, b, c, in[2], S22, 4243563512u); /* 30 */
GG(c, d, a, b, in[7], S23, 1735328473u); /* 31 */
GG(b, c, d, a, in[12], S24, 2368359562u); /* 32 */
/*
* Round 3
*/
#define S31 4
#define S32 11
#define S33 16
#define S34 23
HH(a, b, c, d, in[5], S31, 4294588738u); /* 33 */
HH(d, a, b, c, in[8], S32, 2272392833u); /* 34 */
HH(c, d, a, b, in[11], S33, 1839030562u); /* 35 */
HH(b, c, d, a, in[14], S34, 4259657740u); /* 36 */
HH(a, b, c, d, in[1], S31, 2763975236u); /* 37 */
HH(d, a, b, c, in[4], S32, 1272893353u); /* 38 */
HH(c, d, a, b, in[7], S33, 4139469664u); /* 39 */
HH(b, c, d, a, in[10], S34, 3200236656u); /* 40 */
HH(a, b, c, d, in[13], S31, 681279174u); /* 41 */
HH(d, a, b, c, in[0], S32, 3936430074u); /* 42 */
HH(c, d, a, b, in[3], S33, 3572445317u); /* 43 */
HH(b, c, d, a, in[6], S34, 76029189u); /* 44 */
HH(a, b, c, d, in[9], S31, 3654602809u); /* 45 */
HH(d, a, b, c, in[12], S32, 3873151461u); /* 46 */
HH(c, d, a, b, in[15], S33, 530742520u); /* 47 */
HH(b, c, d, a, in[2], S34, 3299628645u); /* 48 */
/*
* Round 4
*/
#define S41 6
#define S42 10
#define S43 15
#define S44 21
II(a, b, c, d, in[0], S41, 4096336452u); /* 49 */
II(d, a, b, c, in[7], S42, 1126891415u); /* 50 */
II(c, d, a, b, in[14], S43, 2878612391u); /* 51 */
II(b, c, d, a, in[5], S44, 4237533241u); /* 52 */
II(a, b, c, d, in[12], S41, 1700485571u); /* 53 */
II(d, a, b, c, in[3], S42, 2399980690u); /* 54 */
II(c, d, a, b, in[10], S43, 4293915773u); /* 55 */
II(b, c, d, a, in[1], S44, 2240044497u); /* 56 */
II(a, b, c, d, in[8], S41, 1873313359u); /* 57 */
II(d, a, b, c, in[15], S42, 4264355552u); /* 58 */
II(c, d, a, b, in[6], S43, 2734768916u); /* 59 */
II(b, c, d, a, in[13], S44, 1309151649u); /* 60 */
II(a, b, c, d, in[4], S41, 4149444226u); /* 61 */
II(d, a, b, c, in[11], S42, 3174756917u); /* 62 */
II(c, d, a, b, in[2], S43, 718787259u); /* 63 */
II(b, c, d, a, in[9], S44, 3951481745u); /* 64 */
buf[0] += a;
buf[1] += b;
buf[2] += c;
buf[3] += d;
}

View file

@ -0,0 +1,94 @@
/*
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.
*/
/*
A portable "32-bit Multiply with carry" random number generator.
Used by the fuzzer component.
Original source code contributed by A. Schiffler for GSOC project.
*/
#include "SDL_config.h"
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include "SDL_test.h"
/* Initialize random number generator with two integer variables */
void SDLTest_RandomInit(SDLTest_RandomContext * rndContext, unsigned int xi, unsigned int ci)
{
if (rndContext==NULL) return;
/*
* Choose a value for 'a' from this list
* 1791398085 1929682203 1683268614 1965537969 1675393560
* 1967773755 1517746329 1447497129 1655692410 1606218150
* 2051013963 1075433238 1557985959 1781943330 1893513180
* 1631296680 2131995753 2083801278 1873196400 1554115554
*/
rndContext->a = 1655692410;
rndContext->x = 30903;
rndContext->c = 0;
if (xi != 0) {
rndContext->x = xi;
}
rndContext->c = ci;
rndContext->ah = rndContext->a >> 16;
rndContext->al = rndContext->a & 65535;
}
/* Initialize random number generator from system time */
void SDLTest_RandomInitTime(SDLTest_RandomContext * rndContext)
{
int a, b;
if (rndContext==NULL) return;
srand((unsigned int)time(NULL));
a=rand();
srand(clock());
b=rand();
SDLTest_RandomInit(rndContext, a, b);
}
/* Returns random numbers */
unsigned int SDLTest_Random(SDLTest_RandomContext * rndContext)
{
unsigned int xh, xl;
if (rndContext==NULL) return -1;
xh = rndContext->x >> 16, xl = rndContext->x & 65535;
rndContext->x = rndContext->x * rndContext->a + rndContext->c;
rndContext->c =
xh * rndContext->ah + ((xh * rndContext->al) >> 16) +
((xl * rndContext->ah) >> 16);
if (xl * rndContext->al >= (~rndContext->c + 1))
rndContext->c++;
return (rndContext->x);
}

View file

@ -1004,6 +1004,7 @@ int
SDL_GetWindowDisplayMode(SDL_Window * window, SDL_DisplayMode * mode) SDL_GetWindowDisplayMode(SDL_Window * window, SDL_DisplayMode * mode)
{ {
SDL_DisplayMode fullscreen_mode; SDL_DisplayMode fullscreen_mode;
SDL_VideoDisplay *display;
CHECK_WINDOW_MAGIC(window, -1); CHECK_WINDOW_MAGIC(window, -1);
@ -1014,8 +1015,15 @@ SDL_GetWindowDisplayMode(SDL_Window * window, SDL_DisplayMode * mode)
if (!fullscreen_mode.h) { if (!fullscreen_mode.h) {
fullscreen_mode.h = window->h; fullscreen_mode.h = window->h;
} }
display = SDL_GetDisplayForWindow(window);
if (!SDL_GetClosestDisplayModeForDisplay(SDL_GetDisplayForWindow(window), /* if in desktop size mode, just return the size of the desktop */
if ( ( window->flags & SDL_WINDOW_FULLSCREEN_DESKTOP ) == SDL_WINDOW_FULLSCREEN_DESKTOP )
{
fullscreen_mode = display->desktop_mode;
}
else if (!SDL_GetClosestDisplayModeForDisplay(SDL_GetDisplayForWindow(window),
&fullscreen_mode, &fullscreen_mode,
&fullscreen_mode)) { &fullscreen_mode)) {
SDL_SetError("Couldn't find display mode match"); SDL_SetError("Couldn't find display mode match");
@ -1090,7 +1098,13 @@ SDL_UpdateFullscreenMode(SDL_Window * window, SDL_bool fullscreen)
resized = SDL_FALSE; resized = SDL_FALSE;
} }
SDL_SetDisplayModeForDisplay(display, &fullscreen_mode); /* only do the mode change if we want exclusive fullscreen */
if ( ( window->flags & SDL_WINDOW_FULLSCREEN_DESKTOP ) != SDL_WINDOW_FULLSCREEN_DESKTOP )
SDL_SetDisplayModeForDisplay(display, &fullscreen_mode);
else
SDL_SetDisplayModeForDisplay(display, NULL);
if (_this->SetWindowFullscreen) { if (_this->SetWindowFullscreen) {
_this->SetWindowFullscreen(_this, other, display, SDL_TRUE); _this->SetWindowFullscreen(_this, other, display, SDL_TRUE);
} }
@ -1143,7 +1157,7 @@ SDL_FinishWindowCreation(SDL_Window *window, Uint32 flags)
SDL_MinimizeWindow(window); SDL_MinimizeWindow(window);
} }
if (flags & SDL_WINDOW_FULLSCREEN) { if (flags & SDL_WINDOW_FULLSCREEN) {
SDL_SetWindowFullscreen(window, SDL_TRUE); SDL_SetWindowFullscreen(window, flags);
} }
if (flags & SDL_WINDOW_INPUT_GRABBED) { if (flags & SDL_WINDOW_INPUT_GRABBED) {
SDL_SetWindowGrab(window, SDL_TRUE); SDL_SetWindowGrab(window, SDL_TRUE);
@ -1699,19 +1713,22 @@ SDL_RestoreWindow(SDL_Window * window)
} }
} }
#define FULLSCREEN_MASK ( SDL_WINDOW_FULLSCREEN_DESKTOP | SDL_WINDOW_FULLSCREEN )
int int
SDL_SetWindowFullscreen(SDL_Window * window, SDL_bool fullscreen) SDL_SetWindowFullscreen(SDL_Window * window, Uint32 flags)
{ {
CHECK_WINDOW_MAGIC(window, -1); CHECK_WINDOW_MAGIC(window, -1);
if (!!fullscreen == !!(window->flags & SDL_WINDOW_FULLSCREEN)) { flags &= FULLSCREEN_MASK;
if ( flags == (window->flags & FULLSCREEN_MASK) ) {
return 0; return 0;
} }
if (fullscreen) {
window->flags |= SDL_WINDOW_FULLSCREEN; /* clear the previous flags and OR in the new ones */
} else { window->flags &= ~FULLSCREEN_MASK;
window->flags &= ~SDL_WINDOW_FULLSCREEN; window->flags |= flags;
}
SDL_UpdateFullscreenMode(window, FULLSCREEN_VISIBLE(window)); SDL_UpdateFullscreenMode(window, FULLSCREEN_VISIBLE(window));
return 0; return 0;
@ -1976,6 +1993,19 @@ SDL_OnWindowFocusGained(SDL_Window * window)
SDL_UpdateWindowGrab(window); SDL_UpdateWindowGrab(window);
} }
static SDL_bool ShouldMinimizeOnFocusLoss()
{
const char *hint = SDL_GetHint(SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS);
if (hint) {
if (*hint == '0') {
return SDL_FALSE;
} else {
return SDL_TRUE;
}
}
return SDL_TRUE;
}
void void
SDL_OnWindowFocusLost(SDL_Window * window) SDL_OnWindowFocusLost(SDL_Window * window)
{ {
@ -1986,8 +2016,8 @@ SDL_OnWindowFocusLost(SDL_Window * window)
SDL_UpdateWindowGrab(window); SDL_UpdateWindowGrab(window);
/* If we're fullscreen on a single-head system and lose focus, minimize */ /* If we're fullscreen on a single-head system and lose focus, minimize */
if ((window->flags & SDL_WINDOW_FULLSCREEN) && _this->num_displays == 1) { if ((window->flags & SDL_WINDOW_FULLSCREEN) && ShouldMinimizeOnFocusLoss() ) {
SDL_MinimizeWindow(window); SDL_MinimizeWindow(window);
} }
} }

View file

@ -51,8 +51,8 @@ Cocoa_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid)
[alert setAlertStyle:NSInformationalAlertStyle]; [alert setAlertStyle:NSInformationalAlertStyle];
} }
[alert setMessageText:[[NSString alloc] initWithUTF8String:messageboxdata->title]]; [alert setMessageText:[NSString stringWithUTF8String:messageboxdata->title]];
[alert setInformativeText:[[NSString alloc] initWithUTF8String:messageboxdata->message]]; [alert setInformativeText:[NSString stringWithUTF8String:messageboxdata->message]];
const SDL_MessageBoxButtonData *buttons = messageboxdata->buttons; const SDL_MessageBoxButtonData *buttons = messageboxdata->buttons;
int i; int i;
@ -70,6 +70,7 @@ Cocoa_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid)
NSInteger clicked = [alert runModal]; NSInteger clicked = [alert runModal];
clicked -= NSAlertFirstButtonReturn; clicked -= NSAlertFirstButtonReturn;
*buttonid = buttons[clicked].buttonid; *buttonid = buttons[clicked].buttonid;
[alert release];
[pool release]; [pool release];

View file

@ -228,11 +228,7 @@ Cocoa_CreateImage(SDL_Surface * surface)
void SDL_NSLog(const char *text) void SDL_NSLog(const char *text)
{ {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; NSLog(@"%s", text);
NSLog(@"%@", [[NSString alloc] initWithUTF8String:text]);
[pool release];
} }
/* /*

View file

@ -996,6 +996,23 @@ Cocoa_SetWindowGrab(_THIS, SDL_Window * window, SDL_bool grabbed)
cgpoint.y = window->y + y; cgpoint.y = window->y + y;
CGDisplayMoveCursorToPoint(kCGDirectMainDisplay, cgpoint); CGDisplayMoveCursorToPoint(kCGDirectMainDisplay, cgpoint);
} }
if ( window->flags & SDL_WINDOW_FULLSCREEN )
{
SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
if (window->flags & SDL_WINDOW_INPUT_FOCUS)
{
/* OpenGL is rendering to the window, so make it visible! */
[data->nswindow setLevel:CGShieldingWindowLevel()];
}
else
{
[data->nswindow setLevel:kCGNormalWindowLevel];
}
}
} }
void void

0
src/video/sdlgenblit.pl Normal file → Executable file
View file

View file

@ -76,8 +76,8 @@ UIKit_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid)
UIAlertView* alert = [[UIAlertView alloc] init]; UIAlertView* alert = [[UIAlertView alloc] init];
alert.title = [[NSString alloc] initWithUTF8String:messageboxdata->title]; alert.title = [NSString stringWithUTF8String:messageboxdata->title];
alert.message = [[NSString alloc] initWithUTF8String:messageboxdata->message]; alert.message = [NSString stringWithUTF8String:messageboxdata->message];
alert.delegate = [[UIKit_UIAlertViewDelegate alloc] initWithButtonIndex:&clicked]; alert.delegate = [[UIKit_UIAlertViewDelegate alloc] initWithButtonIndex:&clicked];
const SDL_MessageBoxButtonData *buttons = messageboxdata->buttons; const SDL_MessageBoxButtonData *buttons = messageboxdata->buttons;
@ -100,6 +100,9 @@ UIKit_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid)
s_showingMessageBox = SDL_FALSE; s_showingMessageBox = SDL_FALSE;
*buttonid = messageboxdata->buttons[clicked].buttonid; *buttonid = messageboxdata->buttons[clicked].buttonid;
[alert.delegate release];
[alert release];
[pool release]; [pool release];

View file

@ -137,11 +137,7 @@ UIKit_VideoQuit(_THIS)
void SDL_NSLog(const char *text) void SDL_NSLog(const char *text)
{ {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; NSLog(@"%s", text);
NSLog(@"%@", [[NSString alloc] initWithUTF8String:text]);
[pool release];
} }
#endif /* SDL_VIDEO_DRIVER_UIKIT */ #endif /* SDL_VIDEO_DRIVER_UIKIT */

View file

@ -18,6 +18,7 @@
misrepresented as being the original software. misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
*/ */
#include "SDL_config.h" #include "SDL_config.h"
#if SDL_VIDEO_DRIVER_X11 #if SDL_VIDEO_DRIVER_X11
@ -25,6 +26,19 @@
#include "SDL.h" #include "SDL.h"
#include "SDL_x11video.h" #include "SDL_x11video.h"
#include "SDL_x11dyn.h" #include "SDL_x11dyn.h"
#include "SDL_assert.h"
#include <locale.h>
#define SDL_FORK_MESSAGEBOX 1
#if SDL_FORK_MESSAGEBOX
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
#include <errno.h>
#endif
#define MAX_BUTTONS 8 /* Maximum number of buttons supported */ #define MAX_BUTTONS 8 /* Maximum number of buttons supported */
#define MAX_TEXT_LINES 32 /* Maximum number of text lines supported */ #define MAX_TEXT_LINES 32 /* Maximum number of text lines supported */
@ -32,23 +46,22 @@
#define MIN_DIALOG_WIDTH 200 /* Minimum dialog width */ #define MIN_DIALOG_WIDTH 200 /* Minimum dialog width */
#define MIN_DIALOG_HEIGHT 100 /* Minimum dialog height */ #define MIN_DIALOG_HEIGHT 100 /* Minimum dialog height */
static const char g_MessageBoxFont[] = "-*-*-medium-r-normal--0-120-*-*-p-0-iso8859-1"; static const char g_MessageBoxFontLatin1[] = "-*-*-medium-r-normal--0-120-*-*-p-0-iso8859-1";
static const char g_MessageBoxFont[] = "-*-*-*-*-*-*-*-*-*-*-*-*-*-*";
static const SDL_MessageBoxColor g_default_colors[ SDL_MESSAGEBOX_COLOR_MAX ] = static const SDL_MessageBoxColor g_default_colors[ SDL_MESSAGEBOX_COLOR_MAX ] = {
{ { 56, 54, 53 }, // SDL_MESSAGEBOX_COLOR_BACKGROUND,
{ 56, 54, 53 }, // SDL_MESSAGEBOX_COLOR_BACKGROUND, { 209, 207, 205 }, // SDL_MESSAGEBOX_COLOR_TEXT,
{ 209, 207, 205 }, // SDL_MESSAGEBOX_COLOR_TEXT, { 140, 135, 129 }, // SDL_MESSAGEBOX_COLOR_BUTTON_BORDER,
{ 140, 135, 129 }, // SDL_MESSAGEBOX_COLOR_BUTTON_BORDER,
{ 105, 102, 99 }, // SDL_MESSAGEBOX_COLOR_BUTTON_BACKGROUND, { 105, 102, 99 }, // SDL_MESSAGEBOX_COLOR_BUTTON_BACKGROUND,
{ 205, 202, 53 }, // SDL_MESSAGEBOX_COLOR_BUTTON_SELECTED, { 205, 202, 53 }, // SDL_MESSAGEBOX_COLOR_BUTTON_SELECTED,
}; };
#define SDL_MAKE_RGB( _r, _g, _b ) ( ( ( Uint32 )( _r ) << 16 ) | \ #define SDL_MAKE_RGB( _r, _g, _b ) ( ( ( Uint32 )( _r ) << 16 ) | \
( ( Uint32 )( _g ) << 8 ) | \ ( ( Uint32 )( _g ) << 8 ) | \
( ( Uint32 )( _b ) ) ) ( ( Uint32 )( _b ) ) )
typedef struct SDL_MessageBoxButtonDataX11 typedef struct SDL_MessageBoxButtonDataX11 {
{
int x, y; /* Text position */ int x, y; /* Text position */
int length; /* Text length */ int length; /* Text length */
int text_width; /* Text width */ int text_width; /* Text width */
@ -58,16 +71,15 @@ typedef struct SDL_MessageBoxButtonDataX11
const SDL_MessageBoxButtonData *buttondata; /* Button data from caller */ const SDL_MessageBoxButtonData *buttondata; /* Button data from caller */
} SDL_MessageBoxButtonDataX11; } SDL_MessageBoxButtonDataX11;
typedef struct TextLineData typedef struct TextLineData {
{
int width; /* Width of this text line */ int width; /* Width of this text line */
int length; /* String length of this text line */ int length; /* String length of this text line */
const char *text; /* Text for this line */ const char *text; /* Text for this line */
} TextLineData; } TextLineData;
typedef struct SDL_MessageBoxDataX11 typedef struct SDL_MessageBoxDataX11 {
{ XFontSet font_set; /* for UTF-8 systems */
Font hfont; XFontStruct *font_struct; /* Latin1 (ASCII) fallback. */
Window window; Window window;
Display *display; Display *display;
long event_mask; long event_mask;
@ -105,17 +117,22 @@ IntMax( int a, int b )
/* Return width and height for a string. */ /* Return width and height for a string. */
static void static void
GetTextWidthHeight( XFontStruct *font_struct, const char *str, int nchars, int *pwidth, int *pheight ) GetTextWidthHeight( SDL_MessageBoxDataX11 *data, const char *str, int nbytes, int *pwidth, int *pheight )
{ {
XCharStruct text_structure; if (SDL_X11_HAVE_UTF8) {
int font_direction, font_ascent, font_descent; XRectangle overall_ink, overall_logical;
Xutf8TextExtents(data->font_set, str, nbytes, &overall_ink, &overall_logical);
XTextExtents( font_struct, str, nchars, *pwidth = overall_logical.width;
&font_direction, &font_ascent, &font_descent, *pheight = overall_logical.height;
&text_structure ); } else {
XCharStruct text_structure;
*pwidth = text_structure.width; int font_direction, font_ascent, font_descent;
*pheight = text_structure.ascent + text_structure.descent; XTextExtents( data->font_struct, str, nbytes,
&font_direction, &font_ascent, &font_descent,
&text_structure );
*pwidth = text_structure.width;
*pheight = text_structure.ascent + text_structure.descent;
}
} }
/* Return index of button if position x,y is contained therein. */ /* Return index of button if position x,y is contained therein. */
@ -126,15 +143,13 @@ GetHitButtonIndex( SDL_MessageBoxDataX11 *data, int x, int y )
int numbuttons = data->numbuttons; int numbuttons = data->numbuttons;
SDL_MessageBoxButtonDataX11 *buttonpos = data->buttonpos; SDL_MessageBoxButtonDataX11 *buttonpos = data->buttonpos;
for ( i = 0; i < numbuttons; i++ ) for ( i = 0; i < numbuttons; i++ ) {
{
SDL_Rect *rect = &buttonpos[ i ].rect; SDL_Rect *rect = &buttonpos[ i ].rect;
if ( ( x >= rect->x ) && if ( ( x >= rect->x ) &&
( x <= ( rect->x + rect->w ) ) && ( x <= ( rect->x + rect->w ) ) &&
( y >= rect->y ) && ( y >= rect->y ) &&
( y <= ( rect->y + rect->h ) ) ) ( y <= ( rect->y + rect->h ) ) ) {
{
return i; return i;
} }
} }
@ -169,10 +184,24 @@ X11_MessageBoxInit( SDL_MessageBoxDataX11 *data, const SDL_MessageBoxData * mess
return -1; return -1;
} }
data->hfont = XLoadFont( data->display, g_MessageBoxFont ); if (SDL_X11_HAVE_UTF8) {
if ( data->hfont == None ) { char **missing = NULL;
SDL_SetError("Couldn't load font %s", g_MessageBoxFont); int num_missing = 0;
return -1; data->font_set = XCreateFontSet(data->display, g_MessageBoxFont,
&missing, &num_missing, NULL);
if ( missing != NULL ) {
XFreeStringList(missing);
}
if ( data->font_set == NULL ) {
SDL_SetError("Couldn't load font %s", g_MessageBoxFont);
return -1;
}
} else {
data->font_struct = XLoadQueryFont( data->display, g_MessageBoxFontLatin1 );
if ( data->font_struct == NULL ) {
SDL_SetError("Couldn't load font %s", g_MessageBoxFontLatin1);
return -1;
}
} }
if ( messageboxdata->colorScheme ) { if ( messageboxdata->colorScheme ) {
@ -200,20 +229,12 @@ X11_MessageBoxInitPositions( SDL_MessageBoxDataX11 *data )
int button_width = MIN_BUTTON_WIDTH; int button_width = MIN_BUTTON_WIDTH;
const SDL_MessageBoxData *messageboxdata = data->messageboxdata; const SDL_MessageBoxData *messageboxdata = data->messageboxdata;
XFontStruct *fontinfo = XQueryFont( data->display, data->hfont );
if ( !fontinfo ) {
SDL_SetError("Couldn't get font info");
return -1;
}
/* Go over text and break linefeeds into separate lines. */ /* Go over text and break linefeeds into separate lines. */
if ( messageboxdata->message && messageboxdata->message[ 0 ] ) if ( messageboxdata->message && messageboxdata->message[ 0 ] ) {
{
const char *text = messageboxdata->message; const char *text = messageboxdata->message;
TextLineData *plinedata = data->linedata; TextLineData *plinedata = data->linedata;
for ( i = 0; i < MAX_TEXT_LINES; i++, plinedata++ ) for ( i = 0; i < MAX_TEXT_LINES; i++, plinedata++ ) {
{
int height; int height;
char *lf = SDL_strchr( ( char * )text, '\n' ); char *lf = SDL_strchr( ( char * )text, '\n' );
@ -223,12 +244,16 @@ X11_MessageBoxInitPositions( SDL_MessageBoxDataX11 *data )
plinedata->length = ( lf && ( i < MAX_TEXT_LINES - 1 ) ) ? ( lf - text ) : SDL_strlen( text ); plinedata->length = ( lf && ( i < MAX_TEXT_LINES - 1 ) ) ? ( lf - text ) : SDL_strlen( text );
plinedata->text = text; plinedata->text = text;
GetTextWidthHeight( fontinfo, text, plinedata->length, &plinedata->width, &height ); GetTextWidthHeight( data, text, plinedata->length, &plinedata->width, &height );
/* Text and widths are the largest we've ever seen. */ /* Text and widths are the largest we've ever seen. */
data->text_height = IntMax( data->text_height, height ); data->text_height = IntMax( data->text_height, height );
text_width_max = IntMax( text_width_max, plinedata->width ); text_width_max = IntMax( text_width_max, plinedata->width );
if (lf && (lf > text) && (lf[-1] == '\r')) {
plinedata->length--;
}
text += plinedata->length + 1; text += plinedata->length + 1;
/* Break if there are no more linefeeds. */ /* Break if there are no more linefeeds. */
@ -241,22 +266,20 @@ X11_MessageBoxInitPositions( SDL_MessageBoxDataX11 *data )
} }
/* Loop through all buttons and calculate the button widths and height. */ /* Loop through all buttons and calculate the button widths and height. */
for ( i = 0; i < data->numbuttons; i++ ) for ( i = 0; i < data->numbuttons; i++ ) {
{
int height; int height;
data->buttonpos[ i ].buttondata = &data->buttondata[ i ]; data->buttonpos[ i ].buttondata = &data->buttondata[ i ];
data->buttonpos[ i ].length = SDL_strlen( data->buttondata[ i ].text ); data->buttonpos[ i ].length = SDL_strlen( data->buttondata[ i ].text );
GetTextWidthHeight( fontinfo, data->buttondata[ i ].text, SDL_strlen( data->buttondata[ i ].text ), GetTextWidthHeight( data, data->buttondata[ i ].text, SDL_strlen( data->buttondata[ i ].text ),
&data->buttonpos[ i ].text_width, &height ); &data->buttonpos[ i ].text_width, &height );
button_width = IntMax( button_width, data->buttonpos[ i ].text_width ); button_width = IntMax( button_width, data->buttonpos[ i ].text_width );
button_text_height = IntMax( button_text_height, height ); button_text_height = IntMax( button_text_height, height );
} }
if ( data->numlines ) if ( data->numlines ) {
{
/* x,y for this line of text. */ /* x,y for this line of text. */
data->xtext = data->text_height; data->xtext = data->text_height;
data->ytext = data->text_height + data->text_height; data->ytext = data->text_height + data->text_height;
@ -267,15 +290,12 @@ X11_MessageBoxInitPositions( SDL_MessageBoxDataX11 *data )
/* Bump the dialog box width and height up if needed. */ /* Bump the dialog box width and height up if needed. */
data->dialog_width = IntMax( data->dialog_width, 2 * data->xtext + text_width_max ); data->dialog_width = IntMax( data->dialog_width, 2 * data->xtext + text_width_max );
data->dialog_height = IntMax( data->dialog_height, ybuttons ); data->dialog_height = IntMax( data->dialog_height, ybuttons );
} } else {
else
{
/* Button y starts at height of button text. */ /* Button y starts at height of button text. */
ybuttons = button_text_height; ybuttons = button_text_height;
} }
if ( data->numbuttons ) if ( data->numbuttons ) {
{
int x, y; int x, y;
int width_of_buttons; int width_of_buttons;
int button_spacing = button_text_height; int button_spacing = button_text_height;
@ -295,8 +315,7 @@ X11_MessageBoxInitPositions( SDL_MessageBoxDataX11 *data )
x = ( data->dialog_width - width_of_buttons ) / 2; x = ( data->dialog_width - width_of_buttons ) / 2;
y = ybuttons + ( data->dialog_height - ybuttons - button_height ) / 2; y = ybuttons + ( data->dialog_height - ybuttons - button_height ) / 2;
for ( i = 0; i < data->numbuttons; i++ ) for ( i = 0; i < data->numbuttons; i++ ) {
{
/* Button coordinates. */ /* Button coordinates. */
data->buttonpos[ i ].rect.x = x; data->buttonpos[ i ].rect.x = x;
data->buttonpos[ i ].rect.y = y; data->buttonpos[ i ].rect.y = y;
@ -312,7 +331,6 @@ X11_MessageBoxInitPositions( SDL_MessageBoxDataX11 *data )
} }
} }
XFreeFontInfo( NULL, fontinfo, 1 );
return 0; return 0;
} }
@ -320,16 +338,18 @@ X11_MessageBoxInitPositions( SDL_MessageBoxDataX11 *data )
static void static void
X11_MessageBoxShutdown( SDL_MessageBoxDataX11 *data ) X11_MessageBoxShutdown( SDL_MessageBoxDataX11 *data )
{ {
if ( data->hfont != None ) if ( data->font_set != NULL ) {
{ XFreeFontSet( data->display, data->font_set );
XUnloadFont( data->display, data->hfont ); data->font_set = NULL;
data->hfont = None;
} }
if ( data->display ) if ( data->font_struct != NULL ) {
{ XFreeFont( data->display, data->font_struct );
if ( data->window != None ) data->font_struct = NULL;
{ }
if ( data->display ) {
if ( data->window != None ) {
XUnmapWindow( data->display, data->window ); XUnmapWindow( data->display, data->window );
XDestroyWindow( data->display, data->window ); XDestroyWindow( data->display, data->window );
data->window = None; data->window = None;
@ -356,16 +376,16 @@ X11_MessageBoxCreateWindow( SDL_MessageBoxDataX11 *data )
} }
data->event_mask = ExposureMask | data->event_mask = ExposureMask |
ButtonPressMask | ButtonReleaseMask | KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask | KeyPressMask | KeyReleaseMask |
StructureNotifyMask | FocusChangeMask | PointerMotionMask; StructureNotifyMask | FocusChangeMask | PointerMotionMask;
wnd_attr.event_mask = data->event_mask; wnd_attr.event_mask = data->event_mask;
data->window = XCreateWindow( data->window = XCreateWindow(
display, DefaultRootWindow( display ), display, DefaultRootWindow( display ),
0, 0, 0, 0,
data->dialog_width, data->dialog_height, data->dialog_width, data->dialog_height,
0, CopyFromParent, InputOutput, CopyFromParent, 0, CopyFromParent, InputOutput, CopyFromParent,
CWEventMask, &wnd_attr ); CWEventMask, &wnd_attr );
if ( data->window == None ) { if ( data->window == None ) {
SDL_SetError("Couldn't create X window"); SDL_SetError("Couldn't create X window");
return -1; return -1;
@ -430,17 +450,21 @@ X11_MessageBoxDraw( SDL_MessageBoxDataX11 *data, GC ctx )
XFillRectangle( display, window, ctx, 0, 0, data->dialog_width, data->dialog_height ); XFillRectangle( display, window, ctx, 0, 0, data->dialog_width, data->dialog_height );
XSetForeground( display, ctx, data->color[ SDL_MESSAGEBOX_COLOR_TEXT ] ); XSetForeground( display, ctx, data->color[ SDL_MESSAGEBOX_COLOR_TEXT ] );
for ( i = 0; i < data->numlines; i++ ) for ( i = 0; i < data->numlines; i++ ) {
{
TextLineData *plinedata = &data->linedata[ i ]; TextLineData *plinedata = &data->linedata[ i ];
XDrawString( display, window, ctx, if (SDL_X11_HAVE_UTF8) {
data->xtext, data->ytext + i * data->text_height, Xutf8DrawString( display, window, data->font_set, ctx,
plinedata->text, plinedata->length ); data->xtext, data->ytext + i * data->text_height,
plinedata->text, plinedata->length );
} else {
XDrawString( display, window, ctx,
data->xtext, data->ytext + i * data->text_height,
plinedata->text, plinedata->length );
}
} }
for ( i = 0; i < data->numbuttons; i++ ) for ( i = 0; i < data->numbuttons; i++ ) {
{
SDL_MessageBoxButtonDataX11 *buttondatax11 = &data->buttonpos[ i ]; SDL_MessageBoxButtonDataX11 *buttondatax11 = &data->buttonpos[ i ];
const SDL_MessageBoxButtonData *buttondata = buttondatax11->buttondata; const SDL_MessageBoxButtonData *buttondata = buttondatax11->buttondata;
int border = ( buttondata->flags & SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT ) ? 2 : 0; int border = ( buttondata->flags & SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT ) ? 2 : 0;
@ -459,9 +483,17 @@ X11_MessageBoxDraw( SDL_MessageBoxDataX11 *data, GC ctx )
XSetForeground( display, ctx, ( data->mouse_over_index == i ) ? XSetForeground( display, ctx, ( data->mouse_over_index == i ) ?
data->color[ SDL_MESSAGEBOX_COLOR_BUTTON_SELECTED ] : data->color[ SDL_MESSAGEBOX_COLOR_BUTTON_SELECTED ] :
data->color[ SDL_MESSAGEBOX_COLOR_TEXT ] ); data->color[ SDL_MESSAGEBOX_COLOR_TEXT ] );
XDrawString( display, window, ctx,
buttondatax11->x + offset, buttondatax11->y + offset, if (SDL_X11_HAVE_UTF8) {
buttondata->text, buttondatax11->length ); Xutf8DrawString( display, window, data->font_set, ctx,
buttondatax11->x + offset,
buttondatax11->y + offset,
buttondata->text, buttondatax11->length );
} else {
XDrawString( display, window, ctx,
buttondatax11->x + offset, buttondatax11->y + offset,
buttondata->text, buttondatax11->length );
}
} }
} }
@ -474,12 +506,18 @@ X11_MessageBoxLoop( SDL_MessageBoxDataX11 *data )
SDL_bool close_dialog = SDL_FALSE; SDL_bool close_dialog = SDL_FALSE;
SDL_bool has_focus = SDL_TRUE; SDL_bool has_focus = SDL_TRUE;
KeySym last_key_pressed = XK_VoidSymbol; KeySym last_key_pressed = XK_VoidSymbol;
unsigned long gcflags = GCForeground | GCBackground;
ctx_vals.font = data->hfont; SDL_zero(ctx_vals);
ctx_vals.foreground = data->color[ SDL_MESSAGEBOX_COLOR_BACKGROUND ]; ctx_vals.foreground = data->color[ SDL_MESSAGEBOX_COLOR_BACKGROUND ];
ctx_vals.background = data->color[ SDL_MESSAGEBOX_COLOR_BACKGROUND ]; ctx_vals.background = data->color[ SDL_MESSAGEBOX_COLOR_BACKGROUND ];
ctx = XCreateGC( data->display, data->window, GCForeground | GCBackground | GCFont, &ctx_vals ); if (!SDL_X11_HAVE_UTF8) {
gcflags |= GCFont;
ctx_vals.font = data->font_struct->fid;
}
ctx = XCreateGC( data->display, data->window, gcflags, &ctx_vals );
if ( ctx == None ) { if ( ctx == None ) {
SDL_SetError("Couldn't create graphics context"); SDL_SetError("Couldn't create graphics context");
return -1; return -1;
@ -538,8 +576,7 @@ X11_MessageBoxLoop( SDL_MessageBoxDataX11 *data )
last_key_pressed = XLookupKeysym( &e.xkey, 0 ); last_key_pressed = XLookupKeysym( &e.xkey, 0 );
break; break;
case KeyRelease: case KeyRelease: {
{
Uint32 mask = 0; Uint32 mask = 0;
KeySym key = XLookupKeysym( &e.xkey, 0 ); KeySym key = XLookupKeysym( &e.xkey, 0 );
@ -603,18 +640,28 @@ X11_MessageBoxLoop( SDL_MessageBoxDataX11 *data )
return 0; return 0;
} }
/* Display an x11 message box. */ static int
int X11_ShowMessageBoxImpl(const SDL_MessageBoxData *messageboxdata, int *buttonid)
X11_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid)
{ {
int ret; int ret;
SDL_MessageBoxDataX11 data; SDL_MessageBoxDataX11 data;
char *origlocale;
SDL_memset( &data, 0, sizeof( data ) ); SDL_zero(data);
if ( !SDL_X11_LoadSymbols() ) if ( !SDL_X11_LoadSymbols() )
return -1; return -1;
origlocale = setlocale(LC_ALL, NULL);
if (origlocale != NULL) {
origlocale = SDL_strdup(origlocale);
if (origlocale == NULL) {
SDL_OutOfMemory();
return -1;
}
setlocale(LC_ALL, "");
}
/* This code could get called from multiple threads maybe? */ /* This code could get called from multiple threads maybe? */
XInitThreads(); XInitThreads();
@ -634,9 +681,70 @@ X11_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid)
} }
X11_MessageBoxShutdown( &data ); X11_MessageBoxShutdown( &data );
if (origlocale) {
setlocale(LC_ALL, origlocale);
SDL_free(origlocale);
}
return ret; return ret;
} }
/* Display an x11 message box. */
int
X11_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid)
{
#if SDL_FORK_MESSAGEBOX
/* Use a child process to protect against setlocale(). Annoying. */
pid_t pid;
int fds[2];
int status = 0;
if (pipe(fds) == -1) {
return X11_ShowMessageBoxImpl(messageboxdata, buttonid); /* oh well. */
}
pid = fork();
if (pid == -1) { /* failed */
close(fds[0]);
close(fds[1]);
return X11_ShowMessageBoxImpl(messageboxdata, buttonid); /* oh well. */
} else if (pid == 0) { /* we're the child */
int exitcode = 0;
close(fds[0]);
status = X11_ShowMessageBoxImpl(messageboxdata, buttonid);
if (write(fds[1], &status, sizeof (int)) != sizeof (int))
exitcode = 1;
else if (write(fds[1], buttonid, sizeof (int)) != sizeof (int))
exitcode = 1;
close(fds[1]);
_exit(exitcode); /* don't run atexit() stuff, static destructors, etc. */
} else { /* we're the parent */
pid_t rc;
close(fds[1]);
do {
rc = waitpid(pid, &status, 0);
} while ((rc == -1) && (errno == EINTR));
SDL_assert(rc == pid); /* not sure what to do if this fails. */
if ((rc == -1) || (!WIFEXITED(status)) || (WEXITSTATUS(status) != 0)) {
SDL_SetError("msgbox child process failed");
return -1;
}
if (read(fds[0], &status, sizeof (int)) != sizeof (int))
status = -1;
else if (read(fds[0], buttonid, sizeof (int)) != sizeof (int))
status = -1;
close(fds[0]);
return status;
}
#else
return X11_ShowMessageBoxImpl(messageboxdata, buttonid);
#endif
}
#endif /* SDL_VIDEO_DRIVER_X11 */ #endif /* SDL_VIDEO_DRIVER_X11 */
/* vi: set ts=4 sw=4 expandtab: */ /* vi: set ts=4 sw=4 expandtab: */

View file

@ -37,6 +37,7 @@ SDL_X11_SYM(Pixmap,XCreateBitmapFromData,(Display *dpy,Drawable d,_Xconst char *
SDL_X11_SYM(Colormap,XCreateColormap,(Display* a,Window b,Visual* c,int d),(a,b,c,d),return) SDL_X11_SYM(Colormap,XCreateColormap,(Display* a,Window b,Visual* c,int d),(a,b,c,d),return)
SDL_X11_SYM(Cursor,XCreatePixmapCursor,(Display* a,Pixmap b,Pixmap c,XColor* d,XColor* e,unsigned int f,unsigned int g),(a,b,c,d,e,f,g),return) SDL_X11_SYM(Cursor,XCreatePixmapCursor,(Display* a,Pixmap b,Pixmap c,XColor* d,XColor* e,unsigned int f,unsigned int g),(a,b,c,d,e,f,g),return)
SDL_X11_SYM(Cursor,XCreateFontCursor,(Display* a,unsigned int b),(a,b),return) SDL_X11_SYM(Cursor,XCreateFontCursor,(Display* a,unsigned int b),(a,b),return)
SDL_X11_SYM(XFontSet,XCreateFontSet,(Display* a, _Xconst char* b, char*** c, int* d, char** e),(a,b,c,d,e),return)
SDL_X11_SYM(GC,XCreateGC,(Display* a,Drawable b,unsigned long c,XGCValues* d),(a,b,c,d),return) SDL_X11_SYM(GC,XCreateGC,(Display* a,Drawable b,unsigned long c,XGCValues* d),(a,b,c,d),return)
SDL_X11_SYM(XImage*,XCreateImage,(Display* a,Visual* b,unsigned int c,int d,int e,char* f,unsigned int g,unsigned int h,int i,int j),(a,b,c,d,e,f,g,h,i,j),return) SDL_X11_SYM(XImage*,XCreateImage,(Display* a,Visual* b,unsigned int c,int d,int e,char* f,unsigned int g,unsigned int h,int i,int j),(a,b,c,d,e,f,g,h,i,j),return)
SDL_X11_SYM(Window,XCreateWindow,(Display* a,Window b,int c,int d,unsigned int e,unsigned int f,unsigned int g,int h,unsigned int i,Visual* j,unsigned long k,XSetWindowAttributes* l),(a,b,c,d,e,f,g,h,i,j,k,l),return) SDL_X11_SYM(Window,XCreateWindow,(Display* a,Window b,int c,int d,unsigned int e,unsigned int f,unsigned int g,int h,unsigned int i,Visual* j,unsigned long k,XSetWindowAttributes* l),(a,b,c,d,e,f,g,h,i,j,k,l),return)
@ -53,10 +54,12 @@ SDL_X11_SYM(Bool,XFilterEvent,(XEvent *event,Window w),(event,w),return)
SDL_X11_SYM(int,XFlush,(Display* a),(a),return) SDL_X11_SYM(int,XFlush,(Display* a),(a),return)
SDL_X11_SYM(int,XFree,(void*a),(a),return) SDL_X11_SYM(int,XFree,(void*a),(a),return)
SDL_X11_SYM(int,XFreeCursor,(Display* a,Cursor b),(a,b),return) SDL_X11_SYM(int,XFreeCursor,(Display* a,Cursor b),(a,b),return)
SDL_X11_SYM(void,XFreeFontSet,(Display* a, XFontSet b),(a,b),)
SDL_X11_SYM(int,XFreeGC,(Display* a,GC b),(a,b),return) SDL_X11_SYM(int,XFreeGC,(Display* a,GC b),(a,b),return)
SDL_X11_SYM(int,XFreeFontInfo,(char** a,XFontStruct* b,int c),(a,b,c),return) SDL_X11_SYM(int,XFreeFont,(Display* a, XFontStruct* b),(a,b),return)
SDL_X11_SYM(int,XFreeModifiermap,(XModifierKeymap* a),(a),return) SDL_X11_SYM(int,XFreeModifiermap,(XModifierKeymap* a),(a),return)
SDL_X11_SYM(int,XFreePixmap,(Display* a,Pixmap b),(a,b),return) SDL_X11_SYM(int,XFreePixmap,(Display* a,Pixmap b),(a,b),return)
SDL_X11_SYM(void,XFreeStringList,(char** a),(a),)
SDL_X11_SYM(char*,XGetAtomName,(Display *a,Atom b),(a,b),return) SDL_X11_SYM(char*,XGetAtomName,(Display *a,Atom b),(a,b),return)
SDL_X11_SYM(int,XGetInputFocus,(Display *a,Window *b,int *c),(a,b,c),return) SDL_X11_SYM(int,XGetInputFocus,(Display *a,Window *b,int *c),(a,b,c),return)
SDL_X11_SYM(int,XGetErrorDatabaseText,(Display* a,_Xconst char* b,_Xconst char* c,_Xconst char* d,char* e,int f),(a,b,c,d,e,f),return) SDL_X11_SYM(int,XGetErrorDatabaseText,(Display* a,_Xconst char* b,_Xconst char* c,_Xconst char* d,char* e,int f),(a,b,c,d,e,f),return)
@ -78,7 +81,7 @@ SDL_X11_SYM(char*,XKeysymToString,(KeySym a),(a),return)
SDL_X11_SYM(int,XInstallColormap,(Display* a,Colormap b),(a,b),return) SDL_X11_SYM(int,XInstallColormap,(Display* a,Colormap b),(a,b),return)
SDL_X11_SYM(Atom,XInternAtom,(Display* a,_Xconst char* b,Bool c),(a,b,c),return) SDL_X11_SYM(Atom,XInternAtom,(Display* a,_Xconst char* b,Bool c),(a,b,c),return)
SDL_X11_SYM(XPixmapFormatValues*,XListPixmapFormats,(Display* a,int* b),(a,b),return) SDL_X11_SYM(XPixmapFormatValues*,XListPixmapFormats,(Display* a,int* b),(a,b),return)
SDL_X11_SYM(Font,XLoadFont,(Display* a,_Xconst char* b),(a,b),return) SDL_X11_SYM(XFontStruct*,XLoadQueryFont,(Display* a,_Xconst char* b),(a,b),return)
SDL_X11_SYM(KeySym,XLookupKeysym,(XKeyEvent* a,int b),(a,b),return) SDL_X11_SYM(KeySym,XLookupKeysym,(XKeyEvent* a,int b),(a,b),return)
SDL_X11_SYM(int,XLookupString,(XKeyEvent* a,char* b,int c,KeySym* d,XComposeStatus* e),(a,b,c,d,e),return) SDL_X11_SYM(int,XLookupString,(XKeyEvent* a,char* b,int c,KeySym* d,XComposeStatus* e),(a,b,c,d,e),return)
SDL_X11_SYM(int,XMapRaised,(Display* a,Window b),(a,b),return) SDL_X11_SYM(int,XMapRaised,(Display* a,Window b),(a,b),return)
@ -91,7 +94,6 @@ SDL_X11_SYM(Status,XInitThreads,(void),(),return)
SDL_X11_SYM(int,XPeekEvent,(Display* a,XEvent* b),(a,b),return) SDL_X11_SYM(int,XPeekEvent,(Display* a,XEvent* b),(a,b),return)
SDL_X11_SYM(int,XPending,(Display* a),(a),return) SDL_X11_SYM(int,XPending,(Display* a),(a),return)
SDL_X11_SYM(int,XPutImage,(Display* a,Drawable b,GC c,XImage* d,int e,int f,int g,int h,unsigned int i,unsigned int j),(a,b,c,d,e,f,g,h,i,j),return) SDL_X11_SYM(int,XPutImage,(Display* a,Drawable b,GC c,XImage* d,int e,int f,int g,int h,unsigned int i,unsigned int j),(a,b,c,d,e,f,g,h,i,j),return)
SDL_X11_SYM(XFontStruct*,XQueryFont,(Display* a,XID b),(a,b),return)
SDL_X11_SYM(int,XQueryKeymap,(Display* a,char *b),(a,b),return) SDL_X11_SYM(int,XQueryKeymap,(Display* a,char *b),(a,b),return)
SDL_X11_SYM(Bool,XQueryPointer,(Display* a,Window b,Window* c,Window* d,int* e,int* f,int* g,int* h,unsigned int* i),(a,b,c,d,e,f,g,h,i),return) SDL_X11_SYM(Bool,XQueryPointer,(Display* a,Window b,Window* c,Window* d,int* e,int* f,int* g,int* h,unsigned int* i),(a,b,c,d,e,f,g,h,i),return)
SDL_X11_SYM(int,XRaiseWindow,(Display* a,Window b),(a,b),return) SDL_X11_SYM(int,XRaiseWindow,(Display* a,Window b),(a,b),return)
@ -181,6 +183,8 @@ SDL_X11_SYM(void,XSetICFocus,(XIC a),(a),)
SDL_X11_SYM(void,XUnsetICFocus,(XIC a),(a),) SDL_X11_SYM(void,XUnsetICFocus,(XIC a),(a),)
SDL_X11_SYM(XIM,XOpenIM,(Display* a,struct _XrmHashBucketRec* b,char* c,char* d),(a,b,c,d),return) SDL_X11_SYM(XIM,XOpenIM,(Display* a,struct _XrmHashBucketRec* b,char* c,char* d),(a,b,c,d),return)
SDL_X11_SYM(Status,XCloseIM,(XIM a),(a),return) SDL_X11_SYM(Status,XCloseIM,(XIM a),(a),return)
SDL_X11_SYM(void,Xutf8DrawString,(Display *a, Drawable b, XFontSet c, GC d, int e, int f, _Xconst char *g, int h),(a,b,c,d,e,f,g,h),)
SDL_X11_SYM(int,Xutf8TextExtents,(XFontSet a, _Xconst char* b, int c, XRectangle* d, XRectangle* e),(a,b,c,d,e),return)
#endif #endif
#ifndef NO_SHARED_MEMORY #ifndef NO_SHARED_MEMORY

View file

@ -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@

View file

@ -62,13 +62,13 @@ static void rwops_testParam (void)
static int rwops_testGeneric( SDL_RWops *rw, int write ) static int rwops_testGeneric( SDL_RWops *rw, int write )
{ {
char buf[sizeof(hello_world)]; char buf[sizeof(hello_world)];
int i; Sint64 i;
/* Set to start. */ /* Set to start. */
i = SDL_RWseek( rw, 0, RW_SEEK_SET ); i = SDL_RWseek( rw, 0, RW_SEEK_SET );
if (SDL_ATvassert( i == 0, if (SDL_ATvassert( i == 0,
"Seeking with SDL_RWseek (RW_SEEK_SET): got %d, expected %d", "Seeking with SDL_RWseek (RW_SEEK_SET): got %d, expected %d",
i, 0 )) (int)i, 0 ))
return 1; return 1;
/* Test write. */ /* Test write. */
@ -86,14 +86,14 @@ static int rwops_testGeneric( SDL_RWops *rw, int write )
i = SDL_RWseek( rw, 6, RW_SEEK_SET ); i = SDL_RWseek( rw, 6, RW_SEEK_SET );
if (SDL_ATvassert( i == 6, if (SDL_ATvassert( i == 6,
"Seeking with SDL_RWseek (RW_SEEK_SET): got %d, expected %d", "Seeking with SDL_RWseek (RW_SEEK_SET): got %d, expected %d",
i, 0 )) (int)i, 0 ))
return 1; return 1;
/* Test seek. */ /* Test seek. */
i = SDL_RWseek( rw, 0, RW_SEEK_SET ); i = SDL_RWseek( rw, 0, RW_SEEK_SET );
if (SDL_ATvassert( i == 0, if (SDL_ATvassert( i == 0,
"Seeking with SDL_RWseek (RW_SEEK_SET): got %d, expected %d", "Seeking with SDL_RWseek (RW_SEEK_SET): got %d, expected %d",
i, 0 )) (int)i, 0 ))
return 1; return 1;
/* Test read. */ /* Test read. */
@ -108,12 +108,12 @@ static int rwops_testGeneric( SDL_RWops *rw, int write )
i = SDL_RWseek( rw, -4, RW_SEEK_CUR ); i = SDL_RWseek( rw, -4, RW_SEEK_CUR );
if (SDL_ATvassert( i == sizeof(hello_world)-5, if (SDL_ATvassert( i == sizeof(hello_world)-5,
"Seeking with SDL_RWseek (RW_SEEK_CUR): got %d, expected %d", "Seeking with SDL_RWseek (RW_SEEK_CUR): got %d, expected %d",
i, sizeof(hello_world)-5 )) (int)i, sizeof(hello_world)-5 ))
return 1; return 1;
i = SDL_RWseek( rw, -1, RW_SEEK_END ); i = SDL_RWseek( rw, -1, RW_SEEK_END );
if (SDL_ATvassert( i == sizeof(hello_world)-2, if (SDL_ATvassert( i == sizeof(hello_world)-2,
"Seeking with SDL_RWseek (RW_SEEK_END): got %d, expected %d", "Seeking with SDL_RWseek (RW_SEEK_END): got %d, expected %d",
i, sizeof(hello_world)-2 )) (int)i, sizeof(hello_world)-2 ))
return 1; return 1;
return 0; return 0;

17
test/automated/surface/surface.c Executable file → Normal file
View file

@ -27,7 +27,7 @@
/* Testcases. */ /* Testcases. */
static void surface_testLoad( SDL_Surface *testsur ); static void surface_testLoad( SDL_Surface *testsur );
static void surface_testBlit( SDL_Surface *testsur ); static void surface_testBlit( SDL_Surface *testsur );
static int surface_testBlitBlendMode( SDL_Surface *testsur, SDL_Surface *face, int mode ); static int surface_testBlitBlendMode( SDL_Surface *testsur, SDL_Surface *face, SDL_BlendMode bMode );
static void surface_testBlitBlend( SDL_Surface *testsur ); static void surface_testBlitBlend( SDL_Surface *testsur );
@ -212,7 +212,7 @@ static void surface_testBlit( SDL_Surface *testsur )
/** /**
* @brief Tests a blend mode. * @brief Tests a blend mode.
*/ */
static int surface_testBlitBlendMode( SDL_Surface *testsur, SDL_Surface *face, int mode ) static int surface_testBlitBlendMode( SDL_Surface *testsur, SDL_Surface *face, SDL_BlendMode bMode )
{ {
int ret; int ret;
int i, j, ni, nj; int i, j, ni, nj;
@ -236,7 +236,7 @@ static int surface_testBlitBlendMode( SDL_Surface *testsur, SDL_Surface *face, i
for (j=0; j <= nj; j+=4) { for (j=0; j <= nj; j+=4) {
for (i=0; i <= ni; i+=4) { for (i=0; i <= ni; i+=4) {
/* Set blend mode. */ /* Set blend mode. */
ret = SDL_SetSurfaceBlendMode( face, mode ); ret = SDL_SetSurfaceBlendMode( face, bMode );
if (SDL_ATassert( "SDL_SetSurfaceBlendMode", ret == 0)) if (SDL_ATassert( "SDL_SetSurfaceBlendMode", ret == 0))
return 1; return 1;
@ -263,6 +263,7 @@ static void surface_testBlitBlend( SDL_Surface *testsur )
SDL_Surface *face; SDL_Surface *face;
int i, j, ni, nj; int i, j, ni, nj;
int mode; int mode;
SDL_BlendMode bMode;
SDL_ATbegin( "Blit Blending Tests" ); SDL_ATbegin( "Blit Blending Tests" );
@ -353,11 +354,11 @@ static void surface_testBlitBlend( SDL_Surface *testsur )
/* Crazy blending mode magic. */ /* Crazy blending mode magic. */
mode = (i/4*j/4) % 4; mode = (i/4*j/4) % 4;
if (mode==0) mode = SDL_BLENDMODE_NONE; if (mode==0) bMode = SDL_BLENDMODE_NONE;
else if (mode==1) mode = SDL_BLENDMODE_BLEND; else if (mode==1) bMode = SDL_BLENDMODE_BLEND;
else if (mode==2) mode = SDL_BLENDMODE_ADD; else if (mode==2) bMode = SDL_BLENDMODE_ADD;
else if (mode==3) mode = SDL_BLENDMODE_MOD; else if (mode==3) bMode = SDL_BLENDMODE_MOD;
ret = SDL_SetSurfaceBlendMode( face, mode ); ret = SDL_SetSurfaceBlendMode( face, bMode );
if (SDL_ATassert( "SDL_SetSurfaceBlendMode", ret == 0)) if (SDL_ATassert( "SDL_SetSurfaceBlendMode", ret == 0))
return; return;

4246
test/configure vendored

File diff suppressed because it is too large Load diff

View file

@ -78,6 +78,7 @@ poked(int sig)
int int
main(int argc, char *argv[]) main(int argc, char *argv[])
{ {
int i;
char filename[4096]; char filename[4096];
/* Load the SDL library */ /* Load the SDL library */
@ -110,6 +111,17 @@ main(int argc, char *argv[])
signal(SIGTERM, poked); signal(SIGTERM, poked);
#endif /* HAVE_SIGNAL_H */ #endif /* HAVE_SIGNAL_H */
/* Show the list of available drivers */
printf("Available audio drivers: ");
for (i = 0; i < SDL_GetNumAudioDrivers(); ++i) {
if (i == 0) {
printf("%s", SDL_GetAudioDriver(i));
} else {
printf(", %s", SDL_GetAudioDriver(i));
}
}
printf("\n");
/* Initialize fillerup() variables */ /* Initialize fillerup() variables */
if (SDL_OpenAudio(&wave.spec, NULL) < 0) { if (SDL_OpenAudio(&wave.spec, NULL) < 0) {
fprintf(stderr, "Couldn't open audio: %s\n", SDL_GetError()); fprintf(stderr, "Couldn't open audio: %s\n", SDL_GetError());
@ -130,3 +142,5 @@ main(int argc, char *argv[])
SDL_Quit(); SDL_Quit();
return (0); return (0);
} }
/* vi: set ts=4 sw=4 expandtab: */

0
test/nds-test-progs/general/source/main.c Executable file → Normal file
View file

113
test/testautomation.c Normal file
View file

@ -0,0 +1,113 @@
/*
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.
*/
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include "SDL.h"
#include "SDL_test.h"
#include "tests/testsuites.h"
static SDLTest_CommonState *state;
/* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */
static void
quit(int rc)
{
SDLTest_CommonQuit(state);
exit(rc);
}
int
main(int argc, char *argv[])
{
int result;
int testIterations = 1;
Uint64 userExecKey = 0;
char *userRunSeed = NULL;
int i;
/* Initialize test framework */
state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO);
if (!state) {
return 1;
}
// Needed?
// state->window_flags |= SDL_WINDOW_RESIZABLE;
/* Parse commandline */
for (i = 1; i < argc;) {
int consumed;
consumed = SDLTest_CommonArg(state, i);
if (consumed == 0) {
consumed = -1;
if (SDL_strcasecmp(argv[i], "--iterations") == 0) {
if (argv[i + 1]) {
testIterations = SDL_atoi(argv[i + 1]);
if (testIterations < 1) testIterations = 1;
consumed = 2;
}
}
else if (SDL_strcasecmp(argv[i], "--execKey") == 0) {
if (argv[i + 1]) {
SDL_sscanf(argv[i + 1], "%llu", &userExecKey);
consumed = 2;
}
}
else if (SDL_strcasecmp(argv[i], "--seed") == 0) {
if (argv[i + 1]) {
userRunSeed = SDL_strdup(argv[i + 1]);
consumed = 2;
}
}
}
if (consumed < 0) {
fprintf(stderr,
"Usage: %s %s [--iterations #] [--execKey #] [--seed string]\n",
argv[0], SDLTest_CommonUsage(state));
quit(1);
}
i += consumed;
}
/* Initialize common state */
if (!SDLTest_CommonInit(state)) {
quit(2);
}
/* Create the windows, initialize the renderers */
for (i = 0; i < state->num_windows; ++i) {
SDL_Renderer *renderer = state->renderers[i];
SDL_SetRenderDrawColor(renderer, 0xFF, 0xFF, 0xFF, 0xFF);
SDL_RenderClear(renderer);
}
/* Call Harness */
result = SDLTest_RunSuites(testSuites, userRunSeed, userExecKey, testIterations);
/* Clean up */
if (userRunSeed != NULL) {
SDL_free(userRunSeed);
}
/* Shutdown everything */
quit(result);
return(result);
}
/* vi: set ts=4 sw=4 expandtab: */

205
test/testgamecontroller.c Normal file
View 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);
}

View file

@ -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
@ -32,21 +36,41 @@ DrawRect(SDL_Renderer *r, const int x, const int y, const int w, const int h)
SDL_RenderFillRect(r, &area); SDL_RenderFillRect(r, &area);
} }
void static SDL_bool
WatchJoystick(SDL_Joystick * joystick) 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; SDL_bool retval = SDL_FALSE;
SDL_bool done = SDL_FALSE;
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 SDL_FALSE;
}
screen = SDL_CreateRenderer(window, -1, 0);
if (screen == NULL) {
fprintf(stderr, "Couldn't create renderer: %s\n", SDL_GetError());
SDL_DestroyWindow(window);
return SDL_FALSE;
}
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 +78,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:
@ -95,152 +123,149 @@ WatchJoystick(SDL_Joystick * joystick)
} }
/* Fall through to signal quit */ /* Fall through to signal quit */
case SDL_QUIT: case SDL_QUIT:
done = 1; done = SDL_TRUE;
break; break;
default: default:
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) {
DrawRect(screen, i * 34, SCREEN_HEIGHT - 34, 32, 32);
}
}
/* Erase previous axes */ SDL_SetRenderDrawColor(screen, 0xFF, 0x00, 0x00, SDL_ALPHA_OPAQUE);
SDL_SetRenderDrawColor(screen, 0x00, 0x00, 0x00, SDL_ALPHA_OPAQUE); for (i = 0; i < SDL_JoystickNumAxes(joystick) / 2; ++i) {
SDL_RenderClear(screen); /* Draw the X/Y axis */
int x, y;
/* Query the sizes */ x = (((int) SDL_JoystickGetAxis(joystick, i * 2 + 0)) + 32768);
SDL_RenderGetViewport(screen, &viewport); x *= SCREEN_WIDTH;
x /= 65535;
SDL_SetRenderDrawColor(screen, 0x00, 0xFF, 0x00, SDL_ALPHA_OPAQUE); if (x < 0) {
for (i = 0; i < SDL_JoystickNumButtons(joystick); ++i) { x = 0;
if (SDL_JoystickGetButton(joystick, i) == SDL_PRESSED) { } else if (x > (SCREEN_WIDTH - 16)) {
DrawRect(screen, i * 34, viewport.h - 34, 32, 32); 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;
} }
SDL_SetRenderDrawColor(screen, 0xFF, 0x00, 0x00, SDL_ALPHA_OPAQUE); DrawRect(screen, x, y, 16, 16);
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 = 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;
} }
SDL_SetRenderDrawColor(screen, 0x00, 0x00, 0xFF, SDL_ALPHA_OPAQUE); if (hat_pos & SDL_HAT_LEFT) {
for (i = 0; i < SDL_JoystickNumHats(joystick); ++i) { x = 0;
/* Derive the new position */ } else if (hat_pos & SDL_HAT_RIGHT) {
int x = viewport.w/2; x = SCREEN_WIDTH-8;
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); DrawRect(screen, x, y, 8, 8);
}
SDL_RenderPresent(screen);
if (SDL_JoystickGetAttached( joystick ) == 0) {
done = SDL_TRUE;
retval = SDL_TRUE; /* keep going, wait for reattach. */
} }
} }
SDL_DestroyRenderer(screen);
SDL_DestroyWindow(window);
return retval;
} }
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) {
fprintf(stderr, "SDL_JoystickOpen(%d) failed: %s\n", i, fprintf(stderr, "SDL_JoystickOpen(%d) failed: %s\n", i,
SDL_GetError()); SDL_GetError());
} else { } else {
char guid[64];
SDL_JoystickGetGUIDString(SDL_JoystickGetGUID(joystick),
guid, sizeof (guid));
printf(" axes: %d\n", SDL_JoystickNumAxes(joystick)); printf(" axes: %d\n", SDL_JoystickNumAxes(joystick));
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));
printf(" guid: %s\n", guid);
SDL_JoystickClose(joystick); SDL_JoystickClose(joystick);
} }
} }
for (i = 1; i < argc;) { if (argv[1]) {
int consumed; SDL_bool reportederror = SDL_FALSE;
SDL_bool keepGoing = SDL_TRUE;
SDL_Event event;
joystick = SDL_JoystickOpen(atoi(argv[1]));
while ( keepGoing ) {
if (joystick == NULL) {
if ( !reportederror ) {
printf("Couldn't open joystick %d: %s\n", atoi(argv[1]), SDL_GetError());
keepGoing = SDL_FALSE;
reportederror = SDL_TRUE;
}
} else {
reportederror = SDL_FALSE;
keepGoing = WatchJoystick(joystick);
SDL_JoystickClose(joystick);
}
consumed = CommonArg(state, i); joystick = NULL;
if (consumed == 0) { if (keepGoing) {
consumed = -1; printf("Waiting for attach\n");
if (SDL_isdigit(*argv[i])) { }
joy = SDL_atoi(argv[i]); while (keepGoing) {
consumed = 1; SDL_WaitEvent(&event);
if (event.type == SDL_QUIT) {
keepGoing = SDL_FALSE;
} else if (event.type == SDL_JOYDEVICEADDED) {
joystick = SDL_JoystickOpen(atoi(argv[1]));
break;
}
} }
} }
if (consumed < 0) {
return 1;
}
i += consumed;
}
if (!CommonInit(state)) {
return 2;
} }
SDL_QuitSubSystem(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK);
if (joy > -1) { return 0;
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);
} }

View file

@ -49,6 +49,35 @@ main(int argc, char *argv[])
quit(1); quit(1);
} }
success = SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR,
"Simple MessageBox",
"This is a simple MessageBox with a newline:\r\nHello world!",
NULL);
if (success == -1) {
printf("Error Presenting MessageBox: %s\n", SDL_GetError());
quit(1);
}
/* Google says this is Traditional Chinese for "beef with broccoli" */
success = SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR,
"UTF-8 Simple MessageBox",
"Unicode text: '牛肉西蘭花' ...",
NULL);
if (success == -1) {
printf("Error Presenting MessageBox: %s\n", SDL_GetError());
quit(1);
}
/* Google says this is Traditional Chinese for "beef with broccoli" */
success = SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR,
"UTF-8 Simple MessageBox",
"Unicode text and newline:\r\n'牛肉西蘭花'\n'牛肉西蘭花'",
NULL);
if (success == -1) {
printf("Error Presenting MessageBox: %s\n", SDL_GetError());
quit(1);
}
{ {
const SDL_MessageBoxButtonData buttons[] = { const SDL_MessageBoxButtonData buttons[] = {
{ {

561
test/tests/testplatform.c Normal file
View file

@ -0,0 +1,561 @@
/**
* Original code: automated SDL platform test written by Edgar Simo "bobbens"
* Extended and updated by aschiffler at ferzkopp dot net
*/
#include <stdio.h>
#include "SDL.h"
#include "SDL_test.h"
/* ================= Test Case Implementation ================== */
/* Helper functions */
/**
* @brief Compare sizes of types.
*
* @note Watcom C flags these as Warning 201: "Unreachable code" if you just
* compare them directly, so we push it through a function to keep the
* compiler quiet. --ryan.
*/
static int _compareSizeOfType( size_t sizeoftype, size_t hardcodetype )
{
return sizeoftype != hardcodetype;
}
/* Test case functions */
/**
* @brief Tests type sizes.
*/
int platform_testTypes(void *arg)
{
int ret;
ret = _compareSizeOfType( sizeof(Uint8), 1 );
SDLTest_AssertCheck( ret == 0, "sizeof(Uint8) = %lu, expected 1", sizeof(Uint8) );
ret = _compareSizeOfType( sizeof(Uint16), 2 );
SDLTest_AssertCheck( ret == 0, "sizeof(Uint16) = %lu, expected 2", sizeof(Uint16) );
ret = _compareSizeOfType( sizeof(Uint32), 4 );
SDLTest_AssertCheck( ret == 0, "sizeof(Uint32) = %lu, expected 4", sizeof(Uint32) );
ret = _compareSizeOfType( sizeof(Uint64), 8 );
SDLTest_AssertCheck( ret == 0, "sizeof(Uint64) = %lu, expected 8", sizeof(Uint64) );
return TEST_COMPLETED;
}
/**
* @brief Tests platform endianness and SDL_SwapXY functions.
*/
int platform_testEndianessAndSwap(void *arg)
{
int real_byteorder;
Uint16 value = 0x1234;
Uint16 value16 = 0xCDAB;
Uint16 swapped16 = 0xABCD;
Uint32 value32 = 0xEFBEADDE;
Uint32 swapped32 = 0xDEADBEEF;
Uint64 value64, swapped64;
value64 = 0xEFBEADDE;
value64 <<= 32;
value64 |= 0xCDAB3412;
swapped64 = 0x1234ABCD;
swapped64 <<= 32;
swapped64 |= 0xDEADBEEF;
if ((*((char *) &value) >> 4) == 0x1) {
real_byteorder = SDL_BIG_ENDIAN;
} else {
real_byteorder = SDL_LIL_ENDIAN;
}
/* Test endianness. */
SDLTest_AssertCheck( real_byteorder == SDL_BYTEORDER,
"Machine detected as %s endian, appears to be %s endian.",
(SDL_BYTEORDER == SDL_LIL_ENDIAN) ? "little" : "big",
(real_byteorder == SDL_LIL_ENDIAN) ? "little" : "big" );
/* Test 16 swap. */
SDLTest_AssertCheck( SDL_Swap16(value16) == swapped16,
"SDL_Swap16(): 16 bit swapped: 0x%X => 0x%X",
value16, SDL_Swap16(value16) );
/* Test 32 swap. */
SDLTest_AssertCheck( SDL_Swap32(value32) == swapped32,
"SDL_Swap32(): 32 bit swapped: 0x%X => 0x%X",
value32, SDL_Swap32(value32) );
/* Test 64 swap. */
SDLTest_AssertCheck( SDL_Swap64(value64) == swapped64,
#ifdef _MSC_VER
"SDL_Swap64(): 64 bit swapped: 0x%I64X => 0x%I64X",
#else
"SDL_Swap64(): 64 bit swapped: 0x%llX => 0x%llX",
#endif
value64, SDL_Swap64(value64) );
return TEST_COMPLETED;
}
/*!
* \brief Tests SDL_GetXYZ() functions
* \sa
* http://wiki.libsdl.org/moin.cgi/SDL_GetPlatform
* http://wiki.libsdl.org/moin.cgi/SDL_GetCPUCount
* http://wiki.libsdl.org/moin.cgi/SDL_GetCPUCacheLineSize
* http://wiki.libsdl.org/moin.cgi/SDL_GetRevision
* http://wiki.libsdl.org/moin.cgi/SDL_GetRevisionNumber
*/
int platform_testGetFunctions (void *arg)
{
char *platform;
char *revision;
int ret;
int len;
platform = (char *)SDL_GetPlatform();
SDLTest_AssertPass("SDL_GetPlatform()");
SDLTest_AssertCheck(platform != NULL, "SDL_GetPlatform() != NULL");
if (platform != NULL) {
len = strlen(platform);
SDLTest_AssertCheck(len > 0,
"SDL_GetPlatform(): expected non-empty platform, was platform: '%s', len: %i",
platform,
len);
}
ret = SDL_GetCPUCount();
SDLTest_AssertPass("SDL_GetCPUCount()");
SDLTest_AssertCheck(ret > 0,
"SDL_GetCPUCount(): expected count > 0, was: %i",
ret);
ret = SDL_GetCPUCacheLineSize();
SDLTest_AssertPass("SDL_GetCPUCacheLineSize()");
SDLTest_AssertCheck(ret >= 0,
"SDL_GetCPUCacheLineSize(): expected size >= 0, was: %i",
ret);
revision = (char *)SDL_GetRevision();
SDLTest_AssertPass("SDL_GetRevision()");
SDLTest_AssertCheck(revision != NULL, "SDL_GetRevision() != NULL");
ret = SDL_GetRevisionNumber();
SDLTest_AssertPass("SDL_GetRevisionNumber()");
return TEST_COMPLETED;
}
/*!
* \brief Tests SDL_HasXYZ() functions
* \sa
* http://wiki.libsdl.org/moin.cgi/SDL_Has3DNow
* http://wiki.libsdl.org/moin.cgi/SDL_HasAltiVec
* http://wiki.libsdl.org/moin.cgi/SDL_HasMMX
* http://wiki.libsdl.org/moin.cgi/SDL_HasRDTSC
* http://wiki.libsdl.org/moin.cgi/SDL_HasSSE
* http://wiki.libsdl.org/moin.cgi/SDL_HasSSE2
* http://wiki.libsdl.org/moin.cgi/SDL_HasSSE3
* http://wiki.libsdl.org/moin.cgi/SDL_HasSSE41
* http://wiki.libsdl.org/moin.cgi/SDL_HasSSE42
*/
int platform_testHasFunctions (void *arg)
{
int ret;
// TODO: independently determine and compare values as well
ret = SDL_HasRDTSC();
SDLTest_AssertPass("SDL_HasRDTSC()");
ret = SDL_HasAltiVec();
SDLTest_AssertPass("SDL_HasAltiVec()");
ret = SDL_HasMMX();
SDLTest_AssertPass("SDL_HasMMX()");
ret = SDL_Has3DNow();
SDLTest_AssertPass("SDL_Has3DNow()");
ret = SDL_HasSSE();
SDLTest_AssertPass("SDL_HasSSE()");
ret = SDL_HasSSE2();
SDLTest_AssertPass("SDL_HasSSE2()");
ret = SDL_HasSSE3();
SDLTest_AssertPass("SDL_HasSSE3()");
ret = SDL_HasSSE41();
SDLTest_AssertPass("SDL_HasSSE41()");
ret = SDL_HasSSE42();
SDLTest_AssertPass("SDL_HasSSE42()");
return TEST_COMPLETED;
}
/*!
* \brief Tests SDL_GetVersion
* \sa
* http://wiki.libsdl.org/moin.cgi/SDL_GetVersion
*/
int platform_testGetVersion(void *arg)
{
SDL_version linked;
int major = SDL_MAJOR_VERSION;
int minor = SDL_MINOR_VERSION;
SDL_GetVersion(&linked);
SDLTest_AssertCheck( linked.major >= major,
"SDL_GetVersion(): returned major %i (>= %i)",
linked.major,
major);
SDLTest_AssertCheck( linked.minor >= minor,
"SDL_GetVersion(): returned minor %i (>= %i)",
linked.minor,
minor);
return TEST_COMPLETED;
}
/*!
* \brief Tests SDL_VERSION macro
*/
int platform_testSDLVersion(void *arg)
{
SDL_version compiled;
int major = SDL_MAJOR_VERSION;
int minor = SDL_MINOR_VERSION;
SDL_VERSION(&compiled);
SDLTest_AssertCheck( compiled.major >= major,
"SDL_VERSION() returned major %i (>= %i)",
compiled.major,
major);
SDLTest_AssertCheck( compiled.minor >= minor,
"SDL_VERSION() returned minor %i (>= %i)",
compiled.minor,
minor);
return TEST_COMPLETED;
}
/*!
* \brief Tests default SDL_Init
*/
int platform_testDefaultInit(void *arg)
{
int ret;
int subsystem;
subsystem = SDL_WasInit(SDL_INIT_EVERYTHING);
SDLTest_AssertCheck( subsystem != 0,
"SDL_WasInit(0): returned %i, expected != 0",
subsystem);
ret = SDL_Init(SDL_WasInit(SDL_INIT_EVERYTHING));
SDLTest_AssertCheck( ret == 0,
"SDL_Init(0): returned %i, expected 0, error: %s",
ret,
SDL_GetError());
return TEST_COMPLETED;
}
/*!
* \brief Tests SDL_Get/Set/ClearError
* \sa
* http://wiki.libsdl.org/moin.cgi/SDL_GetError
* http://wiki.libsdl.org/moin.cgi/SDL_SetError
* http://wiki.libsdl.org/moin.cgi/SDL_ClearError
*/
int platform_testGetSetClearError(void *arg)
{
const char *testError = "Testing";
char *lastError;
int len;
SDL_ClearError();
SDLTest_AssertPass("SDL_ClearError()");
lastError = (char *)SDL_GetError();
SDLTest_AssertPass("SDL_GetError()");
SDLTest_AssertCheck(lastError != NULL,
"SDL_GetError() != NULL");
if (lastError != NULL)
{
len = strlen(lastError);
SDLTest_AssertCheck(len == 0,
"SDL_GetError(): no message expected, len: %i", len);
}
SDL_SetError("%s", testError);
SDLTest_AssertPass("SDL_SetError()");
lastError = (char *)SDL_GetError();
SDLTest_AssertCheck(lastError != NULL,
"SDL_GetError() != NULL");
if (lastError != NULL)
{
len = strlen(lastError);
SDLTest_AssertCheck(len == strlen(testError),
"SDL_GetError(): expected message len %i, was len: %i",
strlen(testError),
len);
SDLTest_AssertCheck(strcmp(lastError, testError) == 0,
"SDL_GetError(): expected message %s, was message: %s",
testError,
lastError);
}
// Clean up
SDL_ClearError();
SDLTest_AssertPass("SDL_ClearError()");
return TEST_COMPLETED;
}
/*!
* \brief Tests SDL_SetError with empty input
* \sa
* http://wiki.libsdl.org/moin.cgi/SDL_SetError
*/
int platform_testSetErrorEmptyInput(void *arg)
{
const char *testError = "";
char *lastError;
int len;
SDL_SetError("%s", testError);
SDLTest_AssertPass("SDL_SetError()");
lastError = (char *)SDL_GetError();
SDLTest_AssertCheck(lastError != NULL,
"SDL_GetError() != NULL");
if (lastError != NULL)
{
len = strlen(lastError);
SDLTest_AssertCheck(len == strlen(testError),
"SDL_GetError(): expected message len %i, was len: %i",
strlen(testError),
len);
SDLTest_AssertCheck(strcmp(lastError, testError) == 0,
"SDL_GetError(): expected message '%s', was message: '%s'",
testError,
lastError);
}
// Clean up
SDL_ClearError();
SDLTest_AssertPass("SDL_ClearError()");
return TEST_COMPLETED;
}
/*!
* \brief Tests SDL_SetError with invalid input
* \sa
* http://wiki.libsdl.org/moin.cgi/SDL_SetError
*/
int platform_testSetErrorInvalidInput(void *arg)
{
const char *testError = NULL;
const char *probeError = "Testing";
char *lastError;
int len;
// Reset
SDL_ClearError();
SDLTest_AssertPass("SDL_ClearError()");
// Check for no-op
SDL_SetError(testError);
SDLTest_AssertPass("SDL_SetError()");
lastError = (char *)SDL_GetError();
SDLTest_AssertCheck(lastError != NULL,
"SDL_GetError() != NULL");
if (lastError != NULL)
{
len = strlen(lastError);
SDLTest_AssertCheck(len == 0,
"SDL_GetError(): expected message len 0, was len: %i",
0,
len);
SDLTest_AssertCheck(strcmp(lastError, "") == 0,
"SDL_GetError(): expected message '', was message: '%s'",
lastError);
}
// Set
SDL_SetError(probeError);
SDLTest_AssertPass("SDL_SetError()");
// Check for no-op
SDL_SetError(testError);
SDLTest_AssertPass("SDL_SetError()");
lastError = (char *)SDL_GetError();
SDLTest_AssertCheck(lastError != NULL,
"SDL_GetError() != NULL");
if (lastError != NULL)
{
len = strlen(lastError);
SDLTest_AssertCheck(len == strlen(probeError),
"SDL_GetError(): expected message len %i, was len: %i",
strlen(probeError),
len);
SDLTest_AssertCheck(strcmp(lastError, probeError) == 0,
"SDL_GetError(): expected message '%s', was message: '%s'",
probeError,
lastError);
}
// Clean up
SDL_ClearError();
SDLTest_AssertPass("SDL_ClearError()");
return TEST_COMPLETED;
}
/*!
* \brief Tests SDL_GetPowerInfo
* \sa
* http://wiki.libsdl.org/moin.cgi/SDL_GetPowerInfo
*/
int platform_testGetPowerInfo(void *arg)
{
SDL_PowerState state;
SDL_PowerState stateAgain;
int secs;
int secsAgain;
int pct;
int pctAgain;
state = SDL_GetPowerInfo(&secs, &pct);
SDLTest_AssertPass("SDL_GetPowerInfo()");
SDLTest_AssertCheck(
state==SDL_POWERSTATE_UNKNOWN ||
state==SDL_POWERSTATE_ON_BATTERY ||
state==SDL_POWERSTATE_NO_BATTERY ||
state==SDL_POWERSTATE_CHARGING ||
state==SDL_POWERSTATE_CHARGED,
"SDL_GetPowerInfo(): state %i is one of the expected values",
(int)state);
if (state==SDL_POWERSTATE_ON_BATTERY)
{
SDLTest_AssertCheck(
secs >= 0,
"SDL_GetPowerInfo(): on battery, secs >= 0, was: %i",
secs);
SDLTest_AssertCheck(
(pct >= 0) && (pct <= 100),
"SDL_GetPowerInfo(): on battery, pct=[0,100], was: %i",
pct);
}
if (state==SDL_POWERSTATE_UNKNOWN ||
state==SDL_POWERSTATE_NO_BATTERY)
{
SDLTest_AssertCheck(
secs == -1,
"SDL_GetPowerInfo(): no battery, secs == -1, was: %i",
secs);
SDLTest_AssertCheck(
pct == -1,
"SDL_GetPowerInfo(): no battery, pct == -1, was: %i",
pct);
}
// Partial return value variations
stateAgain = SDL_GetPowerInfo(&secsAgain, NULL);
SDLTest_AssertCheck(
state==stateAgain,
"State %i returned when only 'secs' requested",
stateAgain);
SDLTest_AssertCheck(
secs==secsAgain,
"Value %i matches when only 'secs' requested",
secsAgain);
stateAgain = SDL_GetPowerInfo(NULL, &pctAgain);
SDLTest_AssertCheck(
state==stateAgain,
"State %i returned when only 'pct' requested",
stateAgain);
SDLTest_AssertCheck(
pct==pctAgain,
"Value %i matches when only 'pct' requested",
pctAgain);
stateAgain = SDL_GetPowerInfo(NULL, NULL);
SDLTest_AssertCheck(
state==stateAgain,
"State %i returned when no value requested",
stateAgain);
return TEST_COMPLETED;
}
/* ================= Test References ================== */
/* Platform test cases */
static const SDLTest_TestCaseReference platformTest1 =
{ (SDLTest_TestCaseFp)platform_testTypes, "platform_testTypes", "Tests predefined types", TEST_ENABLED};
static const SDLTest_TestCaseReference platformTest2 =
{ (SDLTest_TestCaseFp)platform_testEndianessAndSwap, "platform_testEndianessAndSwap", "Tests endianess and swap functions", TEST_ENABLED};
static const SDLTest_TestCaseReference platformTest3 =
{ (SDLTest_TestCaseFp)platform_testGetFunctions, "platform_testGetFunctions", "Tests various SDL_GetXYZ functions", TEST_ENABLED};
static const SDLTest_TestCaseReference platformTest4 =
{ (SDLTest_TestCaseFp)platform_testHasFunctions, "platform_testHasFunctions", "Tests various SDL_HasXYZ functions", TEST_ENABLED};
static const SDLTest_TestCaseReference platformTest5 =
{ (SDLTest_TestCaseFp)platform_testGetVersion, "platform_testGetVersion", "Tests SDL_GetVersion function", TEST_ENABLED};
static const SDLTest_TestCaseReference platformTest6 =
{ (SDLTest_TestCaseFp)platform_testSDLVersion, "platform_testSDLVersion", "Tests SDL_VERSION macro", TEST_ENABLED};
static const SDLTest_TestCaseReference platformTest7 =
{ (SDLTest_TestCaseFp)platform_testDefaultInit, "platform_testDefaultInit", "Tests default SDL_Init", TEST_ENABLED};
static const SDLTest_TestCaseReference platformTest8 =
{ (SDLTest_TestCaseFp)platform_testGetSetClearError, "platform_testGetSetClearError", "Tests SDL_Get/Set/ClearError", TEST_ENABLED};
static const SDLTest_TestCaseReference platformTest9 =
{ (SDLTest_TestCaseFp)platform_testSetErrorEmptyInput, "platform_testSetErrorEmptyInput", "Tests SDL_SetError with empty input", TEST_ENABLED};
static const SDLTest_TestCaseReference platformTest10 =
{ (SDLTest_TestCaseFp)platform_testSetErrorInvalidInput, "platform_testSetErrorInvalidInput", "Tests SDL_SetError with invalid input", TEST_ENABLED};
static const SDLTest_TestCaseReference platformTest11 =
{ (SDLTest_TestCaseFp)platform_testGetPowerInfo, "platform_testGetPowerInfo", "Tests SDL_GetPowerInfo function", TEST_ENABLED };
/* Sequence of Platform test cases */
static const SDLTest_TestCaseReference *platformTests[] = {
&platformTest1,
&platformTest2,
&platformTest3,
&platformTest4,
&platformTest5,
&platformTest6,
&platformTest7,
&platformTest8,
&platformTest9,
&platformTest10,
&platformTest11,
NULL
};
/* Platform test suite (global) */
SDLTest_TestSuiteReference platformTestSuite = {
"Platform",
NULL,
platformTests,
NULL
};

1677
test/tests/testrect.c Normal file

File diff suppressed because it is too large Load diff

40
test/tests/testsuites.h Normal file
View file

@ -0,0 +1,40 @@
/**
* Reference to all test suites.
*
*/
#ifndef _testsuites_h
#define _testsuites_h
#include "SDL_test.h"
// Test collections
//extern SDLTest_TestSuiteReference audioTestSuite;
//extern SDLTest_TestSuiteReference clipboardTestSuite;
//extern SDLTest_TestSuiteReference eventsTestSuite;
//extern SDLTest_TestSuiteReference keyboardTestSuite;
extern SDLTest_TestSuiteReference platformTestSuite;
extern SDLTest_TestSuiteReference rectTestSuite;
//extern SDLTest_TestSuiteReference renderTestSuite;
//extern SDLTest_TestSuiteReference rwopsTestSuite;
//extern SDLTest_TestSuiteReference surfaceTestSuite;
//extern SDLTest_TestSuiteReference syswmTestSuite;
//extern SDLTest_TestSuiteReference videoTestSuite;
// All test suites
SDLTest_TestSuiteReference *testSuites[] = {
// &audioTestSuite,
// &clipboardTestSuite,
// &eventsTestSuite,
// &keyboardTestSuite,
&platformTestSuite,
&rectTestSuite,
// &renderTestSuite,
// &rwopsTestSuite,
// &surfaceTestSuite,
// &syswmTestSuite,
// &videoTestSuite,
NULL
};
#endif