Fixed bug #925
authorSam Lantinga <slouken@libsdl.org>
Thu, 20 Jan 2011 18:04:05 -0800
changeset 5062e8916fe9cfc8
parent 5061 9e9940eae455
child 5063 5680976fb37a
Fixed bug #925

Changed "win32" to "windows"
VisualC/SDL/SDL_VS2005.vcproj
VisualC/SDL/SDL_VS2008.vcproj
VisualC/SDL/SDL_VS2010.vcxproj
VisualC/SDLmain/SDLmain_VS2005.vcproj
VisualC/SDLmain/SDLmain_VS2008.vcproj
VisualC/SDLmain/SDLmain_VS2010.vcxproj
configure.in
include/SDL_compat.h
include/SDL_config.h.default
include/SDL_config.h.in
include/SDL_config_win32.h
include/SDL_config_windows.h
include/SDL_main.h
include/SDL_opengl.h
include/SDL_platform.h
include/SDL_rwops.h
include/SDL_syswm.h
include/SDL_thread.h
include/begin_code.h
src/SDL.c
src/audio/SDL_audio.c
src/cpuinfo/SDL_cpuinfo.c
src/events/SDL_events.c
src/events/SDL_sysevents.h
src/events/scancodes_win32.h
src/events/scancodes_windows.h
src/file/SDL_rwops.c
src/haptic/win32/SDL_syshaptic.c
src/haptic/windows/SDL_syshaptic.c
src/joystick/win32/SDL_dxjoystick.c
src/joystick/win32/SDL_dxjoystick_c.h
src/joystick/win32/SDL_mmjoystick.c
src/joystick/windows/SDL_dxjoystick.c
src/joystick/windows/SDL_dxjoystick_c.h
src/joystick/windows/SDL_mmjoystick.c
src/loadso/win32/SDL_sysloadso.c
src/loadso/windows/SDL_sysloadso.c
src/main/win32/SDL_win32_main.c
src/main/win32/version.rc
src/main/windows/SDL_windows_main.c
src/main/windows/version.rc
src/stdlib/SDL_getenv.c
src/thread/SDL_thread_c.h
src/thread/win32/SDL_sysmutex.c
src/thread/win32/SDL_syssem.c
src/thread/win32/SDL_systhread.c
src/thread/win32/SDL_systhread_c.h
src/thread/win32/win_ce_semaphore.c
src/thread/win32/win_ce_semaphore.h
src/thread/windows/SDL_sysmutex.c
src/thread/windows/SDL_syssem.c
src/thread/windows/SDL_systhread.c
src/thread/windows/SDL_systhread_c.h
src/thread/windows/win_ce_semaphore.c
src/thread/windows/win_ce_semaphore.h
src/timer/win32/SDL_systimer.c
src/timer/windows/SDL_systimer.c
src/video/SDL_renderer_gl.c
src/video/SDL_sysvideo.h
src/video/SDL_video.c
src/video/win32/SDL_ceddrawrender.c
src/video/win32/SDL_ceddrawrender.h
src/video/win32/SDL_d3drender.c
src/video/win32/SDL_d3drender.h
src/video/win32/SDL_gapirender.c
src/video/win32/SDL_gapirender.h
src/video/win32/SDL_gapirender_c.h
src/video/win32/SDL_gdirender.c
src/video/win32/SDL_gdirender.h
src/video/win32/SDL_msctf.h
src/video/win32/SDL_vkeys.h
src/video/win32/SDL_win32clipboard.c
src/video/win32/SDL_win32clipboard.h
src/video/win32/SDL_win32events.c
src/video/win32/SDL_win32events.h
src/video/win32/SDL_win32gamma.c
src/video/win32/SDL_win32gamma.h
src/video/win32/SDL_win32keyboard.c
src/video/win32/SDL_win32keyboard.h
src/video/win32/SDL_win32modes.c
src/video/win32/SDL_win32modes.h
src/video/win32/SDL_win32mouse.c
src/video/win32/SDL_win32mouse.h
src/video/win32/SDL_win32opengl.c
src/video/win32/SDL_win32opengl.h
src/video/win32/SDL_win32shape.c
src/video/win32/SDL_win32shape.h
src/video/win32/SDL_win32video.c
src/video/win32/SDL_win32video.h
src/video/win32/SDL_win32window.c
src/video/win32/SDL_win32window.h
src/video/win32/wmmsg.h
src/video/windows/SDL_ceddrawrender.c
src/video/windows/SDL_ceddrawrender.h
src/video/windows/SDL_d3drender.c
src/video/windows/SDL_d3drender.h
src/video/windows/SDL_gapirender.c
src/video/windows/SDL_gapirender.h
src/video/windows/SDL_gapirender_c.h
src/video/windows/SDL_gdirender.c
src/video/windows/SDL_gdirender.h
src/video/windows/SDL_msctf.h
src/video/windows/SDL_vkeys.h
src/video/windows/SDL_windowsclipboard.c
src/video/windows/SDL_windowsclipboard.h
src/video/windows/SDL_windowsevents.c
src/video/windows/SDL_windowsevents.h
src/video/windows/SDL_windowsgamma.c
src/video/windows/SDL_windowsgamma.h
src/video/windows/SDL_windowskeyboard.c
src/video/windows/SDL_windowskeyboard.h
src/video/windows/SDL_windowsmodes.c
src/video/windows/SDL_windowsmodes.h
src/video/windows/SDL_windowsmouse.c
src/video/windows/SDL_windowsmouse.h
src/video/windows/SDL_windowsopengl.c
src/video/windows/SDL_windowsopengl.h
src/video/windows/SDL_windowsshape.c
src/video/windows/SDL_windowsshape.h
src/video/windows/SDL_windowsvideo.c
src/video/windows/SDL_windowsvideo.h
src/video/windows/SDL_windowswindow.c
src/video/windows/SDL_windowswindow.h
src/video/windows/wmmsg.h
test/automated/rwops/TestSupportRWops_Generic.c
test/testfile.c
test/testgesture.c
test/testnative.c
test/testnative.h
test/testnativew32.c
     1.1 --- a/VisualC/SDL/SDL_VS2005.vcproj	Thu Jan 20 17:33:06 2011 -0800
     1.2 +++ b/VisualC/SDL/SDL_VS2005.vcproj	Thu Jan 20 18:04:05 2011 -0800
     1.3 @@ -29,7 +29,7 @@
     1.4  			<Tool
     1.5  				Name="VCPreBuildEventTool"
     1.6  				Description="Making sure basic SDL headers are in place..."
     1.7 -				CommandLine="if exist &quot;$(ProjectDir)\..\..\include\SDL_config.h&quot; goto SDLCONFIGOKAY&#x0D;&#x0A;echo Copying SDL_config_win32.h to SDL_config.h...&#x0D;&#x0A;copy &quot;$(ProjectDir)\..\..\include\SDL_config_win32.h&quot; &quot;$(ProjectDir)\..\..\include\SDL_config.h&quot;&#x0D;&#x0A;:SDLCONFIGOKAY&#x0D;&#x0A;&#x0D;&#x0A;if exist &quot;$(ProjectDir)\..\..\include\SDL_revision.h&quot; goto SDLREVISIONOKAY&#x0D;&#x0A;echo Creating stub SDL_revision.h file...&#x0D;&#x0A;echo #define SDL_REVISION 0 &gt;&quot;$(ProjectDir)\..\..\include\SDL_revision.h&quot;&#x0D;&#x0A;:SDLREVISIONOKAY&#x0D;&#x0A;"
     1.8 +				CommandLine="if exist &quot;$(ProjectDir)\..\..\include\SDL_config.h&quot; goto SDLCONFIGOKAY&#x0D;&#x0A;echo Copying SDL_config_windows.h to SDL_config.h...&#x0D;&#x0A;copy &quot;$(ProjectDir)\..\..\include\SDL_config_windows.h&quot; &quot;$(ProjectDir)\..\..\include\SDL_config.h&quot;&#x0D;&#x0A;:SDLCONFIGOKAY&#x0D;&#x0A;&#x0D;&#x0A;if exist &quot;$(ProjectDir)\..\..\include\SDL_revision.h&quot; goto SDLREVISIONOKAY&#x0D;&#x0A;echo Creating stub SDL_revision.h file...&#x0D;&#x0A;echo #define SDL_REVISION 0 &gt;&quot;$(ProjectDir)\..\..\include\SDL_revision.h&quot;&#x0D;&#x0A;:SDLREVISIONOKAY&#x0D;&#x0A;"
     1.9  			/>
    1.10  			<Tool
    1.11  				Name="VCCustomBuildTool"
    1.12 @@ -207,7 +207,7 @@
    1.13  			<Tool
    1.14  				Name="VCPreBuildEventTool"
    1.15  				Description="Making sure basic SDL headers are in place..."
    1.16 -				CommandLine="if exist &quot;$(ProjectDir)\..\..\include\SDL_config.h&quot; goto SDLCONFIGOKAY&#x0D;&#x0A;echo Copying SDL_config_win32.h to SDL_config.h...&#x0D;&#x0A;copy &quot;$(ProjectDir)\..\..\include\SDL_config_win32.h&quot; &quot;$(ProjectDir)\..\..\include\SDL_config.h&quot;&#x0D;&#x0A;:SDLCONFIGOKAY&#x0D;&#x0A;&#x0D;&#x0A;if exist &quot;$(ProjectDir)\..\..\include\SDL_revision.h&quot; goto SDLREVISIONOKAY&#x0D;&#x0A;echo Creating stub SDL_revision.h file...&#x0D;&#x0A;echo #define SDL_REVISION 0 &gt;&quot;$(ProjectDir)\..\..\include\SDL_revision.h&quot;&#x0D;&#x0A;:SDLREVISIONOKAY&#x0D;&#x0A;"
    1.17 +				CommandLine="if exist &quot;$(ProjectDir)\..\..\include\SDL_config.h&quot; goto SDLCONFIGOKAY&#x0D;&#x0A;echo Copying SDL_config_windows.h to SDL_config.h...&#x0D;&#x0A;copy &quot;$(ProjectDir)\..\..\include\SDL_config_windows.h&quot; &quot;$(ProjectDir)\..\..\include\SDL_config.h&quot;&#x0D;&#x0A;:SDLCONFIGOKAY&#x0D;&#x0A;&#x0D;&#x0A;if exist &quot;$(ProjectDir)\..\..\include\SDL_revision.h&quot; goto SDLREVISIONOKAY&#x0D;&#x0A;echo Creating stub SDL_revision.h file...&#x0D;&#x0A;echo #define SDL_REVISION 0 &gt;&quot;$(ProjectDir)\..\..\include\SDL_revision.h&quot;&#x0D;&#x0A;:SDLREVISIONOKAY&#x0D;&#x0A;"
    1.18  			/>
    1.19  			<Tool
    1.20  				Name="VCCustomBuildTool"
    1.21 @@ -411,7 +411,7 @@
    1.22  				>
    1.23  			</File>
    1.24  			<File
    1.25 -				RelativePath="..\..\include\SDL_config_win32.h"
    1.26 +				RelativePath="..\..\include\SDL_config_windows.h"
    1.27  				>
    1.28  			</File>
    1.29  			<File
    1.30 @@ -768,11 +768,11 @@
    1.31  			>
    1.32  		</File>
    1.33  		<File
    1.34 -			RelativePath="..\..\src\video\win32\SDL_d3drender.c"
    1.35 +			RelativePath="..\..\src\video\windows\SDL_d3drender.c"
    1.36  			>
    1.37  		</File>
    1.38  		<File
    1.39 -			RelativePath="..\..\src\video\win32\SDL_d3drender.h"
    1.40 +			RelativePath="..\..\src\video\windows\SDL_d3drender.h"
    1.41  			>
    1.42  		</File>
    1.43  		<File
    1.44 @@ -824,7 +824,7 @@
    1.45  			>
    1.46  		</File>
    1.47  		<File
    1.48 -			RelativePath="..\..\src\joystick\win32\SDL_dxjoystick.c"
    1.49 +			RelativePath="..\..\src\joystick\windows\SDL_dxjoystick.c"
    1.50  			>
    1.51  		</File>
    1.52  		<File
    1.53 @@ -860,11 +860,11 @@
    1.54  			>
    1.55  		</File>
    1.56  		<File
    1.57 -			RelativePath="..\..\src\video\win32\SDL_gdirender.c"
    1.58 +			RelativePath="..\..\src\video\windows\SDL_gdirender.c"
    1.59  			>
    1.60  		</File>
    1.61  		<File
    1.62 -			RelativePath="..\..\src\video\win32\SDL_gdirender.h"
    1.63 +			RelativePath="..\..\src\video\windows\SDL_gdirender.h"
    1.64  			>
    1.65  		</File>
    1.66  		<File
    1.67 @@ -948,7 +948,7 @@
    1.68  			>
    1.69  		</File>
    1.70  		<File
    1.71 -			RelativePath="..\..\src\joystick\win32\SDL_mmjoystick.c"
    1.72 +			RelativePath="..\..\src\joystick\windows\SDL_mmjoystick.c"
    1.73  			>
    1.74  		</File>
    1.75  		<File
    1.76 @@ -1072,7 +1072,7 @@
    1.77  			>
    1.78  		</File>
    1.79  		<File
    1.80 -			RelativePath="..\..\src\haptic\win32\SDL_syshaptic.c"
    1.81 +			RelativePath="..\..\src\haptic\windows\SDL_syshaptic.c"
    1.82  			>
    1.83  		</File>
    1.84  		<File
    1.85 @@ -1084,11 +1084,11 @@
    1.86  			>
    1.87  		</File>
    1.88  		<File
    1.89 -			RelativePath="..\..\src\loadso\win32\SDL_sysloadso.c"
    1.90 +			RelativePath="..\..\src\loadso\windows\SDL_sysloadso.c"
    1.91  			>
    1.92  		</File>
    1.93  		<File
    1.94 -			RelativePath="..\..\src\thread\win32\SDL_sysmutex.c"
    1.95 +			RelativePath="..\..\src\thread\windows\SDL_sysmutex.c"
    1.96  			>
    1.97  		</File>
    1.98  		<File
    1.99 @@ -1096,11 +1096,11 @@
   1.100  			>
   1.101  		</File>
   1.102  		<File
   1.103 -			RelativePath="..\..\src\thread\win32\SDL_syssem.c"
   1.104 +			RelativePath="..\..\src\thread\windows\SDL_syssem.c"
   1.105  			>
   1.106  		</File>
   1.107  		<File
   1.108 -			RelativePath="..\..\src\thread\win32\SDL_systhread.c"
   1.109 +			RelativePath="..\..\src\thread\windows\SDL_systhread.c"
   1.110  			>
   1.111  		</File>
   1.112  		<File
   1.113 @@ -1108,11 +1108,11 @@
   1.114  			>
   1.115  		</File>
   1.116  		<File
   1.117 -			RelativePath="..\..\src\thread\win32\SDL_systhread_c.h"
   1.118 +			RelativePath="..\..\src\thread\windows\SDL_systhread_c.h"
   1.119  			>
   1.120  		</File>
   1.121  		<File
   1.122 -			RelativePath="..\..\src\timer\win32\SDL_systimer.c"
   1.123 +			RelativePath="..\..\src\timer\windows\SDL_systimer.c"
   1.124  			>
   1.125  		</File>
   1.126  		<File
   1.127 @@ -1152,7 +1152,7 @@
   1.128  			>
   1.129  		</File>
   1.130  		<File
   1.131 -			RelativePath="..\..\src\video\win32\SDL_vkeys.h"
   1.132 +			RelativePath="..\..\src\video\windows\SDL_vkeys.h"
   1.133  			>
   1.134  		</File>
   1.135  		<File
   1.136 @@ -1164,83 +1164,83 @@
   1.137  			>
   1.138  		</File>
   1.139  		<File
   1.140 -			RelativePath="..\..\src\video\win32\SDL_win32clipboard.c"
   1.141 +			RelativePath="..\..\src\video\windows\SDL_windowsclipboard.c"
   1.142  			>
   1.143  		</File>
   1.144  		<File
   1.145 -			RelativePath="..\..\src\video\win32\SDL_win32clipboard.h"
   1.146 +			RelativePath="..\..\src\video\windows\SDL_windowsclipboard.h"
   1.147  			>
   1.148  		</File>
   1.149  		<File
   1.150 -			RelativePath="..\..\src\video\win32\SDL_win32events.c"
   1.151 +			RelativePath="..\..\src\video\windows\SDL_windowsevents.c"
   1.152  			>
   1.153  		</File>
   1.154  		<File
   1.155 -			RelativePath="..\..\src\video\win32\SDL_win32events.h"
   1.156 +			RelativePath="..\..\src\video\windows\SDL_windowsevents.h"
   1.157  			>
   1.158  		</File>
   1.159  		<File
   1.160 -			RelativePath="..\..\src\video\win32\SDL_win32gamma.c"
   1.161 +			RelativePath="..\..\src\video\windows\SDL_windowsgamma.c"
   1.162  			>
   1.163  		</File>
   1.164  		<File
   1.165 -			RelativePath="..\..\src\video\win32\SDL_win32gamma.h"
   1.166 +			RelativePath="..\..\src\video\windows\SDL_windowsgamma.h"
   1.167  			>
   1.168  		</File>
   1.169  		<File
   1.170 -			RelativePath="..\..\src\video\win32\SDL_win32keyboard.c"
   1.171 +			RelativePath="..\..\src\video\windows\SDL_windowskeyboard.c"
   1.172  			>
   1.173  		</File>
   1.174  		<File
   1.175 -			RelativePath="..\..\src\video\win32\SDL_win32keyboard.h"
   1.176 +			RelativePath="..\..\src\video\windows\SDL_windowskeyboard.h"
   1.177  			>
   1.178  		</File>
   1.179  		<File
   1.180 -			RelativePath="..\..\src\video\win32\SDL_win32modes.c"
   1.181 +			RelativePath="..\..\src\video\windows\SDL_windowsmodes.c"
   1.182  			>
   1.183  		</File>
   1.184  		<File
   1.185 -			RelativePath="..\..\src\video\win32\SDL_win32modes.h"
   1.186 +			RelativePath="..\..\src\video\windows\SDL_windowsmodes.h"
   1.187  			>
   1.188  		</File>
   1.189  		<File
   1.190 -			RelativePath="..\..\src\video\win32\SDL_win32mouse.c"
   1.191 +			RelativePath="..\..\src\video\windows\SDL_windowsmouse.c"
   1.192  			>
   1.193  		</File>
   1.194  		<File
   1.195 -			RelativePath="..\..\src\video\win32\SDL_win32mouse.h"
   1.196 +			RelativePath="..\..\src\video\windows\SDL_windowsmouse.h"
   1.197  			>
   1.198  		</File>
   1.199  		<File
   1.200 -			RelativePath="..\..\src\video\win32\SDL_win32opengl.c"
   1.201 +			RelativePath="..\..\src\video\windows\SDL_windowsopengl.c"
   1.202  			>
   1.203  		</File>
   1.204  		<File
   1.205 -			RelativePath="..\..\src\video\win32\SDL_win32opengl.h"
   1.206 +			RelativePath="..\..\src\video\windows\SDL_windowsopengl.h"
   1.207  			>
   1.208  		</File>
   1.209  		<File
   1.210 -			RelativePath="..\..\src\video\win32\SDL_win32shape.c"
   1.211 +			RelativePath="..\..\src\video\windows\SDL_windowsshape.c"
   1.212  			>
   1.213  		</File>
   1.214  		<File
   1.215 -			RelativePath="..\..\src\video\win32\SDL_win32shape.h"
   1.216 +			RelativePath="..\..\src\video\windows\SDL_windowsshape.h"
   1.217  			>
   1.218  		</File>
   1.219  		<File
   1.220 -			RelativePath="..\..\src\video\win32\SDL_win32video.c"
   1.221 +			RelativePath="..\..\src\video\windows\SDL_windowsvideo.c"
   1.222  			>
   1.223  		</File>
   1.224  		<File
   1.225 -			RelativePath="..\..\src\video\win32\SDL_win32video.h"
   1.226 +			RelativePath="..\..\src\video\windows\SDL_windowsvideo.h"
   1.227  			>
   1.228  		</File>
   1.229  		<File
   1.230 -			RelativePath="..\..\src\video\win32\SDL_win32window.c"
   1.231 +			RelativePath="..\..\src\video\windows\SDL_windowswindow.c"
   1.232  			>
   1.233  		</File>
   1.234  		<File
   1.235 -			RelativePath="..\..\src\video\win32\SDL_win32window.h"
   1.236 +			RelativePath="..\..\src\video\windows\SDL_windowswindow.h"
   1.237  			>
   1.238  		</File>
   1.239  		<File
   1.240 @@ -1264,7 +1264,7 @@
   1.241  			>
   1.242  		</File>
   1.243  		<File
   1.244 -			RelativePath="..\..\src\video\win32\wmmsg.h"
   1.245 +			RelativePath="..\..\src\video\windows\wmmsg.h"
   1.246  			>
   1.247  		</File>
   1.248  	</Files>
     2.1 --- a/VisualC/SDL/SDL_VS2008.vcproj	Thu Jan 20 17:33:06 2011 -0800
     2.2 +++ b/VisualC/SDL/SDL_VS2008.vcproj	Thu Jan 20 18:04:05 2011 -0800
     2.3 @@ -30,7 +30,7 @@
     2.4  			<Tool
     2.5  				Name="VCPreBuildEventTool"
     2.6  				Description="Making sure basic SDL headers are in place..."
     2.7 -				CommandLine="if exist &quot;$(ProjectDir)\..\..\include\SDL_config.h&quot; goto SDLCONFIGOKAY&#x0D;&#x0A;echo Copying SDL_config_win32.h to SDL_config.h...&#x0D;&#x0A;copy &quot;$(ProjectDir)\..\..\include\SDL_config_win32.h&quot; &quot;$(ProjectDir)\..\..\include\SDL_config.h&quot;&#x0D;&#x0A;:SDLCONFIGOKAY&#x0D;&#x0A;&#x0D;&#x0A;if exist &quot;$(ProjectDir)\..\..\include\SDL_revision.h&quot; goto SDLREVISIONOKAY&#x0D;&#x0A;echo Creating stub SDL_revision.h file...&#x0D;&#x0A;echo #define SDL_REVISION 0 &gt;&quot;$(ProjectDir)\..\..\include\SDL_revision.h&quot;&#x0D;&#x0A;:SDLREVISIONOKAY&#x0D;&#x0A;"
     2.8 +				CommandLine="if exist &quot;$(ProjectDir)\..\..\include\SDL_config.h&quot; goto SDLCONFIGOKAY&#x0D;&#x0A;echo Copying SDL_config_windows.h to SDL_config.h...&#x0D;&#x0A;copy &quot;$(ProjectDir)\..\..\include\SDL_config_windows.h&quot; &quot;$(ProjectDir)\..\..\include\SDL_config.h&quot;&#x0D;&#x0A;:SDLCONFIGOKAY&#x0D;&#x0A;&#x0D;&#x0A;if exist &quot;$(ProjectDir)\..\..\include\SDL_revision.h&quot; goto SDLREVISIONOKAY&#x0D;&#x0A;echo Creating stub SDL_revision.h file...&#x0D;&#x0A;echo #define SDL_REVISION 0 &gt;&quot;$(ProjectDir)\..\..\include\SDL_revision.h&quot;&#x0D;&#x0A;:SDLREVISIONOKAY&#x0D;&#x0A;"
     2.9  			/>
    2.10  			<Tool
    2.11  				Name="VCCustomBuildTool"
    2.12 @@ -201,7 +201,7 @@
    2.13  			<Tool
    2.14  				Name="VCPreBuildEventTool"
    2.15  				Description="Making sure basic SDL headers are in place..."
    2.16 -				CommandLine="if exist &quot;$(ProjectDir)\..\..\include\SDL_config.h&quot; goto SDLCONFIGOKAY&#x0D;&#x0A;echo Copying SDL_config_win32.h to SDL_config.h...&#x0D;&#x0A;copy &quot;$(ProjectDir)\..\..\include\SDL_config_win32.h&quot; &quot;$(ProjectDir)\..\..\include\SDL_config.h&quot;&#x0D;&#x0A;:SDLCONFIGOKAY&#x0D;&#x0A;&#x0D;&#x0A;if exist &quot;$(ProjectDir)\..\..\include\SDL_revision.h&quot; goto SDLREVISIONOKAY&#x0D;&#x0A;echo Creating stub SDL_revision.h file...&#x0D;&#x0A;echo #define SDL_REVISION 0 &gt;&quot;$(ProjectDir)\..\..\include\SDL_revision.h&quot;&#x0D;&#x0A;:SDLREVISIONOKAY&#x0D;&#x0A;"
    2.17 +				CommandLine="if exist &quot;$(ProjectDir)\..\..\include\SDL_config.h&quot; goto SDLCONFIGOKAY&#x0D;&#x0A;echo Copying SDL_config_windows.h to SDL_config.h...&#x0D;&#x0A;copy &quot;$(ProjectDir)\..\..\include\SDL_config_windows.h&quot; &quot;$(ProjectDir)\..\..\include\SDL_config.h&quot;&#x0D;&#x0A;:SDLCONFIGOKAY&#x0D;&#x0A;&#x0D;&#x0A;if exist &quot;$(ProjectDir)\..\..\include\SDL_revision.h&quot; goto SDLREVISIONOKAY&#x0D;&#x0A;echo Creating stub SDL_revision.h file...&#x0D;&#x0A;echo #define SDL_REVISION 0 &gt;&quot;$(ProjectDir)\..\..\include\SDL_revision.h&quot;&#x0D;&#x0A;:SDLREVISIONOKAY&#x0D;&#x0A;"
    2.18  			/>
    2.19  			<Tool
    2.20  				Name="VCCustomBuildTool"
    2.21 @@ -398,7 +398,7 @@
    2.22  				>
    2.23  			</File>
    2.24  			<File
    2.25 -				RelativePath="..\..\include\SDL_config_win32.h"
    2.26 +				RelativePath="..\..\include\SDL_config_windows.h"
    2.27  				>
    2.28  			</File>
    2.29  			<File
    2.30 @@ -751,11 +751,11 @@
    2.31  			>
    2.32  		</File>
    2.33  		<File
    2.34 -			RelativePath="..\..\src\video\win32\SDL_d3drender.c"
    2.35 +			RelativePath="..\..\src\video\windows\SDL_d3drender.c"
    2.36  			>
    2.37  		</File>
    2.38  		<File
    2.39 -			RelativePath="..\..\src\video\win32\SDL_d3drender.h"
    2.40 +			RelativePath="..\..\src\video\windows\SDL_d3drender.h"
    2.41  			>
    2.42  		</File>
    2.43  		<File
    2.44 @@ -807,7 +807,7 @@
    2.45  			>
    2.46  		</File>
    2.47  		<File
    2.48 -			RelativePath="..\..\src\joystick\win32\SDL_dxjoystick.c"
    2.49 +			RelativePath="..\..\src\joystick\windows\SDL_dxjoystick.c"
    2.50  			>
    2.51  		</File>
    2.52  		<File
    2.53 @@ -843,11 +843,11 @@
    2.54  			>
    2.55  		</File>
    2.56  		<File
    2.57 -			RelativePath="..\..\src\video\win32\SDL_gdirender.c"
    2.58 +			RelativePath="..\..\src\video\windows\SDL_gdirender.c"
    2.59  			>
    2.60  		</File>
    2.61  		<File
    2.62 -			RelativePath="..\..\src\video\win32\SDL_gdirender.h"
    2.63 +			RelativePath="..\..\src\video\windows\SDL_gdirender.h"
    2.64  			>
    2.65  		</File>
    2.66  		<File
    2.67 @@ -931,7 +931,7 @@
    2.68  			>
    2.69  		</File>
    2.70  		<File
    2.71 -			RelativePath="..\..\src\joystick\win32\SDL_mmjoystick.c"
    2.72 +			RelativePath="..\..\src\joystick\windows\SDL_mmjoystick.c"
    2.73  			>
    2.74  		</File>
    2.75  		<File
    2.76 @@ -1059,7 +1059,7 @@
    2.77  			>
    2.78  		</File>
    2.79  		<File
    2.80 -			RelativePath="..\..\src\haptic\win32\SDL_syshaptic.c"
    2.81 +			RelativePath="..\..\src\haptic\windows\SDL_syshaptic.c"
    2.82  			>
    2.83  		</File>
    2.84  		<File
    2.85 @@ -1071,11 +1071,11 @@
    2.86  			>
    2.87  		</File>
    2.88  		<File
    2.89 -			RelativePath="..\..\src\loadso\win32\SDL_sysloadso.c"
    2.90 +			RelativePath="..\..\src\loadso\windows\SDL_sysloadso.c"
    2.91  			>
    2.92  		</File>
    2.93  		<File
    2.94 -			RelativePath="..\..\src\thread\win32\SDL_sysmutex.c"
    2.95 +			RelativePath="..\..\src\thread\windows\SDL_sysmutex.c"
    2.96  			>
    2.97  		</File>
    2.98  		<File
    2.99 @@ -1083,11 +1083,11 @@
   2.100  			>
   2.101  		</File>
   2.102  		<File
   2.103 -			RelativePath="..\..\src\thread\win32\SDL_syssem.c"
   2.104 +			RelativePath="..\..\src\thread\windows\SDL_syssem.c"
   2.105  			>
   2.106  		</File>
   2.107  		<File
   2.108 -			RelativePath="..\..\src\thread\win32\SDL_systhread.c"
   2.109 +			RelativePath="..\..\src\thread\windows\SDL_systhread.c"
   2.110  			>
   2.111  		</File>
   2.112  		<File
   2.113 @@ -1095,11 +1095,11 @@
   2.114  			>
   2.115  		</File>
   2.116  		<File
   2.117 -			RelativePath="..\..\src\thread\win32\SDL_systhread_c.h"
   2.118 +			RelativePath="..\..\src\thread\windows\SDL_systhread_c.h"
   2.119  			>
   2.120  		</File>
   2.121  		<File
   2.122 -			RelativePath="..\..\src\timer\win32\SDL_systimer.c"
   2.123 +			RelativePath="..\..\src\timer\windows\SDL_systimer.c"
   2.124  			>
   2.125  		</File>
   2.126  		<File
   2.127 @@ -1139,7 +1139,7 @@
   2.128  			>
   2.129  		</File>
   2.130  		<File
   2.131 -			RelativePath="..\..\src\video\win32\SDL_vkeys.h"
   2.132 +			RelativePath="..\..\src\video\windows\SDL_vkeys.h"
   2.133  			>
   2.134  		</File>
   2.135  		<File
   2.136 @@ -1151,83 +1151,83 @@
   2.137  			>
   2.138  		</File>
   2.139  		<File
   2.140 -			RelativePath="..\..\src\video\win32\SDL_win32clipboard.c"
   2.141 +			RelativePath="..\..\src\video\windows\SDL_windowsclipboard.c"
   2.142  			>
   2.143  		</File>
   2.144  		<File
   2.145 -			RelativePath="..\..\src\video\win32\SDL_win32clipboard.h"
   2.146 +			RelativePath="..\..\src\video\windows\SDL_windowsclipboard.h"
   2.147  			>
   2.148  		</File>
   2.149  		<File
   2.150 -			RelativePath="..\..\src\video\win32\SDL_win32events.c"
   2.151 +			RelativePath="..\..\src\video\windows\SDL_windowsevents.c"
   2.152  			>
   2.153  		</File>
   2.154  		<File
   2.155 -			RelativePath="..\..\src\video\win32\SDL_win32events.h"
   2.156 +			RelativePath="..\..\src\video\windows\SDL_windowsevents.h"
   2.157  			>
   2.158  		</File>
   2.159  		<File
   2.160 -			RelativePath="..\..\src\video\win32\SDL_win32gamma.c"
   2.161 +			RelativePath="..\..\src\video\windows\SDL_windowsgamma.c"
   2.162  			>
   2.163  		</File>
   2.164  		<File
   2.165 -			RelativePath="..\..\src\video\win32\SDL_win32gamma.h"
   2.166 +			RelativePath="..\..\src\video\windows\SDL_windowsgamma.h"
   2.167  			>
   2.168  		</File>
   2.169  		<File
   2.170 -			RelativePath="..\..\src\video\win32\SDL_win32keyboard.c"
   2.171 +			RelativePath="..\..\src\video\windows\SDL_windowskeyboard.c"
   2.172  			>
   2.173  		</File>
   2.174  		<File
   2.175 -			RelativePath="..\..\src\video\win32\SDL_win32keyboard.h"
   2.176 +			RelativePath="..\..\src\video\windows\SDL_windowskeyboard.h"
   2.177  			>
   2.178  		</File>
   2.179  		<File
   2.180 -			RelativePath="..\..\src\video\win32\SDL_win32modes.c"
   2.181 +			RelativePath="..\..\src\video\windows\SDL_windowsmodes.c"
   2.182  			>
   2.183  		</File>
   2.184  		<File
   2.185 -			RelativePath="..\..\src\video\win32\SDL_win32modes.h"
   2.186 +			RelativePath="..\..\src\video\windows\SDL_windowsmodes.h"
   2.187  			>
   2.188  		</File>
   2.189  		<File
   2.190 -			RelativePath="..\..\src\video\win32\SDL_win32mouse.c"
   2.191 +			RelativePath="..\..\src\video\windows\SDL_windowsmouse.c"
   2.192  			>
   2.193  		</File>
   2.194  		<File
   2.195 -			RelativePath="..\..\src\video\win32\SDL_win32mouse.h"
   2.196 +			RelativePath="..\..\src\video\windows\SDL_windowsmouse.h"
   2.197  			>
   2.198  		</File>
   2.199  		<File
   2.200 -			RelativePath="..\..\src\video\win32\SDL_win32opengl.c"
   2.201 +			RelativePath="..\..\src\video\windows\SDL_windowsopengl.c"
   2.202  			>
   2.203  		</File>
   2.204  		<File
   2.205 -			RelativePath="..\..\src\video\win32\SDL_win32opengl.h"
   2.206 +			RelativePath="..\..\src\video\windows\SDL_windowsopengl.h"
   2.207  			>
   2.208  		</File>
   2.209  		<File
   2.210 -			RelativePath="..\..\src\video\win32\SDL_win32shape.c"
   2.211 +			RelativePath="..\..\src\video\windows\SDL_windowsshape.c"
   2.212  			>
   2.213  		</File>
   2.214  		<File
   2.215 -			RelativePath="..\..\src\video\win32\SDL_win32shape.h"
   2.216 +			RelativePath="..\..\src\video\windows\SDL_windowsshape.h"
   2.217  			>
   2.218  		</File>
   2.219  		<File
   2.220 -			RelativePath="..\..\src\video\win32\SDL_win32video.c"
   2.221 +			RelativePath="..\..\src\video\windows\SDL_windowsvideo.c"
   2.222  			>
   2.223  		</File>
   2.224  		<File
   2.225 -			RelativePath="..\..\src\video\win32\SDL_win32video.h"
   2.226 +			RelativePath="..\..\src\video\windows\SDL_windowsvideo.h"
   2.227  			>
   2.228  		</File>
   2.229  		<File
   2.230 -			RelativePath="..\..\src\video\win32\SDL_win32window.c"
   2.231 +			RelativePath="..\..\src\video\windows\SDL_windowswindow.c"
   2.232  			>
   2.233  		</File>
   2.234  		<File
   2.235 -			RelativePath="..\..\src\video\win32\SDL_win32window.h"
   2.236 +			RelativePath="..\..\src\video\windows\SDL_windowswindow.h"
   2.237  			>
   2.238  		</File>
   2.239  		<File
   2.240 @@ -1251,7 +1251,7 @@
   2.241  			>
   2.242  		</File>
   2.243  		<File
   2.244 -			RelativePath="..\..\src\video\win32\wmmsg.h"
   2.245 +			RelativePath="..\..\src\video\windows\wmmsg.h"
   2.246  			>
   2.247  		</File>
   2.248  	</Files>
     3.1 --- a/VisualC/SDL/SDL_VS2010.vcxproj	Thu Jan 20 17:33:06 2011 -0800
     3.2 +++ b/VisualC/SDL/SDL_VS2010.vcxproj	Thu Jan 20 18:04:05 2011 -0800
     3.3 @@ -75,8 +75,8 @@
     3.4      <PreBuildEvent>
     3.5        <Message>Making sure basic SDL headers are in place...</Message>
     3.6        <Command>if exist "$(ProjectDir)\..\..\include\SDL_config.h" goto SDLCONFIGOKAY
     3.7 -echo Copying SDL_config_win32.h to SDL_config.h...
     3.8 -copy "$(ProjectDir)\..\..\include\SDL_config_win32.h" "$(ProjectDir)\..\..\include\SDL_config.h"
     3.9 +echo Copying SDL_config_windows.h to SDL_config.h...
    3.10 +copy "$(ProjectDir)\..\..\include\SDL_config_windows.h" "$(ProjectDir)\..\..\include\SDL_config.h"
    3.11  :SDLCONFIGOKAY
    3.12  
    3.13  if exist "$(ProjectDir)\..\..\include\SDL_revision.h" goto SDLREVISIONOKAY
    3.14 @@ -155,8 +155,8 @@
    3.15      <PreBuildEvent>
    3.16        <Message>Making sure basic SDL headers are in place...</Message>
    3.17        <Command>if exist "$(ProjectDir)\..\..\include\SDL_config.h" goto SDLCONFIGOKAY
    3.18 -echo Copying SDL_config_win32.h to SDL_config.h...
    3.19 -copy "$(ProjectDir)\..\..\include\SDL_config_win32.h" "$(ProjectDir)\..\..\include\SDL_config.h"
    3.20 +echo Copying SDL_config_windows.h to SDL_config.h...
    3.21 +copy "$(ProjectDir)\..\..\include\SDL_config_windows.h" "$(ProjectDir)\..\..\include\SDL_config.h"
    3.22  :SDLCONFIGOKAY
    3.23  
    3.24  if exist "$(ProjectDir)\..\..\include\SDL_revision.h" goto SDLREVISIONOKAY
    3.25 @@ -238,7 +238,7 @@
    3.26      <ClInclude Include="..\..\include\SDL_clipboard.h" />
    3.27      <ClInclude Include="..\..\include\SDL_compat.h" />
    3.28      <ClInclude Include="..\..\include\SDL_config.h" />
    3.29 -    <ClInclude Include="..\..\include\SDL_config_win32.h" />
    3.30 +    <ClInclude Include="..\..\include\SDL_config_windows.h" />
    3.31      <ClInclude Include="..\..\include\SDL_copying.h" />
    3.32      <ClInclude Include="..\..\include\SDL_cpuinfo.h" />
    3.33      <ClInclude Include="..\..\include\SDL_endian.h" />
    3.34 @@ -290,7 +290,7 @@
    3.35      <ClInclude Include="..\..\src\video\SDL_blit_copy.h" />
    3.36      <ClInclude Include="..\..\src\video\SDL_blit_slow.h" />
    3.37      <ClInclude Include="..\..\src\video\SDL_shape_internals.h" />
    3.38 -    <ClInclude Include="..\..\src\video\win32\SDL_d3drender.h" />
    3.39 +    <ClInclude Include="..\..\src\video\windows\SDL_d3drender.h" />
    3.40      <ClInclude Include="..\..\src\audio\windib\SDL_dibaudio.h" />
    3.41      <ClInclude Include="..\..\src\audio\disk\SDL_diskaudio.h" />
    3.42      <ClInclude Include="..\..\src\video\SDL_draw.h" />
    3.43 @@ -299,7 +299,7 @@
    3.44      <ClInclude Include="..\..\src\SDL_error_c.h" />
    3.45      <ClInclude Include="..\..\src\events\SDL_events_c.h" />
    3.46      <ClInclude Include="..\..\src\SDL_fatal.h" />
    3.47 -    <ClInclude Include="..\..\src\video\win32\SDL_gdirender.h" />
    3.48 +    <ClInclude Include="..\..\src\video\windows\SDL_gdirender.h" />
    3.49      <ClInclude Include="..\..\src\video\SDL_glesfuncs.h" />
    3.50      <ClInclude Include="..\..\src\video\SDL_glfuncs.h" />
    3.51      <ClInclude Include="..\..\src\joystick\SDL_joystick_c.h" />
    3.52 @@ -323,26 +323,26 @@
    3.53      <ClInclude Include="..\..\src\haptic\SDL_syshaptic.h" />
    3.54      <ClInclude Include="..\..\src\joystick\SDL_sysjoystick.h" />
    3.55      <ClInclude Include="..\..\src\thread\SDL_systhread.h" />
    3.56 -    <ClInclude Include="..\..\src\thread\win32\SDL_systhread_c.h" />
    3.57 +    <ClInclude Include="..\..\src\thread\windows\SDL_systhread_c.h" />
    3.58      <ClInclude Include="..\..\src\timer\SDL_systimer.h" />
    3.59      <ClInclude Include="..\..\src\video\SDL_sysvideo.h" />
    3.60      <ClInclude Include="..\..\src\thread\SDL_thread_c.h" />
    3.61      <ClInclude Include="..\..\src\timer\SDL_timer_c.h" />
    3.62 -    <ClInclude Include="..\..\src\video\win32\SDL_vkeys.h" />
    3.63 +    <ClInclude Include="..\..\src\video\windows\SDL_vkeys.h" />
    3.64      <ClInclude Include="..\..\src\audio\SDL_wave.h" />
    3.65 -    <ClInclude Include="..\..\src\video\win32\SDL_win32clipboard.h" />
    3.66 -    <ClInclude Include="..\..\src\video\win32\SDL_win32events.h" />
    3.67 -    <ClInclude Include="..\..\src\video\win32\SDL_win32gamma.h" />
    3.68 -    <ClInclude Include="..\..\src\video\win32\SDL_win32keyboard.h" />
    3.69 -    <ClInclude Include="..\..\src\video\win32\SDL_win32modes.h" />
    3.70 -    <ClInclude Include="..\..\src\video\win32\SDL_win32mouse.h" />
    3.71 -    <ClInclude Include="..\..\src\video\win32\SDL_win32opengl.h" />
    3.72 -    <ClInclude Include="..\..\src\video\win32\SDL_win32shape.h" />
    3.73 -    <ClInclude Include="..\..\src\video\win32\SDL_win32video.h" />
    3.74 -    <ClInclude Include="..\..\src\video\win32\SDL_win32window.h" />
    3.75 +    <ClInclude Include="..\..\src\video\windows\SDL_windowsclipboard.h" />
    3.76 +    <ClInclude Include="..\..\src\video\windows\SDL_windowsevents.h" />
    3.77 +    <ClInclude Include="..\..\src\video\windows\SDL_windowsgamma.h" />
    3.78 +    <ClInclude Include="..\..\src\video\windows\SDL_windowskeyboard.h" />
    3.79 +    <ClInclude Include="..\..\src\video\windows\SDL_windowsmodes.h" />
    3.80 +    <ClInclude Include="..\..\src\video\windows\SDL_windowsmouse.h" />
    3.81 +    <ClInclude Include="..\..\src\video\windows\SDL_windowsopengl.h" />
    3.82 +    <ClInclude Include="..\..\src\video\windows\SDL_windowsshape.h" />
    3.83 +    <ClInclude Include="..\..\src\video\windows\SDL_windowsvideo.h" />
    3.84 +    <ClInclude Include="..\..\src\video\windows\SDL_windowswindow.h" />
    3.85      <ClInclude Include="..\..\src\events\SDL_windowevents_c.h" />
    3.86      <ClInclude Include="..\..\src\video\SDL_yuv_sw_c.h" />
    3.87 -    <ClInclude Include="..\..\src\video\win32\wmmsg.h" />
    3.88 +    <ClInclude Include="..\..\src\video\windows\wmmsg.h" />
    3.89    </ItemGroup>
    3.90    <ItemGroup>
    3.91      <ClCompile Include="..\..\src\events\SDL_clipboardevents.c" />
    3.92 @@ -389,7 +389,7 @@
    3.93      <ClCompile Include="..\..\src\cpuinfo\SDL_cpuinfo.c" />
    3.94      <ClCompile Include="..\..\src\video\SDL_clipboard.c" />
    3.95      <ClCompile Include="..\..\src\video\SDL_shape.c" />
    3.96 -    <ClCompile Include="..\..\src\video\win32\SDL_d3drender.c" />
    3.97 +    <ClCompile Include="..\..\src\video\windows\SDL_d3drender.c" />
    3.98      <ClCompile Include="..\..\src\audio\windib\SDL_dibaudio.c" />
    3.99      <ClCompile Include="..\..\src\audio\disk\SDL_diskaudio.c" />
   3.100      <ClCompile Include="..\..\src\video\SDL_drawline.c" />
   3.101 @@ -397,13 +397,13 @@
   3.102      <ClCompile Include="..\..\src\video\SDL_drawrect.c" />
   3.103      <ClCompile Include="..\..\src\audio\dummy\SDL_dummyaudio.c" />
   3.104      <ClCompile Include="..\..\src\audio\windx5\SDL_dx5audio.c" />
   3.105 -    <ClCompile Include="..\..\src\joystick\win32\SDL_dxjoystick.c" />
   3.106 +    <ClCompile Include="..\..\src\joystick\windows\SDL_dxjoystick.c" />
   3.107      <ClCompile Include="..\..\src\SDL_error.c" />
   3.108      <ClCompile Include="..\..\src\events\SDL_events.c" />
   3.109      <ClCompile Include="..\..\src\SDL_fatal.c" />
   3.110      <ClCompile Include="..\..\src\video\SDL_fillrect.c" />
   3.111      <ClCompile Include="..\..\src\video\SDL_gamma.c" />
   3.112 -    <ClCompile Include="..\..\src\video\win32\SDL_gdirender.c" />
   3.113 +    <ClCompile Include="..\..\src\video\windows\SDL_gdirender.c" />
   3.114      <ClCompile Include="..\..\src\stdlib\SDL_getenv.c" />
   3.115      <ClCompile Include="..\..\src\haptic\SDL_haptic.c" />
   3.116      <ClCompile Include="..\..\src\stdlib\SDL_iconv.c" />
   3.117 @@ -414,7 +414,7 @@
   3.118      <ClCompile Include="..\..\src\audio\SDL_mixer_m68k.c" />
   3.119      <ClCompile Include="..\..\src\audio\SDL_mixer_MMX.c" />
   3.120      <ClCompile Include="..\..\src\audio\SDL_mixer_MMX_VC.c" />
   3.121 -    <ClCompile Include="..\..\src\joystick\win32\SDL_mmjoystick.c" />
   3.122 +    <ClCompile Include="..\..\src\joystick\windows\SDL_mmjoystick.c" />
   3.123      <ClCompile Include="..\..\src\events\SDL_mouse.c" />
   3.124      <ClCompile Include="..\..\src\video\dummy\SDL_nullevents.c" />
   3.125      <ClCompile Include="..\..\src\video\dummy\SDL_nullrender.c" />
   3.126 @@ -432,27 +432,27 @@
   3.127      <ClCompile Include="..\..\src\video\SDL_stretch.c" />
   3.128      <ClCompile Include="..\..\src\stdlib\SDL_string.c" />
   3.129      <ClCompile Include="..\..\src\video\SDL_surface.c" />
   3.130 -    <ClCompile Include="..\..\src\haptic\win32\SDL_syshaptic.c" />
   3.131 -    <ClCompile Include="..\..\src\loadso\win32\SDL_sysloadso.c" />
   3.132 -    <ClCompile Include="..\..\src\thread\win32\SDL_sysmutex.c" />
   3.133 +    <ClCompile Include="..\..\src\haptic\windows\SDL_syshaptic.c" />
   3.134 +    <ClCompile Include="..\..\src\loadso\windows\SDL_sysloadso.c" />
   3.135 +    <ClCompile Include="..\..\src\thread\windows\SDL_sysmutex.c" />
   3.136      <ClCompile Include="..\..\src\power\windows\SDL_syspower.c" />
   3.137 -    <ClCompile Include="..\..\src\thread\win32\SDL_syssem.c" />
   3.138 -    <ClCompile Include="..\..\src\thread\win32\SDL_systhread.c" />
   3.139 -    <ClCompile Include="..\..\src\timer\win32\SDL_systimer.c" />
   3.140 +    <ClCompile Include="..\..\src\thread\windows\SDL_syssem.c" />
   3.141 +    <ClCompile Include="..\..\src\thread\windows\SDL_systhread.c" />
   3.142 +    <ClCompile Include="..\..\src\timer\windows\SDL_systimer.c" />
   3.143      <ClCompile Include="..\..\src\thread\SDL_thread.c" />
   3.144      <ClCompile Include="..\..\src\timer\SDL_timer.c" />
   3.145      <ClCompile Include="..\..\src\video\SDL_video.c" />
   3.146      <ClCompile Include="..\..\src\audio\SDL_wave.c" />
   3.147 -    <ClCompile Include="..\..\src\video\win32\SDL_win32clipboard.c" />
   3.148 -    <ClCompile Include="..\..\src\video\win32\SDL_win32events.c" />
   3.149 -    <ClCompile Include="..\..\src\video\win32\SDL_win32gamma.c" />
   3.150 -    <ClCompile Include="..\..\src\video\win32\SDL_win32keyboard.c" />
   3.151 -    <ClCompile Include="..\..\src\video\win32\SDL_win32modes.c" />
   3.152 -    <ClCompile Include="..\..\src\video\win32\SDL_win32mouse.c" />
   3.153 -    <ClCompile Include="..\..\src\video\win32\SDL_win32opengl.c" />
   3.154 -    <ClCompile Include="..\..\src\video\win32\SDL_win32shape.c" />
   3.155 -    <ClCompile Include="..\..\src\video\win32\SDL_win32video.c" />
   3.156 -    <ClCompile Include="..\..\src\video\win32\SDL_win32window.c" />
   3.157 +    <ClCompile Include="..\..\src\video\windows\SDL_windowsclipboard.c" />
   3.158 +    <ClCompile Include="..\..\src\video\windows\SDL_windowsevents.c" />
   3.159 +    <ClCompile Include="..\..\src\video\windows\SDL_windowsgamma.c" />
   3.160 +    <ClCompile Include="..\..\src\video\windows\SDL_windowskeyboard.c" />
   3.161 +    <ClCompile Include="..\..\src\video\windows\SDL_windowsmodes.c" />
   3.162 +    <ClCompile Include="..\..\src\video\windows\SDL_windowsmouse.c" />
   3.163 +    <ClCompile Include="..\..\src\video\windows\SDL_windowsopengl.c" />
   3.164 +    <ClCompile Include="..\..\src\video\windows\SDL_windowsshape.c" />
   3.165 +    <ClCompile Include="..\..\src\video\windows\SDL_windowsvideo.c" />
   3.166 +    <ClCompile Include="..\..\src\video\windows\SDL_windowswindow.c" />
   3.167      <ClCompile Include="..\..\src\events\SDL_windowevents.c" />
   3.168      <ClCompile Include="..\..\src\video\SDL_yuv_mmx.c" />
   3.169      <ClCompile Include="..\..\src\video\SDL_yuv_sw.c" />
   3.170 @@ -460,4 +460,4 @@
   3.171    <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
   3.172    <ImportGroup Label="ExtensionTargets">
   3.173    </ImportGroup>
   3.174 -</Project>
   3.175 \ No newline at end of file
   3.176 +</Project>
     4.1 --- a/VisualC/SDLmain/SDLmain_VS2005.vcproj	Thu Jan 20 17:33:06 2011 -0800
     4.2 +++ b/VisualC/SDLmain/SDLmain_VS2005.vcproj	Thu Jan 20 18:04:05 2011 -0800
     4.3 @@ -29,7 +29,7 @@
     4.4  			<Tool
     4.5  				Name="VCPreBuildEventTool"
     4.6  				Description="Making sure basic SDL headers are in place..."
     4.7 -				CommandLine="if exist &quot;$(ProjectDir)\..\..\include\SDL_config.h&quot; goto SDLCONFIGOKAY&#x0D;&#x0A;echo Copying SDL_config_win32.h to SDL_config.h...&#x0D;&#x0A;copy &quot;$(ProjectDir)\..\..\include\SDL_config_win32.h&quot; &quot;$(ProjectDir)\..\..\include\SDL_config.h&quot;&#x0D;&#x0A;:SDLCONFIGOKAY&#x0D;&#x0A;&#x0D;&#x0A;if exist &quot;$(ProjectDir)\..\..\include\SDL_revision.h&quot; goto SDLREVISIONOKAY&#x0D;&#x0A;echo Creating stub SDL_revision.h file...&#x0D;&#x0A;echo #define SDL_REVISION 0 &gt;&quot;$(ProjectDir)\..\..\include\SDL_revision.h&quot;&#x0D;&#x0A;:SDLREVISIONOKAY&#x0D;&#x0A;"
     4.8 +				CommandLine="if exist &quot;$(ProjectDir)\..\..\include\SDL_config.h&quot; goto SDLCONFIGOKAY&#x0D;&#x0A;echo Copying SDL_config_windows.h to SDL_config.h...&#x0D;&#x0A;copy &quot;$(ProjectDir)\..\..\include\SDL_config_windows.h&quot; &quot;$(ProjectDir)\..\..\include\SDL_config.h&quot;&#x0D;&#x0A;:SDLCONFIGOKAY&#x0D;&#x0A;&#x0D;&#x0A;if exist &quot;$(ProjectDir)\..\..\include\SDL_revision.h&quot; goto SDLREVISIONOKAY&#x0D;&#x0A;echo Creating stub SDL_revision.h file...&#x0D;&#x0A;echo #define SDL_REVISION 0 &gt;&quot;$(ProjectDir)\..\..\include\SDL_revision.h&quot;&#x0D;&#x0A;:SDLREVISIONOKAY&#x0D;&#x0A;"
     4.9  			/>
    4.10  			<Tool
    4.11  				Name="VCCustomBuildTool"
    4.12 @@ -164,7 +164,7 @@
    4.13  			<Tool
    4.14  				Name="VCPreBuildEventTool"
    4.15  				Description="Making sure basic SDL headers are in place..."
    4.16 -				CommandLine="if exist &quot;$(ProjectDir)\..\..\include\SDL_config.h&quot; goto SDLCONFIGOKAY&#x0D;&#x0A;echo Copying SDL_config_win32.h to SDL_config.h...&#x0D;&#x0A;copy &quot;$(ProjectDir)\..\..\include\SDL_config_win32.h&quot; &quot;$(ProjectDir)\..\..\include\SDL_config.h&quot;&#x0D;&#x0A;:SDLCONFIGOKAY&#x0D;&#x0A;&#x0D;&#x0A;if exist &quot;$(ProjectDir)\..\..\include\SDL_revision.h&quot; goto SDLREVISIONOKAY&#x0D;&#x0A;echo Creating stub SDL_revision.h file...&#x0D;&#x0A;echo #define SDL_REVISION 0 &gt;&quot;$(ProjectDir)\..\..\include\SDL_revision.h&quot;&#x0D;&#x0A;:SDLREVISIONOKAY&#x0D;&#x0A;"
    4.17 +				CommandLine="if exist &quot;$(ProjectDir)\..\..\include\SDL_config.h&quot; goto SDLCONFIGOKAY&#x0D;&#x0A;echo Copying SDL_config_windows.h to SDL_config.h...&#x0D;&#x0A;copy &quot;$(ProjectDir)\..\..\include\SDL_config_windows.h&quot; &quot;$(ProjectDir)\..\..\include\SDL_config.h&quot;&#x0D;&#x0A;:SDLCONFIGOKAY&#x0D;&#x0A;&#x0D;&#x0A;if exist &quot;$(ProjectDir)\..\..\include\SDL_revision.h&quot; goto SDLREVISIONOKAY&#x0D;&#x0A;echo Creating stub SDL_revision.h file...&#x0D;&#x0A;echo #define SDL_REVISION 0 &gt;&quot;$(ProjectDir)\..\..\include\SDL_revision.h&quot;&#x0D;&#x0A;:SDLREVISIONOKAY&#x0D;&#x0A;"
    4.18  			/>
    4.19  			<Tool
    4.20  				Name="VCCustomBuildTool"
    4.21 @@ -299,7 +299,7 @@
    4.22  			<Tool
    4.23  				Name="VCPreBuildEventTool"
    4.24  				Description="Making sure basic SDL headers are in place..."
    4.25 -				CommandLine="if exist &quot;$(ProjectDir)\..\..\include\SDL_config.h&quot; goto SDLCONFIGOKAY&#x0D;&#x0A;echo Copying SDL_config_win32.h to SDL_config.h...&#x0D;&#x0A;copy &quot;$(ProjectDir)\..\..\include\SDL_config_win32.h&quot; &quot;$(ProjectDir)\..\..\include\SDL_config.h&quot;&#x0D;&#x0A;:SDLCONFIGOKAY&#x0D;&#x0A;&#x0D;&#x0A;if exist &quot;$(ProjectDir)\..\..\include\SDL_revision.h&quot; goto SDLREVISIONOKAY&#x0D;&#x0A;echo Creating stub SDL_revision.h file...&#x0D;&#x0A;echo #define SDL_REVISION 0 &gt;&quot;$(ProjectDir)\..\..\include\SDL_revision.h&quot;&#x0D;&#x0A;:SDLREVISIONOKAY&#x0D;&#x0A;"
    4.26 +				CommandLine="if exist &quot;$(ProjectDir)\..\..\include\SDL_config.h&quot; goto SDLCONFIGOKAY&#x0D;&#x0A;echo Copying SDL_config_windows.h to SDL_config.h...&#x0D;&#x0A;copy &quot;$(ProjectDir)\..\..\include\SDL_config_windows.h&quot; &quot;$(ProjectDir)\..\..\include\SDL_config.h&quot;&#x0D;&#x0A;:SDLCONFIGOKAY&#x0D;&#x0A;&#x0D;&#x0A;if exist &quot;$(ProjectDir)\..\..\include\SDL_revision.h&quot; goto SDLREVISIONOKAY&#x0D;&#x0A;echo Creating stub SDL_revision.h file...&#x0D;&#x0A;echo #define SDL_REVISION 0 &gt;&quot;$(ProjectDir)\..\..\include\SDL_revision.h&quot;&#x0D;&#x0A;:SDLREVISIONOKAY&#x0D;&#x0A;"
    4.27  			/>
    4.28  			<Tool
    4.29  				Name="VCCustomBuildTool"
    4.30 @@ -425,7 +425,7 @@
    4.31  	</References>
    4.32  	<Files>
    4.33  		<File
    4.34 -			RelativePath="..\..\Src\Main\Win32\SDL_win32_main.c"
    4.35 +			RelativePath="..\..\src\main\windows\SDL_windows_main.c"
    4.36  			>
    4.37  		</File>
    4.38  	</Files>
     5.1 --- a/VisualC/SDLmain/SDLmain_VS2008.vcproj	Thu Jan 20 17:33:06 2011 -0800
     5.2 +++ b/VisualC/SDLmain/SDLmain_VS2008.vcproj	Thu Jan 20 18:04:05 2011 -0800
     5.3 @@ -30,7 +30,7 @@
     5.4  			<Tool
     5.5  				Name="VCPreBuildEventTool"
     5.6  				Description="Making sure basic SDL headers are in place..."
     5.7 -				CommandLine="if exist &quot;$(ProjectDir)\..\..\include\SDL_config.h&quot; goto SDLCONFIGOKAY&#x0D;&#x0A;echo Copying SDL_config_win32.h to SDL_config.h...&#x0D;&#x0A;copy &quot;$(ProjectDir)\..\..\include\SDL_config_win32.h&quot; &quot;$(ProjectDir)\..\..\include\SDL_config.h&quot;&#x0D;&#x0A;:SDLCONFIGOKAY&#x0D;&#x0A;&#x0D;&#x0A;if exist &quot;$(ProjectDir)\..\..\include\SDL_revision.h&quot; goto SDLREVISIONOKAY&#x0D;&#x0A;echo Creating stub SDL_revision.h file...&#x0D;&#x0A;echo #define SDL_REVISION 0 &gt;&quot;$(ProjectDir)\..\..\include\SDL_revision.h&quot;&#x0D;&#x0A;:SDLREVISIONOKAY&#x0D;&#x0A;"
     5.8 +				CommandLine="if exist &quot;$(ProjectDir)\..\..\include\SDL_config.h&quot; goto SDLCONFIGOKAY&#x0D;&#x0A;echo Copying SDL_config_windows.h to SDL_config.h...&#x0D;&#x0A;copy &quot;$(ProjectDir)\..\..\include\SDL_config_windows.h&quot; &quot;$(ProjectDir)\..\..\include\SDL_config.h&quot;&#x0D;&#x0A;:SDLCONFIGOKAY&#x0D;&#x0A;&#x0D;&#x0A;if exist &quot;$(ProjectDir)\..\..\include\SDL_revision.h&quot; goto SDLREVISIONOKAY&#x0D;&#x0A;echo Creating stub SDL_revision.h file...&#x0D;&#x0A;echo #define SDL_REVISION 0 &gt;&quot;$(ProjectDir)\..\..\include\SDL_revision.h&quot;&#x0D;&#x0A;:SDLREVISIONOKAY&#x0D;&#x0A;"
     5.9  			/>
    5.10  			<Tool
    5.11  				Name="VCCustomBuildTool"
    5.12 @@ -165,7 +165,7 @@
    5.13  			<Tool
    5.14  				Name="VCPreBuildEventTool"
    5.15  				Description="Making sure basic SDL headers are in place..."
    5.16 -				CommandLine="if exist &quot;$(ProjectDir)\..\..\include\SDL_config.h&quot; goto SDLCONFIGOKAY&#x0D;&#x0A;echo Copying SDL_config_win32.h to SDL_config.h...&#x0D;&#x0A;copy &quot;$(ProjectDir)\..\..\include\SDL_config_win32.h&quot; &quot;$(ProjectDir)\..\..\include\SDL_config.h&quot;&#x0D;&#x0A;:SDLCONFIGOKAY&#x0D;&#x0A;&#x0D;&#x0A;if exist &quot;$(ProjectDir)\..\..\include\SDL_revision.h&quot; goto SDLREVISIONOKAY&#x0D;&#x0A;echo Creating stub SDL_revision.h file...&#x0D;&#x0A;echo #define SDL_REVISION 0 &gt;&quot;$(ProjectDir)\..\..\include\SDL_revision.h&quot;&#x0D;&#x0A;:SDLREVISIONOKAY&#x0D;&#x0A;"
    5.17 +				CommandLine="if exist &quot;$(ProjectDir)\..\..\include\SDL_config.h&quot; goto SDLCONFIGOKAY&#x0D;&#x0A;echo Copying SDL_config_windows.h to SDL_config.h...&#x0D;&#x0A;copy &quot;$(ProjectDir)\..\..\include\SDL_config_windows.h&quot; &quot;$(ProjectDir)\..\..\include\SDL_config.h&quot;&#x0D;&#x0A;:SDLCONFIGOKAY&#x0D;&#x0A;&#x0D;&#x0A;if exist &quot;$(ProjectDir)\..\..\include\SDL_revision.h&quot; goto SDLREVISIONOKAY&#x0D;&#x0A;echo Creating stub SDL_revision.h file...&#x0D;&#x0A;echo #define SDL_REVISION 0 &gt;&quot;$(ProjectDir)\..\..\include\SDL_revision.h&quot;&#x0D;&#x0A;:SDLREVISIONOKAY&#x0D;&#x0A;"
    5.18  			/>
    5.19  			<Tool
    5.20  				Name="VCCustomBuildTool"
    5.21 @@ -300,7 +300,7 @@
    5.22  			<Tool
    5.23  				Name="VCPreBuildEventTool"
    5.24  				Description="Making sure basic SDL headers are in place..."
    5.25 -				CommandLine="if exist &quot;$(ProjectDir)\..\..\include\SDL_config.h&quot; goto SDLCONFIGOKAY&#x0D;&#x0A;echo Copying SDL_config_win32.h to SDL_config.h...&#x0D;&#x0A;copy &quot;$(ProjectDir)\..\..\include\SDL_config_win32.h&quot; &quot;$(ProjectDir)\..\..\include\SDL_config.h&quot;&#x0D;&#x0A;:SDLCONFIGOKAY&#x0D;&#x0A;&#x0D;&#x0A;if exist &quot;$(ProjectDir)\..\..\include\SDL_revision.h&quot; goto SDLREVISIONOKAY&#x0D;&#x0A;echo Creating stub SDL_revision.h file...&#x0D;&#x0A;echo #define SDL_REVISION 0 &gt;&quot;$(ProjectDir)\..\..\include\SDL_revision.h&quot;&#x0D;&#x0A;:SDLREVISIONOKAY&#x0D;&#x0A;"
    5.26 +				CommandLine="if exist &quot;$(ProjectDir)\..\..\include\SDL_config.h&quot; goto SDLCONFIGOKAY&#x0D;&#x0A;echo Copying SDL_config_windows.h to SDL_config.h...&#x0D;&#x0A;copy &quot;$(ProjectDir)\..\..\include\SDL_config_windows.h&quot; &quot;$(ProjectDir)\..\..\include\SDL_config.h&quot;&#x0D;&#x0A;:SDLCONFIGOKAY&#x0D;&#x0A;&#x0D;&#x0A;if exist &quot;$(ProjectDir)\..\..\include\SDL_revision.h&quot; goto SDLREVISIONOKAY&#x0D;&#x0A;echo Creating stub SDL_revision.h file...&#x0D;&#x0A;echo #define SDL_REVISION 0 &gt;&quot;$(ProjectDir)\..\..\include\SDL_revision.h&quot;&#x0D;&#x0A;:SDLREVISIONOKAY&#x0D;&#x0A;"
    5.27  			/>
    5.28  			<Tool
    5.29  				Name="VCCustomBuildTool"
    5.30 @@ -426,7 +426,7 @@
    5.31  	</References>
    5.32  	<Files>
    5.33  		<File
    5.34 -			RelativePath="..\..\Src\Main\Win32\SDL_win32_main.c"
    5.35 +			RelativePath="..\..\src\main\windows\SDL_windows_main.c"
    5.36  			>
    5.37  		</File>
    5.38  	</Files>
     6.1 --- a/VisualC/SDLmain/SDLmain_VS2010.vcxproj	Thu Jan 20 17:33:06 2011 -0800
     6.2 +++ b/VisualC/SDLmain/SDLmain_VS2010.vcxproj	Thu Jan 20 18:04:05 2011 -0800
     6.3 @@ -102,8 +102,8 @@
     6.4      <PreBuildEvent>
     6.5        <Message>Making sure basic SDL headers are in place...</Message>
     6.6        <Command>if exist "$(ProjectDir)\..\..\include\SDL_config.h" goto SDLCONFIGOKAY
     6.7 -echo Copying SDL_config_win32.h to SDL_config.h...
     6.8 -copy "$(ProjectDir)\..\..\include\SDL_config_win32.h" "$(ProjectDir)\..\..\include\SDL_config.h"
     6.9 +echo Copying SDL_config_windows.h to SDL_config.h...
    6.10 +copy "$(ProjectDir)\..\..\include\SDL_config_windows.h" "$(ProjectDir)\..\..\include\SDL_config.h"
    6.11  :SDLCONFIGOKAY
    6.12  
    6.13  if exist "$(ProjectDir)\..\..\include\SDL_revision.h" goto SDLREVISIONOKAY
    6.14 @@ -155,8 +155,8 @@
    6.15      <PreBuildEvent>
    6.16        <Message>Making sure basic SDL headers are in place...</Message>
    6.17        <Command>if exist "$(ProjectDir)\..\..\include\SDL_config.h" goto SDLCONFIGOKAY
    6.18 -echo Copying SDL_config_win32.h to SDL_config.h...
    6.19 -copy "$(ProjectDir)\..\..\include\SDL_config_win32.h" "$(ProjectDir)\..\..\include\SDL_config.h"
    6.20 +echo Copying SDL_config_windows.h to SDL_config.h...
    6.21 +copy "$(ProjectDir)\..\..\include\SDL_config_windows.h" "$(ProjectDir)\..\..\include\SDL_config.h"
    6.22  :SDLCONFIGOKAY
    6.23  
    6.24  if exist "$(ProjectDir)\..\..\include\SDL_revision.h" goto SDLREVISIONOKAY
    6.25 @@ -208,8 +208,8 @@
    6.26      <PreBuildEvent>
    6.27        <Message>Making sure basic SDL headers are in place...</Message>
    6.28        <Command>if exist "$(ProjectDir)\..\..\include\SDL_config.h" goto SDLCONFIGOKAY
    6.29 -echo Copying SDL_config_win32.h to SDL_config.h...
    6.30 -copy "$(ProjectDir)\..\..\include\SDL_config_win32.h" "$(ProjectDir)\..\..\include\SDL_config.h"
    6.31 +echo Copying SDL_config_windows.h to SDL_config.h...
    6.32 +copy "$(ProjectDir)\..\..\include\SDL_config_windows.h" "$(ProjectDir)\..\..\include\SDL_config.h"
    6.33  :SDLCONFIGOKAY
    6.34  
    6.35  if exist "$(ProjectDir)\..\..\include\SDL_revision.h" goto SDLREVISIONOKAY
    6.36 @@ -256,9 +256,9 @@
    6.37      </Lib>
    6.38    </ItemDefinitionGroup>
    6.39    <ItemGroup>
    6.40 -    <ClCompile Include="..\..\Src\Main\Win32\SDL_win32_main.c" />
    6.41 +    <ClCompile Include="..\..\src\main\windows\SDL_windows_main.c" />
    6.42    </ItemGroup>
    6.43    <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
    6.44    <ImportGroup Label="ExtensionTargets">
    6.45    </ImportGroup>
    6.46 -</Project>
    6.47 \ No newline at end of file
    6.48 +</Project>
     7.1 --- a/configure.in	Thu Jan 20 17:33:06 2011 -0800
     7.2 +++ b/configure.in	Thu Jan 20 18:04:05 2011 -0800
     7.3 @@ -1645,8 +1645,8 @@
     7.4  }
     7.5  
     7.6  
     7.7 -dnl Check for Win32 OpenGL
     7.8 -CheckWIN32GL()
     7.9 +dnl Check for Windows OpenGL
    7.10 +CheckWINDOWSGL()
    7.11  {
    7.12      if test x$enable_video = xyes -a x$enable_video_opengl = xyes; then
    7.13          AC_DEFINE(SDL_VIDEO_OPENGL)
    7.14 @@ -1906,10 +1906,10 @@
    7.15      fi
    7.16  }
    7.17  
    7.18 -dnl Determine whether the compiler can produce Win32 executables
    7.19 -CheckWIN32()
    7.20 +dnl Determine whether the compiler can produce Windows executables
    7.21 +CheckWINDOWS()
    7.22  {
    7.23 -    AC_MSG_CHECKING(Win32 compiler)
    7.24 +    AC_MSG_CHECKING(Windows compiler)
    7.25      have_win32_gcc=no
    7.26      AC_TRY_COMPILE([
    7.27       #include <windows.h>
    7.28 @@ -1920,7 +1920,7 @@
    7.29      AC_MSG_RESULT($have_win32_gcc)
    7.30      if test x$have_win32_gcc != xyes; then
    7.31         AC_MSG_ERROR([
    7.32 -*** Your compiler ($CC) does not produce Win32 executables!
    7.33 +*** Your compiler ($CC) does not produce Windows executables!
    7.34         ])
    7.35      fi
    7.36  
    7.37 @@ -1938,7 +1938,7 @@
    7.38  
    7.39      dnl See if the user wants to redirect standard output to files
    7.40      AC_ARG_ENABLE(stdio-redirect,
    7.41 -AC_HELP_STRING([--enable-stdio-redirect], [Redirect STDIO to files on Win32 [[default=yes]]]),
    7.42 +AC_HELP_STRING([--enable-stdio-redirect], [Redirect STDIO to files on Windows [[default=yes]]]),
    7.43                    , enable_stdio_redirect=yes)
    7.44      if test x$enable_stdio_redirect != xyes; then
    7.45          EXTRA_CFLAGS="$EXTRA_CFLAGS -DNO_STDIO_REDIRECT"
    7.46 @@ -1949,7 +1949,7 @@
    7.47  CheckDIRECTX()
    7.48  {
    7.49      AC_ARG_ENABLE(directx,
    7.50 -AC_HELP_STRING([--enable-directx], [use DirectX for Win32 audio/video [[default=yes]]]),
    7.51 +AC_HELP_STRING([--enable-directx], [use DirectX for Windows audio/video [[default=yes]]]),
    7.52                    , enable_directx=yes)
    7.53      if test x$enable_directx = xyes; then
    7.54          AC_CHECK_HEADER(d3d9.h, have_d3d=yes)
    7.55 @@ -2332,10 +2332,10 @@
    7.56          CheckDummyVideo
    7.57          CheckDiskAudio
    7.58          CheckDummyAudio
    7.59 -        CheckWIN32
    7.60 +        CheckWINDOWS
    7.61          if test x$enable_video = xyes; then
    7.62 -            AC_DEFINE(SDL_VIDEO_DRIVER_WIN32)
    7.63 -            SOURCES="$SOURCES $srcdir/src/video/win32/*.c"
    7.64 +            AC_DEFINE(SDL_VIDEO_DRIVER_WINDOWS)
    7.65 +            SOURCES="$SOURCES $srcdir/src/video/windows/*.c"
    7.66              have_video=yes
    7.67              AC_ARG_ENABLE(render-gdi,
    7.68  AC_HELP_STRING([--enable-render-gdi], [enable the GDI render driver [[default=yes]]]),
    7.69 @@ -2381,10 +2381,10 @@
    7.70          fi
    7.71          # Set up files for the thread library
    7.72          if test x$enable_threads = xyes; then
    7.73 -            AC_DEFINE(SDL_THREAD_WIN32)
    7.74 -            SOURCES="$SOURCES $srcdir/src/thread/win32/SDL_sysmutex.c"
    7.75 -            SOURCES="$SOURCES $srcdir/src/thread/win32/SDL_syssem.c"
    7.76 -            SOURCES="$SOURCES $srcdir/src/thread/win32/SDL_systhread.c"
    7.77 +            AC_DEFINE(SDL_THREAD_WINDOWS)
    7.78 +            SOURCES="$SOURCES $srcdir/src/thread/windows/SDL_sysmutex.c"
    7.79 +            SOURCES="$SOURCES $srcdir/src/thread/windows/SDL_syssem.c"
    7.80 +            SOURCES="$SOURCES $srcdir/src/thread/windows/SDL_systhread.c"
    7.81              SOURCES="$SOURCES $srcdir/src/thread/generic/SDL_syscond.c"
    7.82              have_threads=yes
    7.83          fi
    7.84 @@ -2396,8 +2396,8 @@
    7.85          fi
    7.86          # Set up files for the shared object loading library
    7.87          if test x$enable_loadso = xyes; then
    7.88 -            AC_DEFINE(SDL_LOADSO_WIN32)
    7.89 -            SOURCES="$SOURCES $srcdir/src/loadso/win32/*.c"
    7.90 +            AC_DEFINE(SDL_LOADSO_WINDOWS)
    7.91 +            SOURCES="$SOURCES $srcdir/src/loadso/windows/*.c"
    7.92              have_loadso=yes
    7.93          fi
    7.94          # Set up the system libraries we need
    7.95 @@ -2412,8 +2412,8 @@
    7.96          	;;
    7.97  	esac
    7.98  
    7.99 -        # The Win32 platform requires special setup
   7.100 -        SDLMAIN_SOURCES="$srcdir/src/main/win32/*.c"
   7.101 +        # The Windows platform requires special setup
   7.102 +        SDLMAIN_SOURCES="$srcdir/src/main/windows/*.c"
   7.103          EXTRA_CFLAGS="$EXTRA_CFLAGS -Dmain=SDL_main -D_WIN32_WCE=0x420"
   7.104          EXTRA_LDFLAGS="-lSDLmain $EXTRA_LDFLAGS"
   7.105          ;;
   7.106 @@ -2431,13 +2431,13 @@
   7.107          CheckDummyVideo
   7.108          CheckDiskAudio
   7.109          CheckDummyAudio
   7.110 -        CheckWIN32
   7.111 -        CheckWIN32GL
   7.112 +        CheckWINDOWS
   7.113 +        CheckWINDOWSGL
   7.114          CheckDIRECTX
   7.115          # Set up files for the video library
   7.116          if test x$enable_video = xyes; then
   7.117 -            AC_DEFINE(SDL_VIDEO_DRIVER_WIN32)
   7.118 -            SOURCES="$SOURCES $srcdir/src/video/win32/*.c"
   7.119 +            AC_DEFINE(SDL_VIDEO_DRIVER_WINDOWS)
   7.120 +            SOURCES="$SOURCES $srcdir/src/video/windows/*.c"
   7.121              have_video=yes
   7.122              AC_ARG_ENABLE(render-gdi,
   7.123  AC_HELP_STRING([--enable-render-gdi], [enable the GDI render driver [[default=yes]]]),
   7.124 @@ -2466,18 +2466,18 @@
   7.125          if test x$enable_joystick = xyes; then
   7.126              if test x$have_dinput = xyes; then
   7.127                  AC_DEFINE(SDL_JOYSTICK_DINPUT)
   7.128 -                SOURCES="$SOURCES $srcdir/src/joystick/win32/SDL_dxjoystick.c"
   7.129 +                SOURCES="$SOURCES $srcdir/src/joystick/windows/SDL_dxjoystick.c"
   7.130                  EXTRA_LDFLAGS="$EXTRA_LDFLAGS -ldinput8 -ldxguid -ldxerr8"
   7.131              else
   7.132                  AC_DEFINE(SDL_JOYSTICK_WINMM)
   7.133 -                SOURCES="$SOURCES $srcdir/src/joystick/win32/SDL_mmjoystick.c"
   7.134 +                SOURCES="$SOURCES $srcdir/src/joystick/windows/SDL_mmjoystick.c"
   7.135              fi
   7.136              have_joystick=yes
   7.137          fi
   7.138          if test x$enable_haptic = xyes; then
   7.139              if test x$have_dinput = xyes; then
   7.140                  AC_DEFINE(SDL_HAPTIC_DINPUT)
   7.141 -                SOURCES="$SOURCES $srcdir/src/haptic/win32/SDL_syshaptic.c"
   7.142 +                SOURCES="$SOURCES $srcdir/src/haptic/windows/SDL_syshaptic.c"
   7.143                  have_haptic=yes
   7.144              fi
   7.145          fi
   7.146 @@ -2488,23 +2488,23 @@
   7.147          fi
   7.148          # Set up files for the thread library
   7.149          if test x$enable_threads = xyes; then
   7.150 -            AC_DEFINE(SDL_THREAD_WIN32)
   7.151 -            SOURCES="$SOURCES $srcdir/src/thread/win32/SDL_sysmutex.c"
   7.152 -            SOURCES="$SOURCES $srcdir/src/thread/win32/SDL_syssem.c"
   7.153 -            SOURCES="$SOURCES $srcdir/src/thread/win32/SDL_systhread.c"
   7.154 +            AC_DEFINE(SDL_THREAD_WINDOWS)
   7.155 +            SOURCES="$SOURCES $srcdir/src/thread/windows/SDL_sysmutex.c"
   7.156 +            SOURCES="$SOURCES $srcdir/src/thread/windows/SDL_syssem.c"
   7.157 +            SOURCES="$SOURCES $srcdir/src/thread/windows/SDL_systhread.c"
   7.158              SOURCES="$SOURCES $srcdir/src/thread/generic/SDL_syscond.c"
   7.159              have_threads=yes
   7.160          fi
   7.161          # Set up files for the timer library
   7.162          if test x$enable_timers = xyes; then
   7.163 -            AC_DEFINE(SDL_TIMER_WIN32)
   7.164 -            SOURCES="$SOURCES $srcdir/src/timer/win32/*.c"
   7.165 +            AC_DEFINE(SDL_TIMER_WINDOWS)
   7.166 +            SOURCES="$SOURCES $srcdir/src/timer/windows/*.c"
   7.167              have_timers=yes
   7.168          fi
   7.169          # Set up files for the shared object loading library
   7.170          if test x$enable_loadso = xyes; then
   7.171 -            AC_DEFINE(SDL_LOADSO_WIN32)
   7.172 -            SOURCES="$SOURCES $srcdir/src/loadso/win32/*.c"
   7.173 +            AC_DEFINE(SDL_LOADSO_WINDOWS)
   7.174 +            SOURCES="$SOURCES $srcdir/src/loadso/windows/*.c"
   7.175              have_loadso=yes
   7.176          fi
   7.177          # Set up the system libraries we need
   7.178 @@ -2512,9 +2512,9 @@
   7.179          # You can get this here: http://libunicows.sourceforge.net/
   7.180          #EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lunicows"
   7.181          EXTRA_LDFLAGS="$EXTRA_LDFLAGS -luser32 -lgdi32 -lmsimg32 -lwinmm -limm32 -lole32 -loleaut32 -lversion -luuid"
   7.182 -        # The Win32 platform requires special setup
   7.183 -        VERSION_SOURCES="$srcdir/src/main/win32/*.rc"
   7.184 -        SDLMAIN_SOURCES="$srcdir/src/main/win32/*.c"
   7.185 +        # The Windows platform requires special setup
   7.186 +        VERSION_SOURCES="$srcdir/src/main/windows/*.rc"
   7.187 +        SDLMAIN_SOURCES="$srcdir/src/main/windows/*.c"
   7.188          SDL_CFLAGS="$SDL_CFLAGS -Dmain=SDL_main"
   7.189          SDL_LIBS="-lmingw32 -lSDLmain $SDL_LIBS -mwindows"
   7.190          ;;
     8.1 --- a/include/SDL_compat.h	Thu Jan 20 17:33:06 2011 -0800
     8.2 +++ b/include/SDL_compat.h	Thu Jan 20 18:04:05 2011 -0800
     8.3 @@ -64,6 +64,12 @@
     8.4   */
     8.5  /*@{*/
     8.6  
     8.7 +/* Platform */
     8.8 +#ifdef __WINDOWS__
     8.9 +#undef __WIN32__
    8.10 +#define __WIN32__   1
    8.11 +#endif
    8.12 +
    8.13  /**
    8.14   *  \name Surface flags
    8.15   */
     9.1 --- a/include/SDL_config.h.default	Thu Jan 20 17:33:06 2011 -0800
     9.2 +++ b/include/SDL_config.h.default	Thu Jan 20 18:04:05 2011 -0800
     9.3 @@ -40,8 +40,8 @@
     9.4  #include "SDL_config_iphoneos.h"
     9.5  #elif defined(__MACOSX__)
     9.6  #include "SDL_config_macosx.h"
     9.7 -#elif defined(__WIN32__)
     9.8 -#include "SDL_config_win32.h"
     9.9 +#elif defined(__WINDOWS__)
    9.10 +#include "SDL_config_windows.h"
    9.11  #else
    9.12  #include "SDL_config_minimal.h"
    9.13  #endif /* platform config */
    10.1 --- a/include/SDL_config.h.in	Thu Jan 20 17:33:06 2011 -0800
    10.2 +++ b/include/SDL_config.h.in	Thu Jan 20 18:04:05 2011 -0800
    10.3 @@ -89,7 +89,7 @@
    10.4  #undef HAVE_REALLOC
    10.5  #undef HAVE_FREE
    10.6  #undef HAVE_ALLOCA
    10.7 -#ifndef _WIN32 /* Don't use C runtime versions of these on Windows */
    10.8 +#ifndef __WINDOWS__ /* Don't use C runtime versions of these on Windows */
    10.9  #undef HAVE_GETENV
   10.10  #undef HAVE_SETENV
   10.11  #undef HAVE_PUTENV
   10.12 @@ -235,7 +235,7 @@
   10.13  #undef SDL_LOADSO_DLOPEN
   10.14  #undef SDL_LOADSO_DUMMY
   10.15  #undef SDL_LOADSO_LDG
   10.16 -#undef SDL_LOADSO_WIN32
   10.17 +#undef SDL_LOADSO_WINDOWS
   10.18  
   10.19  /* Enable various threading systems */
   10.20  #undef SDL_THREAD_BEOS
   10.21 @@ -244,7 +244,7 @@
   10.22  #undef SDL_THREAD_PTHREAD_RECURSIVE_MUTEX
   10.23  #undef SDL_THREAD_PTHREAD_RECURSIVE_MUTEX_NP
   10.24  #undef SDL_THREAD_SPROC
   10.25 -#undef SDL_THREAD_WIN32
   10.26 +#undef SDL_THREAD_WINDOWS
   10.27  
   10.28  /* Enable various timer systems */
   10.29  #undef SDL_TIMER_BEOS
   10.30 @@ -252,7 +252,7 @@
   10.31  #undef SDL_TIMER_NDS
   10.32  #undef SDL_TIMER_RISCOS
   10.33  #undef SDL_TIMER_UNIX
   10.34 -#undef SDL_TIMER_WIN32
   10.35 +#undef SDL_TIMER_WINDOWS
   10.36  #undef SDL_TIMER_WINCE
   10.37  
   10.38  /* Enable various video drivers */
   10.39 @@ -265,7 +265,7 @@
   10.40  #undef SDL_VIDEO_DRIVER_PHOTON
   10.41  #undef SDL_VIDEO_DRIVER_QNXGF
   10.42  #undef SDL_VIDEO_DRIVER_RISCOS
   10.43 -#undef SDL_VIDEO_DRIVER_WIN32
   10.44 +#undef SDL_VIDEO_DRIVER_WINDOWS
   10.45  #undef SDL_VIDEO_DRIVER_X11
   10.46  #undef SDL_VIDEO_DRIVER_X11_DYNAMIC
   10.47  #undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT
    11.1 --- a/include/SDL_config_win32.h	Thu Jan 20 17:33:06 2011 -0800
    11.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    11.3 @@ -1,199 +0,0 @@
    11.4 -/*
    11.5 -    SDL - Simple DirectMedia Layer
    11.6 -    Copyright (C) 1997-2010 Sam Lantinga
    11.7 -
    11.8 -    This library is free software; you can redistribute it and/or
    11.9 -    modify it under the terms of the GNU Lesser General Public
   11.10 -    License as published by the Free Software Foundation; either
   11.11 -    version 2.1 of the License, or (at your option) any later version.
   11.12 -
   11.13 -    This library is distributed in the hope that it will be useful,
   11.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
   11.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   11.16 -    Lesser General Public License for more details.
   11.17 -
   11.18 -    You should have received a copy of the GNU Lesser General Public
   11.19 -    License along with this library; if not, write to the Free Software
   11.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   11.21 -
   11.22 -    Sam Lantinga
   11.23 -    slouken@libsdl.org
   11.24 -*/
   11.25 -
   11.26 -#ifndef _SDL_config_win32_h
   11.27 -#define _SDL_config_win32_h
   11.28 -
   11.29 -#include "SDL_platform.h"
   11.30 -
   11.31 -/* This is a set of defines to configure the SDL features */
   11.32 -
   11.33 -#if !defined(_STDINT_H_) && (!defined(HAVE_STDINT_H) || !_HAVE_STDINT_H)
   11.34 -#if defined(__GNUC__) || defined(__DMC__) || defined(__WATCOMC__)
   11.35 -#define HAVE_STDINT_H	1
   11.36 -#elif defined(_MSC_VER)
   11.37 -typedef signed __int8 int8_t;
   11.38 -typedef unsigned __int8 uint8_t;
   11.39 -typedef signed __int16 int16_t;
   11.40 -typedef unsigned __int16 uint16_t;
   11.41 -typedef signed __int32 int32_t;
   11.42 -typedef unsigned __int32 uint32_t;
   11.43 -typedef signed __int64 int64_t;
   11.44 -typedef unsigned __int64 uint64_t;
   11.45 -#ifndef _UINTPTR_T_DEFINED
   11.46 -#ifdef  _WIN64
   11.47 -typedef unsigned __int64 uintptr_t;
   11.48 -#else
   11.49 -typedef unsigned int uintptr_t;
   11.50 -#endif
   11.51 -#define _UINTPTR_T_DEFINED
   11.52 -#endif
   11.53 -/* Older Visual C++ headers don't have the Win64-compatible typedefs... */
   11.54 -#if ((_MSC_VER <= 1200) && (!defined(DWORD_PTR)))
   11.55 -#define DWORD_PTR DWORD
   11.56 -#endif
   11.57 -#if ((_MSC_VER <= 1200) && (!defined(LONG_PTR)))
   11.58 -#define LONG_PTR LONG
   11.59 -#endif
   11.60 -#else /* !__GNUC__ && !_MSC_VER */
   11.61 -typedef signed char int8_t;
   11.62 -typedef unsigned char uint8_t;
   11.63 -typedef signed short int16_t;
   11.64 -typedef unsigned short uint16_t;
   11.65 -typedef signed int int32_t;
   11.66 -typedef unsigned int uint32_t;
   11.67 -typedef signed long long int64_t;
   11.68 -typedef unsigned long long uint64_t;
   11.69 -#ifndef _SIZE_T_DEFINED_
   11.70 -#define _SIZE_T_DEFINED_
   11.71 -typedef unsigned int size_t;
   11.72 -#endif
   11.73 -typedef unsigned int uintptr_t;
   11.74 -#endif /* __GNUC__ || _MSC_VER */
   11.75 -#endif /* !_STDINT_H_ && !HAVE_STDINT_H */
   11.76 -
   11.77 -#ifdef _WIN64
   11.78 -# define SIZEOF_VOIDP 8
   11.79 -#else
   11.80 -# define SIZEOF_VOIDP 4
   11.81 -#endif
   11.82 -#define SDL_HAS_64BIT_TYPE	1
   11.83 -
   11.84 -/* Enabled for SDL 1.2 (binary compatibility) */
   11.85 -//#define HAVE_LIBC     1
   11.86 -#ifdef HAVE_LIBC
   11.87 -/* Useful headers */
   11.88 -#define HAVE_STDIO_H 1
   11.89 -#define STDC_HEADERS 1
   11.90 -#define HAVE_STRING_H 1
   11.91 -#define HAVE_CTYPE_H 1
   11.92 -#define HAVE_MATH_H 1
   11.93 -#ifndef _WIN32_WCE
   11.94 -#define HAVE_SIGNAL_H 1
   11.95 -#endif
   11.96 -
   11.97 -/* C library functions */
   11.98 -#define HAVE_MALLOC 1
   11.99 -#define HAVE_CALLOC 1
  11.100 -#define HAVE_REALLOC 1
  11.101 -#define HAVE_FREE 1
  11.102 -#define HAVE_ALLOCA 1
  11.103 -#define HAVE_QSORT 1
  11.104 -#define HAVE_ABS 1
  11.105 -#define HAVE_MEMSET 1
  11.106 -#define HAVE_MEMCPY 1
  11.107 -#define HAVE_MEMMOVE 1
  11.108 -#define HAVE_MEMCMP 1
  11.109 -#define HAVE_STRLEN 1
  11.110 -#define HAVE__STRREV 1
  11.111 -#define HAVE__STRUPR 1
  11.112 -#define HAVE__STRLWR 1
  11.113 -#define HAVE_STRCHR 1
  11.114 -#define HAVE_STRRCHR 1
  11.115 -#define HAVE_STRSTR 1
  11.116 -#define HAVE_ITOA 1
  11.117 -#define HAVE__LTOA 1
  11.118 -#define HAVE__ULTOA 1
  11.119 -#define HAVE_STRTOL 1
  11.120 -#define HAVE_STRTOUL 1
  11.121 -#define HAVE_STRTOLL 1
  11.122 -#define HAVE_STRTOD 1
  11.123 -#define HAVE_ATOI 1
  11.124 -#define HAVE_ATOF 1
  11.125 -#define HAVE_STRCMP 1
  11.126 -#define HAVE_STRNCMP 1
  11.127 -#define HAVE__STRICMP 1
  11.128 -#define HAVE__STRNICMP 1
  11.129 -#define HAVE_SSCANF 1
  11.130 -#define HAVE_M_PI 1
  11.131 -#define HAVE_ATAN 1
  11.132 -#define HAVE_ATAN2 1
  11.133 -#define HAVE_CEIL 1
  11.134 -#define HAVE_COPYSIGN 1
  11.135 -#define HAVE_COS 1
  11.136 -#define HAVE_COSF 1
  11.137 -#define HAVE_FABS 1
  11.138 -#define HAVE_FLOOR 1
  11.139 -#define HAVE_LOG 1
  11.140 -#define HAVE_POW 1
  11.141 -#define HAVE_SCALBN 1
  11.142 -#define HAVE_SIN 1
  11.143 -#define HAVE_SINF 1
  11.144 -#define HAVE_SQRT 1
  11.145 -#else
  11.146 -#define HAVE_STDARG_H	1
  11.147 -#define HAVE_STDDEF_H	1
  11.148 -#endif
  11.149 -
  11.150 -/* Enable various audio drivers */
  11.151 -#ifndef _WIN32_WCE
  11.152 -#define SDL_AUDIO_DRIVER_DSOUND	1
  11.153 -#endif
  11.154 -#define SDL_AUDIO_DRIVER_WINWAVEOUT	1
  11.155 -#define SDL_AUDIO_DRIVER_DISK	1
  11.156 -#define SDL_AUDIO_DRIVER_DUMMY	1
  11.157 -
  11.158 -/* Enable various input drivers */
  11.159 -#ifdef _WIN32_WCE
  11.160 -#define SDL_JOYSTICK_DISABLED	1
  11.161 -#define SDL_HAPTIC_DUMMY	1
  11.162 -#else
  11.163 -#define SDL_JOYSTICK_DINPUT	1
  11.164 -#define SDL_HAPTIC_DINPUT	1
  11.165 -#endif
  11.166 -
  11.167 -/* Enable various shared object loading systems */
  11.168 -#define SDL_LOADSO_WIN32	1
  11.169 -
  11.170 -/* Enable various threading systems */
  11.171 -#define SDL_THREAD_WIN32	1
  11.172 -
  11.173 -/* Enable various timer systems */
  11.174 -#ifdef _WIN32_WCE
  11.175 -#define SDL_TIMER_WINCE	1
  11.176 -#else
  11.177 -#define SDL_TIMER_WIN32	1
  11.178 -#endif
  11.179 -
  11.180 -/* Enable various video drivers */
  11.181 -#define SDL_VIDEO_DRIVER_DUMMY	1
  11.182 -#define SDL_VIDEO_DRIVER_WIN32	1
  11.183 -
  11.184 -#define SDL_VIDEO_RENDER_D3D	1
  11.185 -#define SDL_VIDEO_RENDER_GDI	1
  11.186 -
  11.187 -/* Enable OpenGL support */
  11.188 -#ifndef _WIN32_WCE
  11.189 -#define SDL_VIDEO_OPENGL	1
  11.190 -#define SDL_VIDEO_OPENGL_WGL	1
  11.191 -#define SDL_VIDEO_RENDER_OGL	1
  11.192 -#endif
  11.193 -
  11.194 -/* Enable system power support */
  11.195 -#define SDL_POWER_WINDOWS 1
  11.196 -
  11.197 -/* Enable assembly routines (Win64 doesn't have inline asm) */
  11.198 -#ifndef _WIN64
  11.199 -#define SDL_ASSEMBLY_ROUTINES	1
  11.200 -#endif
  11.201 -
  11.202 -#endif /* _SDL_config_win32_h */
    12.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    12.2 +++ b/include/SDL_config_windows.h	Thu Jan 20 18:04:05 2011 -0800
    12.3 @@ -0,0 +1,199 @@
    12.4 +/*
    12.5 +    SDL - Simple DirectMedia Layer
    12.6 +    Copyright (C) 1997-2010 Sam Lantinga
    12.7 +
    12.8 +    This library is free software; you can redistribute it and/or
    12.9 +    modify it under the terms of the GNU Lesser General Public
   12.10 +    License as published by the Free Software Foundation; either
   12.11 +    version 2.1 of the License, or (at your option) any later version.
   12.12 +
   12.13 +    This library is distributed in the hope that it will be useful,
   12.14 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
   12.15 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   12.16 +    Lesser General Public License for more details.
   12.17 +
   12.18 +    You should have received a copy of the GNU Lesser General Public
   12.19 +    License along with this library; if not, write to the Free Software
   12.20 +    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   12.21 +
   12.22 +    Sam Lantinga
   12.23 +    slouken@libsdl.org
   12.24 +*/
   12.25 +
   12.26 +#ifndef _SDL_config_windows2_h
   12.27 +#define _SDL_config_windows2_h
   12.28 +
   12.29 +#include "SDL_platform.h"
   12.30 +
   12.31 +/* This is a set of defines to configure the SDL features */
   12.32 +
   12.33 +#if !defined(_STDINT_H_) && (!defined(HAVE_STDINT_H) || !_HAVE_STDINT_H)
   12.34 +#if defined(__GNUC__) || defined(__DMC__) || defined(__WATCOMC__)
   12.35 +#define HAVE_STDINT_H	1
   12.36 +#elif defined(_MSC_VER)
   12.37 +typedef signed __int8 int8_t;
   12.38 +typedef unsigned __int8 uint8_t;
   12.39 +typedef signed __int16 int16_t;
   12.40 +typedef unsigned __int16 uint16_t;
   12.41 +typedef signed __int32 int32_t;
   12.42 +typedef unsigned __int32 uint32_t;
   12.43 +typedef signed __int64 int64_t;
   12.44 +typedef unsigned __int64 uint64_t;
   12.45 +#ifndef _UINTPTR_T_DEFINED
   12.46 +#ifdef  _WIN64
   12.47 +typedef unsigned __int64 uintptr_t;
   12.48 +#else
   12.49 +typedef unsigned int uintptr_t;
   12.50 +#endif
   12.51 +#define _UINTPTR_T_DEFINED
   12.52 +#endif
   12.53 +/* Older Visual C++ headers don't have the Win64-compatible typedefs... */
   12.54 +#if ((_MSC_VER <= 1200) && (!defined(DWORD_PTR)))
   12.55 +#define DWORD_PTR DWORD
   12.56 +#endif
   12.57 +#if ((_MSC_VER <= 1200) && (!defined(LONG_PTR)))
   12.58 +#define LONG_PTR LONG
   12.59 +#endif
   12.60 +#else /* !__GNUC__ && !_MSC_VER */
   12.61 +typedef signed char int8_t;
   12.62 +typedef unsigned char uint8_t;
   12.63 +typedef signed short int16_t;
   12.64 +typedef unsigned short uint16_t;
   12.65 +typedef signed int int32_t;
   12.66 +typedef unsigned int uint32_t;
   12.67 +typedef signed long long int64_t;
   12.68 +typedef unsigned long long uint64_t;
   12.69 +#ifndef _SIZE_T_DEFINED_
   12.70 +#define _SIZE_T_DEFINED_
   12.71 +typedef unsigned int size_t;
   12.72 +#endif
   12.73 +typedef unsigned int uintptr_t;
   12.74 +#endif /* __GNUC__ || _MSC_VER */
   12.75 +#endif /* !_STDINT_H_ && !HAVE_STDINT_H */
   12.76 +
   12.77 +#ifdef _WIN64
   12.78 +# define SIZEOF_VOIDP 8
   12.79 +#else
   12.80 +# define SIZEOF_VOIDP 4
   12.81 +#endif
   12.82 +#define SDL_HAS_64BIT_TYPE	1
   12.83 +
   12.84 +/* Enabled for SDL 1.2 (binary compatibility) */
   12.85 +//#define HAVE_LIBC     1
   12.86 +#ifdef HAVE_LIBC
   12.87 +/* Useful headers */
   12.88 +#define HAVE_STDIO_H 1
   12.89 +#define STDC_HEADERS 1
   12.90 +#define HAVE_STRING_H 1
   12.91 +#define HAVE_CTYPE_H 1
   12.92 +#define HAVE_MATH_H 1
   12.93 +#ifndef _WIN32_WCE
   12.94 +#define HAVE_SIGNAL_H 1
   12.95 +#endif
   12.96 +
   12.97 +/* C library functions */
   12.98 +#define HAVE_MALLOC 1
   12.99 +#define HAVE_CALLOC 1
  12.100 +#define HAVE_REALLOC 1
  12.101 +#define HAVE_FREE 1
  12.102 +#define HAVE_ALLOCA 1
  12.103 +#define HAVE_QSORT 1
  12.104 +#define HAVE_ABS 1
  12.105 +#define HAVE_MEMSET 1
  12.106 +#define HAVE_MEMCPY 1
  12.107 +#define HAVE_MEMMOVE 1
  12.108 +#define HAVE_MEMCMP 1
  12.109 +#define HAVE_STRLEN 1
  12.110 +#define HAVE__STRREV 1
  12.111 +#define HAVE__STRUPR 1
  12.112 +#define HAVE__STRLWR 1
  12.113 +#define HAVE_STRCHR 1
  12.114 +#define HAVE_STRRCHR 1
  12.115 +#define HAVE_STRSTR 1
  12.116 +#define HAVE_ITOA 1
  12.117 +#define HAVE__LTOA 1
  12.118 +#define HAVE__ULTOA 1
  12.119 +#define HAVE_STRTOL 1
  12.120 +#define HAVE_STRTOUL 1
  12.121 +#define HAVE_STRTOLL 1
  12.122 +#define HAVE_STRTOD 1
  12.123 +#define HAVE_ATOI 1
  12.124 +#define HAVE_ATOF 1
  12.125 +#define HAVE_STRCMP 1
  12.126 +#define HAVE_STRNCMP 1
  12.127 +#define HAVE__STRICMP 1
  12.128 +#define HAVE__STRNICMP 1
  12.129 +#define HAVE_SSCANF 1
  12.130 +#define HAVE_M_PI 1
  12.131 +#define HAVE_ATAN 1
  12.132 +#define HAVE_ATAN2 1
  12.133 +#define HAVE_CEIL 1
  12.134 +#define HAVE_COPYSIGN 1
  12.135 +#define HAVE_COS 1
  12.136 +#define HAVE_COSF 1
  12.137 +#define HAVE_FABS 1
  12.138 +#define HAVE_FLOOR 1
  12.139 +#define HAVE_LOG 1
  12.140 +#define HAVE_POW 1
  12.141 +#define HAVE_SCALBN 1
  12.142 +#define HAVE_SIN 1
  12.143 +#define HAVE_SINF 1
  12.144 +#define HAVE_SQRT 1
  12.145 +#else
  12.146 +#define HAVE_STDARG_H	1
  12.147 +#define HAVE_STDDEF_H	1
  12.148 +#endif
  12.149 +
  12.150 +/* Enable various audio drivers */
  12.151 +#ifndef _WIN32_WCE
  12.152 +#define SDL_AUDIO_DRIVER_DSOUND	1
  12.153 +#endif
  12.154 +#define SDL_AUDIO_DRIVER_WINWAVEOUT	1
  12.155 +#define SDL_AUDIO_DRIVER_DISK	1
  12.156 +#define SDL_AUDIO_DRIVER_DUMMY	1
  12.157 +
  12.158 +/* Enable various input drivers */
  12.159 +#ifdef _WIN32_WCE
  12.160 +#define SDL_JOYSTICK_DISABLED	1
  12.161 +#define SDL_HAPTIC_DUMMY	1
  12.162 +#else
  12.163 +#define SDL_JOYSTICK_DINPUT	1
  12.164 +#define SDL_HAPTIC_DINPUT	1
  12.165 +#endif
  12.166 +
  12.167 +/* Enable various shared object loading systems */
  12.168 +#define SDL_LOADSO_WINDOWS	1
  12.169 +
  12.170 +/* Enable various threading systems */
  12.171 +#define SDL_THREAD_WINDOWS	1
  12.172 +
  12.173 +/* Enable various timer systems */
  12.174 +#ifdef _WIN32_WCE
  12.175 +#define SDL_TIMER_WINCE	1
  12.176 +#else
  12.177 +#define SDL_TIMER_WINDOWS	1
  12.178 +#endif
  12.179 +
  12.180 +/* Enable various video drivers */
  12.181 +#define SDL_VIDEO_DRIVER_DUMMY	1
  12.182 +#define SDL_VIDEO_DRIVER_WINDOWS	1
  12.183 +
  12.184 +#define SDL_VIDEO_RENDER_D3D	1
  12.185 +#define SDL_VIDEO_RENDER_GDI	1
  12.186 +
  12.187 +/* Enable OpenGL support */
  12.188 +#ifndef _WIN32_WCE
  12.189 +#define SDL_VIDEO_OPENGL	1
  12.190 +#define SDL_VIDEO_OPENGL_WGL	1
  12.191 +#define SDL_VIDEO_RENDER_OGL	1
  12.192 +#endif
  12.193 +
  12.194 +/* Enable system power support */
  12.195 +#define SDL_POWER_WINDOWS 1
  12.196 +
  12.197 +/* Enable assembly routines (Win64 doesn't have inline asm) */
  12.198 +#ifndef _WIN64
  12.199 +#define SDL_ASSEMBLY_ROUTINES	1
  12.200 +#endif
  12.201 +
  12.202 +#endif /* _SDL_config_windows2_h */
    13.1 --- a/include/SDL_main.h	Thu Jan 20 17:33:06 2011 -0800
    13.2 +++ b/include/SDL_main.h	Thu Jan 20 18:04:05 2011 -0800
    13.3 @@ -31,7 +31,7 @@
    13.4   *  Redefine main() on some platforms so that it is called by SDL.
    13.5   */
    13.6  
    13.7 -#if defined(__WIN32__) || \
    13.8 +#if defined(__WINDOWS__) || \
    13.9      (defined(__MWERKS__) && !defined(__BEOS__)) || \
   13.10      defined(__SYMBIAN32__) || defined(__IPHONEOS__) || \
   13.11      defined(__ANDROID__)
   13.12 @@ -66,7 +66,7 @@
   13.13  
   13.14  
   13.15  /* From the SDL library code -- needed for registering the app on Win32 */
   13.16 -#ifdef __WIN32__
   13.17 +#ifdef __WINDOWS__
   13.18  
   13.19  #include "begin_code.h"
   13.20  #ifdef __cplusplus
    14.1 --- a/include/SDL_opengl.h	Thu Jan 20 17:33:06 2011 -0800
    14.2 +++ b/include/SDL_opengl.h	Thu Jan 20 18:04:05 2011 -0800
    14.3 @@ -31,7 +31,7 @@
    14.4  
    14.5  #include "SDL_config.h"
    14.6  
    14.7 -#ifdef __WIN32__
    14.8 +#ifdef __WINDOWS__
    14.9  #define WIN32_LEAN_AND_MEAN
   14.10  #ifndef NOMINMAX
   14.11  #define NOMINMAX                /* Don't defined min() and max() */
    15.1 --- a/include/SDL_platform.h	Thu Jan 20 17:33:06 2011 -0800
    15.2 +++ b/include/SDL_platform.h	Thu Jan 20 18:04:05 2011 -0800
    15.3 @@ -125,8 +125,8 @@
    15.4  #define __SOLARIS__	1
    15.5  #endif
    15.6  #if defined(WIN32) || defined(_WIN32)
    15.7 -#undef __WIN32__
    15.8 -#define __WIN32__	1
    15.9 +#undef __WINDOWS__
   15.10 +#define __WINDOWS__	1
   15.11  #endif
   15.12  
   15.13  #if defined(__NDS__)
    16.1 --- a/include/SDL_rwops.h	Thu Jan 20 17:33:06 2011 -0800
    16.2 +++ b/include/SDL_rwops.h	Thu Jan 20 18:04:05 2011 -0800
    16.3 @@ -83,7 +83,7 @@
    16.4      Uint32 type;
    16.5      union
    16.6      {
    16.7 -#ifdef __WIN32__
    16.8 +#ifdef __WINDOWS__
    16.9          struct
   16.10          {
   16.11              SDL_bool append;
   16.12 @@ -94,7 +94,7 @@
   16.13                  size_t size;
   16.14                  size_t left;
   16.15              } buffer;
   16.16 -        } win32io;
   16.17 +        } windowsio;
   16.18  #endif
   16.19  #ifdef HAVE_STDIO_H
   16.20          struct
    17.1 --- a/include/SDL_syswm.h	Thu Jan 20 17:33:06 2011 -0800
    17.2 +++ b/include/SDL_syswm.h	Thu Jan 20 18:04:05 2011 -0800
    17.3 @@ -54,7 +54,7 @@
    17.4  struct SDL_SysWMinfo;
    17.5  #else
    17.6  
    17.7 -#if defined(SDL_VIDEO_DRIVER_WIN32)
    17.8 +#if defined(SDL_VIDEO_DRIVER_WINDOWS)
    17.9  #define WIN32_LEAN_AND_MEAN
   17.10  #include <windows.h>
   17.11  #endif
   17.12 @@ -118,7 +118,7 @@
   17.13      SDL_SYSWM_TYPE subsystem;
   17.14      union
   17.15      {
   17.16 -#if defined(SDL_VIDEO_DRIVER_WIN32)
   17.17 +#if defined(SDL_VIDEO_DRIVER_WINDOWS)
   17.18          struct {
   17.19              HWND hwnd;                  /**< The window for the message */
   17.20              UINT msg;                   /**< The type of message */
   17.21 @@ -163,7 +163,7 @@
   17.22      SDL_SYSWM_TYPE subsystem;
   17.23      union
   17.24      {
   17.25 -#if defined(SDL_VIDEO_DRIVER_WIN32)
   17.26 +#if defined(SDL_VIDEO_DRIVER_WINDOWS)
   17.27          struct
   17.28          {
   17.29              HWND window;                /**< The window handle */
    18.1 --- a/include/SDL_thread.h	Thu Jan 20 17:33:06 2011 -0800
    18.2 +++ b/include/SDL_thread.h	Thu Jan 20 18:04:05 2011 -0800
    18.3 @@ -55,7 +55,7 @@
    18.4   */
    18.5  typedef int (SDLCALL * SDL_ThreadFunction) (void *data);
    18.6  
    18.7 -#if defined(__WIN32__) && !defined(HAVE_LIBC)
    18.8 +#if defined(__WINDOWS__) && !defined(HAVE_LIBC)
    18.9  /**
   18.10   *  \file SDL_thread.h
   18.11   *  
    19.1 --- a/include/begin_code.h	Thu Jan 20 17:33:06 2011 -0800
    19.2 +++ b/include/begin_code.h	Thu Jan 20 18:04:05 2011 -0800
    19.3 @@ -42,7 +42,7 @@
    19.4  #  else
    19.5  #   define DECLSPEC	__declspec(export)
    19.6  #  endif
    19.7 -# elif defined(__WIN32__)
    19.8 +# elif defined(__WINDOWS__)
    19.9  #  ifdef __BORLANDC__
   19.10  #   ifdef BUILD_SDL
   19.11  #    define DECLSPEC
   19.12 @@ -63,7 +63,7 @@
   19.13  
   19.14  /* By default SDL uses the C calling convention */
   19.15  #ifndef SDLCALL
   19.16 -#if defined(__WIN32__) && !defined(__GNUC__)
   19.17 +#if defined(__WINDOWS__) && !defined(__GNUC__)
   19.18  #define SDLCALL __cdecl
   19.19  #else
   19.20  #define SDLCALL
    20.1 --- a/src/SDL.c	Thu Jan 20 17:33:06 2011 -0800
    20.2 +++ b/src/SDL.c	Thu Jan 20 18:04:05 2011 -0800
    20.3 @@ -39,7 +39,7 @@
    20.4  extern int SDL_TimerInit(void);
    20.5  extern void SDL_TimerQuit(void);
    20.6  #endif
    20.7 -#if defined(__WIN32__)
    20.8 +#if defined(__WINDOWS__)
    20.9  extern int SDL_HelperWindowCreate(void);
   20.10  extern int SDL_HelperWindowDestroy(void);
   20.11  #endif
   20.12 @@ -147,7 +147,7 @@
   20.13      /* Clear the error message */
   20.14      SDL_ClearError();
   20.15  
   20.16 -#if defined(__WIN32__)
   20.17 +#if defined(__WINDOWS__)
   20.18      if (SDL_HelperWindowCreate() < 0) {
   20.19          return -1;
   20.20      }
   20.21 @@ -220,7 +220,7 @@
   20.22      fflush(stdout);
   20.23  #endif
   20.24  
   20.25 -#if defined(__WIN32__)
   20.26 +#if defined(__WINDOWS__)
   20.27      SDL_HelperWindowDestroy();
   20.28  #endif
   20.29      SDL_QuitSubSystem(SDL_INIT_EVERYTHING);
   20.30 @@ -312,7 +312,7 @@
   20.31      return "RISC OS";
   20.32  #elif __SOLARIS__
   20.33      return "Solaris";
   20.34 -#elif __WIN32__
   20.35 +#elif __WINDOWS__
   20.36  #ifdef _WIN32_WCE
   20.37      return "Windows CE";
   20.38  #else
   20.39 @@ -325,7 +325,7 @@
   20.40  #endif
   20.41  }
   20.42  
   20.43 -#if defined(__WIN32__)
   20.44 +#if defined(__WINDOWS__)
   20.45  
   20.46  #if !defined(HAVE_LIBC) || (defined(__WATCOMC__) && defined(BUILD_DLL))
   20.47  /* Need to include DllMain() on Watcom C for some reason.. */
   20.48 @@ -347,6 +347,6 @@
   20.49  }
   20.50  #endif /* building DLL with Watcom C */
   20.51  
   20.52 -#endif /* __WIN32__ */
   20.53 +#endif /* __WINDOWS__ */
   20.54  
   20.55  /* vi: set ts=4 sw=4 expandtab: */
    21.1 --- a/src/audio/SDL_audio.c	Thu Jan 20 17:33:06 2011 -0800
    21.2 +++ b/src/audio/SDL_audio.c	Thu Jan 20 18:04:05 2011 -0800
    21.3 @@ -971,7 +971,7 @@
    21.4      if (!current_audio.impl.ProvidesOwnCallbackThread) {
    21.5          /* Start the audio thread */
    21.6  /* !!! FIXME: this is nasty. */
    21.7 -#if (defined(__WIN32__) && !defined(_WIN32_WCE)) && !defined(HAVE_LIBC)
    21.8 +#if (defined(__WINDOWS__) && !defined(_WIN32_WCE)) && !defined(HAVE_LIBC)
    21.9  #undef SDL_CreateThread
   21.10          device->thread = SDL_CreateThread(SDL_RunAudio, device, NULL, NULL);
   21.11  #else
    22.1 --- a/src/cpuinfo/SDL_cpuinfo.c	Thu Jan 20 17:33:06 2011 -0800
    22.2 +++ b/src/cpuinfo/SDL_cpuinfo.c	Thu Jan 20 18:04:05 2011 -0800
    22.3 @@ -38,7 +38,7 @@
    22.4  #include <signal.h>
    22.5  #include <setjmp.h>
    22.6  #endif
    22.7 -#ifdef __WIN32__
    22.8 +#ifdef __WINDOWS__
    22.9  #define WIN32_LEAN_AND_MEAN
   22.10  #include <windows.h>
   22.11  #endif
   22.12 @@ -319,7 +319,7 @@
   22.13              sysctlbyname("hw.ncpu", &SDL_CPUCount, &size, NULL, 0);
   22.14          }
   22.15  #endif
   22.16 -#ifdef __WIN32__
   22.17 +#ifdef __WINDOWS__
   22.18          if (SDL_CPUCount <= 0) {
   22.19              SYSTEM_INFO info;
   22.20              GetSystemInfo(&info);
    23.1 --- a/src/events/SDL_events.c	Thu Jan 20 17:33:06 2011 -0800
    23.2 +++ b/src/events/SDL_events.c	Thu Jan 20 18:04:05 2011 -0800
    23.3 @@ -170,7 +170,7 @@
    23.4  
    23.5          /* The event thread will handle timers too */
    23.6          SDL_SetTimerThreaded(2);
    23.7 -#if (defined(__WIN32__) && !defined(_WIN32_WCE)) && !defined(HAVE_LIBC)
    23.8 +#if (defined(__WINDOWS__) && !defined(_WIN32_WCE)) && !defined(HAVE_LIBC)
    23.9  #undef SDL_CreateThread
   23.10          SDL_EventThread =
   23.11              SDL_CreateThread(SDL_GobbleEvents, NULL, NULL, NULL);
    24.1 --- a/src/events/SDL_sysevents.h	Thu Jan 20 17:33:06 2011 -0800
    24.2 +++ b/src/events/SDL_sysevents.h	Thu Jan 20 18:04:05 2011 -0800
    24.3 @@ -29,7 +29,7 @@
    24.4  #define MUST_THREAD_EVENTS
    24.5  #endif
    24.6  
    24.7 -#ifdef __WIN32__                /* Win32 doesn't allow a separate event thread */
    24.8 +#ifdef __WINDOWS__              /* Windows doesn't allow a separate event thread */
    24.9  #define CANT_THREAD_EVENTS
   24.10  #endif
   24.11  
    25.1 --- a/src/events/scancodes_win32.h	Thu Jan 20 17:33:06 2011 -0800
    25.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    25.3 @@ -1,287 +0,0 @@
    25.4 -/*
    25.5 -    SDL - Simple DirectMedia Layer
    25.6 -    Copyright (C) 1997-2010 Sam Lantinga
    25.7 -
    25.8 -    This library is free software; you can redistribute it and/or
    25.9 -    modify it under the terms of the GNU Lesser General Public
   25.10 -    License as published by the Free Software Foundation; either
   25.11 -    version 2.1 of the License, or (at your option) any later version.
   25.12 -
   25.13 -    This library is distributed in the hope that it will be useful,
   25.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
   25.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   25.16 -    Lesser General Public License for more details.
   25.17 -
   25.18 -    You should have received a copy of the GNU Lesser General Public
   25.19 -    License along with this library; if not, write to the Free Software
   25.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   25.21 -
   25.22 -    Sam Lantinga
   25.23 -    slouken@libsdl.org
   25.24 -*/
   25.25 -#include "../../include/SDL_scancode.h"
   25.26 -
   25.27 -/* Win32 virtual key code to SDL scancode mapping table
   25.28 -   Sources:
   25.29 -   - msdn.microsoft.com
   25.30 -*/
   25.31 -/* *INDENT-OFF* */
   25.32 -static const SDL_scancode win32_scancode_table[] = {
   25.33 -    /*  0, 0x00 */      SDL_SCANCODE_UNKNOWN,
   25.34 -    /*  1, 0x01 */      SDL_SCANCODE_UNKNOWN,
   25.35 -    /*  2, 0x02 */      SDL_SCANCODE_UNKNOWN,
   25.36 -    /*  3, 0x03 */      SDL_SCANCODE_UNKNOWN,
   25.37 -    /*  4, 0x04 */      SDL_SCANCODE_UNKNOWN,
   25.38 -    /*  5, 0x05 */      SDL_SCANCODE_UNKNOWN,
   25.39 -    /*  6, 0x06 */      SDL_SCANCODE_UNKNOWN,
   25.40 -    /*  7, 0x07 */      SDL_SCANCODE_UNKNOWN,
   25.41 -    /*  8, 0x08 */      SDL_SCANCODE_BACKSPACE,
   25.42 -    /*  9, 0x09 */      SDL_SCANCODE_TAB,
   25.43 -    /*  10, 0x0a */     SDL_SCANCODE_KP_ENTER, /* Not a VKEY, SDL specific */
   25.44 -    /*  11, 0x0b */     SDL_SCANCODE_UNKNOWN,
   25.45 -    /*  12, 0x0c */     SDL_SCANCODE_CLEAR,
   25.46 -    /*  13, 0x0d */     SDL_SCANCODE_RETURN,
   25.47 -    /*  14, 0x0e */     SDL_SCANCODE_UNKNOWN,
   25.48 -    /*  15, 0x0f */     SDL_SCANCODE_UNKNOWN,
   25.49 -    /*  16, 0x10 */     SDL_SCANCODE_UNKNOWN,
   25.50 -    /*  17, 0x11 */     SDL_SCANCODE_UNKNOWN,
   25.51 -    /*  18, 0x12 */     SDL_SCANCODE_APPLICATION,
   25.52 -    /*  19, 0x13 */     SDL_SCANCODE_PAUSE,
   25.53 -    /*  20, 0x14 */     SDL_SCANCODE_CAPSLOCK,
   25.54 -    /*  21, 0x15 */     SDL_SCANCODE_UNKNOWN,
   25.55 -    /*  22, 0x16 */     SDL_SCANCODE_UNKNOWN,
   25.56 -    /*  23, 0x17 */     SDL_SCANCODE_UNKNOWN,
   25.57 -    /*  24, 0x18 */     SDL_SCANCODE_UNKNOWN,
   25.58 -    /*  25, 0x19 */     SDL_SCANCODE_UNKNOWN,
   25.59 -    /*  26, 0x1a */     SDL_SCANCODE_UNKNOWN,
   25.60 -    /*  27, 0x1b */     SDL_SCANCODE_ESCAPE,
   25.61 -    /*  28, 0x1c */     SDL_SCANCODE_UNKNOWN,
   25.62 -    /*  29, 0x1d */     SDL_SCANCODE_UNKNOWN,
   25.63 -    /*  30, 0x1e */     SDL_SCANCODE_UNKNOWN,
   25.64 -    /*  31, 0x1f */     SDL_SCANCODE_MODE,
   25.65 -    /*  32, 0x20 */     SDL_SCANCODE_SPACE,
   25.66 -    /*  33, 0x21 */     SDL_SCANCODE_PAGEUP,
   25.67 -    /*  34, 0x22 */     SDL_SCANCODE_PAGEDOWN,
   25.68 -    /*  35, 0x23 */     SDL_SCANCODE_END,
   25.69 -    /*  36, 0x24 */     SDL_SCANCODE_HOME,
   25.70 -    /*  37, 0x25 */     SDL_SCANCODE_LEFT,
   25.71 -    /*  38, 0x26 */     SDL_SCANCODE_UP,
   25.72 -    /*  39, 0x27 */     SDL_SCANCODE_RIGHT,
   25.73 -    /*  40, 0x28 */     SDL_SCANCODE_DOWN,
   25.74 -    /*  41, 0x29 */     SDL_SCANCODE_SELECT,
   25.75 -    /*  42, 0x2a */     SDL_SCANCODE_UNKNOWN, /* VK_PRINT */
   25.76 -    /*  43, 0x2b */     SDL_SCANCODE_EXECUTE,
   25.77 -    /*  44, 0x2c */     SDL_SCANCODE_PRINTSCREEN,
   25.78 -    /*  45, 0x2d */     SDL_SCANCODE_INSERT,
   25.79 -    /*  46, 0x2e */     SDL_SCANCODE_DELETE,
   25.80 -    /*  47, 0x2f */     SDL_SCANCODE_HELP,
   25.81 -    /*  48, 0x30 */     SDL_SCANCODE_0,
   25.82 -    /*  49, 0x31 */     SDL_SCANCODE_1,
   25.83 -    /*  50, 0x32 */     SDL_SCANCODE_2,
   25.84 -    /*  51, 0x33 */     SDL_SCANCODE_3,
   25.85 -    /*  52, 0x34 */     SDL_SCANCODE_4,
   25.86 -    /*  53, 0x35 */     SDL_SCANCODE_5,
   25.87 -    /*  54, 0x36 */     SDL_SCANCODE_6,
   25.88 -    /*  55, 0x37 */     SDL_SCANCODE_7,
   25.89 -    /*  56, 0x38 */     SDL_SCANCODE_8,
   25.90 -    /*  57, 0x39 */     SDL_SCANCODE_9,
   25.91 -    /*  58, 0x3a */     SDL_SCANCODE_UNKNOWN,
   25.92 -    /*  59, 0x3b */     SDL_SCANCODE_UNKNOWN,
   25.93 -    /*  60, 0x3c */     SDL_SCANCODE_UNKNOWN,
   25.94 -    /*  61, 0x3d */     SDL_SCANCODE_UNKNOWN,
   25.95 -    /*  62, 0x3e */     SDL_SCANCODE_UNKNOWN,
   25.96 -    /*  63, 0x3f */     SDL_SCANCODE_UNKNOWN,
   25.97 -    /*  64, 0x40 */     SDL_SCANCODE_UNKNOWN,
   25.98 -    /*  65, 0x41 */     SDL_SCANCODE_A,
   25.99 -    /*  66, 0x42 */     SDL_SCANCODE_B,
  25.100 -    /*  67, 0x43 */     SDL_SCANCODE_C,
  25.101 -    /*  68, 0x44 */     SDL_SCANCODE_D,
  25.102 -    /*  69, 0x45 */     SDL_SCANCODE_E,
  25.103 -    /*  70, 0x46 */     SDL_SCANCODE_F,
  25.104 -    /*  71, 0x47 */     SDL_SCANCODE_G,
  25.105 -    /*  72, 0x48 */     SDL_SCANCODE_H,
  25.106 -    /*  73, 0x49 */     SDL_SCANCODE_I,
  25.107 -    /*  74, 0x4a */     SDL_SCANCODE_J,
  25.108 -    /*  75, 0x4b */     SDL_SCANCODE_K,
  25.109 -    /*  76, 0x4c */     SDL_SCANCODE_L,
  25.110 -    /*  77, 0x4d */     SDL_SCANCODE_M,
  25.111 -    /*  78, 0x4e */     SDL_SCANCODE_N,
  25.112 -    /*  79, 0x4f */     SDL_SCANCODE_O,
  25.113 -    /*  80, 0x50 */     SDL_SCANCODE_P,
  25.114 -    /*  81, 0x51 */     SDL_SCANCODE_Q,
  25.115 -    /*  82, 0x52 */     SDL_SCANCODE_R,
  25.116 -    /*  83, 0x53 */     SDL_SCANCODE_S,
  25.117 -    /*  84, 0x54 */     SDL_SCANCODE_T,
  25.118 -    /*  85, 0x55 */     SDL_SCANCODE_U,
  25.119 -    /*  86, 0x56 */     SDL_SCANCODE_V,
  25.120 -    /*  87, 0x57 */     SDL_SCANCODE_W,
  25.121 -    /*  88, 0x58 */     SDL_SCANCODE_X,
  25.122 -    /*  89, 0x59 */     SDL_SCANCODE_Y,
  25.123 -    /*  90, 0x5a */     SDL_SCANCODE_Z,
  25.124 -    /*  91, 0x5b */     SDL_SCANCODE_LGUI,
  25.125 -    /*  92, 0x5c */     SDL_SCANCODE_RGUI,
  25.126 -    /*  93, 0x5d */     SDL_SCANCODE_APPLICATION,
  25.127 -    /*  94, 0x5e */     SDL_SCANCODE_UNKNOWN,
  25.128 -    /*  95, 0x5f */     SDL_SCANCODE_UNKNOWN,
  25.129 -    /*  96, 0x60 */     SDL_SCANCODE_KP_0,
  25.130 -    /*  97, 0x61 */     SDL_SCANCODE_KP_1,
  25.131 -    /*  98, 0x62 */     SDL_SCANCODE_KP_2,
  25.132 -    /*  99, 0x63 */     SDL_SCANCODE_KP_3,
  25.133 -    /*  100, 0x64 */    SDL_SCANCODE_KP_4,
  25.134 -    /*  101, 0x65 */    SDL_SCANCODE_KP_5,
  25.135 -    /*  102, 0x66 */    SDL_SCANCODE_KP_6,
  25.136 -    /*  103, 0x67 */    SDL_SCANCODE_KP_7,
  25.137 -    /*  104, 0x68 */    SDL_SCANCODE_KP_8,
  25.138 -    /*  105, 0x69 */    SDL_SCANCODE_KP_9,
  25.139 -    /*  106, 0x6a */    SDL_SCANCODE_KP_MULTIPLY,
  25.140 -    /*  107, 0x6b */    SDL_SCANCODE_KP_PLUS,
  25.141 -    /*  108, 0x6c */    SDL_SCANCODE_SEPARATOR,
  25.142 -    /*  109, 0x6d */    SDL_SCANCODE_KP_MINUS,
  25.143 -    /*  110, 0x6e */    SDL_SCANCODE_KP_DECIMAL,
  25.144 -    /*  111, 0x6f */    SDL_SCANCODE_KP_DIVIDE,
  25.145 -    /*  112, 0x70 */    SDL_SCANCODE_F1,
  25.146 -    /*  113, 0x71 */    SDL_SCANCODE_F2,
  25.147 -    /*  114, 0x72 */    SDL_SCANCODE_F3,
  25.148 -    /*  115, 0x73 */    SDL_SCANCODE_F4,
  25.149 -    /*  116, 0x74 */    SDL_SCANCODE_F5,
  25.150 -    /*  117, 0x75 */    SDL_SCANCODE_F6,
  25.151 -    /*  118, 0x76 */    SDL_SCANCODE_F7,
  25.152 -    /*  119, 0x77 */    SDL_SCANCODE_F8,
  25.153 -    /*  120, 0x78 */    SDL_SCANCODE_F9,
  25.154 -    /*  121, 0x79 */    SDL_SCANCODE_F10,
  25.155 -    /*  122, 0x7a */    SDL_SCANCODE_F11,
  25.156 -    /*  123, 0x7b */    SDL_SCANCODE_F12,
  25.157 -    /*  124, 0x7c */    SDL_SCANCODE_F13,
  25.158 -    /*  125, 0x7d */    SDL_SCANCODE_F14,
  25.159 -    /*  126, 0x7e */    SDL_SCANCODE_F15,
  25.160 -    /*  127, 0x7f */    SDL_SCANCODE_F16,
  25.161 -    /*  128, 0x80 */    SDL_SCANCODE_F17, /* or SDL_SCANCODE_AUDIONEXT */
  25.162 -    /*  129, 0x81 */    SDL_SCANCODE_F18, /* or SDL_SCANCODE_AUDIOPREV */
  25.163 -    /*  130, 0x82 */    SDL_SCANCODE_F19, /* or SDL_SCANCODE_AUDIOSTOP */
  25.164 -    /*  131, 0x83 */    SDL_SCANCODE_F20, /* or SDL_SCANCODE_AUDIOPLAY */
  25.165 -    /*  132, 0x84 */    SDL_SCANCODE_F21, /* or SDL_SCANCODE_MAIL */
  25.166 -    /*  133, 0x85 */    SDL_SCANCODE_F22, /* or SDL_SCANCODE_MEDIASELECT */
  25.167 -    /*  134, 0x86 */    SDL_SCANCODE_F23, /* or SDL_SCANCODE_WWW */
  25.168 -    /*  135, 0x87 */    SDL_SCANCODE_F24, /* or SDL_SCANCODE_CALCULATOR */
  25.169 -    /*  136, 0x88 */    SDL_SCANCODE_UNKNOWN,
  25.170 -    /*  137, 0x89 */    SDL_SCANCODE_UNKNOWN,
  25.171 -    /*  138, 0x8a */    SDL_SCANCODE_UNKNOWN,
  25.172 -    /*  139, 0x8b */    SDL_SCANCODE_UNKNOWN,
  25.173 -    /*  140, 0x8c */    SDL_SCANCODE_UNKNOWN,
  25.174 -    /*  141, 0x8d */    SDL_SCANCODE_UNKNOWN,
  25.175 -    /*  142, 0x8e */    SDL_SCANCODE_UNKNOWN,
  25.176 -    /*  143, 0x8f */    SDL_SCANCODE_UNKNOWN,
  25.177 -    /*  144, 0x90 */    SDL_SCANCODE_NUMLOCKCLEAR,
  25.178 -    /*  145, 0x91 */    SDL_SCANCODE_SCROLLLOCK,
  25.179 -    /*  146, 0x92 */    SDL_SCANCODE_KP_EQUALS,
  25.180 -    /*  147, 0x93 */    SDL_SCANCODE_UNKNOWN,
  25.181 -    /*  148, 0x94 */    SDL_SCANCODE_UNKNOWN,
  25.182 -    /*  149, 0x95 */    SDL_SCANCODE_UNKNOWN,
  25.183 -    /*  150, 0x96 */    SDL_SCANCODE_UNKNOWN,
  25.184 -    /*  151, 0x97 */    SDL_SCANCODE_UNKNOWN,
  25.185 -    /*  152, 0x98 */    SDL_SCANCODE_UNKNOWN,
  25.186 -    /*  153, 0x99 */    SDL_SCANCODE_UNKNOWN,
  25.187 -    /*  154, 0x9a */    SDL_SCANCODE_UNKNOWN,
  25.188 -    /*  155, 0x9b */    SDL_SCANCODE_UNKNOWN,
  25.189 -    /*  156, 0x9c */    SDL_SCANCODE_UNKNOWN,
  25.190 -    /*  157, 0x9d */    SDL_SCANCODE_UNKNOWN,
  25.191 -    /*  158, 0x9e */    SDL_SCANCODE_UNKNOWN,
  25.192 -    /*  159, 0x9f */    SDL_SCANCODE_UNKNOWN,
  25.193 -    /*  160, 0xa0 */    SDL_SCANCODE_LSHIFT,
  25.194 -    /*  161, 0xa1 */    SDL_SCANCODE_RSHIFT,
  25.195 -    /*  162, 0xa2 */    SDL_SCANCODE_LCTRL,
  25.196 -    /*  163, 0xa3 */    SDL_SCANCODE_RCTRL,
  25.197 -    /*  164, 0xa4 */    SDL_SCANCODE_LALT,
  25.198 -    /*  165, 0xa5 */    SDL_SCANCODE_RALT,
  25.199 -    /*  166, 0xa6 */    SDL_SCANCODE_AC_BACK,
  25.200 -    /*  167, 0xa7 */    SDL_SCANCODE_AC_FORWARD,
  25.201 -    /*  168, 0xa8 */    SDL_SCANCODE_AC_REFRESH,
  25.202 -    /*  169, 0xa9 */    SDL_SCANCODE_AC_STOP,
  25.203 -    /*  170, 0xaa */    SDL_SCANCODE_AC_SEARCH,
  25.204 -    /*  171, 0xab */    SDL_SCANCODE_AC_BOOKMARKS,
  25.205 -    /*  172, 0xac */    SDL_SCANCODE_AC_HOME,
  25.206 -    /*  173, 0xad */    SDL_SCANCODE_AUDIOMUTE,
  25.207 -    /*  174, 0xae */    SDL_SCANCODE_VOLUMEDOWN,
  25.208 -    /*  175, 0xaf */    SDL_SCANCODE_VOLUMEUP,
  25.209 -    /*  176, 0xb0 */    SDL_SCANCODE_AUDIONEXT,
  25.210 -    /*  177, 0xb1 */    SDL_SCANCODE_AUDIOPREV,
  25.211 -    /*  178, 0xb2 */    SDL_SCANCODE_AUDIOSTOP,
  25.212 -    /*  179, 0xb3 */    SDL_SCANCODE_AUDIOPLAY,
  25.213 -    /*  180, 0xb4 */    SDL_SCANCODE_MAIL,
  25.214 -    /*  181, 0xb5 */    SDL_SCANCODE_MEDIASELECT,
  25.215 -    /*  182, 0xb6 */    SDL_SCANCODE_UNKNOWN, /* VK_LAUNCH_APP1 */
  25.216 -    /*  183, 0xb7 */    SDL_SCANCODE_UNKNOWN, /* VK_LAUNCH_APP2 */
  25.217 -    /*  184, 0xb8 */    SDL_SCANCODE_UNKNOWN,
  25.218 -    /*  185, 0xb9 */    SDL_SCANCODE_UNKNOWN,
  25.219 -    /*  186, 0xba */    SDL_SCANCODE_SEMICOLON,
  25.220 -    /*  187, 0xbb */    SDL_SCANCODE_EQUALS,
  25.221 -    /*  188, 0xbc */    SDL_SCANCODE_COMMA,
  25.222 -    /*  189, 0xbd */    SDL_SCANCODE_MINUS,
  25.223 -    /*  190, 0xbe */    SDL_SCANCODE_PERIOD,
  25.224 -    /*  191, 0xbf */    SDL_SCANCODE_SLASH,
  25.225 -    /*  192, 0xc0 */    SDL_SCANCODE_GRAVE,
  25.226 -    /*  193, 0xc1 */    SDL_SCANCODE_UNKNOWN,
  25.227 -    /*  194, 0xc2 */    SDL_SCANCODE_UNKNOWN,
  25.228 -    /*  195, 0xc3 */    SDL_SCANCODE_UNKNOWN,
  25.229 -    /*  196, 0xc4 */    SDL_SCANCODE_UNKNOWN,
  25.230 -    /*  197, 0xc5 */    SDL_SCANCODE_UNKNOWN,
  25.231 -    /*  198, 0xc6 */    SDL_SCANCODE_UNKNOWN,
  25.232 -    /*  199, 0xc7 */    SDL_SCANCODE_UNKNOWN,
  25.233 -    /*  200, 0xc8 */    SDL_SCANCODE_UNKNOWN,
  25.234 -    /*  201, 0xc9 */    SDL_SCANCODE_UNKNOWN,
  25.235 -    /*  202, 0xca */    SDL_SCANCODE_UNKNOWN,
  25.236 -    /*  203, 0xcb */    SDL_SCANCODE_UNKNOWN,
  25.237 -    /*  204, 0xcc */    SDL_SCANCODE_UNKNOWN,
  25.238 -    /*  205, 0xcd */    SDL_SCANCODE_UNKNOWN,
  25.239 -    /*  206, 0xce */    SDL_SCANCODE_UNKNOWN,
  25.240 -    /*  207, 0xcf */    SDL_SCANCODE_UNKNOWN,
  25.241 -    /*  208, 0xd0 */    SDL_SCANCODE_UNKNOWN,
  25.242 -    /*  209, 0xd1 */    SDL_SCANCODE_UNKNOWN,
  25.243 -    /*  210, 0xd2 */    SDL_SCANCODE_UNKNOWN,
  25.244 -    /*  211, 0xd3 */    SDL_SCANCODE_UNKNOWN,
  25.245 -    /*  212, 0xd4 */    SDL_SCANCODE_UNKNOWN,
  25.246 -    /*  213, 0xd5 */    SDL_SCANCODE_UNKNOWN,
  25.247 -    /*  214, 0xd6 */    SDL_SCANCODE_UNKNOWN,
  25.248 -    /*  215, 0xd7 */    SDL_SCANCODE_UNKNOWN,
  25.249 -    /*  216, 0xd8 */    SDL_SCANCODE_UNKNOWN,
  25.250 -    /*  217, 0xd9 */    SDL_SCANCODE_UNKNOWN,
  25.251 -    /*  218, 0xda */    SDL_SCANCODE_UNKNOWN,
  25.252 -    /*  219, 0xdb */    SDL_SCANCODE_LEFTBRACKET,
  25.253 -    /*  220, 0xdc */    SDL_SCANCODE_BACKSLASH,
  25.254 -    /*  221, 0xdd */    SDL_SCANCODE_RIGHTBRACKET,
  25.255 -    /*  222, 0xde */    SDL_SCANCODE_APOSTROPHE,
  25.256 -    /*  223, 0xdf */    SDL_SCANCODE_UNKNOWN,
  25.257 -    /*  224, 0xe0 */    SDL_SCANCODE_UNKNOWN,
  25.258 -    /*  225, 0xe1 */    SDL_SCANCODE_UNKNOWN,
  25.259 -    /*  226, 0xe2 */    SDL_SCANCODE_NONUSBACKSLASH,
  25.260 -    /*  227, 0xe3 */    SDL_SCANCODE_UNKNOWN,
  25.261 -    /*  228, 0xe4 */    SDL_SCANCODE_UNKNOWN,
  25.262 -    /*  229, 0xe5 */    SDL_SCANCODE_UNKNOWN,
  25.263 -    /*  230, 0xe6 */    SDL_SCANCODE_UNKNOWN,
  25.264 -    /*  231, 0xe7 */    SDL_SCANCODE_UNKNOWN,
  25.265 -    /*  232, 0xe8 */    SDL_SCANCODE_UNKNOWN,
  25.266 -    /*  233, 0xe9 */    SDL_SCANCODE_UNKNOWN,
  25.267 -    /*  234, 0xea */    SDL_SCANCODE_UNKNOWN,
  25.268 -    /*  235, 0xeb */    SDL_SCANCODE_UNKNOWN,
  25.269 -    /*  236, 0xec */    SDL_SCANCODE_UNKNOWN,
  25.270 -    /*  237, 0xed */    SDL_SCANCODE_UNKNOWN,
  25.271 -    /*  238, 0xee */    SDL_SCANCODE_UNKNOWN,
  25.272 -    /*  239, 0xef */    SDL_SCANCODE_UNKNOWN,
  25.273 -    /*  240, 0xf0 */    SDL_SCANCODE_UNKNOWN,
  25.274 -    /*  241, 0xf1 */    SDL_SCANCODE_UNKNOWN,
  25.275 -    /*  242, 0xf2 */    SDL_SCANCODE_UNKNOWN,
  25.276 -    /*  243, 0xf3 */    SDL_SCANCODE_UNKNOWN,
  25.277 -    /*  244, 0xf4 */    SDL_SCANCODE_UNKNOWN,
  25.278 -    /*  245, 0xf5 */    SDL_SCANCODE_UNKNOWN,
  25.279 -    /*  246, 0xf6 */    SDL_SCANCODE_SYSREQ,
  25.280 -    /*  247, 0xf7 */    SDL_SCANCODE_CRSEL,
  25.281 -    /*  248, 0xf8 */    SDL_SCANCODE_EXSEL,
  25.282 -    /*  249, 0xf9 */    SDL_SCANCODE_UNKNOWN, /* VK_EREOF */
  25.283 -    /*  250, 0xfa */    SDL_SCANCODE_UNKNOWN, /* VK_PLAY */
  25.284 -    /*  251, 0xfb */    SDL_SCANCODE_UNKNOWN, /* VK_ZOOM */
  25.285 -    /*  252, 0xfc */    SDL_SCANCODE_UNKNOWN,
  25.286 -    /*  253, 0xfd */    SDL_SCANCODE_UNKNOWN, /* VK_PA1 */
  25.287 -    /*  254, 0xfe */    SDL_SCANCODE_CLEAR,
  25.288 -    /*  255, 0xff */    SDL_SCANCODE_UNKNOWN,
  25.289 -};
  25.290 -/* *INDENT-ON* */
    26.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    26.2 +++ b/src/events/scancodes_windows.h	Thu Jan 20 18:04:05 2011 -0800
    26.3 @@ -0,0 +1,287 @@
    26.4 +/*
    26.5 +    SDL - Simple DirectMedia Layer
    26.6 +    Copyright (C) 1997-2010 Sam Lantinga
    26.7 +
    26.8 +    This library is free software; you can redistribute it and/or
    26.9 +    modify it under the terms of the GNU Lesser General Public
   26.10 +    License as published by the Free Software Foundation; either
   26.11 +    version 2.1 of the License, or (at your option) any later version.
   26.12 +
   26.13 +    This library is distributed in the hope that it will be useful,
   26.14 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
   26.15 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   26.16 +    Lesser General Public License for more details.
   26.17 +
   26.18 +    You should have received a copy of the GNU Lesser General Public
   26.19 +    License along with this library; if not, write to the Free Software
   26.20 +    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   26.21 +
   26.22 +    Sam Lantinga
   26.23 +    slouken@libsdl.org
   26.24 +*/
   26.25 +#include "../../include/SDL_scancode.h"
   26.26 +
   26.27 +/* Win32 virtual key code to SDL scancode mapping table
   26.28 +   Sources:
   26.29 +   - msdn.microsoft.com
   26.30 +*/
   26.31 +/* *INDENT-OFF* */
   26.32 +static const SDL_scancode windows_scancode_table[] = {
   26.33 +    /*  0, 0x00 */      SDL_SCANCODE_UNKNOWN,
   26.34 +    /*  1, 0x01 */      SDL_SCANCODE_UNKNOWN,
   26.35 +    /*  2, 0x02 */      SDL_SCANCODE_UNKNOWN,
   26.36 +    /*  3, 0x03 */      SDL_SCANCODE_UNKNOWN,
   26.37 +    /*  4, 0x04 */      SDL_SCANCODE_UNKNOWN,
   26.38 +    /*  5, 0x05 */      SDL_SCANCODE_UNKNOWN,
   26.39 +    /*  6, 0x06 */      SDL_SCANCODE_UNKNOWN,
   26.40 +    /*  7, 0x07 */      SDL_SCANCODE_UNKNOWN,
   26.41 +    /*  8, 0x08 */      SDL_SCANCODE_BACKSPACE,
   26.42 +    /*  9, 0x09 */      SDL_SCANCODE_TAB,
   26.43 +    /*  10, 0x0a */     SDL_SCANCODE_KP_ENTER, /* Not a VKEY, SDL specific */
   26.44 +    /*  11, 0x0b */     SDL_SCANCODE_UNKNOWN,
   26.45 +    /*  12, 0x0c */     SDL_SCANCODE_CLEAR,
   26.46 +    /*  13, 0x0d */     SDL_SCANCODE_RETURN,
   26.47 +    /*  14, 0x0e */     SDL_SCANCODE_UNKNOWN,
   26.48 +    /*  15, 0x0f */     SDL_SCANCODE_UNKNOWN,
   26.49 +    /*  16, 0x10 */     SDL_SCANCODE_UNKNOWN,
   26.50 +    /*  17, 0x11 */     SDL_SCANCODE_UNKNOWN,
   26.51 +    /*  18, 0x12 */     SDL_SCANCODE_APPLICATION,
   26.52 +    /*  19, 0x13 */     SDL_SCANCODE_PAUSE,
   26.53 +    /*  20, 0x14 */     SDL_SCANCODE_CAPSLOCK,
   26.54 +    /*  21, 0x15 */     SDL_SCANCODE_UNKNOWN,
   26.55 +    /*  22, 0x16 */     SDL_SCANCODE_UNKNOWN,
   26.56 +    /*  23, 0x17 */     SDL_SCANCODE_UNKNOWN,
   26.57 +    /*  24, 0x18 */     SDL_SCANCODE_UNKNOWN,
   26.58 +    /*  25, 0x19 */     SDL_SCANCODE_UNKNOWN,
   26.59 +    /*  26, 0x1a */     SDL_SCANCODE_UNKNOWN,
   26.60 +    /*  27, 0x1b */     SDL_SCANCODE_ESCAPE,
   26.61 +    /*  28, 0x1c */     SDL_SCANCODE_UNKNOWN,
   26.62 +    /*  29, 0x1d */     SDL_SCANCODE_UNKNOWN,
   26.63 +    /*  30, 0x1e */     SDL_SCANCODE_UNKNOWN,
   26.64 +    /*  31, 0x1f */     SDL_SCANCODE_MODE,
   26.65 +    /*  32, 0x20 */     SDL_SCANCODE_SPACE,
   26.66 +    /*  33, 0x21 */     SDL_SCANCODE_PAGEUP,
   26.67 +    /*  34, 0x22 */     SDL_SCANCODE_PAGEDOWN,
   26.68 +    /*  35, 0x23 */     SDL_SCANCODE_END,
   26.69 +    /*  36, 0x24 */     SDL_SCANCODE_HOME,
   26.70 +    /*  37, 0x25 */     SDL_SCANCODE_LEFT,
   26.71 +    /*  38, 0x26 */     SDL_SCANCODE_UP,
   26.72 +    /*  39, 0x27 */     SDL_SCANCODE_RIGHT,
   26.73 +    /*  40, 0x28 */     SDL_SCANCODE_DOWN,
   26.74 +    /*  41, 0x29 */     SDL_SCANCODE_SELECT,
   26.75 +    /*  42, 0x2a */     SDL_SCANCODE_UNKNOWN, /* VK_PRINT */
   26.76 +    /*  43, 0x2b */     SDL_SCANCODE_EXECUTE,
   26.77 +    /*  44, 0x2c */     SDL_SCANCODE_PRINTSCREEN,
   26.78 +    /*  45, 0x2d */     SDL_SCANCODE_INSERT,
   26.79 +    /*  46, 0x2e */     SDL_SCANCODE_DELETE,
   26.80 +    /*  47, 0x2f */     SDL_SCANCODE_HELP,
   26.81 +    /*  48, 0x30 */     SDL_SCANCODE_0,
   26.82 +    /*  49, 0x31 */     SDL_SCANCODE_1,
   26.83 +    /*  50, 0x32 */     SDL_SCANCODE_2,
   26.84 +    /*  51, 0x33 */     SDL_SCANCODE_3,
   26.85 +    /*  52, 0x34 */     SDL_SCANCODE_4,
   26.86 +    /*  53, 0x35 */     SDL_SCANCODE_5,
   26.87 +    /*  54, 0x36 */     SDL_SCANCODE_6,
   26.88 +    /*  55, 0x37 */     SDL_SCANCODE_7,
   26.89 +    /*  56, 0x38 */     SDL_SCANCODE_8,
   26.90 +    /*  57, 0x39 */     SDL_SCANCODE_9,
   26.91 +    /*  58, 0x3a */     SDL_SCANCODE_UNKNOWN,
   26.92 +    /*  59, 0x3b */     SDL_SCANCODE_UNKNOWN,
   26.93 +    /*  60, 0x3c */     SDL_SCANCODE_UNKNOWN,
   26.94 +    /*  61, 0x3d */     SDL_SCANCODE_UNKNOWN,
   26.95 +    /*  62, 0x3e */     SDL_SCANCODE_UNKNOWN,
   26.96 +    /*  63, 0x3f */     SDL_SCANCODE_UNKNOWN,
   26.97 +    /*  64, 0x40 */     SDL_SCANCODE_UNKNOWN,
   26.98 +    /*  65, 0x41 */     SDL_SCANCODE_A,
   26.99 +    /*  66, 0x42 */     SDL_SCANCODE_B,
  26.100 +    /*  67, 0x43 */     SDL_SCANCODE_C,
  26.101 +    /*  68, 0x44 */     SDL_SCANCODE_D,
  26.102 +    /*  69, 0x45 */     SDL_SCANCODE_E,
  26.103 +    /*  70, 0x46 */     SDL_SCANCODE_F,
  26.104 +    /*  71, 0x47 */     SDL_SCANCODE_G,
  26.105 +    /*  72, 0x48 */     SDL_SCANCODE_H,
  26.106 +    /*  73, 0x49 */     SDL_SCANCODE_I,
  26.107 +    /*  74, 0x4a */     SDL_SCANCODE_J,
  26.108 +    /*  75, 0x4b */     SDL_SCANCODE_K,
  26.109 +    /*  76, 0x4c */     SDL_SCANCODE_L,
  26.110 +    /*  77, 0x4d */     SDL_SCANCODE_M,
  26.111 +    /*  78, 0x4e */     SDL_SCANCODE_N,
  26.112 +    /*  79, 0x4f */     SDL_SCANCODE_O,
  26.113 +    /*  80, 0x50 */     SDL_SCANCODE_P,
  26.114 +    /*  81, 0x51 */     SDL_SCANCODE_Q,
  26.115 +    /*  82, 0x52 */     SDL_SCANCODE_R,
  26.116 +    /*  83, 0x53 */     SDL_SCANCODE_S,
  26.117 +    /*  84, 0x54 */     SDL_SCANCODE_T,
  26.118 +    /*  85, 0x55 */     SDL_SCANCODE_U,
  26.119 +    /*  86, 0x56 */     SDL_SCANCODE_V,
  26.120 +    /*  87, 0x57 */     SDL_SCANCODE_W,
  26.121 +    /*  88, 0x58 */     SDL_SCANCODE_X,
  26.122 +    /*  89, 0x59 */     SDL_SCANCODE_Y,
  26.123 +    /*  90, 0x5a */     SDL_SCANCODE_Z,
  26.124 +    /*  91, 0x5b */     SDL_SCANCODE_LGUI,
  26.125 +    /*  92, 0x5c */     SDL_SCANCODE_RGUI,
  26.126 +    /*  93, 0x5d */     SDL_SCANCODE_APPLICATION,
  26.127 +    /*  94, 0x5e */     SDL_SCANCODE_UNKNOWN,
  26.128 +    /*  95, 0x5f */     SDL_SCANCODE_UNKNOWN,
  26.129 +    /*  96, 0x60 */     SDL_SCANCODE_KP_0,
  26.130 +    /*  97, 0x61 */     SDL_SCANCODE_KP_1,
  26.131 +    /*  98, 0x62 */     SDL_SCANCODE_KP_2,
  26.132 +    /*  99, 0x63 */     SDL_SCANCODE_KP_3,
  26.133 +    /*  100, 0x64 */    SDL_SCANCODE_KP_4,
  26.134 +    /*  101, 0x65 */    SDL_SCANCODE_KP_5,
  26.135 +    /*  102, 0x66 */    SDL_SCANCODE_KP_6,
  26.136 +    /*  103, 0x67 */    SDL_SCANCODE_KP_7,
  26.137 +    /*  104, 0x68 */    SDL_SCANCODE_KP_8,
  26.138 +    /*  105, 0x69 */    SDL_SCANCODE_KP_9,
  26.139 +    /*  106, 0x6a */    SDL_SCANCODE_KP_MULTIPLY,
  26.140 +    /*  107, 0x6b */    SDL_SCANCODE_KP_PLUS,
  26.141 +    /*  108, 0x6c */    SDL_SCANCODE_SEPARATOR,
  26.142 +    /*  109, 0x6d */    SDL_SCANCODE_KP_MINUS,
  26.143 +    /*  110, 0x6e */    SDL_SCANCODE_KP_DECIMAL,
  26.144 +    /*  111, 0x6f */    SDL_SCANCODE_KP_DIVIDE,
  26.145 +    /*  112, 0x70 */    SDL_SCANCODE_F1,
  26.146 +    /*  113, 0x71 */    SDL_SCANCODE_F2,
  26.147 +    /*  114, 0x72 */    SDL_SCANCODE_F3,
  26.148 +    /*  115, 0x73 */    SDL_SCANCODE_F4,
  26.149 +    /*  116, 0x74 */    SDL_SCANCODE_F5,
  26.150 +    /*  117, 0x75 */    SDL_SCANCODE_F6,
  26.151 +    /*  118, 0x76 */    SDL_SCANCODE_F7,
  26.152 +    /*  119, 0x77 */    SDL_SCANCODE_F8,
  26.153 +    /*  120, 0x78 */    SDL_SCANCODE_F9,
  26.154 +    /*  121, 0x79 */    SDL_SCANCODE_F10,
  26.155 +    /*  122, 0x7a */    SDL_SCANCODE_F11,
  26.156 +    /*  123, 0x7b */    SDL_SCANCODE_F12,
  26.157 +    /*  124, 0x7c */    SDL_SCANCODE_F13,
  26.158 +    /*  125, 0x7d */    SDL_SCANCODE_F14,
  26.159 +    /*  126, 0x7e */    SDL_SCANCODE_F15,
  26.160 +    /*  127, 0x7f */    SDL_SCANCODE_F16,
  26.161 +    /*  128, 0x80 */    SDL_SCANCODE_F17, /* or SDL_SCANCODE_AUDIONEXT */
  26.162 +    /*  129, 0x81 */    SDL_SCANCODE_F18, /* or SDL_SCANCODE_AUDIOPREV */
  26.163 +    /*  130, 0x82 */    SDL_SCANCODE_F19, /* or SDL_SCANCODE_AUDIOSTOP */
  26.164 +    /*  131, 0x83 */    SDL_SCANCODE_F20, /* or SDL_SCANCODE_AUDIOPLAY */
  26.165 +    /*  132, 0x84 */    SDL_SCANCODE_F21, /* or SDL_SCANCODE_MAIL */
  26.166 +    /*  133, 0x85 */    SDL_SCANCODE_F22, /* or SDL_SCANCODE_MEDIASELECT */
  26.167 +    /*  134, 0x86 */    SDL_SCANCODE_F23, /* or SDL_SCANCODE_WWW */
  26.168 +    /*  135, 0x87 */    SDL_SCANCODE_F24, /* or SDL_SCANCODE_CALCULATOR */
  26.169 +    /*  136, 0x88 */    SDL_SCANCODE_UNKNOWN,
  26.170 +    /*  137, 0x89 */    SDL_SCANCODE_UNKNOWN,
  26.171 +    /*  138, 0x8a */    SDL_SCANCODE_UNKNOWN,
  26.172 +    /*  139, 0x8b */    SDL_SCANCODE_UNKNOWN,
  26.173 +    /*  140, 0x8c */    SDL_SCANCODE_UNKNOWN,
  26.174 +    /*  141, 0x8d */    SDL_SCANCODE_UNKNOWN,
  26.175 +    /*  142, 0x8e */    SDL_SCANCODE_UNKNOWN,
  26.176 +    /*  143, 0x8f */    SDL_SCANCODE_UNKNOWN,
  26.177 +    /*  144, 0x90 */    SDL_SCANCODE_NUMLOCKCLEAR,
  26.178 +    /*  145, 0x91 */    SDL_SCANCODE_SCROLLLOCK,
  26.179 +    /*  146, 0x92 */    SDL_SCANCODE_KP_EQUALS,
  26.180 +    /*  147, 0x93 */    SDL_SCANCODE_UNKNOWN,
  26.181 +    /*  148, 0x94 */    SDL_SCANCODE_UNKNOWN,
  26.182 +    /*  149, 0x95 */    SDL_SCANCODE_UNKNOWN,
  26.183 +    /*  150, 0x96 */    SDL_SCANCODE_UNKNOWN,
  26.184 +    /*  151, 0x97 */    SDL_SCANCODE_UNKNOWN,
  26.185 +    /*  152, 0x98 */    SDL_SCANCODE_UNKNOWN,
  26.186 +    /*  153, 0x99 */    SDL_SCANCODE_UNKNOWN,
  26.187 +    /*  154, 0x9a */    SDL_SCANCODE_UNKNOWN,
  26.188 +    /*  155, 0x9b */    SDL_SCANCODE_UNKNOWN,
  26.189 +    /*  156, 0x9c */    SDL_SCANCODE_UNKNOWN,
  26.190 +    /*  157, 0x9d */    SDL_SCANCODE_UNKNOWN,
  26.191 +    /*  158, 0x9e */    SDL_SCANCODE_UNKNOWN,
  26.192 +    /*  159, 0x9f */    SDL_SCANCODE_UNKNOWN,
  26.193 +    /*  160, 0xa0 */    SDL_SCANCODE_LSHIFT,
  26.194 +    /*  161, 0xa1 */    SDL_SCANCODE_RSHIFT,
  26.195 +    /*  162, 0xa2 */    SDL_SCANCODE_LCTRL,
  26.196 +    /*  163, 0xa3 */    SDL_SCANCODE_RCTRL,
  26.197 +    /*  164, 0xa4 */    SDL_SCANCODE_LALT,
  26.198 +    /*  165, 0xa5 */    SDL_SCANCODE_RALT,
  26.199 +    /*  166, 0xa6 */    SDL_SCANCODE_AC_BACK,
  26.200 +    /*  167, 0xa7 */    SDL_SCANCODE_AC_FORWARD,
  26.201 +    /*  168, 0xa8 */    SDL_SCANCODE_AC_REFRESH,
  26.202 +    /*  169, 0xa9 */    SDL_SCANCODE_AC_STOP,
  26.203 +    /*  170, 0xaa */    SDL_SCANCODE_AC_SEARCH,
  26.204 +    /*  171, 0xab */    SDL_SCANCODE_AC_BOOKMARKS,
  26.205 +    /*  172, 0xac */    SDL_SCANCODE_AC_HOME,
  26.206 +    /*  173, 0xad */    SDL_SCANCODE_AUDIOMUTE,
  26.207 +    /*  174, 0xae */    SDL_SCANCODE_VOLUMEDOWN,
  26.208 +    /*  175, 0xaf */    SDL_SCANCODE_VOLUMEUP,
  26.209 +    /*  176, 0xb0 */    SDL_SCANCODE_AUDIONEXT,
  26.210 +    /*  177, 0xb1 */    SDL_SCANCODE_AUDIOPREV,
  26.211 +    /*  178, 0xb2 */    SDL_SCANCODE_AUDIOSTOP,
  26.212 +    /*  179, 0xb3 */    SDL_SCANCODE_AUDIOPLAY,
  26.213 +    /*  180, 0xb4 */    SDL_SCANCODE_MAIL,
  26.214 +    /*  181, 0xb5 */    SDL_SCANCODE_MEDIASELECT,
  26.215 +    /*  182, 0xb6 */    SDL_SCANCODE_UNKNOWN, /* VK_LAUNCH_APP1 */
  26.216 +    /*  183, 0xb7 */    SDL_SCANCODE_UNKNOWN, /* VK_LAUNCH_APP2 */
  26.217 +    /*  184, 0xb8 */    SDL_SCANCODE_UNKNOWN,
  26.218 +    /*  185, 0xb9 */    SDL_SCANCODE_UNKNOWN,
  26.219 +    /*  186, 0xba */    SDL_SCANCODE_SEMICOLON,
  26.220 +    /*  187, 0xbb */    SDL_SCANCODE_EQUALS,
  26.221 +    /*  188, 0xbc */    SDL_SCANCODE_COMMA,
  26.222 +    /*  189, 0xbd */    SDL_SCANCODE_MINUS,
  26.223 +    /*  190, 0xbe */    SDL_SCANCODE_PERIOD,
  26.224 +    /*  191, 0xbf */    SDL_SCANCODE_SLASH,
  26.225 +    /*  192, 0xc0 */    SDL_SCANCODE_GRAVE,
  26.226 +    /*  193, 0xc1 */    SDL_SCANCODE_UNKNOWN,
  26.227 +    /*  194, 0xc2 */    SDL_SCANCODE_UNKNOWN,
  26.228 +    /*  195, 0xc3 */    SDL_SCANCODE_UNKNOWN,
  26.229 +    /*  196, 0xc4 */    SDL_SCANCODE_UNKNOWN,
  26.230 +    /*  197, 0xc5 */    SDL_SCANCODE_UNKNOWN,
  26.231 +    /*  198, 0xc6 */    SDL_SCANCODE_UNKNOWN,
  26.232 +    /*  199, 0xc7 */    SDL_SCANCODE_UNKNOWN,
  26.233 +    /*  200, 0xc8 */    SDL_SCANCODE_UNKNOWN,
  26.234 +    /*  201, 0xc9 */    SDL_SCANCODE_UNKNOWN,
  26.235 +    /*  202, 0xca */    SDL_SCANCODE_UNKNOWN,
  26.236 +    /*  203, 0xcb */    SDL_SCANCODE_UNKNOWN,
  26.237 +    /*  204, 0xcc */    SDL_SCANCODE_UNKNOWN,
  26.238 +    /*  205, 0xcd */    SDL_SCANCODE_UNKNOWN,
  26.239 +    /*  206, 0xce */    SDL_SCANCODE_UNKNOWN,
  26.240 +    /*  207, 0xcf */    SDL_SCANCODE_UNKNOWN,
  26.241 +    /*  208, 0xd0 */    SDL_SCANCODE_UNKNOWN,
  26.242 +    /*  209, 0xd1 */    SDL_SCANCODE_UNKNOWN,
  26.243 +    /*  210, 0xd2 */    SDL_SCANCODE_UNKNOWN,
  26.244 +    /*  211, 0xd3 */    SDL_SCANCODE_UNKNOWN,
  26.245 +    /*  212, 0xd4 */    SDL_SCANCODE_UNKNOWN,
  26.246 +    /*  213, 0xd5 */    SDL_SCANCODE_UNKNOWN,
  26.247 +    /*  214, 0xd6 */    SDL_SCANCODE_UNKNOWN,
  26.248 +    /*  215, 0xd7 */    SDL_SCANCODE_UNKNOWN,
  26.249 +    /*  216, 0xd8 */    SDL_SCANCODE_UNKNOWN,
  26.250 +    /*  217, 0xd9 */    SDL_SCANCODE_UNKNOWN,
  26.251 +    /*  218, 0xda */    SDL_SCANCODE_UNKNOWN,
  26.252 +    /*  219, 0xdb */    SDL_SCANCODE_LEFTBRACKET,
  26.253 +    /*  220, 0xdc */    SDL_SCANCODE_BACKSLASH,
  26.254 +    /*  221, 0xdd */    SDL_SCANCODE_RIGHTBRACKET,
  26.255 +    /*  222, 0xde */    SDL_SCANCODE_APOSTROPHE,
  26.256 +    /*  223, 0xdf */    SDL_SCANCODE_UNKNOWN,
  26.257 +    /*  224, 0xe0 */    SDL_SCANCODE_UNKNOWN,
  26.258 +    /*  225, 0xe1 */    SDL_SCANCODE_UNKNOWN,
  26.259 +    /*  226, 0xe2 */    SDL_SCANCODE_NONUSBACKSLASH,
  26.260 +    /*  227, 0xe3 */    SDL_SCANCODE_UNKNOWN,
  26.261 +    /*  228, 0xe4 */    SDL_SCANCODE_UNKNOWN,
  26.262 +    /*  229, 0xe5 */    SDL_SCANCODE_UNKNOWN,
  26.263 +    /*  230, 0xe6 */    SDL_SCANCODE_UNKNOWN,
  26.264 +    /*  231, 0xe7 */    SDL_SCANCODE_UNKNOWN,
  26.265 +    /*  232, 0xe8 */    SDL_SCANCODE_UNKNOWN,
  26.266 +    /*  233, 0xe9 */    SDL_SCANCODE_UNKNOWN,
  26.267 +    /*  234, 0xea */    SDL_SCANCODE_UNKNOWN,
  26.268 +    /*  235, 0xeb */    SDL_SCANCODE_UNKNOWN,
  26.269 +    /*  236, 0xec */    SDL_SCANCODE_UNKNOWN,
  26.270 +    /*  237, 0xed */    SDL_SCANCODE_UNKNOWN,
  26.271 +    /*  238, 0xee */    SDL_SCANCODE_UNKNOWN,
  26.272 +    /*  239, 0xef */    SDL_SCANCODE_UNKNOWN,
  26.273 +    /*  240, 0xf0 */    SDL_SCANCODE_UNKNOWN,
  26.274 +    /*  241, 0xf1 */    SDL_SCANCODE_UNKNOWN,
  26.275 +    /*  242, 0xf2 */    SDL_SCANCODE_UNKNOWN,
  26.276 +    /*  243, 0xf3 */    SDL_SCANCODE_UNKNOWN,
  26.277 +    /*  244, 0xf4 */    SDL_SCANCODE_UNKNOWN,
  26.278 +    /*  245, 0xf5 */    SDL_SCANCODE_UNKNOWN,
  26.279 +    /*  246, 0xf6 */    SDL_SCANCODE_SYSREQ,
  26.280 +    /*  247, 0xf7 */    SDL_SCANCODE_CRSEL,
  26.281 +    /*  248, 0xf8 */    SDL_SCANCODE_EXSEL,
  26.282 +    /*  249, 0xf9 */    SDL_SCANCODE_UNKNOWN, /* VK_EREOF */
  26.283 +    /*  250, 0xfa */    SDL_SCANCODE_UNKNOWN, /* VK_PLAY */
  26.284 +    /*  251, 0xfb */    SDL_SCANCODE_UNKNOWN, /* VK_ZOOM */
  26.285 +    /*  252, 0xfc */    SDL_SCANCODE_UNKNOWN,
  26.286 +    /*  253, 0xfd */    SDL_SCANCODE_UNKNOWN, /* VK_PA1 */
  26.287 +    /*  254, 0xfe */    SDL_SCANCODE_CLEAR,
  26.288 +    /*  255, 0xff */    SDL_SCANCODE_UNKNOWN,
  26.289 +};
  26.290 +/* *INDENT-ON* */
    27.1 --- a/src/file/SDL_rwops.c	Thu Jan 20 17:33:06 2011 -0800
    27.2 +++ b/src/file/SDL_rwops.c	Thu Jan 20 18:04:05 2011 -0800
    27.3 @@ -37,7 +37,7 @@
    27.4  #include <fat.h>
    27.5  #endif /* __NDS__ */
    27.6  
    27.7 -#ifdef __WIN32__
    27.8 +#ifdef __WINDOWS__
    27.9  
   27.10  /* Functions to read/write Win32 API file pointers */
   27.11  /* Will not use it on WinCE because stdio is buffered, it means
   27.12 @@ -54,7 +54,7 @@
   27.13  #define READAHEAD_BUFFER_SIZE	1024
   27.14  
   27.15  static int SDLCALL
   27.16 -win32_file_open(SDL_RWops * context, const char *filename, const char *mode)
   27.17 +windows_file_open(SDL_RWops * context, const char *filename, const char *mode)
   27.18  {
   27.19  #ifndef _WIN32_WCE
   27.20      UINT old_error_mode;
   27.21 @@ -67,10 +67,10 @@
   27.22      if (!context)
   27.23          return -1;              /* failed (invalid call) */
   27.24  
   27.25 -    context->hidden.win32io.h = INVALID_HANDLE_VALUE;   /* mark this as unusable */
   27.26 -    context->hidden.win32io.buffer.data = NULL;
   27.27 -    context->hidden.win32io.buffer.size = 0;
   27.28 -    context->hidden.win32io.buffer.left = 0;
   27.29 +    context->hidden.windowsio.h = INVALID_HANDLE_VALUE;   /* mark this as unusable */
   27.30 +    context->hidden.windowsio.buffer.data = NULL;
   27.31 +    context->hidden.windowsio.buffer.size = 0;
   27.32 +    context->hidden.windowsio.buffer.left = 0;
   27.33  
   27.34      /* "r" = reading, file must exist */
   27.35      /* "w" = writing, truncate existing, file may not exist */
   27.36 @@ -90,9 +90,9 @@
   27.37      if (!r_right && !w_right)   /* inconsistent mode */
   27.38          return -1;              /* failed (invalid call) */
   27.39  
   27.40 -    context->hidden.win32io.buffer.data =
   27.41 +    context->hidden.windowsio.buffer.data =
   27.42          (char *) SDL_malloc(READAHEAD_BUFFER_SIZE);
   27.43 -    if (!context->hidden.win32io.buffer.data) {
   27.44 +    if (!context->hidden.windowsio.buffer.data) {
   27.45          SDL_OutOfMemory();
   27.46          return -1;
   27.47      }
   27.48 @@ -104,8 +104,8 @@
   27.49          if (MultiByteToWideChar(CP_UTF8, 0, filename, -1, filenameW, size) ==
   27.50              0) {
   27.51              SDL_stack_free(filenameW);
   27.52 -            SDL_free(context->hidden.win32io.buffer.data);
   27.53 -            context->hidden.win32io.buffer.data = NULL;
   27.54 +            SDL_free(context->hidden.windowsio.buffer.data);
   27.55 +            context->hidden.windowsio.buffer.data = NULL;
   27.56              SDL_SetError("Unable to convert filename to Unicode");
   27.57              return -1;
   27.58          }
   27.59 @@ -130,51 +130,51 @@
   27.60  #endif /* _WIN32_WCE */
   27.61  
   27.62      if (h == INVALID_HANDLE_VALUE) {
   27.63 -        SDL_free(context->hidden.win32io.buffer.data);
   27.64 -        context->hidden.win32io.buffer.data = NULL;
   27.65 +        SDL_free(context->hidden.windowsio.buffer.data);
   27.66 +        context->hidden.windowsio.buffer.data = NULL;
   27.67          SDL_SetError("Couldn't open %s", filename);
   27.68          return -2;              /* failed (CreateFile) */
   27.69      }
   27.70 -    context->hidden.win32io.h = h;
   27.71 -    context->hidden.win32io.append = a_mode ? SDL_TRUE : SDL_FALSE;
   27.72 +    context->hidden.windowsio.h = h;
   27.73 +    context->hidden.windowsio.append = a_mode ? SDL_TRUE : SDL_FALSE;
   27.74  
   27.75      return 0;                   /* ok */
   27.76  }
   27.77  
   27.78  static long SDLCALL
   27.79 -win32_file_seek(SDL_RWops * context, long offset, int whence)
   27.80 +windows_file_seek(SDL_RWops * context, long offset, int whence)
   27.81  {
   27.82 -    DWORD win32whence;
   27.83 +    DWORD windowswhence;
   27.84      long file_pos;
   27.85  
   27.86 -    if (!context || context->hidden.win32io.h == INVALID_HANDLE_VALUE) {
   27.87 -        SDL_SetError("win32_file_seek: invalid context/file not opened");
   27.88 +    if (!context || context->hidden.windowsio.h == INVALID_HANDLE_VALUE) {
   27.89 +        SDL_SetError("windows_file_seek: invalid context/file not opened");
   27.90          return -1;
   27.91      }
   27.92  
   27.93      /* FIXME: We may be able to satisfy the seek within buffered data */
   27.94 -    if (whence == RW_SEEK_CUR && context->hidden.win32io.buffer.left) {
   27.95 -        offset -= (long)context->hidden.win32io.buffer.left;
   27.96 +    if (whence == RW_SEEK_CUR && context->hidden.windowsio.buffer.left) {
   27.97 +        offset -= (long)context->hidden.windowsio.buffer.left;
   27.98      }
   27.99 -    context->hidden.win32io.buffer.left = 0;
  27.100 +    context->hidden.windowsio.buffer.left = 0;
  27.101  
  27.102      switch (whence) {
  27.103      case RW_SEEK_SET:
  27.104 -        win32whence = FILE_BEGIN;
  27.105 +        windowswhence = FILE_BEGIN;
  27.106          break;
  27.107      case RW_SEEK_CUR:
  27.108 -        win32whence = FILE_CURRENT;
  27.109 +        windowswhence = FILE_CURRENT;
  27.110          break;
  27.111      case RW_SEEK_END:
  27.112 -        win32whence = FILE_END;
  27.113 +        windowswhence = FILE_END;
  27.114          break;
  27.115      default:
  27.116 -        SDL_SetError("win32_file_seek: Unknown value for 'whence'");
  27.117 +        SDL_SetError("windows_file_seek: Unknown value for 'whence'");
  27.118          return -1;
  27.119      }
  27.120  
  27.121      file_pos =
  27.122 -        SetFilePointer(context->hidden.win32io.h, offset, NULL, win32whence);
  27.123 +        SetFilePointer(context->hidden.windowsio.h, offset, NULL, windowswhence);
  27.124  
  27.125      if (file_pos != INVALID_SET_FILE_POINTER)
  27.126          return file_pos;        /* success */
  27.127 @@ -184,7 +184,7 @@
  27.128  }
  27.129  
  27.130  static size_t SDLCALL
  27.131 -win32_file_read(SDL_RWops * context, void *ptr, size_t size, size_t maxnum)
  27.132 +windows_file_read(SDL_RWops * context, void *ptr, size_t size, size_t maxnum)
  27.133  {
  27.134      size_t total_need;
  27.135      size_t total_read = 0;
  27.136 @@ -193,18 +193,18 @@
  27.137  
  27.138      total_need = size * maxnum;
  27.139  
  27.140 -    if (!context || context->hidden.win32io.h == INVALID_HANDLE_VALUE
  27.141 +    if (!context || context->hidden.windowsio.h == INVALID_HANDLE_VALUE
  27.142          || !total_need)
  27.143          return 0;
  27.144  
  27.145 -    if (context->hidden.win32io.buffer.left > 0) {
  27.146 -        void *data = (char *) context->hidden.win32io.buffer.data +
  27.147 -            context->hidden.win32io.buffer.size -
  27.148 -            context->hidden.win32io.buffer.left;
  27.149 +    if (context->hidden.windowsio.buffer.left > 0) {
  27.150 +        void *data = (char *) context->hidden.windowsio.buffer.data +
  27.151 +            context->hidden.windowsio.buffer.size -
  27.152 +            context->hidden.windowsio.buffer.left;
  27.153          read_ahead =
  27.154 -            SDL_min(total_need, context->hidden.win32io.buffer.left);
  27.155 +            SDL_min(total_need, context->hidden.windowsio.buffer.left);
  27.156          SDL_memcpy(ptr, data, read_ahead);
  27.157 -        context->hidden.win32io.buffer.left -= read_ahead;
  27.158 +        context->hidden.windowsio.buffer.left -= read_ahead;
  27.159  
  27.160          if (read_ahead == total_need) {
  27.161              return maxnum;
  27.162 @@ -216,19 +216,19 @@
  27.163  
  27.164      if (total_need < READAHEAD_BUFFER_SIZE) {
  27.165          if (!ReadFile
  27.166 -            (context->hidden.win32io.h, context->hidden.win32io.buffer.data,
  27.167 +            (context->hidden.windowsio.h, context->hidden.windowsio.buffer.data,
  27.168               READAHEAD_BUFFER_SIZE, &byte_read, NULL)) {
  27.169              SDL_Error(SDL_EFREAD);
  27.170              return 0;
  27.171          }
  27.172          read_ahead = SDL_min(total_need, (int) byte_read);
  27.173 -        SDL_memcpy(ptr, context->hidden.win32io.buffer.data, read_ahead);
  27.174 -        context->hidden.win32io.buffer.size = byte_read;
  27.175 -        context->hidden.win32io.buffer.left = byte_read - read_ahead;
  27.176 +        SDL_memcpy(ptr, context->hidden.windowsio.buffer.data, read_ahead);
  27.177 +        context->hidden.windowsio.buffer.size = byte_read;
  27.178 +        context->hidden.windowsio.buffer.left = byte_read - read_ahead;
  27.179          total_read += read_ahead;
  27.180      } else {
  27.181          if (!ReadFile
  27.182 -            (context->hidden.win32io.h, ptr, (DWORD)total_need, &byte_read, NULL)) {
  27.183 +            (context->hidden.windowsio.h, ptr, (DWORD)total_need, &byte_read, NULL)) {
  27.184              SDL_Error(SDL_EFREAD);
  27.185              return 0;
  27.186          }
  27.187 @@ -238,7 +238,7 @@
  27.188  }
  27.189  
  27.190  static size_t SDLCALL
  27.191 -win32_file_write(SDL_RWops * context, const void *ptr, size_t size,
  27.192 +windows_file_write(SDL_RWops * context, const void *ptr, size_t size,
  27.193                   size_t num)
  27.194  {
  27.195  
  27.196 @@ -248,20 +248,20 @@
  27.197  
  27.198      total_bytes = size * num;
  27.199  
  27.200 -    if (!context || context->hidden.win32io.h == INVALID_HANDLE_VALUE
  27.201 +    if (!context || context->hidden.windowsio.h == INVALID_HANDLE_VALUE
  27.202          || total_bytes <= 0 || !size)
  27.203          return 0;
  27.204  
  27.205 -    if (context->hidden.win32io.buffer.left) {
  27.206 -        SetFilePointer(context->hidden.win32io.h,
  27.207 -                       -(LONG)context->hidden.win32io.buffer.left, NULL,
  27.208 +    if (context->hidden.windowsio.buffer.left) {
  27.209 +        SetFilePointer(context->hidden.windowsio.h,
  27.210 +                       -(LONG)context->hidden.windowsio.buffer.left, NULL,
  27.211                         FILE_CURRENT);
  27.212 -        context->hidden.win32io.buffer.left = 0;
  27.213 +        context->hidden.windowsio.buffer.left = 0;
  27.214      }
  27.215  
  27.216      /* if in append mode, we must go to the EOF before write */
  27.217 -    if (context->hidden.win32io.append) {
  27.218 -        if (SetFilePointer(context->hidden.win32io.h, 0L, NULL, FILE_END) ==
  27.219 +    if (context->hidden.windowsio.append) {
  27.220 +        if (SetFilePointer(context->hidden.windowsio.h, 0L, NULL, FILE_END) ==
  27.221              INVALID_SET_FILE_POINTER) {
  27.222              SDL_Error(SDL_EFWRITE);
  27.223              return 0;
  27.224 @@ -269,7 +269,7 @@
  27.225      }
  27.226  
  27.227      if (!WriteFile
  27.228 -        (context->hidden.win32io.h, ptr, (DWORD)total_bytes, &byte_written, NULL)) {
  27.229 +        (context->hidden.windowsio.h, ptr, (DWORD)total_bytes, &byte_written, NULL)) {
  27.230          SDL_Error(SDL_EFWRITE);
  27.231          return 0;
  27.232      }
  27.233 @@ -279,23 +279,23 @@
  27.234  }
  27.235  
  27.236  static int SDLCALL
  27.237 -win32_file_close(SDL_RWops * context)
  27.238 +windows_file_close(SDL_RWops * context)
  27.239  {
  27.240  
  27.241      if (context) {
  27.242 -        if (context->hidden.win32io.h != INVALID_HANDLE_VALUE) {
  27.243 -            CloseHandle(context->hidden.win32io.h);
  27.244 -            context->hidden.win32io.h = INVALID_HANDLE_VALUE;   /* to be sure */
  27.245 +        if (context->hidden.windowsio.h != INVALID_HANDLE_VALUE) {
  27.246 +            CloseHandle(context->hidden.windowsio.h);
  27.247 +            context->hidden.windowsio.h = INVALID_HANDLE_VALUE;   /* to be sure */
  27.248          }
  27.249 -        if (context->hidden.win32io.buffer.data) {
  27.250 -            SDL_free(context->hidden.win32io.buffer.data);
  27.251 -            context->hidden.win32io.buffer.data = NULL;
  27.252 +        if (context->hidden.windowsio.buffer.data) {
  27.253 +            SDL_free(context->hidden.windowsio.buffer.data);
  27.254 +            context->hidden.windowsio.buffer.data = NULL;
  27.255          }
  27.256          SDL_FreeRW(context);
  27.257      }
  27.258      return (0);
  27.259  }
  27.260 -#endif /* __WIN32__ */
  27.261 +#endif /* __WINDOWS__ */
  27.262  
  27.263  #ifdef HAVE_STDIO_H
  27.264  
  27.265 @@ -449,18 +449,18 @@
  27.266          SDL_SetError("SDL_RWFromFile(): No file or no mode specified");
  27.267          return NULL;
  27.268      }
  27.269 -#if defined(__WIN32__)
  27.270 +#if defined(__WINDOWS__)
  27.271      rwops = SDL_AllocRW();
  27.272      if (!rwops)
  27.273          return NULL;            /* SDL_SetError already setup by SDL_AllocRW() */
  27.274 -    if (win32_file_open(rwops, file, mode) < 0) {
  27.275 +    if (windows_file_open(rwops, file, mode) < 0) {
  27.276          SDL_FreeRW(rwops);
  27.277          return NULL;
  27.278      }
  27.279 -    rwops->seek = win32_file_seek;
  27.280 -    rwops->read = win32_file_read;
  27.281 -    rwops->write = win32_file_write;
  27.282 -    rwops->close = win32_file_close;
  27.283 +    rwops->seek = windows_file_seek;
  27.284 +    rwops->read = windows_file_read;
  27.285 +    rwops->write = windows_file_write;
  27.286 +    rwops->close = windows_file_close;
  27.287  
  27.288  #elif HAVE_STDIO_H
  27.289  	#ifdef __APPLE__
    28.1 --- a/src/haptic/win32/SDL_syshaptic.c	Thu Jan 20 17:33:06 2011 -0800
    28.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    28.3 @@ -1,1379 +0,0 @@
    28.4 -/*
    28.5 -    SDL - Simple DirectMedia Layer
    28.6 -    Copyright (C) 2008 Edgar Simo
    28.7 -
    28.8 -    This library is free software; you can redistribute it and/or
    28.9 -    modify it under the terms of the GNU Lesser General Public
   28.10 -    License as published by the Free Software Foundation; either
   28.11 -    version 2.1 of the License, or (at your option) any later version.
   28.12 -
   28.13 -    This library is distributed in the hope that it will be useful,
   28.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
   28.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   28.16 -    Lesser General Public License for more details.
   28.17 -
   28.18 -    You should have received a copy of the GNU Lesser General Public
   28.19 -    License along with this library; if not, write to the Free Software
   28.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   28.21 -
   28.22 -    Sam Lantinga
   28.23 -    slouken@libsdl.org
   28.24 -*/
   28.25 -#include "SDL_config.h"
   28.26 -
   28.27 -#ifdef SDL_HAPTIC_DINPUT
   28.28 -
   28.29 -#include "SDL_haptic.h"
   28.30 -#include "../SDL_syshaptic.h"
   28.31 -#include "SDL_joystick.h"
   28.32 -#include "../../joystick/SDL_sysjoystick.h"     /* For the real SDL_Joystick */
   28.33 -#include "../../joystick/win32/SDL_dxjoystick_c.h"      /* For joystick hwdata */
   28.34 -
   28.35 -
   28.36 -#define MAX_HAPTICS  32
   28.37 -
   28.38 -
   28.39 -/*
   28.40 - * List of available haptic devices.
   28.41 - */
   28.42 -static struct
   28.43 -{
   28.44 -    DIDEVICEINSTANCE instance;
   28.45 -    SDL_Haptic *haptic;
   28.46 -    DIDEVCAPS capabilities;
   28.47 -} SDL_hapticlist[MAX_HAPTICS];
   28.48 -
   28.49 -
   28.50 -/*
   28.51 - * Haptic system hardware data.
   28.52 - */
   28.53 -struct haptic_hwdata
   28.54 -{
   28.55 -    LPDIRECTINPUTDEVICE2 device;
   28.56 -    DWORD axes[3];              /* Axes to use. */
   28.57 -    int is_joystick;            /* Device is loaded as joystick. */
   28.58 -};
   28.59 -
   28.60 -
   28.61 -/*
   28.62 - * Haptic system effect data.
   28.63 - */
   28.64 -struct haptic_hweffect
   28.65 -{
   28.66 -    DIEFFECT effect;
   28.67 -    LPDIRECTINPUTEFFECT ref;
   28.68 -};
   28.69 -
   28.70 -
   28.71 -/*
   28.72 - * Internal stuff.
   28.73 - */
   28.74 -static LPDIRECTINPUT dinput = NULL;
   28.75 -
   28.76 -
   28.77 -/*
   28.78 - * External stuff.
   28.79 - */
   28.80 -extern HWND SDL_HelperWindow;
   28.81 -
   28.82 -
   28.83 -/*
   28.84 - * Prototypes.
   28.85 - */
   28.86 -static void DI_SetError(const char *str, HRESULT err);
   28.87 -static int DI_GUIDIsSame(const GUID * a, const GUID * b);
   28.88 -static int SDL_SYS_HapticOpenFromInstance(SDL_Haptic * haptic,
   28.89 -                                          DIDEVICEINSTANCE instance);
   28.90 -static int SDL_SYS_HapticOpenFromDevice2(SDL_Haptic * haptic,
   28.91 -                                         LPDIRECTINPUTDEVICE2 device2);
   28.92 -static DWORD DIGetTriggerButton(Uint16 button);
   28.93 -static int SDL_SYS_SetDirection(DIEFFECT * effect, SDL_HapticDirection * dir,
   28.94 -                                int naxes);
   28.95 -static int SDL_SYS_ToDIEFFECT(SDL_Haptic * haptic, DIEFFECT * dest,
   28.96 -                              SDL_HapticEffect * src);
   28.97 -static void SDL_SYS_HapticFreeDIEFFECT(DIEFFECT * effect, int type);
   28.98 -static REFGUID SDL_SYS_HapticEffectType(SDL_HapticEffect * effect);
   28.99 -/* Callbacks. */
  28.100 -static BOOL CALLBACK EnumHapticsCallback(const DIDEVICEINSTANCE *
  28.101 -                                         pdidInstance, VOID * pContext);
  28.102 -static BOOL CALLBACK DI_EffectCallback(LPCDIEFFECTINFO pei, LPVOID pv);
  28.103 -
  28.104 -
  28.105 -/* 
  28.106 - * Like SDL_SetError but for DX error codes.
  28.107 - */
  28.108 -static void
  28.109 -DI_SetError(const char *str, HRESULT err)
  28.110 -{
  28.111 -    /*
  28.112 -       SDL_SetError("Haptic: %s - %s: %s", str,
  28.113 -       DXGetErrorString8A(err), DXGetErrorDescription8A(err));
  28.114 -     */
  28.115 -    SDL_SetError("Haptic error %s", str);
  28.116 -}
  28.117 -
  28.118 -
  28.119 -/*
  28.120 - * Checks to see if two GUID are the same.
  28.121 - */
  28.122 -static int
  28.123 -DI_GUIDIsSame(const GUID * a, const GUID * b)
  28.124 -{
  28.125 -    if (((a)->Data1 == (b)->Data1) &&
  28.126 -        ((a)->Data2 == (b)->Data2) &&
  28.127 -        ((a)->Data3 == (b)->Data3) &&
  28.128 -        (SDL_strcmp((a)->Data4, (b)->Data4) == 0))
  28.129 -        return 1;
  28.130 -    return 0;
  28.131 -}
  28.132 -
  28.133 -
  28.134 -/*
  28.135 - * Initializes the haptic subsystem.
  28.136 - */
  28.137 -int
  28.138 -SDL_SYS_HapticInit(void)
  28.139 -{
  28.140 -    HRESULT ret;
  28.141 -    HINSTANCE instance;
  28.142 -
  28.143 -    if (dinput != NULL) {       /* Already open. */
  28.144 -        SDL_SetError("Haptic: SubSystem already open.");
  28.145 -        return -1;
  28.146 -    }
  28.147 -
  28.148 -    /* Clear all the memory. */
  28.149 -    SDL_memset(SDL_hapticlist, 0, sizeof(SDL_hapticlist));
  28.150 -
  28.151 -    SDL_numhaptics = 0;
  28.152 -
  28.153 -    ret = CoInitialize(NULL);
  28.154 -    if (FAILED(ret)) {
  28.155 -        DI_SetError("Coinitialize", ret);
  28.156 -        return -1;
  28.157 -    }
  28.158 -
  28.159 -    ret = CoCreateInstance(&CLSID_DirectInput, NULL, CLSCTX_INPROC_SERVER,
  28.160 -                           &IID_IDirectInput, (LPVOID) & dinput);
  28.161 -    if (FAILED(ret)) {
  28.162 -        DI_SetError("CoCreateInstance", ret);
  28.163 -        return -1;
  28.164 -    }
  28.165 -
  28.166 -    /* Because we used CoCreateInstance, we need to Initialize it, first. */
  28.167 -    instance = GetModuleHandle(NULL);
  28.168 -    if (instance == NULL) {
  28.169 -        SDL_SetError("GetModuleHandle() failed with error code %d.",
  28.170 -                     GetLastError());
  28.171 -        return -1;
  28.172 -    }
  28.173 -    ret = IDirectInput_Initialize(dinput, instance, DIRECTINPUT_VERSION);
  28.174 -    if (FAILED(ret)) {
  28.175 -        DI_SetError("Initializing DirectInput device", ret);
  28.176 -        return -1;
  28.177 -    }
  28.178 -
  28.179 -    /* Look for haptic devices. */
  28.180 -    ret = IDirectInput_EnumDevices(dinput,
  28.181 -                                   0,
  28.182 -                                   EnumHapticsCallback,
  28.183 -                                   NULL,
  28.184 -                                   DIEDFL_FORCEFEEDBACK |
  28.185 -                                   DIEDFL_ATTACHEDONLY);
  28.186 -    if (FAILED(ret)) {
  28.187 -        DI_SetError("Enumerating DirectInput devices", ret);
  28.188 -        return -1;
  28.189 -    }
  28.190 -
  28.191 -    return SDL_numhaptics;
  28.192 -}
  28.193 -
  28.194 -/*
  28.195 - * Callback to find the haptic devices.
  28.196 - */
  28.197 -static BOOL CALLBACK
  28.198 -EnumHapticsCallback(const DIDEVICEINSTANCE * pdidInstance, VOID * pContext)
  28.199 -{
  28.200 -    HRESULT ret;
  28.201 -    LPDIRECTINPUTDEVICE device;
  28.202 -
  28.203 -    /* Copy the instance over, useful for creating devices. */
  28.204 -    SDL_memcpy(&SDL_hapticlist[SDL_numhaptics].instance, pdidInstance,
  28.205 -               sizeof(DIDEVICEINSTANCE));
  28.206 -
  28.207 -    /* Open the device */
  28.208 -    ret = IDirectInput_CreateDevice(dinput, &pdidInstance->guidInstance,
  28.209 -                                    &device, NULL);
  28.210 -    if (FAILED(ret)) {
  28.211 -        /* DI_SetError("Creating DirectInput device",ret); */
  28.212 -        return DIENUM_CONTINUE;
  28.213 -    }
  28.214 -
  28.215 -    /* Get capabilities. */
  28.216 -    SDL_hapticlist[SDL_numhaptics].capabilities.dwSize = sizeof(DIDEVCAPS);
  28.217 -    ret = IDirectInputDevice_GetCapabilities(device,
  28.218 -                                             &SDL_hapticlist[SDL_numhaptics].
  28.219 -                                             capabilities);
  28.220 -    if (FAILED(ret)) {
  28.221 -        /* DI_SetError("Getting device capabilities",ret); */
  28.222 -        IDirectInputDevice_Release(device);
  28.223 -        return DIENUM_CONTINUE;
  28.224 -    }
  28.225 -
  28.226 -    /* Close up device and count it. */
  28.227 -    IDirectInputDevice_Release(device);
  28.228 -    SDL_numhaptics++;
  28.229 -
  28.230 -    /* Watch out for hard limit. */
  28.231 -    if (SDL_numhaptics >= MAX_HAPTICS)
  28.232 -        return DIENUM_STOP;
  28.233 -
  28.234 -    return DIENUM_CONTINUE;
  28.235 -}
  28.236 -
  28.237 -
  28.238 -/*
  28.239 - * Return the name of a haptic device, does not need to be opened.
  28.240 - */
  28.241 -const char *
  28.242 -SDL_SYS_HapticName(int index)
  28.243 -{
  28.244 -    return SDL_hapticlist[index].instance.tszProductName;
  28.245 -}
  28.246 -
  28.247 -
  28.248 -/*
  28.249 - * Callback to get all supported effects.
  28.250 - */
  28.251 -#define EFFECT_TEST(e,s)               \
  28.252 -if (DI_GUIDIsSame(&pei->guid, &(e)))   \
  28.253 -   haptic->supported |= (s)
  28.254 -static BOOL CALLBACK
  28.255 -DI_EffectCallback(LPCDIEFFECTINFO pei, LPVOID pv)
  28.256 -{
  28.257 -    /* Prepare the haptic device. */
  28.258 -    SDL_Haptic *haptic = (SDL_Haptic *) pv;
  28.259 -
  28.260 -    /* Get supported. */
  28.261 -    EFFECT_TEST(GUID_Spring, SDL_HAPTIC_SPRING);
  28.262 -    EFFECT_TEST(GUID_Damper, SDL_HAPTIC_DAMPER);
  28.263 -    EFFECT_TEST(GUID_Inertia, SDL_HAPTIC_INERTIA);
  28.264 -    EFFECT_TEST(GUID_Friction, SDL_HAPTIC_FRICTION);
  28.265 -    EFFECT_TEST(GUID_ConstantForce, SDL_HAPTIC_CONSTANT);
  28.266 -    EFFECT_TEST(GUID_CustomForce, SDL_HAPTIC_CUSTOM);
  28.267 -    EFFECT_TEST(GUID_Sine, SDL_HAPTIC_SINE);
  28.268 -    EFFECT_TEST(GUID_Square, SDL_HAPTIC_SQUARE);
  28.269 -    EFFECT_TEST(GUID_Triangle, SDL_HAPTIC_TRIANGLE);
  28.270 -    EFFECT_TEST(GUID_SawtoothUp, SDL_HAPTIC_SAWTOOTHUP);
  28.271 -    EFFECT_TEST(GUID_SawtoothDown, SDL_HAPTIC_SAWTOOTHDOWN);
  28.272 -    EFFECT_TEST(GUID_RampForce, SDL_HAPTIC_RAMP);
  28.273 -
  28.274 -    /* Check for more. */
  28.275 -    return DIENUM_CONTINUE;
  28.276 -}
  28.277 -
  28.278 -
  28.279 -/*
  28.280 - * Callback to get supported axes.
  28.281 - */
  28.282 -static BOOL CALLBACK
  28.283 -DI_DeviceObjectCallback(LPCDIDEVICEOBJECTINSTANCE dev, LPVOID pvRef)
  28.284 -{
  28.285 -    SDL_Haptic *haptic = (SDL_Haptic *) pvRef;
  28.286 -
  28.287 -    if ((dev->dwType & DIDFT_AXIS) && (dev->dwFlags & DIDOI_FFACTUATOR)) {
  28.288 -
  28.289 -        haptic->hwdata->axes[haptic->naxes] = dev->dwOfs;
  28.290 -        haptic->naxes++;
  28.291 -
  28.292 -        /* Currently using the artificial limit of 3 axes. */
  28.293 -        if (haptic->naxes >= 3) {
  28.294 -            return DIENUM_STOP;
  28.295 -        }
  28.296 -    }
  28.297 -
  28.298 -    return DIENUM_CONTINUE;
  28.299 -}
  28.300 -
  28.301 -
  28.302 -/*
  28.303 - * Opens the haptic device from the file descriptor.
  28.304 - *
  28.305 - *    Steps:
  28.306 - *       - Open temporary DirectInputDevice interface.
  28.307 - *       - Create DirectInputDevice2 interface.
  28.308 - *       - Release DirectInputDevice interface.
  28.309 - *       - Call SDL_SYS_HapticOpenFromDevice2
  28.310 - */
  28.311 -static int
  28.312 -SDL_SYS_HapticOpenFromInstance(SDL_Haptic * haptic, DIDEVICEINSTANCE instance)
  28.313 -{
  28.314 -    HRESULT ret;
  28.315 -    int ret2;
  28.316 -    LPDIRECTINPUTDEVICE device;
  28.317 -
  28.318 -    /* Allocate the hwdata */
  28.319 -    haptic->hwdata = (struct haptic_hwdata *)
  28.320 -        SDL_malloc(sizeof(*haptic->hwdata));
  28.321 -    if (haptic->hwdata == NULL) {
  28.322 -        SDL_OutOfMemory();
  28.323 -        goto creat_err;
  28.324 -    }
  28.325 -    SDL_memset(haptic->hwdata, 0, sizeof(*haptic->hwdata));
  28.326 -
  28.327 -    /* Open the device */
  28.328 -    ret = IDirectInput_CreateDevice(dinput, &instance.guidInstance,
  28.329 -                                    &device, NULL);
  28.330 -    if (FAILED(ret)) {
  28.331 -        DI_SetError("Creating DirectInput device", ret);
  28.332 -        goto creat_err;
  28.333 -    }
  28.334 -
  28.335 -    /* Now get the IDirectInputDevice2 interface, instead. */
  28.336 -    ret = IDirectInputDevice_QueryInterface(device,
  28.337 -                                            &IID_IDirectInputDevice2,
  28.338 -                                            (LPVOID *) & haptic->hwdata->
  28.339 -                                            device);
  28.340 -    /* Done with the temporary one now. */
  28.341 -    IDirectInputDevice_Release(device);
  28.342 -    if (FAILED(ret)) {
  28.343 -        DI_SetError("Querying DirectInput interface", ret);
  28.344 -        goto creat_err;
  28.345 -    }
  28.346 -
  28.347 -    ret2 = SDL_SYS_HapticOpenFromDevice2(haptic, haptic->hwdata->device);
  28.348 -    if (ret2 < 0) {
  28.349 -        goto query_err;
  28.350 -    }
  28.351 -
  28.352 -    return 0;
  28.353 -
  28.354 -  query_err:
  28.355 -    IDirectInputDevice2_Release(haptic->hwdata->device);
  28.356 -  creat_err:
  28.357 -    if (haptic->hwdata != NULL) {
  28.358 -        SDL_free(haptic->hwdata);
  28.359 -        haptic->hwdata = NULL;
  28.360 -    }
  28.361 -    return -1;
  28.362 -}
  28.363 -
  28.364 -
  28.365 -/*
  28.366 - * Opens the haptic device from the file descriptor.
  28.367 - *
  28.368 - *    Steps:
  28.369 - *       - Set cooperative level.
  28.370 - *       - Set data format.
  28.371 - *       - Acquire exclusiveness.
  28.372 - *       - Reset actuators.
  28.373 - *       - Get supported featuers.
  28.374 - */
  28.375 -static int
  28.376 -SDL_SYS_HapticOpenFromDevice2(SDL_Haptic * haptic,
  28.377 -                              LPDIRECTINPUTDEVICE2 device2)
  28.378 -{
  28.379 -    HRESULT ret;
  28.380 -    DIPROPDWORD dipdw;
  28.381 -
  28.382 -    /* We'll use the device2 from now on. */
  28.383 -    haptic->hwdata->device = device2;
  28.384 -
  28.385 -    /* Grab it exclusively to use force feedback stuff. */
  28.386 -    ret = IDirectInputDevice2_SetCooperativeLevel(haptic->hwdata->device,
  28.387 -                                                  SDL_HelperWindow,
  28.388 -                                                  DISCL_EXCLUSIVE |
  28.389 -                                                  DISCL_BACKGROUND);
  28.390 -    if (FAILED(ret)) {
  28.391 -        DI_SetError("Setting cooperative level to exclusive", ret);
  28.392 -        goto acquire_err;
  28.393 -    }
  28.394 -
  28.395 -    /* Set data format. */
  28.396 -    ret = IDirectInputDevice2_SetDataFormat(haptic->hwdata->device,
  28.397 -                                            &c_dfDIJoystick2);
  28.398 -    if (FAILED(ret)) {
  28.399 -        DI_SetError("Setting data format", ret);
  28.400 -        goto acquire_err;
  28.401 -    }
  28.402 -
  28.403 -    /* Get number of axes. */
  28.404 -    ret = IDirectInputDevice2_EnumObjects(haptic->hwdata->device,
  28.405 -                                          DI_DeviceObjectCallback,
  28.406 -                                          haptic, DIDFT_AXIS);
  28.407 -    if (FAILED(ret)) {
  28.408 -        DI_SetError("Getting device axes", ret);
  28.409 -        goto acquire_err;
  28.410 -    }
  28.411 -
  28.412 -    /* Acquire the device. */
  28.413 -    ret = IDirectInputDevice2_Acquire(haptic->hwdata->device);
  28.414 -    if (FAILED(ret)) {
  28.415 -        DI_SetError("Acquiring DirectInput device", ret);
  28.416 -        goto acquire_err;
  28.417 -    }
  28.418 -
  28.419 -    /* Reset all actuators - just in case. */
  28.420 -    ret = IDirectInputDevice2_SendForceFeedbackCommand(haptic->hwdata->device,
  28.421 -                                                       DISFFC_RESET);
  28.422 -    if (FAILED(ret)) {
  28.423 -        DI_SetError("Resetting device", ret);
  28.424 -        goto acquire_err;
  28.425 -    }
  28.426 -
  28.427 -    /* Enabling actuators. */
  28.428 -    ret = IDirectInputDevice2_SendForceFeedbackCommand(haptic->hwdata->device,
  28.429 -                                                       DISFFC_SETACTUATORSON);
  28.430 -    if (FAILED(ret)) {
  28.431 -        DI_SetError("Enabling actuators", ret);
  28.432 -        goto acquire_err;
  28.433 -    }
  28.434 -
  28.435 -    /* Get supported effects. */
  28.436 -    ret = IDirectInputDevice2_EnumEffects(haptic->hwdata->device,
  28.437 -                                          DI_EffectCallback, haptic,
  28.438 -                                          DIEFT_ALL);
  28.439 -    if (FAILED(ret)) {
  28.440 -        DI_SetError("Enumerating supported effects", ret);
  28.441 -        goto acquire_err;
  28.442 -    }
  28.443 -    if (haptic->supported == 0) {       /* Error since device supports nothing. */
  28.444 -        SDL_SetError("Haptic: Internal error on finding supported effects.");
  28.445 -        goto acquire_err;
  28.446 -    }
  28.447 -
  28.448 -    /* Check autogain and autocenter. */
  28.449 -    dipdw.diph.dwSize = sizeof(DIPROPDWORD);
  28.450 -    dipdw.diph.dwHeaderSize = sizeof(DIPROPHEADER);
  28.451 -    dipdw.diph.dwObj = 0;
  28.452 -    dipdw.diph.dwHow = DIPH_DEVICE;
  28.453 -    dipdw.dwData = 10000;
  28.454 -    ret = IDirectInputDevice2_SetProperty(haptic->hwdata->device,
  28.455 -                                          DIPROP_FFGAIN, &dipdw.diph);
  28.456 -    if (!FAILED(ret)) {         /* Gain is supported. */
  28.457 -        haptic->supported |= SDL_HAPTIC_GAIN;
  28.458 -    }
  28.459 -    dipdw.diph.dwObj = 0;
  28.460 -    dipdw.diph.dwHow = DIPH_DEVICE;
  28.461 -    dipdw.dwData = DIPROPAUTOCENTER_OFF;
  28.462 -    ret = IDirectInputDevice2_SetProperty(haptic->hwdata->device,
  28.463 -                                          DIPROP_AUTOCENTER, &dipdw.diph);
  28.464 -    if (!FAILED(ret)) {         /* Autocenter is supported. */
  28.465 -        haptic->supported |= SDL_HAPTIC_AUTOCENTER;
  28.466 -    }
  28.467 -
  28.468 -    /* Status is always supported. */
  28.469 -    haptic->supported |= SDL_HAPTIC_STATUS | SDL_HAPTIC_PAUSE;
  28.470 -
  28.471 -    /* Check maximum effects. */
  28.472 -    haptic->neffects = 128;     /* This is not actually supported as thus under windows,
  28.473 -                                   there is no way to tell the number of EFFECTS that a
  28.474 -                                   device can hold, so we'll just use a "random" number
  28.475 -                                   instead and put warnings in SDL_haptic.h */
  28.476 -    haptic->nplaying = 128;     /* Even more impossible to get this then neffects. */
  28.477 -
  28.478 -    /* Prepare effects memory. */
  28.479 -    haptic->effects = (struct haptic_effect *)
  28.480 -        SDL_malloc(sizeof(struct haptic_effect) * haptic->neffects);
  28.481 -    if (haptic->effects == NULL) {
  28.482 -        SDL_OutOfMemory();
  28.483 -        goto acquire_err;
  28.484 -    }
  28.485 -    /* Clear the memory */
  28.486 -    SDL_memset(haptic->effects, 0,
  28.487 -               sizeof(struct haptic_effect) * haptic->neffects);
  28.488 -
  28.489 -    return 0;
  28.490 -
  28.491 -    /* Error handling */
  28.492 -  acquire_err:
  28.493 -    IDirectInputDevice2_Unacquire(haptic->hwdata->device);
  28.494 -    return -1;
  28.495 -
  28.496 -}
  28.497 -
  28.498 -
  28.499 -/*
  28.500 - * Opens a haptic device for usage.
  28.501 - */
  28.502 -int
  28.503 -SDL_SYS_HapticOpen(SDL_Haptic * haptic)
  28.504 -{
  28.505 -    return SDL_SYS_HapticOpenFromInstance(haptic,
  28.506 -                                          SDL_hapticlist[haptic->index].
  28.507 -                                          instance);
  28.508 -}
  28.509 -
  28.510 -
  28.511 -/*
  28.512 - * Opens a haptic device from first mouse it finds for usage.
  28.513 - */
  28.514 -int
  28.515 -SDL_SYS_HapticMouse(void)
  28.516 -{
  28.517 -    int i;
  28.518 -
  28.519 -    /* Grab the first mouse haptic device we find. */
  28.520 -    for (i = 0; i < SDL_numhaptics; i++) {
  28.521 -        if (SDL_hapticlist[i].capabilities.dwDevType == DIDEVTYPE_MOUSE) {
  28.522 -            return i;
  28.523 -        }
  28.524 -    }
  28.525 -
  28.526 -    return -1;
  28.527 -}
  28.528 -
  28.529 -
  28.530 -/*
  28.531 - * Checks to see if a joystick has haptic features.
  28.532 - */
  28.533 -int
  28.534 -SDL_SYS_JoystickIsHaptic(SDL_Joystick * joystick)
  28.535 -{
  28.536 -    if (joystick->hwdata->Capabilities.dwFlags & DIDC_FORCEFEEDBACK) {
  28.537 -        return SDL_TRUE;
  28.538 -    }
  28.539 -
  28.540 -    return SDL_FALSE;
  28.541 -}
  28.542 -
  28.543 -
  28.544 -/*
  28.545 - * Checks to see if the haptic device and joystick and in reality the same.
  28.546 - */
  28.547 -int
  28.548 -SDL_SYS_JoystickSameHaptic(SDL_Haptic * haptic, SDL_Joystick * joystick)
  28.549 -{
  28.550 -    HRESULT ret;
  28.551 -    DIDEVICEINSTANCE hap_instance, joy_instance;
  28.552 -
  28.553 -    /* Get the device instances. */
  28.554 -    ret = IDirectInputDevice2_GetDeviceInfo(haptic->hwdata->device,
  28.555 -                                            &hap_instance);
  28.556 -    if (FAILED(ret)) {
  28.557 -        return 0;
  28.558 -    }
  28.559 -    ret = IDirectInputDevice2_GetDeviceInfo(joystick->hwdata->InputDevice,
  28.560 -                                            &joy_instance);
  28.561 -    if (FAILED(ret)) {
  28.562 -        return 0;
  28.563 -    }
  28.564 -
  28.565 -    if (DI_GUIDIsSame(&hap_instance.guidInstance, &joy_instance.guidInstance))
  28.566 -        return 1;
  28.567 -
  28.568 -    return 0;
  28.569 -}
  28.570 -
  28.571 -
  28.572 -/*
  28.573 - * Opens a SDL_Haptic from a SDL_Joystick.
  28.574 - */
  28.575 -int
  28.576 -SDL_SYS_HapticOpenFromJoystick(SDL_Haptic * haptic, SDL_Joystick * joystick)
  28.577 -{
  28.578 -    int ret;
  28.579 -
  28.580 -    /* Allocate the hwdata */
  28.581 -    haptic->hwdata = (struct haptic_hwdata *)
  28.582 -        SDL_malloc(sizeof(*haptic->hwdata));
  28.583 -    if (haptic->hwdata == NULL) {
  28.584 -        SDL_OutOfMemory();
  28.585 -        return -1;
  28.586 -    }
  28.587 -    SDL_memset(haptic->hwdata, 0, sizeof(*haptic->hwdata));
  28.588 -
  28.589 -    /* Now open the device. */
  28.590 -    ret =
  28.591 -        SDL_SYS_HapticOpenFromDevice2(haptic, joystick->hwdata->InputDevice);
  28.592 -    if (ret < 0) {
  28.593 -        return -1;
  28.594 -    }
  28.595 -
  28.596 -    /* It's using the joystick device. */
  28.597 -    haptic->hwdata->is_joystick = 1;
  28.598 -
  28.599 -    return 0;
  28.600 -}
  28.601 -
  28.602 -
  28.603 -/*
  28.604 - * Closes the haptic device.
  28.605 - */
  28.606 -void
  28.607 -SDL_SYS_HapticClose(SDL_Haptic * haptic)
  28.608 -{
  28.609 -    if (haptic->hwdata) {
  28.610 -
  28.611 -        /* Free effects. */
  28.612 -        SDL_free(haptic->effects);
  28.613 -        haptic->effects = NULL;
  28.614 -        haptic->neffects = 0;
  28.615 -
  28.616 -        /* Clean up */
  28.617 -        IDirectInputDevice2_Unacquire(haptic->hwdata->device);
  28.618 -        /* Only release if isn't grabbed by a joystick. */
  28.619 -        if (haptic->hwdata->is_joystick == 0) {
  28.620 -            IDirectInputDevice2_Release(haptic->hwdata->device);
  28.621 -        }
  28.622 -
  28.623 -        /* Free */
  28.624 -        SDL_free(haptic->hwdata);
  28.625 -        haptic->hwdata = NULL;
  28.626 -    }
  28.627 -}
  28.628 -
  28.629 -
  28.630 -/* 
  28.631 - * Clean up after system specific haptic stuff
  28.632 - */
  28.633 -void
  28.634 -SDL_SYS_HapticQuit(void)
  28.635 -{
  28.636 -    IDirectInput_Release(dinput);
  28.637 -    dinput = NULL;
  28.638 -}
  28.639 -
  28.640 -
  28.641 -/*
  28.642 - * Converts an SDL trigger button to an DIEFFECT trigger button.
  28.643 - */
  28.644 -static DWORD
  28.645 -DIGetTriggerButton(Uint16 button)
  28.646 -{
  28.647 -    DWORD dwTriggerButton;
  28.648 -
  28.649 -    dwTriggerButton = DIEB_NOTRIGGER;
  28.650 -
  28.651 -    if (button != 0) {
  28.652 -        dwTriggerButton = DIJOFS_BUTTON(button - 1);
  28.653 -    }
  28.654 -
  28.655 -    return dwTriggerButton;
  28.656 -}
  28.657 -
  28.658 -
  28.659 -/*
  28.660 - * Sets the direction.
  28.661 - */
  28.662 -static int
  28.663 -SDL_SYS_SetDirection(DIEFFECT * effect, SDL_HapticDirection * dir, int naxes)
  28.664 -{
  28.665 -    LONG *rglDir;
  28.666 -
  28.667 -    /* Handle no axes a part. */
  28.668 -    if (naxes == 0) {
  28.669 -        effect->dwFlags |= DIEFF_SPHERICAL;     /* Set as default. */
  28.670 -        effect->rglDirection = NULL;
  28.671 -        return 0;
  28.672 -    }
  28.673 -
  28.674 -    /* Has axes. */
  28.675 -    rglDir = SDL_malloc(sizeof(LONG) * naxes);
  28.676 -    if (rglDir == NULL) {
  28.677 -        SDL_OutOfMemory();
  28.678 -        return -1;
  28.679 -    }
  28.680 -    SDL_memset(rglDir, 0, sizeof(LONG) * naxes);
  28.681 -    effect->rglDirection = rglDir;
  28.682 -
  28.683 -    switch (dir->type) {
  28.684 -    case SDL_HAPTIC_POLAR:
  28.685 -        effect->dwFlags |= DIEFF_POLAR;
  28.686 -        rglDir[0] = dir->dir[0];
  28.687 -        return 0;
  28.688 -    case SDL_HAPTIC_CARTESIAN:
  28.689 -        effect->dwFlags |= DIEFF_CARTESIAN;
  28.690 -        rglDir[0] = dir->dir[0];
  28.691 -        if (naxes > 1)
  28.692 -            rglDir[1] = dir->dir[1];
  28.693 -        if (naxes > 2)
  28.694 -            rglDir[2] = dir->dir[2];
  28.695 -        return 0;
  28.696 -    case SDL_HAPTIC_SPHERICAL:
  28.697 -        effect->dwFlags |= DIEFF_SPHERICAL;
  28.698 -        rglDir[0] = dir->dir[0];
  28.699 -        if (naxes > 1)
  28.700 -            rglDir[1] = dir->dir[1];
  28.701 -        if (naxes > 2)
  28.702 -            rglDir[2] = dir->dir[2];
  28.703 -        return 0;
  28.704 -
  28.705 -    default:
  28.706 -        SDL_SetError("Haptic: Unknown direction type.");
  28.707 -        return -1;
  28.708 -    }
  28.709 -}
  28.710 -
  28.711 -#define CONVERT(x)   (((x) > 0x7FFF) ? 10000 : ((x)*10000) / 0x7FFF)
  28.712 -/*
  28.713 - * Creates the DIEFFECT from a SDL_HapticEffect.
  28.714 - */
  28.715 -static int
  28.716 -SDL_SYS_ToDIEFFECT(SDL_Haptic * haptic, DIEFFECT * dest,
  28.717 -                   SDL_HapticEffect * src)
  28.718 -{
  28.719 -    int i;
  28.720 -    DICONSTANTFORCE *constant;
  28.721 -    DIPERIODIC *periodic;
  28.722 -    DICONDITION *condition;     /* Actually an array of conditions - one per axis. */
  28.723 -    DIRAMPFORCE *ramp;
  28.724 -    DICUSTOMFORCE *custom;
  28.725 -    DIENVELOPE *envelope;
  28.726 -    SDL_HapticConstant *hap_constant;
  28.727 -    SDL_HapticPeriodic *hap_periodic;
  28.728 -    SDL_HapticCondition *hap_condition;
  28.729 -    SDL_HapticRamp *hap_ramp;
  28.730 -    SDL_HapticCustom *hap_custom;
  28.731 -    DWORD *axes;
  28.732 -
  28.733 -    /* Set global stuff. */
  28.734 -    SDL_memset(dest, 0, sizeof(DIEFFECT));
  28.735 -    dest->dwSize = sizeof(DIEFFECT);    /* Set the structure size. */
  28.736 -    dest->dwSamplePeriod = 0;   /* Not used by us. */
  28.737 -    dest->dwGain = 10000;       /* Gain is set globally, not locally. */
  28.738 -    dest->dwFlags = DIEFF_OBJECTOFFSETS;        /* Seems obligatory. */
  28.739 -
  28.740 -    /* Envelope. */
  28.741 -    envelope = SDL_malloc(sizeof(DIENVELOPE));
  28.742 -    if (envelope == NULL) {
  28.743 -        SDL_OutOfMemory();
  28.744 -        return -1;
  28.745 -    }
  28.746 -    SDL_memset(envelope, 0, sizeof(DIENVELOPE));
  28.747 -    dest->lpEnvelope = envelope;
  28.748 -    envelope->dwSize = sizeof(DIENVELOPE);      /* Always should be this. */
  28.749 -
  28.750 -    /* Axes. */
  28.751 -    dest->cAxes = haptic->naxes;
  28.752 -    if (dest->cAxes > 0) {
  28.753 -        axes = SDL_malloc(sizeof(DWORD) * dest->cAxes);
  28.754 -        if (axes == NULL) {
  28.755 -            SDL_OutOfMemory();
  28.756 -            return -1;
  28.757 -        }
  28.758 -        axes[0] = haptic->hwdata->axes[0];      /* Always at least one axis. */
  28.759 -        if (dest->cAxes > 1) {
  28.760 -            axes[1] = haptic->hwdata->axes[1];
  28.761 -        }
  28.762 -        if (dest->cAxes > 2) {
  28.763 -            axes[2] = haptic->hwdata->axes[2];
  28.764 -        }
  28.765 -        dest->rgdwAxes = axes;
  28.766 -    }
  28.767 -
  28.768 -
  28.769 -    /* The big type handling switch, even bigger then linux's version. */
  28.770 -    switch (src->type) {
  28.771 -    case SDL_HAPTIC_CONSTANT:
  28.772 -        hap_constant = &src->constant;
  28.773 -        constant = SDL_malloc(sizeof(DICONSTANTFORCE));
  28.774 -        if (constant == NULL) {
  28.775 -            SDL_OutOfMemory();
  28.776 -            return -1;
  28.777 -        }
  28.778 -        SDL_memset(constant, 0, sizeof(DICONSTANTFORCE));
  28.779 -
  28.780 -        /* Specifics */
  28.781 -        constant->lMagnitude = CONVERT(hap_constant->level);
  28.782 -        dest->cbTypeSpecificParams = sizeof(DICONSTANTFORCE);
  28.783 -        dest->lpvTypeSpecificParams = constant;
  28.784 -
  28.785 -        /* Generics */
  28.786 -        dest->dwDuration = hap_constant->length * 1000; /* In microseconds. */
  28.787 -        dest->dwTriggerButton = DIGetTriggerButton(hap_constant->button);
  28.788 -        dest->dwTriggerRepeatInterval = hap_constant->interval;
  28.789 -        dest->dwStartDelay = hap_constant->delay * 1000;        /* In microseconds. */
  28.790 -
  28.791 -        /* Direction. */
  28.792 -        if (SDL_SYS_SetDirection(dest, &hap_constant->direction, dest->cAxes)
  28.793 -            < 0) {
  28.794 -            return -1;
  28.795 -        }
  28.796 -
  28.797 -        /* Envelope */
  28.798 -        if ((hap_constant->attack_length == 0)
  28.799 -            && (hap_constant->fade_length == 0)) {
  28.800 -            SDL_free(dest->lpEnvelope);
  28.801 -            dest->lpEnvelope = NULL;
  28.802 -        } else {
  28.803 -            envelope->dwAttackLevel = CONVERT(hap_constant->attack_level);
  28.804 -            envelope->dwAttackTime = hap_constant->attack_length * 1000;
  28.805 -            envelope->dwFadeLevel = CONVERT(hap_constant->fade_level);
  28.806 -            envelope->dwFadeTime = hap_constant->fade_length * 1000;
  28.807 -        }
  28.808 -
  28.809 -        break;
  28.810 -
  28.811 -    case SDL_HAPTIC_SINE:
  28.812 -    case SDL_HAPTIC_SQUARE:
  28.813 -    case SDL_HAPTIC_TRIANGLE:
  28.814 -    case SDL_HAPTIC_SAWTOOTHUP:
  28.815 -    case SDL_HAPTIC_SAWTOOTHDOWN:
  28.816 -        hap_periodic = &src->periodic;
  28.817 -        periodic = SDL_malloc(sizeof(DIPERIODIC));
  28.818 -        if (periodic == NULL) {
  28.819 -            SDL_OutOfMemory();
  28.820 -            return -1;
  28.821 -        }
  28.822 -        SDL_memset(periodic, 0, sizeof(DIPERIODIC));
  28.823 -
  28.824 -        /* Specifics */
  28.825 -        periodic->dwMagnitude = CONVERT(hap_periodic->magnitude);
  28.826 -        periodic->lOffset = CONVERT(hap_periodic->offset);
  28.827 -        periodic->dwPhase = hap_periodic->phase;
  28.828 -        periodic->dwPeriod = hap_periodic->period * 1000;
  28.829 -        dest->cbTypeSpecificParams = sizeof(DIPERIODIC);
  28.830 -        dest->lpvTypeSpecificParams = periodic;
  28.831 -
  28.832 -        /* Generics */
  28.833 -        dest->dwDuration = hap_periodic->length * 1000; /* In microseconds. */
  28.834 -        dest->dwTriggerButton = DIGetTriggerButton(hap_periodic->button);
  28.835 -        dest->dwTriggerRepeatInterval = hap_periodic->interval;
  28.836 -        dest->dwStartDelay = hap_periodic->delay * 1000;        /* In microseconds. */
  28.837 -
  28.838 -        /* Direction. */
  28.839 -        if (SDL_SYS_SetDirection(dest, &hap_periodic->direction, dest->cAxes)
  28.840 -            < 0) {
  28.841 -            return -1;
  28.842 -        }
  28.843 -
  28.844 -        /* Envelope */
  28.845 -        if ((hap_periodic->attack_length == 0)
  28.846 -            && (hap_periodic->fade_length == 0)) {
  28.847 -            SDL_free(dest->lpEnvelope);
  28.848 -            dest->lpEnvelope = NULL;
  28.849 -        } else {
  28.850 -            envelope->dwAttackLevel = CONVERT(hap_periodic->attack_level);
  28.851 -            envelope->dwAttackTime = hap_periodic->attack_length * 1000;
  28.852 -            envelope->dwFadeLevel = CONVERT(hap_periodic->fade_level);
  28.853 -            envelope->dwFadeTime = hap_periodic->fade_length * 1000;
  28.854 -        }
  28.855 -
  28.856 -        break;
  28.857 -
  28.858 -    case SDL_HAPTIC_SPRING:
  28.859 -    case SDL_HAPTIC_DAMPER:
  28.860 -    case SDL_HAPTIC_INERTIA:
  28.861 -    case SDL_HAPTIC_FRICTION:
  28.862 -        hap_condition = &src->condition;
  28.863 -        condition = SDL_malloc(sizeof(DICONDITION) * dest->cAxes);
  28.864 -        if (condition == NULL) {
  28.865 -            SDL_OutOfMemory();
  28.866 -            return -1;
  28.867 -        }
  28.868 -        SDL_memset(condition, 0, sizeof(DICONDITION));
  28.869 -
  28.870 -        /* Specifics */
  28.871 -        for (i = 0; i < (int) dest->cAxes; i++) {
  28.872 -            condition[i].lOffset = CONVERT(hap_condition->center[i]);
  28.873 -            condition[i].lPositiveCoefficient =
  28.874 -                CONVERT(hap_condition->right_coeff[i]);
  28.875 -            condition[i].lNegativeCoefficient =
  28.876 -                CONVERT(hap_condition->left_coeff[i]);
  28.877 -            condition[i].dwPositiveSaturation =
  28.878 -                CONVERT(hap_condition->right_sat[i]);
  28.879 -            condition[i].dwNegativeSaturation =
  28.880 -                CONVERT(hap_condition->left_sat[i]);
  28.881 -            condition[i].lDeadBand = CONVERT(hap_condition->deadband[i]);
  28.882 -        }
  28.883 -        dest->cbTypeSpecificParams = sizeof(DICONDITION) * dest->cAxes;
  28.884 -        dest->lpvTypeSpecificParams = condition;
  28.885 -
  28.886 -        /* Generics */
  28.887 -        dest->dwDuration = hap_condition->length * 1000;        /* In microseconds. */
  28.888 -        dest->dwTriggerButton = DIGetTriggerButton(hap_condition->button);
  28.889 -        dest->dwTriggerRepeatInterval = hap_condition->interval;
  28.890 -        dest->dwStartDelay = hap_condition->delay * 1000;       /* In microseconds. */
  28.891 -
  28.892 -        /* Direction. */
  28.893 -        if (SDL_SYS_SetDirection(dest, &hap_condition->direction, dest->cAxes)
  28.894 -            < 0) {
  28.895 -            return -1;
  28.896 -        }
  28.897 -
  28.898 -        /* Envelope - Not actually supported by most CONDITION implementations. */
  28.899 -        SDL_free(dest->lpEnvelope);
  28.900 -        dest->lpEnvelope = NULL;
  28.901 -
  28.902 -        break;
  28.903 -
  28.904 -    case SDL_HAPTIC_RAMP:
  28.905 -        hap_ramp = &src->ramp;
  28.906 -        ramp = SDL_malloc(sizeof(DIRAMPFORCE));
  28.907 -        if (ramp == NULL) {
  28.908 -            SDL_OutOfMemory();
  28.909 -            return -1;
  28.910 -        }
  28.911 -        SDL_memset(ramp, 0, sizeof(DIRAMPFORCE));
  28.912 -
  28.913 -        /* Specifics */
  28.914 -        ramp->lStart = CONVERT(hap_ramp->start);
  28.915 -        ramp->lEnd = CONVERT(hap_ramp->end);
  28.916 -        dest->cbTypeSpecificParams = sizeof(DIRAMPFORCE);
  28.917 -        dest->lpvTypeSpecificParams = ramp;
  28.918 -
  28.919 -        /* Generics */
  28.920 -        dest->dwDuration = hap_ramp->length * 1000;     /* In microseconds. */
  28.921 -        dest->dwTriggerButton = DIGetTriggerButton(hap_ramp->button);
  28.922 -        dest->dwTriggerRepeatInterval = hap_ramp->interval;
  28.923 -        dest->dwStartDelay = hap_ramp->delay * 1000;    /* In microseconds. */
  28.924 -
  28.925 -        /* Direction. */
  28.926 -        if (SDL_SYS_SetDirection(dest, &hap_ramp->direction, dest->cAxes) < 0) {
  28.927 -            return -1;
  28.928 -        }
  28.929 -
  28.930 -        /* Envelope */
  28.931 -        if ((hap_ramp->attack_length == 0) && (hap_ramp->fade_length == 0)) {
  28.932 -            SDL_free(dest->lpEnvelope);
  28.933 -            dest->lpEnvelope = NULL;
  28.934 -        } else {
  28.935 -            envelope->dwAttackLevel = CONVERT(hap_ramp->attack_level);
  28.936 -            envelope->dwAttackTime = hap_ramp->attack_length * 1000;
  28.937 -            envelope->dwFadeLevel = CONVERT(hap_ramp->fade_level);
  28.938 -            envelope->dwFadeTime = hap_ramp->fade_length * 1000;
  28.939 -        }
  28.940 -
  28.941 -        break;
  28.942 -
  28.943 -    case SDL_HAPTIC_CUSTOM:
  28.944 -        hap_custom = &src->custom;
  28.945 -        custom = SDL_malloc(sizeof(DICUSTOMFORCE));
  28.946 -        if (custom == NULL) {
  28.947 -            SDL_OutOfMemory();
  28.948 -            return -1;
  28.949 -        }
  28.950 -        SDL_memset(custom, 0, sizeof(DICUSTOMFORCE));
  28.951 -
  28.952 -        /* Specifics */
  28.953 -        custom->cChannels = hap_custom->channels;
  28.954 -        custom->dwSamplePeriod = hap_custom->period * 1000;
  28.955 -        custom->cSamples = hap_custom->samples;
  28.956 -        custom->rglForceData =
  28.957 -            SDL_malloc(sizeof(LONG) * custom->cSamples * custom->cChannels);
  28.958 -        for (i = 0; i < hap_custom->samples * hap_custom->channels; i++) {      /* Copy data. */
  28.959 -            custom->rglForceData[i] = CONVERT(hap_custom->data[i]);
  28.960 -        }
  28.961 -        dest->cbTypeSpecificParams = sizeof(DICUSTOMFORCE);
  28.962 -        dest->lpvTypeSpecificParams = custom;
  28.963 -
  28.964 -        /* Generics */
  28.965 -        dest->dwDuration = hap_custom->length * 1000;   /* In microseconds. */
  28.966 -        dest->dwTriggerButton = DIGetTriggerButton(hap_custom->button);
  28.967 -        dest->dwTriggerRepeatInterval = hap_custom->interval;
  28.968 -        dest->dwStartDelay = hap_custom->delay * 1000;  /* In microseconds. */
  28.969 -
  28.970 -        /* Direction. */
  28.971 -        if (SDL_SYS_SetDirection(dest, &hap_custom->direction, dest->cAxes) <
  28.972 -            0) {
  28.973 -            return -1;
  28.974 -        }
  28.975 -
  28.976 -        /* Envelope */
  28.977 -        if ((hap_custom->attack_length == 0)
  28.978 -            && (hap_custom->fade_length == 0)) {
  28.979 -            SDL_free(dest->lpEnvelope);
  28.980 -            dest->lpEnvelope = NULL;
  28.981 -        } else {
  28.982 -            envelope->dwAttackLevel = CONVERT(hap_custom->attack_level);
  28.983 -            envelope->dwAttackTime = hap_custom->attack_length * 1000;
  28.984 -            envelope->dwFadeLevel = CONVERT(hap_custom->fade_level);
  28.985 -            envelope->dwFadeTime = hap_custom->fade_length * 1000;
  28.986 -        }
  28.987 -
  28.988 -        break;
  28.989 -
  28.990 -
  28.991 -    default:
  28.992 -        SDL_SetError("Haptic: Unknown effect type.");
  28.993 -        return -1;
  28.994 -    }
  28.995 -
  28.996 -    return 0;
  28.997 -}
  28.998 -
  28.999 -
 28.1000 -/*
 28.1001 - * Frees an DIEFFECT allocated by SDL_SYS_ToDIEFFECT.
 28.1002 - */
 28.1003 -static void
 28.1004 -SDL_SYS_HapticFreeDIEFFECT(DIEFFECT * effect, int type)
 28.1005 -{
 28.1006 -    DICUSTOMFORCE *custom;
 28.1007 -
 28.1008 -    if (effect->lpEnvelope != NULL) {
 28.1009 -        SDL_free(effect->lpEnvelope);
 28.1010 -        effect->lpEnvelope = NULL;
 28.1011 -    }
 28.1012 -    if (effect->rgdwAxes != NULL) {
 28.1013 -        SDL_free(effect->rgdwAxes);
 28.1014 -        effect->rgdwAxes = NULL;
 28.1015 -    }
 28.1016 -    if (effect->lpvTypeSpecificParams != NULL) {
 28.1017 -        if (type == SDL_HAPTIC_CUSTOM) {        /* Must free the custom data. */
 28.1018 -            custom = (DICUSTOMFORCE *) effect->lpvTypeSpecificParams;
 28.1019 -            SDL_free(custom->rglForceData);
 28.1020 -            custom->rglForceData = NULL;
 28.1021 -        }
 28.1022 -        SDL_free(effect->lpvTypeSpecificParams);
 28.1023 -        effect->lpvTypeSpecificParams = NULL;
 28.1024 -    }
 28.1025 -    if (effect->rglDirection != NULL) {
 28.1026 -        SDL_free(effect->rglDirection);
 28.1027 -        effect->rglDirection = NULL;
 28.1028 -    }
 28.1029 -}
 28.1030 -
 28.1031 -
 28.1032 -/*
 28.1033 - * Gets the effect type from the generic SDL haptic effect wrapper.
 28.1034 - */
 28.1035 -static REFGUID
 28.1036 -SDL_SYS_HapticEffectType(SDL_HapticEffect * effect)
 28.1037 -{
 28.1038 -    switch (effect->type) {
 28.1039 -    case SDL_HAPTIC_CONSTANT:
 28.1040 -        return &GUID_ConstantForce;
 28.1041 -
 28.1042 -    case SDL_HAPTIC_RAMP:
 28.1043 -        return &GUID_RampForce;
 28.1044 -
 28.1045 -    case SDL_HAPTIC_SQUARE:
 28.1046 -        return &GUID_Square;
 28.1047 -
 28.1048 -    case SDL_HAPTIC_SINE:
 28.1049 -        return &GUID_Sine;
 28.1050 -
 28.1051 -    case SDL_HAPTIC_TRIANGLE:
 28.1052 -        return &GUID_Triangle;
 28.1053 -
 28.1054 -    case SDL_HAPTIC_SAWTOOTHUP:
 28.1055 -        return &GUID_SawtoothUp;
 28.1056 -
 28.1057 -    case SDL_HAPTIC_SAWTOOTHDOWN:
 28.1058 -        return &GUID_SawtoothDown;
 28.1059 -
 28.1060 -    case SDL_HAPTIC_SPRING:
 28.1061 -        return &GUID_Spring;
 28.1062 -
 28.1063 -    case SDL_HAPTIC_DAMPER:
 28.1064 -        return &GUID_Damper;
 28.1065 -
 28.1066 -    case SDL_HAPTIC_INERTIA:
 28.1067 -        return &GUID_Inertia;
 28.1068 -
 28.1069 -    case SDL_HAPTIC_FRICTION:
 28.1070 -        return &GUID_Friction;
 28.1071 -
 28.1072 -    case SDL_HAPTIC_CUSTOM:
 28.1073 -        return &GUID_CustomForce;
 28.1074 -
 28.1075 -    default:
 28.1076 -        SDL_SetError("Haptic: Unknown effect type.");
 28.1077 -        return NULL;
 28.1078 -    }
 28.1079 -}
 28.1080 -
 28.1081 -
 28.1082 -/*
 28.1083 - * Creates a new haptic effect.
 28.1084 - */
 28.1085 -int
 28.1086 -SDL_SYS_HapticNewEffect(SDL_Haptic * haptic, struct haptic_effect *effect,
 28.1087 -                        SDL_HapticEffect * base)
 28.1088 -{
 28.1089 -    HRESULT ret;
 28.1090 -
 28.1091 -    /* Get the type. */
 28.1092 -    REFGUID type = SDL_SYS_HapticEffectType(base);
 28.1093 -    if (type == NULL) {
 28.1094 -        goto err_hweffect;
 28.1095 -    }
 28.1096 -
 28.1097 -    /* Alloc the effect. */
 28.1098 -    effect->hweffect = (struct haptic_hweffect *)
 28.1099 -        SDL_malloc(sizeof(struct haptic_hweffect));
 28.1100 -    if (effect->hweffect == NULL) {
 28.1101 -        SDL_OutOfMemory();
 28.1102 -        goto err_hweffect;
 28.1103 -    }
 28.1104 -
 28.1105 -    /* Get the effect. */
 28.1106 -    if (SDL_SYS_ToDIEFFECT(haptic, &effect->hweffect->effect, base) < 0) {
 28.1107 -        goto err_effectdone;
 28.1108 -    }
 28.1109 -
 28.1110 -    /* Create the actual effect. */
 28.1111 -    ret = IDirectInputDevice2_CreateEffect(haptic->hwdata->device, type,
 28.1112 -                                           &effect->hweffect->effect,
 28.1113 -                                           &effect->hweffect->ref, NULL);
 28.1114 -    if (FAILED(ret)) {
 28.1115 -        DI_SetError("Unable to create effect", ret);
 28.1116 -        goto err_effectdone;
 28.1117 -    }
 28.1118 -
 28.1119 -    return 0;
 28.1120 -
 28.1121 -  err_effectdone:
 28.1122 -    SDL_SYS_HapticFreeDIEFFECT(&effect->hweffect->effect, base->type);
 28.1123 -  err_hweffect:
 28.1124 -    if (effect->hweffect != NULL) {
 28.1125 -        SDL_free(effect->hweffect);
 28.1126 -        effect->hweffect = NULL;
 28.1127 -    }
 28.1128 -    return -1;
 28.1129 -}
 28.1130 -
 28.1131 -
 28.1132 -/*
 28.1133 - * Updates an effect.
 28.1134 - */
 28.1135 -int
 28.1136 -SDL_SYS_HapticUpdateEffect(SDL_Haptic * haptic,
 28.1137 -                           struct haptic_effect *effect,
 28.1138 -                           SDL_HapticEffect * data)
 28.1139 -{
 28.1140 -    HRESULT ret;
 28.1141 -    DWORD flags;
 28.1142 -    DIEFFECT temp;
 28.1143 -
 28.1144 -    /* Get the effect. */
 28.1145 -    SDL_memset(&temp, 0, sizeof(DIEFFECT));
 28.1146 -    if (SDL_SYS_ToDIEFFECT(haptic, &temp, data) < 0) {
 28.1147 -        goto err_update;
 28.1148 -    }
 28.1149 -
 28.1150 -    /* Set the flags.  Might be worthwhile to diff temp with loaded effect and
 28.1151 -     *  only change those parameters. */
 28.1152 -    flags = DIEP_DIRECTION |
 28.1153 -        DIEP_DURATION |
 28.1154 -        DIEP_ENVELOPE |
 28.1155 -        DIEP_STARTDELAY |
 28.1156 -        DIEP_TRIGGERBUTTON |
 28.1157 -        DIEP_TRIGGERREPEATINTERVAL | DIEP_TYPESPECIFICPARAMS;
 28.1158 -
 28.1159 -    /* Create the actual effect. */
 28.1160 -    ret =
 28.1161 -        IDirectInputEffect_SetParameters(effect->hweffect->ref, &temp, flags);
 28.1162 -    if (FAILED(ret)) {
 28.1163 -        DI_SetError("Unable to update effect", ret);
 28.1164 -        goto err_update;
 28.1165 -    }
 28.1166 -
 28.1167 -    /* Copy it over. */
 28.1168 -    SDL_SYS_HapticFreeDIEFFECT(&effect->hweffect->effect, data->type);
 28.1169 -    SDL_memcpy(&effect->hweffect->effect, &temp, sizeof(DIEFFECT));
 28.1170 -
 28.1171 -    return 0;
 28.1172 -
 28.1173 -  err_update:
 28.1174 -    SDL_SYS_HapticFreeDIEFFECT(&temp, data->type);
 28.1175 -    return -1;
 28.1176 -}
 28.1177 -
 28.1178 -
 28.1179 -/*
 28.1180 - * Runs an effect.
 28.1181 - */
 28.1182 -int
 28.1183 -SDL_SYS_HapticRunEffect(SDL_Haptic * haptic, struct haptic_effect *effect,
 28.1184 -                        Uint32 iterations)
 28.1185 -{
 28.1186 -    HRESULT ret;
 28.1187 -    DWORD iter;
 28.1188 -
 28.1189 -    /* Check if it's infinite. */
 28.1190 -    if (iterations == SDL_HAPTIC_INFINITY) {
 28.1191 -        iter = INFINITE;
 28.1192 -    } else
 28.1193 -        iter = iterations;
 28.1194 -
 28.1195 -    /* Run the effect. */
 28.1196 -    ret = IDirectInputEffect_Start(effect->hweffect->ref, iter, 0);
 28.1197 -    if (FAILED(ret)) {
 28.1198 -        DI_SetError("Running the effect", ret);
 28.1199 -        return -1;
 28.1200 -    }
 28.1201 -
 28.1202 -    return 0;
 28.1203 -}
 28.1204 -
 28.1205 -
 28.1206 -/*
 28.1207 - * Stops an effect.
 28.1208 - */
 28.1209 -int
 28.1210 -SDL_SYS_HapticStopEffect(SDL_Haptic * haptic, struct haptic_effect *effect)
 28.1211 -{
 28.1212 -    HRESULT ret;
 28.1213 -
 28.1214 -    ret = IDirectInputEffect_Stop(effect->hweffect->ref);
 28.1215 -    if (FAILED(ret)) {
 28.1216 -        DI_SetError("Unable to stop effect", ret);
 28.1217 -        return -1;
 28.1218 -    }
 28.1219 -
 28.1220 -    return 0;
 28.1221 -}
 28.1222 -
 28.1223 -
 28.1224 -/*
 28.1225 - * Frees the effect.
 28.1226 - */
 28.1227 -void
 28.1228 -SDL_SYS_HapticDestroyEffect(SDL_Haptic * haptic, struct haptic_effect *effect)
 28.1229 -{
 28.1230 -    HRESULT ret;
 28.1231 -
 28.1232 -    ret = IDirectInputEffect_Unload(effect->hweffect->ref);
 28.1233 -    if (FAILED(ret)) {
 28.1234 -        DI_SetError("Removing effect from the device", ret);
 28.1235 -    }
 28.1236 -    SDL_SYS_HapticFreeDIEFFECT(&effect->hweffect->effect,
 28.1237 -                               effect->effect.type);
 28.1238 -    SDL_free(effect->hweffect);
 28.1239 -    effect->hweffect = NULL;
 28.1240 -}
 28.1241 -
 28.1242 -
 28.1243 -/*
 28.1244 - * Gets the status of a haptic effect.
 28.1245 - */
 28.1246 -int
 28.1247 -SDL_SYS_HapticGetEffectStatus(SDL_Haptic * haptic,
 28.1248 -                              struct haptic_effect *effect)
 28.1249 -{
 28.1250 -    HRESULT ret;
 28.1251 -    DWORD status;
 28.1252 -
 28.1253 -    ret = IDirectInputEffect_GetEffectStatus(effect->hweffect->ref, &status);
 28.1254 -    if (FAILED(ret)) {
 28.1255 -        DI_SetError("Getting effect status", ret);
 28.1256 -        return -1;
 28.1257 -    }
 28.1258 -
 28.1259 -    if (status == 0)
 28.1260 -        return SDL_FALSE;
 28.1261 -    return SDL_TRUE;
 28.1262 -}
 28.1263 -
 28.1264 -
 28.1265 -/*
 28.1266 - * Sets the gain.
 28.1267 - */
 28.1268 -int
 28.1269 -SDL_SYS_HapticSetGain(SDL_Haptic * haptic, int gain)
 28.1270 -{
 28.1271 -    HRESULT ret;
 28.1272 -    DIPROPDWORD dipdw;
 28.1273 -
 28.1274 -    /* Create the weird structure thingy. */
 28.1275 -    dipdw.diph.dwSize = sizeof(DIPROPDWORD);
 28.1276 -    dipdw.diph.dwHeaderSize = sizeof(DIPROPHEADER);
 28.1277 -    dipdw.diph.dwObj = 0;
 28.1278 -    dipdw.diph.dwHow = DIPH_DEVICE;
 28.1279 -    dipdw.dwData = gain * 100;  /* 0 to 10,000 */
 28.1280 -
 28.1281 -    /* Try to set the autocenter. */
 28.1282 -    ret = IDirectInputDevice2_SetProperty(haptic->hwdata->device,
 28.1283 -                                          DIPROP_FFGAIN, &dipdw.diph);
 28.1284 -    if (FAILED(ret)) {
 28.1285 -        DI_SetError("Setting gain", ret);
 28.1286 -        return -1;
 28.1287 -    }
 28.1288 -
 28.1289 -    return 0;
 28.1290 -}
 28.1291 -
 28.1292 -
 28.1293 -/*
 28.1294 - * Sets the autocentering.
 28.1295 - */
 28.1296 -int
 28.1297 -SDL_SYS_HapticSetAutocenter(SDL_Haptic * haptic, int autocenter)
 28.1298 -{
 28.1299 -    HRESULT ret;
 28.1300 -    DIPROPDWORD dipdw;
 28.1301 -
 28.1302 -    /* Create the weird structure thingy. */
 28.1303 -    dipdw.diph.dwSize = sizeof(DIPROPDWORD);
 28.1304 -    dipdw.diph.dwHeaderSize = sizeof(DIPROPHEADER);
 28.1305 -    dipdw.diph.dwObj = 0;
 28.1306 -    dipdw.diph.dwHow = DIPH_DEVICE;
 28.1307 -    dipdw.dwData = (autocenter == 0) ? DIPROPAUTOCENTER_OFF :
 28.1308 -        DIPROPAUTOCENTER_ON;
 28.1309 -
 28.1310 -    /* Try to set the autocenter. */
 28.1311 -    ret = IDirectInputDevice2_SetProperty(haptic->hwdata->device,
 28.1312 -                                          DIPROP_AUTOCENTER, &dipdw.diph);
 28.1313 -    if (FAILED(ret)) {
 28.1314 -        DI_SetError("Setting autocenter", ret);
 28.1315 -        return -1;
 28.1316 -    }
 28.1317 -
 28.1318 -    return 0;
 28.1319 -}
 28.1320 -
 28.1321 -
 28.1322 -/*
 28.1323 - * Pauses the device.
 28.1324 - */
 28.1325 -int
 28.1326 -SDL_SYS_HapticPause(SDL_Haptic * haptic)
 28.1327 -{
 28.1328 -    HRESULT ret;
 28.1329 -
 28.1330 -    /* Pause the device. */
 28.1331 -    ret = IDirectInputDevice2_SendForceFeedbackCommand(haptic->hwdata->device,
 28.1332 -                                                       DISFFC_PAUSE);
 28.1333 -    if (FAILED(ret)) {
 28.1334 -        DI_SetError("Pausing the device", ret);
 28.1335 -        return -1;
 28.1336 -    }
 28.1337 -
 28.1338 -    return 0;
 28.1339 -}
 28.1340 -
 28.1341 -
 28.1342 -/*
 28.1343 - * Pauses the device.
 28.1344 - */
 28.1345 -int
 28.1346 -SDL_SYS_HapticUnpause(SDL_Haptic * haptic)
 28.1347 -{
 28.1348 -    HRESULT ret;
 28.1349 -
 28.1350 -    /* Unpause the device. */
 28.1351 -    ret = IDirectInputDevice2_SendForceFeedbackCommand(haptic->hwdata->device,
 28.1352 -                                                       DISFFC_CONTINUE);
 28.1353 -    if (FAILED(ret)) {
 28.1354 -        DI_SetError("Pausing the device", ret);
 28.1355 -        return -1;
 28.1356 -    }
 28.1357 -
 28.1358 -    return 0;
 28.1359 -}
 28.1360 -
 28.1361 -
 28.1362 -/*
 28.1363 - * Stops all the playing effects on the device.
 28.1364 - */
 28.1365 -int
 28.1366 -SDL_SYS_HapticStopAll(SDL_Haptic * haptic)
 28.1367 -{
 28.1368 -    HRESULT ret;
 28.1369 -
 28.1370 -    /* Try to stop the effects. */
 28.1371 -    ret = IDirectInputDevice2_SendForceFeedbackCommand(haptic->hwdata->device,
 28.1372 -                                                       DISFFC_STOPALL);
 28.1373 -    if (FAILED(ret)) {
 28.1374 -        DI_SetError("Stopping the device", ret);
 28.1375 -        return -1;
 28.1376 -    }
 28.1377 -
 28.1378 -    return 0;
 28.1379 -}
 28.1380 -
 28.1381 -
 28.1382 -#endif /* SDL_HAPTIC_DINPUT */
    29.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    29.2 +++ b/src/haptic/windows/SDL_syshaptic.c	Thu Jan 20 18:04:05 2011 -0800
    29.3 @@ -0,0 +1,1379 @@
    29.4 +/*
    29.5 +    SDL - Simple DirectMedia Layer
    29.6 +    Copyright (C) 2008 Edgar Simo
    29.7 +
    29.8 +    This library is free software; you can redistribute it and/or
    29.9 +    modify it under the terms of the GNU Lesser General Public
   29.10 +    License as published by the Free Software Foundation; either
   29.11 +    version 2.1 of the License, or (at your option) any later version.
   29.12 +
   29.13 +    This library is distributed in the hope that it will be useful,
   29.14 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
   29.15 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   29.16 +    Lesser General Public License for more details.
   29.17 +
   29.18 +    You should have received a copy of the GNU Lesser General Public
   29.19 +    License along with this library; if not, write to the Free Software
   29.20 +    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   29.21 +
   29.22 +    Sam Lantinga
   29.23 +    slouken@libsdl.org
   29.24 +*/
   29.25 +#include "SDL_config.h"
   29.26 +
   29.27 +#ifdef SDL_HAPTIC_DINPUT
   29.28 +
   29.29 +#include "SDL_haptic.h"
   29.30 +#include "../SDL_syshaptic.h"
   29.31 +#include "SDL_joystick.h"
   29.32 +#include "../../joystick/SDL_sysjoystick.h"     /* For the real SDL_Joystick */
   29.33 +#include "../../joystick/windows/SDL_dxjoystick_c.h"      /* For joystick hwdata */
   29.34 +
   29.35 +
   29.36 +#define MAX_HAPTICS  32
   29.37 +
   29.38 +
   29.39 +/*
   29.40 + * List of available haptic devices.
   29.41 + */
   29.42 +static struct
   29.43 +{
   29.44 +    DIDEVICEINSTANCE instance;
   29.45 +    SDL_Haptic *haptic;
   29.46 +    DIDEVCAPS capabilities;
   29.47 +} SDL_hapticlist[MAX_HAPTICS];
   29.48 +
   29.49 +
   29.50 +/*
   29.51 + * Haptic system hardware data.
   29.52 + */
   29.53 +struct haptic_hwdata
   29.54 +{
   29.55 +    LPDIRECTINPUTDEVICE2 device;
   29.56 +    DWORD axes[3];              /* Axes to use. */
   29.57 +    int is_joystick;            /* Device is loaded as joystick. */
   29.58 +};
   29.59 +
   29.60 +
   29.61 +/*
   29.62 + * Haptic system effect data.
   29.63 + */
   29.64 +struct haptic_hweffect
   29.65 +{
   29.66 +    DIEFFECT effect;
   29.67 +    LPDIRECTINPUTEFFECT ref;
   29.68 +};
   29.69 +
   29.70 +
   29.71 +/*
   29.72 + * Internal stuff.
   29.73 + */
   29.74 +static LPDIRECTINPUT dinput = NULL;
   29.75 +
   29.76 +
   29.77 +/*
   29.78 + * External stuff.
   29.79 + */
   29.80 +extern HWND SDL_HelperWindow;
   29.81 +
   29.82 +
   29.83 +/*
   29.84 + * Prototypes.
   29.85 + */
   29.86 +static void DI_SetError(const char *str, HRESULT err);
   29.87 +static int DI_GUIDIsSame(const GUID * a, const GUID * b);
   29.88 +static int SDL_SYS_HapticOpenFromInstance(SDL_Haptic * haptic,
   29.89 +                                          DIDEVICEINSTANCE instance);
   29.90 +static int SDL_SYS_HapticOpenFromDevice2(SDL_Haptic * haptic,
   29.91 +                                         LPDIRECTINPUTDEVICE2 device2);
   29.92 +static DWORD DIGetTriggerButton(Uint16 button);
   29.93 +static int SDL_SYS_SetDirection(DIEFFECT * effect, SDL_HapticDirection * dir,
   29.94 +                                int naxes);
   29.95 +static int SDL_SYS_ToDIEFFECT(SDL_Haptic * haptic, DIEFFECT * dest,
   29.96 +                              SDL_HapticEffect * src);
   29.97 +static void SDL_SYS_HapticFreeDIEFFECT(DIEFFECT * effect, int type);
   29.98 +static REFGUID SDL_SYS_HapticEffectType(SDL_HapticEffect * effect);
   29.99 +/* Callbacks. */
  29.100 +static BOOL CALLBACK EnumHapticsCallback(const DIDEVICEINSTANCE *
  29.101 +                                         pdidInstance, VOID * pContext);
  29.102 +static BOOL CALLBACK DI_EffectCallback(LPCDIEFFECTINFO pei, LPVOID pv);
  29.103 +
  29.104 +
  29.105 +/* 
  29.106 + * Like SDL_SetError but for DX error codes.
  29.107 + */
  29.108 +static void
  29.109 +DI_SetError(const char *str, HRESULT err)
  29.110 +{
  29.111 +    /*
  29.112 +       SDL_SetError("Haptic: %s - %s: %s", str,
  29.113 +       DXGetErrorString8A(err), DXGetErrorDescription8A(err));
  29.114 +     */
  29.115 +    SDL_SetError("Haptic error %s", str);
  29.116 +}
  29.117 +
  29.118 +
  29.119 +/*
  29.120 + * Checks to see if two GUID are the same.
  29.121 + */
  29.122 +static int
  29.123 +DI_GUIDIsSame(const GUID * a, const GUID * b)
  29.124 +{
  29.125 +    if (((a)->Data1 == (b)->Data1) &&
  29.126 +        ((a)->Data2 == (b)->Data2) &&
  29.127 +        ((a)->Data3 == (b)->Data3) &&
  29.128 +        (SDL_strcmp((a)->Data4, (b)->Data4) == 0))
  29.129 +        return 1;
  29.130 +    return 0;
  29.131 +}
  29.132 +
  29.133 +
  29.134 +/*
  29.135 + * Initializes the haptic subsystem.
  29.136 + */
  29.137 +int
  29.138 +SDL_SYS_HapticInit(void)
  29.139 +{
  29.140 +    HRESULT ret;
  29.141 +    HINSTANCE instance;
  29.142 +
  29.143 +    if (dinput != NULL) {       /* Already open. */
  29.144 +        SDL_SetError("Haptic: SubSystem already open.");
  29.145 +        return -1;
  29.146 +    }
  29.147 +
  29.148 +    /* Clear all the memory. */
  29.149 +    SDL_memset(SDL_hapticlist, 0, sizeof(SDL_hapticlist));
  29.150 +
  29.151 +    SDL_numhaptics = 0;
  29.152 +
  29.153 +    ret = CoInitialize(NULL);
  29.154 +    if (FAILED(ret)) {
  29.155 +        DI_SetError("Coinitialize", ret);
  29.156 +        return -1;
  29.157 +    }
  29.158 +
  29.159 +    ret = CoCreateInstance(&CLSID_DirectInput, NULL, CLSCTX_INPROC_SERVER,
  29.160 +                           &IID_IDirectInput, (LPVOID) & dinput);
  29.161 +    if (FAILED(ret)) {
  29.162 +        DI_SetError("CoCreateInstance", ret);
  29.163 +        return -1;
  29.164 +    }
  29.165 +
  29.166 +    /* Because we used CoCreateInstance, we need to Initialize it, first. */
  29.167 +    instance = GetModuleHandle(NULL);
  29.168 +    if (instance == NULL) {
  29.169 +        SDL_SetError("GetModuleHandle() failed with error code %d.",
  29.170 +                     GetLastError());
  29.171 +        return -1;
  29.172 +    }
  29.173 +    ret = IDirectInput_Initialize(dinput, instance, DIRECTINPUT_VERSION);
  29.174 +    if (FAILED(ret)) {
  29.175 +        DI_SetError("Initializing DirectInput device", ret);
  29.176 +        return -1;
  29.177 +    }
  29.178 +
  29.179 +    /* Look for haptic devices. */
  29.180 +    ret = IDirectInput_EnumDevices(dinput,
  29.181 +                                   0,
  29.182 +                                   EnumHapticsCallback,
  29.183 +                                   NULL,
  29.184 +                                   DIEDFL_FORCEFEEDBACK |
  29.185 +                                   DIEDFL_ATTACHEDONLY);
  29.186 +    if (FAILED(ret)) {
  29.187 +        DI_SetError("Enumerating DirectInput devices", ret);
  29.188 +        return -1;
  29.189 +    }
  29.190 +
  29.191 +    return SDL_numhaptics;
  29.192 +}
  29.193 +
  29.194 +/*
  29.195 + * Callback to find the haptic devices.
  29.196 + */
  29.197 +static BOOL CALLBACK
  29.198 +EnumHapticsCallback(const DIDEVICEINSTANCE * pdidInstance, VOID * pContext)
  29.199 +{
  29.200 +    HRESULT ret;
  29.201 +    LPDIRECTINPUTDEVICE device;
  29.202 +
  29.203 +    /* Copy the instance over, useful for creating devices. */
  29.204 +    SDL_memcpy(&SDL_hapticlist[SDL_numhaptics].instance, pdidInstance,
  29.205 +               sizeof(DIDEVICEINSTANCE));
  29.206 +
  29.207 +    /* Open the device */
  29.208 +    ret = IDirectInput_CreateDevice(dinput, &pdidInstance->guidInstance,
  29.209 +                                    &device, NULL);
  29.210 +    if (FAILED(ret)) {
  29.211 +        /* DI_SetError("Creating DirectInput device",ret); */
  29.212 +        return DIENUM_CONTINUE;
  29.213 +    }
  29.214 +
  29.215 +    /* Get capabilities. */
  29.216 +    SDL_hapticlist[SDL_numhaptics].capabilities.dwSize = sizeof(DIDEVCAPS);
  29.217 +    ret = IDirectInputDevice_GetCapabilities(device,
  29.218 +                                             &SDL_hapticlist[SDL_numhaptics].
  29.219 +                                             capabilities);
  29.220 +    if (FAILED(ret)) {
  29.221 +        /* DI_SetError("Getting device capabilities",ret); */
  29.222 +        IDirectInputDevice_Release(device);
  29.223 +        return DIENUM_CONTINUE;
  29.224 +    }
  29.225 +
  29.226 +    /* Close up device and count it. */
  29.227 +    IDirectInputDevice_Release(device);
  29.228 +    SDL_numhaptics++;
  29.229 +
  29.230 +    /* Watch out for hard limit. */
  29.231 +    if (SDL_numhaptics >= MAX_HAPTICS)
  29.232 +        return DIENUM_STOP;
  29.233 +
  29.234 +    return DIENUM_CONTINUE;
  29.235 +}
  29.236 +
  29.237 +
  29.238 +/*
  29.239 + * Return the name of a haptic device, does not need to be opened.
  29.240 + */
  29.241 +const char *
  29.242 +SDL_SYS_HapticName(int index)
  29.243 +{
  29.244 +    return SDL_hapticlist[index].instance.tszProductName;
  29.245 +}
  29.246 +
  29.247 +
  29.248 +/*
  29.249 + * Callback to get all supported effects.
  29.250 + */
  29.251 +#define EFFECT_TEST(e,s)               \
  29.252 +if (DI_GUIDIsSame(&pei->guid, &(e)))   \
  29.253 +   haptic->supported |= (s)
  29.254 +static BOOL CALLBACK
  29.255 +DI_EffectCallback(LPCDIEFFECTINFO pei, LPVOID pv)
  29.256 +{
  29.257 +    /* Prepare the haptic device. */
  29.258 +    SDL_Haptic *haptic = (SDL_Haptic *) pv;
  29.259 +
  29.260 +    /* Get supported. */
  29.261 +    EFFECT_TEST(GUID_Spring, SDL_HAPTIC_SPRING);
  29.262 +    EFFECT_TEST(GUID_Damper, SDL_HAPTIC_DAMPER);
  29.263 +    EFFECT_TEST(GUID_Inertia, SDL_HAPTIC_INERTIA);
  29.264 +    EFFECT_TEST(GUID_Friction, SDL_HAPTIC_FRICTION);
  29.265 +    EFFECT_TEST(GUID_ConstantForce, SDL_HAPTIC_CONSTANT);
  29.266 +    EFFECT_TEST(GUID_CustomForce, SDL_HAPTIC_CUSTOM);
  29.267 +    EFFECT_TEST(GUID_Sine, SDL_HAPTIC_SINE);
  29.268 +    EFFECT_TEST(GUID_Square, SDL_HAPTIC_SQUARE);
  29.269 +    EFFECT_TEST(GUID_Triangle, SDL_HAPTIC_TRIANGLE);
  29.270 +    EFFECT_TEST(GUID_SawtoothUp, SDL_HAPTIC_SAWTOOTHUP);
  29.271 +    EFFECT_TEST(GUID_SawtoothDown, SDL_HAPTIC_SAWTOOTHDOWN);
  29.272 +    EFFECT_TEST(GUID_RampForce, SDL_HAPTIC_RAMP);
  29.273 +
  29.274 +    /* Check for more. */
  29.275 +    return DIENUM_CONTINUE;
  29.276 +}
  29.277 +
  29.278 +
  29.279 +/*
  29.280 + * Callback to get supported axes.
  29.281 + */
  29.282 +static BOOL CALLBACK
  29.283 +DI_DeviceObjectCallback(LPCDIDEVICEOBJECTINSTANCE dev, LPVOID pvRef)
  29.284 +{
  29.285 +    SDL_Haptic *haptic = (SDL_Haptic *) pvRef;
  29.286 +
  29.287 +    if ((dev->dwType & DIDFT_AXIS) && (dev->dwFlags & DIDOI_FFACTUATOR)) {
  29.288 +
  29.289 +        haptic->hwdata->axes[haptic->naxes] = dev->dwOfs;
  29.290 +        haptic->naxes++;
  29.291 +
  29.292 +        /* Currently using the artificial limit of 3 axes. */
  29.293 +        if (haptic->naxes >= 3) {
  29.294 +            return DIENUM_STOP;
  29.295 +        }
  29.296 +    }
  29.297 +
  29.298 +    return DIENUM_CONTINUE;
  29.299 +}
  29.300 +
  29.301 +
  29.302 +/*
  29.303 + * Opens the haptic device from the file descriptor.
  29.304 + *
  29.305 + *    Steps:
  29.306 + *       - Open temporary DirectInputDevice interface.
  29.307 + *       - Create DirectInputDevice2 interface.
  29.308 + *       - Release DirectInputDevice interface.
  29.309 + *       - Call SDL_SYS_HapticOpenFromDevice2
  29.310 + */
  29.311 +static int
  29.312 +SDL_SYS_HapticOpenFromInstance(SDL_Haptic * haptic, DIDEVICEINSTANCE instance)
  29.313 +{
  29.314 +    HRESULT ret;
  29.315 +    int ret2;
  29.316 +    LPDIRECTINPUTDEVICE device;
  29.317 +
  29.318 +    /* Allocate the hwdata */
  29.319 +    haptic->hwdata = (struct haptic_hwdata *)
  29.320 +        SDL_malloc(sizeof(*haptic->hwdata));
  29.321 +    if (haptic->hwdata == NULL) {
  29.322 +        SDL_OutOfMemory();
  29.323 +        goto creat_err;
  29.324 +    }
  29.325 +    SDL_memset(haptic->hwdata, 0, sizeof(*haptic->hwdata));
  29.326 +
  29.327 +    /* Open the device */
  29.328 +    ret = IDirectInput_CreateDevice(dinput, &instance.guidInstance,
  29.329 +                                    &device, NULL);
  29.330 +    if (FAILED(ret)) {
  29.331 +        DI_SetError("Creating DirectInput device", ret);
  29.332 +        goto creat_err;
  29.333 +    }
  29.334 +
  29.335 +    /* Now get the IDirectInputDevice2 interface, instead. */
  29.336 +    ret = IDirectInputDevice_QueryInterface(device,
  29.337 +                                            &IID_IDirectInputDevice2,
  29.338 +                                            (LPVOID *) & haptic->hwdata->
  29.339 +                                            device);
  29.340 +    /* Done with the temporary one now. */
  29.341 +    IDirectInputDevice_Release(device);
  29.342 +    if (FAILED(ret)) {
  29.343 +        DI_SetError("Querying DirectInput interface", ret);
  29.344 +        goto creat_err;
  29.345 +    }
  29.346 +
  29.347 +    ret2 = SDL_SYS_HapticOpenFromDevice2(haptic, haptic->hwdata->device);
  29.348 +    if (ret2 < 0) {
  29.349 +        goto query_err;
  29.350 +    }
  29.351 +
  29.352 +    return 0;
  29.353 +
  29.354 +  query_err:
  29.355 +    IDirectInputDevice2_Release(haptic->hwdata->device);
  29.356 +  creat_err:
  29.357 +    if (haptic->hwdata != NULL) {
  29.358 +        SDL_free(haptic->hwdata);
  29.359 +        haptic->hwdata = NULL;
  29.360 +    }
  29.361 +    return -1;
  29.362 +}
  29.363 +
  29.364 +
  29.365 +/*
  29.366 + * Opens the haptic device from the file descriptor.
  29.367 + *
  29.368 + *    Steps:
  29.369 + *       - Set cooperative level.
  29.370 + *       - Set data format.
  29.371 + *       - Acquire exclusiveness.
  29.372 + *       - Reset actuators.
  29.373 + *       - Get supported featuers.
  29.374 + */
  29.375 +static int
  29.376 +SDL_SYS_HapticOpenFromDevice2(SDL_Haptic * haptic,
  29.377 +                              LPDIRECTINPUTDEVICE2 device2)
  29.378 +{
  29.379 +    HRESULT ret;
  29.380 +    DIPROPDWORD dipdw;
  29.381 +
  29.382 +    /* We'll use the device2 from now on. */
  29.383 +    haptic->hwdata->device = device2;
  29.384 +
  29.385 +    /* Grab it exclusively to use force feedback stuff. */
  29.386 +    ret = IDirectInputDevice2_SetCooperativeLevel(haptic->hwdata->device,
  29.387 +                                                  SDL_HelperWindow,
  29.388 +                                                  DISCL_EXCLUSIVE |
  29.389 +                                                  DISCL_BACKGROUND);
  29.390 +    if (FAILED(ret)) {
  29.391 +        DI_SetError("Setting cooperative level to exclusive", ret);
  29.392 +        goto acquire_err;
  29.393 +    }
  29.394 +
  29.395 +    /* Set data format. */
  29.396 +    ret = IDirectInputDevice2_SetDataFormat(haptic->hwdata->device,
  29.397 +                                            &c_dfDIJoystick2);
  29.398 +    if (FAILED(ret)) {
  29.399 +        DI_SetError("Setting data format", ret);
  29.400 +        goto acquire_err;
  29.401 +    }
  29.402 +
  29.403 +    /* Get number of axes. */
  29.404 +    ret = IDirectInputDevice2_EnumObjects(haptic->hwdata->device,
  29.405 +                                          DI_DeviceObjectCallback,
  29.406 +                                          haptic, DIDFT_AXIS);
  29.407 +    if (FAILED(ret)) {
  29.408 +        DI_SetError("Getting device axes", ret);
  29.409 +        goto acquire_err;
  29.410 +    }
  29.411 +
  29.412 +    /* Acquire the device. */
  29.413 +    ret = IDirectInputDevice2_Acquire(haptic->hwdata->device);
  29.414 +    if (FAILED(ret)) {
  29.415 +        DI_SetError("Acquiring DirectInput device", ret);
  29.416 +        goto acquire_err;
  29.417 +    }
  29.418 +
  29.419 +    /* Reset all actuators - just in case. */
  29.420 +    ret = IDirectInputDevice2_SendForceFeedbackCommand(haptic->hwdata->device,
  29.421 +                                                       DISFFC_RESET);
  29.422 +    if (FAILED(ret)) {
  29.423 +        DI_SetError("Resetting device", ret);
  29.424 +        goto acquire_err;
  29.425 +    }
  29.426 +
  29.427 +    /* Enabling actuators. */
  29.428 +    ret = IDirectInputDevice2_SendForceFeedbackCommand(haptic->hwdata->device,
  29.429 +                                                       DISFFC_SETACTUATORSON);
  29.430 +    if (FAILED(ret)) {
  29.431 +        DI_SetError("Enabling actuators", ret);
  29.432 +        goto acquire_err;
  29.433 +    }
  29.434 +
  29.435 +    /* Get supported effects. */
  29.436 +    ret = IDirectInputDevice2_EnumEffects(haptic->hwdata->device,
  29.437 +                                          DI_EffectCallback, haptic,
  29.438 +                                          DIEFT_ALL);
  29.439 +    if (FAILED(ret)) {
  29.440 +        DI_SetError("Enumerating supported effects", ret);
  29.441 +        goto acquire_err;
  29.442 +    }
  29.443 +    if (haptic->supported == 0) {       /* Error since device supports nothing. */
  29.444 +        SDL_SetError("Haptic: Internal error on finding supported effects.");
  29.445 +        goto acquire_err;
  29.446 +    }
  29.447 +
  29.448 +    /* Check autogain and autocenter. */
  29.449 +    dipdw.diph.dwSize = sizeof(DIPROPDWORD);
  29.450 +    dipdw.diph.dwHeaderSize = sizeof(DIPROPHEADER);
  29.451 +    dipdw.diph.dwObj = 0;
  29.452 +    dipdw.diph.dwHow = DIPH_DEVICE;
  29.453 +    dipdw.dwData = 10000;
  29.454 +    ret = IDirectInputDevice2_SetProperty(haptic->hwdata->device,
  29.455 +                                          DIPROP_FFGAIN, &dipdw.diph);
  29.456 +    if (!FAILED(ret)) {         /* Gain is supported. */
  29.457 +        haptic->supported |= SDL_HAPTIC_GAIN;
  29.458 +    }
  29.459 +    dipdw.diph.dwObj = 0;
  29.460 +    dipdw.diph.dwHow = DIPH_DEVICE;
  29.461 +    dipdw.dwData = DIPROPAUTOCENTER_OFF;
  29.462 +    ret = IDirectInputDevice2_SetProperty(haptic->hwdata->device,
  29.463 +                                          DIPROP_AUTOCENTER, &dipdw.diph);
  29.464 +    if (!FAILED(ret)) {         /* Autocenter is supported. */
  29.465 +        haptic->supported |= SDL_HAPTIC_AUTOCENTER;
  29.466 +    }
  29.467 +
  29.468 +    /* Status is always supported. */
  29.469 +    haptic->supported |= SDL_HAPTIC_STATUS | SDL_HAPTIC_PAUSE;
  29.470 +
  29.471 +    /* Check maximum effects. */
  29.472 +    haptic->neffects = 128;     /* This is not actually supported as thus under windows,
  29.473 +                                   there is no way to tell the number of EFFECTS that a
  29.474 +                                   device can hold, so we'll just use a "random" number
  29.475 +                                   instead and put warnings in SDL_haptic.h */
  29.476 +    haptic->nplaying = 128;     /* Even more impossible to get this then neffects. */
  29.477 +
  29.478 +    /* Prepare effects memory. */
  29.479 +    haptic->effects = (struct haptic_effect *)
  29.480 +        SDL_malloc(sizeof(struct haptic_effect) * haptic->neffects);
  29.481 +    if (haptic->effects == NULL) {
  29.482 +        SDL_OutOfMemory();
  29.483 +        goto acquire_err;
  29.484 +    }
  29.485 +    /* Clear the memory */
  29.486 +    SDL_memset(haptic->effects, 0,
  29.487 +               sizeof(struct haptic_effect) * haptic->neffects);
  29.488 +
  29.489 +    return 0;
  29.490 +
  29.491 +    /* Error handling */
  29.492 +  acquire_err:
  29.493 +    IDirectInputDevice2_Unacquire(haptic->hwdata->device);
  29.494 +    return -1;
  29.495 +
  29.496 +}
  29.497 +
  29.498 +
  29.499 +/*
  29.500 + * Opens a haptic device for usage.
  29.501 + */
  29.502 +int
  29.503 +SDL_SYS_HapticOpen(SDL_Haptic * haptic)
  29.504 +{
  29.505 +    return SDL_SYS_HapticOpenFromInstance(haptic,
  29.506 +                                          SDL_hapticlist[haptic->index].
  29.507 +                                          instance);
  29.508 +}
  29.509 +
  29.510 +
  29.511 +/*
  29.512 + * Opens a haptic device from first mouse it finds for usage.
  29.513 + */
  29.514 +int
  29.515 +SDL_SYS_HapticMouse(void)
  29.516 +{
  29.517 +    int i;
  29.518 +
  29.519 +    /* Grab the first mouse haptic device we find. */
  29.520 +    for (i = 0; i < SDL_numhaptics; i++) {
  29.521 +        if (SDL_hapticlist[i].capabilities.dwDevType == DIDEVTYPE_MOUSE) {
  29.522 +            return i;
  29.523 +        }
  29.524 +    }
  29.525 +
  29.526 +    return -1;
  29.527 +}
  29.528 +
  29.529 +
  29.530 +/*
  29.531 + * Checks to see if a joystick has haptic features.
  29.532 + */
  29.533 +int
  29.534 +SDL_SYS_JoystickIsHaptic(SDL_Joystick * joystick)
  29.535 +{
  29.536 +    if (joystick->hwdata->Capabilities.dwFlags & DIDC_FORCEFEEDBACK) {
  29.537 +        return SDL_TRUE;
  29.538 +    }
  29.539 +
  29.540 +    return SDL_FALSE;
  29.541 +}
  29.542 +
  29.543 +
  29.544 +/*
  29.545 + * Checks to see if the haptic device and joystick and in reality the same.
  29.546 + */
  29.547 +int
  29.548 +SDL_SYS_JoystickSameHaptic(SDL_Haptic * haptic, SDL_Joystick * joystick)
  29.549 +{
  29.550 +    HRESULT ret;
  29.551 +    DIDEVICEINSTANCE hap_instance, joy_instance;
  29.552 +
  29.553 +    /* Get the device instances. */
  29.554 +    ret = IDirectInputDevice2_GetDeviceInfo(haptic->hwdata->device,
  29.555 +                                            &hap_instance);
  29.556 +    if (FAILED(ret)) {
  29.557 +        return 0;
  29.558 +    }
  29.559 +    ret = IDirectInputDevice2_GetDeviceInfo(joystick->hwdata->InputDevice,
  29.560 +                                            &joy_instance);
  29.561 +    if (FAILED(ret)) {
  29.562 +        return 0;
  29.563 +    }
  29.564 +
  29.565 +    if (DI_GUIDIsSame(&hap_instance.guidInstance, &joy_instance.guidInstance))
  29.566 +        return 1;
  29.567 +
  29.568 +    return 0;
  29.569 +}
  29.570 +
  29.571 +
  29.572 +/*
  29.573 + * Opens a SDL_Haptic from a SDL_Joystick.
  29.574 + */
  29.575 +int
  29.576 +SDL_SYS_HapticOpenFromJoystick(SDL_Haptic * haptic, SDL_Joystick * joystick)
  29.577 +{
  29.578 +    int ret;
  29.579 +
  29.580 +    /* Allocate the hwdata */
  29.581 +    haptic->hwdata = (struct haptic_hwdata *)
  29.582 +        SDL_malloc(sizeof(*haptic->hwdata));
  29.583 +    if (haptic->hwdata == NULL) {
  29.584 +        SDL_OutOfMemory();
  29.585 +        return -1;
  29.586 +    }
  29.587 +    SDL_memset(haptic->hwdata, 0, sizeof(*haptic->hwdata));
  29.588 +
  29.589 +    /* Now open the device. */
  29.590 +    ret =
  29.591 +        SDL_SYS_HapticOpenFromDevice2(haptic, joystick->hwdata->InputDevice);
  29.592 +    if (ret < 0) {
  29.593 +        return -1;
  29.594 +    }
  29.595 +
  29.596 +    /* It's using the joystick device. */
  29.597 +    haptic->hwdata->is_joystick = 1;
  29.598 +
  29.599 +    return 0;
  29.600 +}
  29.601 +
  29.602 +
  29.603 +/*
  29.604 + * Closes the haptic device.
  29.605 + */
  29.606 +void
  29.607 +SDL_SYS_HapticClose(SDL_Haptic * haptic)
  29.608 +{
  29.609 +    if (haptic->hwdata) {
  29.610 +
  29.611 +        /* Free effects. */
  29.612 +        SDL_free(haptic->effects);
  29.613 +        haptic->effects = NULL;
  29.614 +        haptic->neffects = 0;
  29.615 +
  29.616 +        /* Clean up */
  29.617 +        IDirectInputDevice2_Unacquire(haptic->hwdata->device);
  29.618 +        /* Only release if isn't grabbed by a joystick. */
  29.619 +        if (haptic->hwdata->is_joystick == 0) {
  29.620 +            IDirectInputDevice2_Release(haptic->hwdata->device);
  29.621 +        }
  29.622 +
  29.623 +        /* Free */
  29.624 +        SDL_free(haptic->hwdata);
  29.625 +        haptic->hwdata = NULL;
  29.626 +    }
  29.627 +}
  29.628 +
  29.629 +
  29.630 +/* 
  29.631 + * Clean up after system specific haptic stuff
  29.632 + */
  29.633 +void
  29.634 +SDL_SYS_HapticQuit(void)
  29.635 +{
  29.636 +    IDirectInput_Release(dinput);
  29.637 +    dinput = NULL;
  29.638 +}
  29.639 +
  29.640 +
  29.641 +/*
  29.642 + * Converts an SDL trigger button to an DIEFFECT trigger button.
  29.643 + */
  29.644 +static DWORD
  29.645 +DIGetTriggerButton(Uint16 button)
  29.646 +{
  29.647 +    DWORD dwTriggerButton;
  29.648 +
  29.649 +    dwTriggerButton = DIEB_NOTRIGGER;
  29.650 +
  29.651 +    if (button != 0) {
  29.652 +        dwTriggerButton = DIJOFS_BUTTON(button - 1);
  29.653 +    }
  29.654 +
  29.655 +    return dwTriggerButton;
  29.656 +}
  29.657 +
  29.658 +
  29.659 +/*
  29.660 + * Sets the direction.
  29.661 + */
  29.662 +static int
  29.663 +SDL_SYS_SetDirection(DIEFFECT * effect, SDL_HapticDirection * dir, int naxes)
  29.664 +{
  29.665 +    LONG *rglDir;
  29.666 +
  29.667 +    /* Handle no axes a part. */
  29.668 +    if (naxes == 0) {
  29.669 +        effect->dwFlags |= DIEFF_SPHERICAL;     /* Set as default. */
  29.670 +        effect->rglDirection = NULL;
  29.671 +        return 0;
  29.672 +    }
  29.673 +
  29.674 +    /* Has axes. */
  29.675 +    rglDir = SDL_malloc(sizeof(LONG) * naxes);
  29.676 +    if (rglDir == NULL) {
  29.677 +        SDL_OutOfMemory();
  29.678 +        return -1;
  29.679 +    }
  29.680 +    SDL_memset(rglDir, 0, sizeof(LONG) * naxes);
  29.681 +    effect->rglDirection = rglDir;
  29.682 +
  29.683 +    switch (dir->type) {
  29.684 +    case SDL_HAPTIC_POLAR:
  29.685 +        effect->dwFlags |= DIEFF_POLAR;
  29.686 +        rglDir[0] = dir->dir[0];
  29.687 +        return 0;
  29.688 +    case SDL_HAPTIC_CARTESIAN:
  29.689 +        effect->dwFlags |= DIEFF_CARTESIAN;
  29.690 +        rglDir[0] = dir->dir[0];
  29.691 +        if (naxes > 1)
  29.692 +            rglDir[1] = dir->dir[1];
  29.693 +        if (naxes > 2)
  29.694 +            rglDir[2] = dir->dir[2];
  29.695 +        return 0;
  29.696 +    case SDL_HAPTIC_SPHERICAL:
  29.697 +        effect->dwFlags |= DIEFF_SPHERICAL;
  29.698 +        rglDir[0] = dir->dir[0];
  29.699 +        if (naxes > 1)
  29.700 +            rglDir[1] = dir->dir[1];
  29.701 +        if (naxes > 2)
  29.702 +            rglDir[2] = dir->dir[2];
  29.703 +        return 0;
  29.704 +
  29.705 +    default:
  29.706 +        SDL_SetError("Haptic: Unknown direction type.");
  29.707 +        return -1;
  29.708 +    }
  29.709 +}
  29.710 +
  29.711 +#define CONVERT(x)   (((x) > 0x7FFF) ? 10000 : ((x)*10000) / 0x7FFF)
  29.712 +/*
  29.713 + * Creates the DIEFFECT from a SDL_HapticEffect.
  29.714 + */
  29.715 +static int
  29.716 +SDL_SYS_ToDIEFFECT(SDL_Haptic * haptic, DIEFFECT * dest,
  29.717 +                   SDL_HapticEffect * src)
  29.718 +{
  29.719 +    int i;
  29.720 +    DICONSTANTFORCE *constant;
  29.721 +    DIPERIODIC *periodic;
  29.722 +    DICONDITION *condition;     /* Actually an array of conditions - one per axis. */
  29.723 +    DIRAMPFORCE *ramp;
  29.724 +    DICUSTOMFORCE *custom;
  29.725 +    DIENVELOPE *envelope;
  29.726 +    SDL_HapticConstant *hap_constant;
  29.727 +    SDL_HapticPeriodic *hap_periodic;
  29.728 +    SDL_HapticCondition *hap_condition;
  29.729 +    SDL_HapticRamp *hap_ramp;
  29.730 +    SDL_HapticCustom *hap_custom;
  29.731 +    DWORD *axes;
  29.732 +
  29.733 +    /* Set global stuff. */
  29.734 +    SDL_memset(dest, 0, sizeof(DIEFFECT));
  29.735 +    dest->dwSize = sizeof(DIEFFECT);    /* Set the structure size. */
  29.736 +    dest->dwSamplePeriod = 0;   /* Not used by us. */
  29.737 +    dest->dwGain = 10000;       /* Gain is set globally, not locally. */
  29.738 +    dest->dwFlags = DIEFF_OBJECTOFFSETS;        /* Seems obligatory. */
  29.739 +
  29.740 +    /* Envelope. */
  29.741 +    envelope = SDL_malloc(sizeof(DIENVELOPE));
  29.742 +    if (envelope == NULL) {
  29.743 +        SDL_OutOfMemory();
  29.744 +        return -1;
  29.745 +    }
  29.746 +    SDL_memset(envelope, 0, sizeof(DIENVELOPE));
  29.747 +    dest->lpEnvelope = envelope;
  29.748 +    envelope->dwSize = sizeof(DIENVELOPE);      /* Always should be this. */
  29.749 +
  29.750 +    /* Axes. */
  29.751 +    dest->cAxes = haptic->naxes;
  29.752 +    if (dest->cAxes > 0) {
  29.753 +        axes = SDL_malloc(sizeof(DWORD) * dest->cAxes);
  29.754 +        if (axes == NULL) {
  29.755 +            SDL_OutOfMemory();
  29.756 +            return -1;
  29.757 +        }
  29.758 +        axes[0] = haptic->hwdata->axes[0];      /* Always at least one axis. */
  29.759 +        if (dest->cAxes > 1) {
  29.760 +            axes[1] = haptic->hwdata->axes[1];
  29.761 +        }
  29.762 +        if (dest->cAxes > 2) {
  29.763 +            axes[2] = haptic->hwdata->axes[2];
  29.764 +        }
  29.765 +        dest->rgdwAxes = axes;
  29.766 +    }
  29.767 +
  29.768 +
  29.769 +    /* The big type handling switch, even bigger then linux's version. */
  29.770 +    switch (src->type) {
  29.771 +    case SDL_HAPTIC_CONSTANT:
  29.772 +        hap_constant = &src->constant;
  29.773 +        constant = SDL_malloc(sizeof(DICONSTANTFORCE));
  29.774 +        if (constant == NULL) {
  29.775 +            SDL_OutOfMemory();
  29.776 +            return -1;
  29.777 +        }
  29.778 +        SDL_memset(constant, 0, sizeof(DICONSTANTFORCE));
  29.779 +
  29.780 +        /* Specifics */
  29.781 +        constant->lMagnitude = CONVERT(hap_constant->level);
  29.782 +        dest->cbTypeSpecificParams = sizeof(DICONSTANTFORCE);
  29.783 +        dest->lpvTypeSpecificParams = constant;
  29.784 +
  29.785 +        /* Generics */
  29.786 +        dest->dwDuration = hap_constant->length * 1000; /* In microseconds. */
  29.787 +        dest->dwTriggerButton = DIGetTriggerButton(hap_constant->button);
  29.788 +        dest->dwTriggerRepeatInterval = hap_constant->interval;
  29.789 +        dest->dwStartDelay = hap_constant->delay * 1000;        /* In microseconds. */
  29.790 +
  29.791 +        /* Direction. */
  29.792 +        if (SDL_SYS_SetDirection(dest, &hap_constant->direction, dest->cAxes)
  29.793 +            < 0) {
  29.794 +            return -1;
  29.795 +        }
  29.796 +
  29.797 +        /* Envelope */
  29.798 +        if ((hap_constant->attack_length == 0)
  29.799 +            && (hap_constant->fade_length == 0)) {
  29.800 +            SDL_free(dest->lpEnvelope);
  29.801 +            dest->lpEnvelope = NULL;
  29.802 +        } else {
  29.803 +            envelope->dwAttackLevel = CONVERT(hap_constant->attack_level);
  29.804 +            envelope->dwAttackTime = hap_constant->attack_length * 1000;
  29.805 +            envelope->dwFadeLevel = CONVERT(hap_constant->fade_level);
  29.806 +            envelope->dwFadeTime = hap_constant->fade_length * 1000;
  29.807 +        }
  29.808 +
  29.809 +        break;
  29.810 +
  29.811 +    case SDL_HAPTIC_SINE:
  29.812 +    case SDL_HAPTIC_SQUARE:
  29.813 +    case SDL_HAPTIC_TRIANGLE:
  29.814 +    case SDL_HAPTIC_SAWTOOTHUP:
  29.815 +    case SDL_HAPTIC_SAWTOOTHDOWN:
  29.816 +        hap_periodic = &src->periodic;
  29.817 +        periodic = SDL_malloc(sizeof(DIPERIODIC));
  29.818 +        if (periodic == NULL) {
  29.819 +            SDL_OutOfMemory();
  29.820 +            return -1;
  29.821 +        }
  29.822 +        SDL_memset(periodic, 0, sizeof(DIPERIODIC));
  29.823 +
  29.824 +        /* Specifics */
  29.825 +        periodic->dwMagnitude = CONVERT(hap_periodic->magnitude);
  29.826 +        periodic->lOffset = CONVERT(hap_periodic->offset);
  29.827 +        periodic->dwPhase = hap_periodic->phase;
  29.828 +        periodic->dwPeriod = hap_periodic->period * 1000;
  29.829 +        dest->cbTypeSpecificParams = sizeof(DIPERIODIC);
  29.830 +        dest->lpvTypeSpecificParams = periodic;
  29.831 +
  29.832 +        /* Generics */
  29.833 +        dest->dwDuration = hap_periodic->length * 1000; /* In microseconds. */
  29.834 +        dest->dwTriggerButton = DIGetTriggerButton(hap_periodic->button);
  29.835 +        dest->dwTriggerRepeatInterval = hap_periodic->interval;
  29.836 +        dest->dwStartDelay = hap_periodic->delay * 1000;        /* In microseconds. */
  29.837 +
  29.838 +        /* Direction. */
  29.839 +        if (SDL_SYS_SetDirection(dest, &hap_periodic->direction, dest->cAxes)
  29.840 +            < 0) {
  29.841 +            return -1;
  29.842 +        }
  29.843 +
  29.844 +        /* Envelope */
  29.845 +        if ((hap_periodic->attack_length == 0)
  29.846 +            && (hap_periodic->fade_length == 0)) {
  29.847 +            SDL_free(dest->lpEnvelope);
  29.848 +            dest->lpEnvelope = NULL;
  29.849 +        } else {
  29.850 +            envelope->dwAttackLevel = CONVERT(hap_periodic->attack_level);
  29.851 +            envelope->dwAttackTime = hap_periodic->attack_length * 1000;
  29.852 +            envelope->dwFadeLevel = CONVERT(hap_periodic->fade_level);
  29.853 +            envelope->dwFadeTime = hap_periodic->fade_length * 1000;
  29.854 +        }
  29.855 +
  29.856 +        break;
  29.857 +
  29.858 +    case SDL_HAPTIC_SPRING:
  29.859 +    case SDL_HAPTIC_DAMPER:
  29.860 +    case SDL_HAPTIC_INERTIA:
  29.861 +    case SDL_HAPTIC_FRICTION:
  29.862 +        hap_condition = &src->condition;
  29.863 +        condition = SDL_malloc(sizeof(DICONDITION) * dest->cAxes);
  29.864 +        if (condition == NULL) {
  29.865 +            SDL_OutOfMemory();
  29.866 +            return -1;
  29.867 +        }
  29.868 +        SDL_memset(condition, 0, sizeof(DICONDITION));
  29.869 +
  29.870 +        /* Specifics */
  29.871 +        for (i = 0; i < (int) dest->cAxes; i++) {
  29.872 +            condition[i].lOffset = CONVERT(hap_condition->center[i]);
  29.873 +            condition[i].lPositiveCoefficient =
  29.874 +                CONVERT(hap_condition->right_coeff[i]);
  29.875 +            condition[i].lNegativeCoefficient =
  29.876 +                CONVERT(hap_condition->left_coeff[i]);
  29.877 +            condition[i].dwPositiveSaturation =
  29.878 +                CONVERT(hap_condition->right_sat[i]);
  29.879 +            condition[i].dwNegativeSaturation =
  29.880 +                CONVERT(hap_condition->left_sat[i]);
  29.881 +            condition[i].lDeadBand = CONVERT(hap_condition->deadband[i]);
  29.882 +        }
  29.883 +        dest->cbTypeSpecificParams = sizeof(DICONDITION) * dest->cAxes;
  29.884 +        dest->lpvTypeSpecificParams = condition;
  29.885 +
  29.886 +        /* Generics */
  29.887 +        dest->dwDuration = hap_condition->length * 1000;        /* In microseconds. */
  29.888 +        dest->dwTriggerButton = DIGetTriggerButton(hap_condition->button);
  29.889 +        dest->dwTriggerRepeatInterval = hap_condition->interval;
  29.890 +        dest->dwStartDelay = hap_condition->delay * 1000;       /* In microseconds. */
  29.891 +
  29.892 +        /* Direction. */
  29.893 +        if (SDL_SYS_SetDirection(dest, &hap_condition->direction, dest->cAxes)
  29.894 +            < 0) {
  29.895 +            return -1;
  29.896 +        }
  29.897 +
  29.898 +        /* Envelope - Not actually supported by most CONDITION implementations. */
  29.899 +        SDL_free(dest->lpEnvelope);
  29.900 +        dest->lpEnvelope = NULL;
  29.901 +
  29.902 +        break;
  29.903 +
  29.904 +    case SDL_HAPTIC_RAMP:
  29.905 +        hap_ramp = &src->ramp;
  29.906 +        ramp = SDL_malloc(sizeof(DIRAMPFORCE));
  29.907 +        if (ramp == NULL) {
  29.908 +            SDL_OutOfMemory();
  29.909 +            return -1;
  29.910 +        }
  29.911 +        SDL_memset(ramp, 0, sizeof(DIRAMPFORCE));
  29.912 +
  29.913 +        /* Specifics */
  29.914 +        ramp->lStart = CONVERT(hap_ramp->start);
  29.915 +        ramp->lEnd = CONVERT(hap_ramp->end);
  29.916 +        dest->cbTypeSpecificParams = sizeof(DIRAMPFORCE);
  29.917 +        dest->lpvTypeSpecificParams = ramp;
  29.918 +
  29.919 +        /* Generics */
  29.920 +        dest->dwDuration = hap_ramp->length * 1000;     /* In microseconds. */
  29.921 +        dest->dwTriggerButton = DIGetTriggerButton(hap_ramp->button);
  29.922 +        dest->dwTriggerRepeatInterval = hap_ramp->interval;
  29.923 +        dest->dwStartDelay = hap_ramp->delay * 1000;    /* In microseconds. */
  29.924 +
  29.925 +        /* Direction. */
  29.926 +        if (SDL_SYS_SetDirection(dest, &hap_ramp->direction, dest->cAxes) < 0) {
  29.927 +            return -1;
  29.928 +        }
  29.929 +
  29.930 +        /* Envelope */
  29.931 +        if ((hap_ramp->attack_length == 0) && (hap_ramp->fade_length == 0)) {
  29.932 +            SDL_free(dest->lpEnvelope);
  29.933 +            dest->lpEnvelope = NULL;
  29.934 +        } else {
  29.935 +            envelope->dwAttackLevel = CONVERT(hap_ramp->attack_level);
  29.936 +            envelope->dwAttackTime = hap_ramp->attack_length * 1000;
  29.937 +            envelope->dwFadeLevel = CONVERT(hap_ramp->fade_level);
  29.938 +            envelope->dwFadeTime = hap_ramp->fade_length * 1000;
  29.939 +        }
  29.940 +
  29.941 +        break;
  29.942 +
  29.943 +    case SDL_HAPTIC_CUSTOM:
  29.944 +        hap_custom = &src->custom;
  29.945 +        custom = SDL_malloc(sizeof(DICUSTOMFORCE));
  29.946 +        if (custom == NULL) {
  29.947 +            SDL_OutOfMemory();
  29.948 +            return -1;
  29.949 +        }
  29.950 +        SDL_memset(custom, 0, sizeof(DICUSTOMFORCE));
  29.951 +
  29.952 +        /* Specifics */
  29.953 +        custom->cChannels = hap_custom->channels;
  29.954 +        custom->dwSamplePeriod = hap_custom->period * 1000;
  29.955 +        custom->cSamples = hap_custom->samples;
  29.956 +        custom->rglForceData =
  29.957 +            SDL_malloc(sizeof(LONG) * custom->cSamples * custom->cChannels);
  29.958 +        for (i = 0; i < hap_custom->samples * hap_custom->channels; i++) {      /* Copy data. */
  29.959 +            custom->rglForceData[i] = CONVERT(hap_custom->data[i]);
  29.960 +        }
  29.961 +        dest->cbTypeSpecificParams = sizeof(DICUSTOMFORCE);
  29.962 +        dest->lpvTypeSpecificParams = custom;
  29.963 +
  29.964 +        /* Generics */
  29.965 +        dest->dwDuration = hap_custom->length * 1000;   /* In microseconds. */
  29.966 +        dest->dwTriggerButton = DIGetTriggerButton(hap_custom->button);
  29.967 +        dest->dwTriggerRepeatInterval = hap_custom->interval;
  29.968 +        dest->dwStartDelay = hap_custom->delay * 1000;  /* In microseconds. */
  29.969 +
  29.970 +        /* Direction. */
  29.971 +        if (SDL_SYS_SetDirection(dest, &hap_custom->direction, dest->cAxes) <
  29.972 +            0) {
  29.973 +            return -1;
  29.974 +        }
  29.975 +
  29.976 +        /* Envelope */
  29.977 +        if ((hap_custom->attack_length == 0)
  29.978 +            && (hap_custom->fade_length == 0)) {
  29.979 +            SDL_free(dest->lpEnvelope);
  29.980 +            dest->lpEnvelope = NULL;
  29.981 +        } else {
  29.982 +            envelope->dwAttackLevel = CONVERT(hap_custom->attack_level);
  29.983 +            envelope->dwAttackTime = hap_custom->attack_length * 1000;
  29.984 +            envelope->dwFadeLevel = CONVERT(hap_custom->fade_level);
  29.985 +            envelope->dwFadeTime = hap_custom->fade_length * 1000;
  29.986 +        }
  29.987 +
  29.988 +        break;
  29.989 +
  29.990 +
  29.991 +    default:
  29.992 +        SDL_SetError("Haptic: Unknown effect type.");
  29.993 +        return -1;
  29.994 +    }
  29.995 +
  29.996 +    return 0;
  29.997 +}
  29.998 +
  29.999 +
 29.1000 +/*
 29.1001 + * Frees an DIEFFECT allocated by SDL_SYS_ToDIEFFECT.
 29.1002 + */
 29.1003 +static void
 29.1004 +SDL_SYS_HapticFreeDIEFFECT(DIEFFECT * effect, int type)
 29.1005 +{
 29.1006 +    DICUSTOMFORCE *custom;
 29.1007 +
 29.1008 +    if (effect->lpEnvelope != NULL) {
 29.1009 +        SDL_free(effect->lpEnvelope);
 29.1010 +        effect->lpEnvelope = NULL;
 29.1011 +    }
 29.1012 +    if (effect->rgdwAxes != NULL) {
 29.1013 +        SDL_free(effect->rgdwAxes);
 29.1014 +        effect->rgdwAxes = NULL;
 29.1015 +    }
 29.1016 +    if (effect->lpvTypeSpecificParams != NULL) {
 29.1017 +        if (type == SDL_HAPTIC_CUSTOM) {        /* Must free the custom data. */
 29.1018 +            custom = (DICUSTOMFORCE *) effect->lpvTypeSpecificParams;
 29.1019 +            SDL_free(custom->rglForceData);
 29.1020 +            custom->rglForceData = NULL;
 29.1021 +        }
 29.1022 +        SDL_free(effect->lpvTypeSpecificParams);
 29.1023 +        effect->lpvTypeSpecificParams = NULL;
 29.1024 +    }
 29.1025 +    if (effect->rglDirection != NULL) {
 29.1026 +        SDL_free(effect->rglDirection);
 29.1027 +        effect->rglDirection = NULL;
 29.1028 +    }
 29.1029 +}
 29.1030 +
 29.1031 +
 29.1032 +/*
 29.1033 + * Gets the effect type from the generic SDL haptic effect wrapper.
 29.1034 + */
 29.1035 +static REFGUID
 29.1036 +SDL_SYS_HapticEffectType(SDL_HapticEffect * effect)
 29.1037 +{
 29.1038 +    switch (effect->type) {
 29.1039 +    case SDL_HAPTIC_CONSTANT:
 29.1040 +        return &GUID_ConstantForce;
 29.1041 +
 29.1042 +    case SDL_HAPTIC_RAMP:
 29.1043 +        return &GUID_RampForce;
 29.1044 +
 29.1045 +    case SDL_HAPTIC_SQUARE:
 29.1046 +        return &GUID_Square;
 29.1047 +
 29.1048 +    case SDL_HAPTIC_SINE:
 29.1049 +        return &GUID_Sine;
 29.1050 +
 29.1051 +    case SDL_HAPTIC_TRIANGLE:
 29.1052 +        return &GUID_Triangle;
 29.1053 +
 29.1054 +    case SDL_HAPTIC_SAWTOOTHUP:
 29.1055 +        return &GUID_SawtoothUp;
 29.1056 +
 29.1057 +    case SDL_HAPTIC_SAWTOOTHDOWN:
 29.1058 +        return &GUID_SawtoothDown;
 29.1059 +
 29.1060 +    case SDL_HAPTIC_SPRING:
 29.1061 +        return &GUID_Spring;
 29.1062 +
 29.1063 +    case SDL_HAPTIC_DAMPER:
 29.1064 +        return &GUID_Damper;
 29.1065 +
 29.1066 +    case SDL_HAPTIC_INERTIA:
 29.1067 +        return &GUID_Inertia;
 29.1068 +
 29.1069 +    case SDL_HAPTIC_FRICTION:
 29.1070 +        return &GUID_Friction;
 29.1071 +
 29.1072 +    case SDL_HAPTIC_CUSTOM:
 29.1073 +        return &GUID_CustomForce;
 29.1074 +
 29.1075 +    default:
 29.1076 +        SDL_SetError("Haptic: Unknown effect type.");
 29.1077 +        return NULL;
 29.1078 +    }
 29.1079 +}
 29.1080 +
 29.1081 +
 29.1082 +/*
 29.1083 + * Creates a new haptic effect.
 29.1084 + */
 29.1085 +int
 29.1086 +SDL_SYS_HapticNewEffect(SDL_Haptic * haptic, struct haptic_effect *effect,
 29.1087 +                        SDL_HapticEffect * base)
 29.1088 +{
 29.1089 +    HRESULT ret;
 29.1090 +
 29.1091 +    /* Get the type. */
 29.1092 +    REFGUID type = SDL_SYS_HapticEffectType(base);
 29.1093 +    if (type == NULL) {
 29.1094 +        goto err_hweffect;
 29.1095 +    }
 29.1096 +
 29.1097 +    /* Alloc the effect. */
 29.1098 +    effect->hweffect = (struct haptic_hweffect *)
 29.1099 +        SDL_malloc(sizeof(struct haptic_hweffect));
 29.1100 +    if (effect->hweffect == NULL) {
 29.1101 +        SDL_OutOfMemory();
 29.1102 +        goto err_hweffect;
 29.1103 +    }
 29.1104 +
 29.1105 +    /* Get the effect. */
 29.1106 +    if (SDL_SYS_ToDIEFFECT(haptic, &effect->hweffect->effect, base) < 0) {
 29.1107 +        goto err_effectdone;
 29.1108 +    }
 29.1109 +
 29.1110 +    /* Create the actual effect. */
 29.1111 +    ret = IDirectInputDevice2_CreateEffect(haptic->hwdata->device, type,
 29.1112 +                                           &effect->hweffect->effect,
 29.1113 +                                           &effect->hweffect->ref, NULL);
 29.1114 +    if (FAILED(ret)) {
 29.1115 +        DI_SetError("Unable to create effect", ret);
 29.1116 +        goto err_effectdone;
 29.1117 +    }
 29.1118 +
 29.1119 +    return 0;
 29.1120 +
 29.1121 +  err_effectdone:
 29.1122 +    SDL_SYS_HapticFreeDIEFFECT(&effect->hweffect->effect, base->type);
 29.1123 +  err_hweffect:
 29.1124 +    if (effect->hweffect != NULL) {
 29.1125 +        SDL_free(effect->hweffect);
 29.1126 +        effect->hweffect = NULL;
 29.1127 +    }
 29.1128 +    return -1;
 29.1129 +}
 29.1130 +
 29.1131 +
 29.1132 +/*
 29.1133 + * Updates an effect.
 29.1134 + */
 29.1135 +int
 29.1136 +SDL_SYS_HapticUpdateEffect(SDL_Haptic * haptic,
 29.1137 +                           struct haptic_effect *effect,
 29.1138 +                           SDL_HapticEffect * data)
 29.1139 +{
 29.1140 +    HRESULT ret;
 29.1141 +    DWORD flags;
 29.1142 +    DIEFFECT temp;
 29.1143 +
 29.1144 +    /* Get the effect. */
 29.1145 +    SDL_memset(&temp, 0, sizeof(DIEFFECT));
 29.1146 +    if (SDL_SYS_ToDIEFFECT(haptic, &temp, data) < 0) {
 29.1147 +        goto err_update;
 29.1148 +    }
 29.1149 +
 29.1150 +    /* Set the flags.  Might be worthwhile to diff temp with loaded effect and
 29.1151 +     *  only change those parameters. */
 29.1152 +    flags = DIEP_DIRECTION |
 29.1153 +        DIEP_DURATION |
 29.1154 +        DIEP_ENVELOPE |
 29.1155 +        DIEP_STARTDELAY |
 29.1156 +        DIEP_TRIGGERBUTTON |
 29.1157 +        DIEP_TRIGGERREPEATINTERVAL | DIEP_TYPESPECIFICPARAMS;
 29.1158 +
 29.1159 +    /* Create the actual effect. */
 29.1160 +    ret =
 29.1161 +        IDirectInputEffect_SetParameters(effect->hweffect->ref, &temp, flags);
 29.1162 +    if (FAILED(ret)) {
 29.1163 +        DI_SetError("Unable to update effect", ret);
 29.1164 +        goto err_update;
 29.1165 +    }
 29.1166 +
 29.1167 +    /* Copy it over. */
 29.1168 +    SDL_SYS_HapticFreeDIEFFECT(&effect->hweffect->effect, data->type);
 29.1169 +    SDL_memcpy(&effect->hweffect->effect, &temp, sizeof(DIEFFECT));
 29.1170 +
 29.1171 +    return 0;
 29.1172 +
 29.1173 +  err_update:
 29.1174 +    SDL_SYS_HapticFreeDIEFFECT(&temp, data->type);
 29.1175 +    return -1;
 29.1176 +}
 29.1177 +
 29.1178 +
 29.1179 +/*
 29.1180 + * Runs an effect.
 29.1181 + */
 29.1182 +int
 29.1183 +SDL_SYS_HapticRunEffect(SDL_Haptic * haptic, struct haptic_effect *effect,
 29.1184 +                        Uint32 iterations)
 29.1185 +{
 29.1186 +    HRESULT ret;
 29.1187 +    DWORD iter;
 29.1188 +
 29.1189 +    /* Check if it's infinite. */
 29.1190 +    if (iterations == SDL_HAPTIC_INFINITY) {
 29.1191 +        iter = INFINITE;
 29.1192 +    } else
 29.1193 +        iter = iterations;
 29.1194 +
 29.1195 +    /* Run the effect. */
 29.1196 +    ret = IDirectInputEffect_Start(effect->hweffect->ref, iter, 0);
 29.1197 +    if (FAILED(ret)) {
 29.1198 +        DI_SetError("Running the effect", ret);
 29.1199 +        return -1;
 29.1200 +    }
 29.1201 +
 29.1202 +    return 0;
 29.1203 +}
 29.1204 +
 29.1205 +
 29.1206 +/*
 29.1207 + * Stops an effect.
 29.1208 + */
 29.1209 +int
 29.1210 +SDL_SYS_HapticStopEffect(SDL_Haptic * haptic, struct haptic_effect *effect)
 29.1211 +{
 29.1212 +    HRESULT ret;
 29.1213 +
 29.1214 +    ret = IDirectInputEffect_Stop(effect->hweffect->ref);
 29.1215 +    if (FAILED(ret)) {
 29.1216 +        DI_SetError("Unable to stop effect", ret);
 29.1217 +        return -1;
 29.1218 +    }
 29.1219 +
 29.1220 +    return 0;
 29.1221 +}
 29.1222 +
 29.1223 +
 29.1224 +/*
 29.1225 + * Frees the effect.
 29.1226 + */
 29.1227 +void
 29.1228 +SDL_SYS_HapticDestroyEffect(SDL_Haptic * haptic, struct haptic_effect *effect)
 29.1229 +{
 29.1230 +    HRESULT ret;
 29.1231 +
 29.1232 +    ret = IDirectInputEffect_Unload(effect->hweffect->ref);
 29.1233 +    if (FAILED(ret)) {
 29.1234 +        DI_SetError("Removing effect from the device", ret);
 29.1235 +    }
 29.1236 +    SDL_SYS_HapticFreeDIEFFECT(&effect->hweffect->effect,
 29.1237 +                               effect->effect.type);
 29.1238 +    SDL_free(effect->hweffect);
 29.1239 +    effect->hweffect = NULL;
 29.1240 +}
 29.1241 +
 29.1242 +
 29.1243 +/*
 29.1244 + * Gets the status of a haptic effect.
 29.1245 + */
 29.1246 +int
 29.1247 +SDL_SYS_HapticGetEffectStatus(SDL_Haptic * haptic,
 29.1248 +                              struct haptic_effect *effect)
 29.1249 +{
 29.1250 +    HRESULT ret;
 29.1251 +    DWORD status;
 29.1252 +
 29.1253 +    ret = IDirectInputEffect_GetEffectStatus(effect->hweffect->ref, &status);
 29.1254 +    if (FAILED(ret)) {
 29.1255 +        DI_SetError("Getting effect status", ret);
 29.1256 +        return -1;
 29.1257 +    }
 29.1258 +
 29.1259 +    if (status == 0)
 29.1260 +        return SDL_FALSE;
 29.1261 +    return SDL_TRUE;
 29.1262 +}
 29.1263 +
 29.1264 +
 29.1265 +/*
 29.1266 + * Sets the gain.
 29.1267 + */
 29.1268 +int
 29.1269 +SDL_SYS_HapticSetGain(SDL_Haptic * haptic, int gain)
 29.1270 +{
 29.1271 +    HRESULT ret;
 29.1272 +    DIPROPDWORD dipdw;
 29.1273 +
 29.1274 +    /* Create the weird structure thingy. */
 29.1275 +    dipdw.diph.dwSize = sizeof(DIPROPDWORD);
 29.1276 +    dipdw.diph.dwHeaderSize = sizeof(DIPROPHEADER);
 29.1277 +    dipdw.diph.dwObj = 0;
 29.1278 +    dipdw.diph.dwHow = DIPH_DEVICE;
 29.1279 +    dipdw.dwData = gain * 100;  /* 0 to 10,000 */
 29.1280 +
 29.1281 +    /* Try to set the autocenter. */
 29.1282 +    ret = IDirectInputDevice2_SetProperty(haptic->hwdata->device,
 29.1283 +                                          DIPROP_FFGAIN, &dipdw.diph);
 29.1284 +    if (FAILED(ret)) {
 29.1285 +        DI_SetError("Setting gain", ret);
 29.1286 +        return -1;
 29.1287 +    }
 29.1288 +
 29.1289 +    return 0;
 29.1290 +}
 29.1291 +
 29.1292 +
 29.1293 +/*
 29.1294 + * Sets the autocentering.
 29.1295 + */
 29.1296 +int
 29.1297 +SDL_SYS_HapticSetAutocenter(SDL_Haptic * haptic, int autocenter)
 29.1298 +{
 29.1299 +    HRESULT ret;
 29.1300 +    DIPROPDWORD dipdw;
 29.1301 +
 29.1302 +    /* Create the weird structure thingy. */
 29.1303 +    dipdw.diph.dwSize = sizeof(DIPROPDWORD);
 29.1304 +    dipdw.diph.dwHeaderSize = sizeof(DIPROPHEADER);
 29.1305 +    dipdw.diph.dwObj = 0;
 29.1306 +    dipdw.diph.dwHow = DIPH_DEVICE;
 29.1307 +    dipdw.dwData = (autocenter == 0) ? DIPROPAUTOCENTER_OFF :
 29.1308 +        DIPROPAUTOCENTER_ON;
 29.1309 +
 29.1310 +    /* Try to set the autocenter. */
 29.1311 +    ret = IDirectInputDevice2_SetProperty(haptic->hwdata->device,
 29.1312 +                                          DIPROP_AUTOCENTER, &dipdw.diph);
 29.1313 +    if (FAILED(ret)) {
 29.1314 +        DI_SetError("Setting autocenter", ret);
 29.1315 +        return -1;
 29.1316 +    }
 29.1317 +
 29.1318 +    return 0;
 29.1319 +}
 29.1320 +
 29.1321 +
 29.1322 +/*
 29.1323 + * Pauses the device.
 29.1324 + */
 29.1325 +int
 29.1326 +SDL_SYS_HapticPause(SDL_Haptic * haptic)
 29.1327 +{
 29.1328 +    HRESULT ret;
 29.1329 +
 29.1330 +    /* Pause the device. */
 29.1331 +    ret = IDirectInputDevice2_SendForceFeedbackCommand(haptic->hwdata->device,
 29.1332 +                                                       DISFFC_PAUSE);
 29.1333 +    if (FAILED(ret)) {
 29.1334 +        DI_SetError("Pausing the device", ret);
 29.1335 +        return -1;
 29.1336 +    }
 29.1337 +
 29.1338 +    return 0;
 29.1339 +}
 29.1340 +
 29.1341 +
 29.1342 +/*
 29.1343 + * Pauses the device.
 29.1344 + */
 29.1345 +int
 29.1346 +SDL_SYS_HapticUnpause(SDL_Haptic * haptic)
 29.1347 +{
 29.1348 +    HRESULT ret;
 29.1349 +
 29.1350 +    /* Unpause the device. */
 29.1351 +    ret = IDirectInputDevice2_SendForceFeedbackCommand(haptic->hwdata->device,
 29.1352 +                                                       DISFFC_CONTINUE);
 29.1353 +    if (FAILED(ret)) {
 29.1354 +        DI_SetError("Pausing the device", ret);
 29.1355 +        return -1;
 29.1356 +    }
 29.1357 +
 29.1358 +    return 0;
 29.1359 +}
 29.1360 +
 29.1361 +
 29.1362 +/*
 29.1363 + * Stops all the playing effects on the device.
 29.1364 + */
 29.1365 +int
 29.1366 +SDL_SYS_HapticStopAll(SDL_Haptic * haptic)
 29.1367 +{
 29.1368 +    HRESULT ret;
 29.1369 +
 29.1370 +    /* Try to stop the effects. */
 29.1371 +    ret = IDirectInputDevice2_SendForceFeedbackCommand(haptic->hwdata->device,
 29.1372 +                                                       DISFFC_STOPALL);
 29.1373 +    if (FAILED(ret)) {
 29.1374 +        DI_SetError("Stopping the device", ret);
 29.1375 +        return -1;
 29.1376 +    }
 29.1377 +
 29.1378 +    return 0;
 29.1379 +}
 29.1380 +
 29.1381 +
 29.1382 +#endif /* SDL_HAPTIC_DINPUT */
    30.1 --- a/src/joystick/win32/SDL_dxjoystick.c	Thu Jan 20 17:33:06 2011 -0800
    30.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    30.3 @@ -1,802 +0,0 @@
    30.4 -/*
    30.5 -    SDL - Simple DirectMedia Layer
    30.6 -    Copyright (C) 1997-2010 Sam Lantinga
    30.7 -
    30.8 -    This library is free software; you can redistribute it and/or
    30.9 -    modify it under the terms of the GNU Lesser General Public
   30.10 -    License as published by the Free Software Foundation; either
   30.11 -    version 2.1 of the License, or (at your option) any later version.
   30.12 -
   30.13 -    This library is distributed in the hope that it will be useful,
   30.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
   30.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   30.16 -    Lesser General Public License for more details.
   30.17 -
   30.18 -    You should have received a copy of the GNU Lesser General Public
   30.19 -    License along with this library; if not, write to the Free Software
   30.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   30.21 -
   30.22 -    Sam Lantinga
   30.23 -    slouken@libsdl.org
   30.24 -*/
   30.25 -#include "SDL_config.h"
   30.26 -
   30.27 -#ifdef SDL_JOYSTICK_DINPUT
   30.28 -
   30.29 -/* DirectInput joystick driver; written by Glenn Maynard, based on Andrei de
   30.30 - * A. Formiga's WINMM driver. 
   30.31 - *
   30.32 - * Hats and sliders are completely untested; the app I'm writing this for mostly
   30.33 - * doesn't use them and I don't own any joysticks with them. 
   30.34 - *
   30.35 - * We don't bother to use event notification here.  It doesn't seem to work
   30.36 - * with polled devices, and it's fine to call IDirectInputDevice2_GetDeviceData and
   30.37 - * let it return 0 events. */
   30.38 -
   30.39 -#include "SDL_error.h"
   30.40 -#include "SDL_events.h"
   30.41 -#include "SDL_joystick.h"
   30.42 -#include "../SDL_sysjoystick.h"
   30.43 -#include "../SDL_joystick_c.h"
   30.44 -#define INITGUID /* Only set here, if set twice will cause mingw32 to break. */
   30.45 -#include "SDL_dxjoystick_c.h"
   30.46 -
   30.47 -
   30.48 -#ifndef DIDFT_OPTIONAL
   30.49 -#define DIDFT_OPTIONAL		0x80000000
   30.50 -#endif
   30.51 -
   30.52 -
   30.53 -#define INPUT_QSIZE	32      /* Buffer up to 32 input messages */
   30.54 -#define MAX_JOYSTICKS	8
   30.55 -#define AXIS_MIN	-32768  /* minimum value for axis coordinate */
   30.56 -#define AXIS_MAX	32767   /* maximum value for axis coordinate */
   30.57 -#define JOY_AXIS_THRESHOLD	(((AXIS_MAX)-(AXIS_MIN))/100)   /* 1% motion */
   30.58 -
   30.59 -/* external variables referenced. */
   30.60 -extern HWND SDL_HelperWindow;
   30.61 -
   30.62 -
   30.63 -/* local variables */
   30.64 -static LPDIRECTINPUT dinput = NULL;
   30.65 -extern HRESULT(WINAPI * DInputCreate) (HINSTANCE hinst, DWORD dwVersion,
   30.66 -                                       LPDIRECTINPUT * ppDI,
   30.67 -                                       LPUNKNOWN punkOuter);
   30.68 -static DIDEVICEINSTANCE SYS_Joystick[MAX_JOYSTICKS];    /* array to hold joystick ID values */
   30.69 -static int SYS_NumJoysticks;
   30.70 -static HINSTANCE DInputDLL = NULL;
   30.71 -
   30.72 -
   30.73 -/* local prototypes */
   30.74 -static void SetDIerror(const char *function, HRESULT code);
   30.75 -static BOOL CALLBACK EnumJoysticksCallback(const DIDEVICEINSTANCE *
   30.76 -                                           pdidInstance, VOID * pContext);
   30.77 -static BOOL CALLBACK EnumDevObjectsCallback(LPCDIDEVICEOBJECTINSTANCE dev,
   30.78 -                                            LPVOID pvRef);
   30.79 -static Uint8 TranslatePOV(DWORD value);
   30.80 -static int SDL_PrivateJoystickAxis_Int(SDL_Joystick * joystick, Uint8 axis,
   30.81 -                                       Sint16 value);
   30.82 -static int SDL_PrivateJoystickHat_Int(SDL_Joystick * joystick, Uint8 hat,
   30.83 -                                      Uint8 value);
   30.84 -static int SDL_PrivateJoystickButton_Int(SDL_Joystick * joystick,
   30.85 -                                         Uint8 button, Uint8 state);
   30.86 -
   30.87 -/* Taken from Wine - Thanks! */
   30.88 -DIOBJECTDATAFORMAT dfDIJoystick2[] = {
   30.89 -  { &GUID_XAxis,DIJOFS_X,DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
   30.90 -  { &GUID_YAxis,DIJOFS_Y,DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
   30.91 -  { &GUID_ZAxis,DIJOFS_Z,DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
   30.92 -  { &GUID_RxAxis,DIJOFS_RX,DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
   30.93 -  { &GUID_RyAxis,DIJOFS_RY,DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
   30.94 -  { &GUID_RzAxis,DIJOFS_RZ,DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
   30.95 -  { &GUID_Slider,DIJOFS_SLIDER(0),DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
   30.96 -  { &GUID_Slider,DIJOFS_SLIDER(1),DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
   30.97 -  { &GUID_POV,DIJOFS_POV(0),DIDFT_OPTIONAL|DIDFT_POV|DIDFT_ANYINSTANCE,0},
   30.98 -  { &GUID_POV,DIJOFS_POV(1),DIDFT_OPTIONAL|DIDFT_POV|DIDFT_ANYINSTANCE,0},
   30.99 -  { &GUID_POV,DIJOFS_POV(2),DIDFT_OPTIONAL|DIDFT_POV|DIDFT_ANYINSTANCE,0},
  30.100 -  { &GUID_POV,DIJOFS_POV(3),DIDFT_OPTIONAL|DIDFT_POV|DIDFT_ANYINSTANCE,0},
  30.101 -  { NULL,DIJOFS_BUTTON(0),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  30.102 -  { NULL,DIJOFS_BUTTON(1),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  30.103 -  { NULL,DIJOFS_BUTTON(2),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  30.104 -  { NULL,DIJOFS_BUTTON(3),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  30.105 -  { NULL,DIJOFS_BUTTON(4),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  30.106 -  { NULL,DIJOFS_BUTTON(5),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  30.107 -  { NULL,DIJOFS_BUTTON(6),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  30.108 -  { NULL,DIJOFS_BUTTON(7),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  30.109 -  { NULL,DIJOFS_BUTTON(8),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  30.110 -  { NULL,DIJOFS_BUTTON(9),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  30.111 -  { NULL,DIJOFS_BUTTON(10),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  30.112 -  { NULL,DIJOFS_BUTTON(11),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  30.113 -  { NULL,DIJOFS_BUTTON(12),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  30.114 -  { NULL,DIJOFS_BUTTON(13),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  30.115 -  { NULL,DIJOFS_BUTTON(14),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  30.116 -  { NULL,DIJOFS_BUTTON(15),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  30.117 -  { NULL,DIJOFS_BUTTON(16),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  30.118 -  { NULL,DIJOFS_BUTTON(17),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  30.119 -  { NULL,DIJOFS_BUTTON(18),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  30.120 -  { NULL,DIJOFS_BUTTON(19),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  30.121 -  { NULL,DIJOFS_BUTTON(20),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  30.122 -  { NULL,DIJOFS_BUTTON(21),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  30.123 -  { NULL,DIJOFS_BUTTON(22),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  30.124 -  { NULL,DIJOFS_BUTTON(23),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  30.125 -  { NULL,DIJOFS_BUTTON(24),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  30.126 -  { NULL,DIJOFS_BUTTON(25),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  30.127 -  { NULL,DIJOFS_BUTTON(26),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  30.128 -  { NULL,DIJOFS_BUTTON(27),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  30.129 -  { NULL,DIJOFS_BUTTON(28),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  30.130 -  { NULL,DIJOFS_BUTTON(29),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  30.131 -  { NULL,DIJOFS_BUTTON(30),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  30.132 -  { NULL,DIJOFS_BUTTON(31),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  30.133 -  { NULL,DIJOFS_BUTTON(32),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  30.134 -  { NULL,DIJOFS_BUTTON(33),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  30.135 -  { NULL,DIJOFS_BUTTON(34),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  30.136 -  { NULL,DIJOFS_BUTTON(35),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  30.137 -  { NULL,DIJOFS_BUTTON(36),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  30.138 -  { NULL,DIJOFS_BUTTON(37),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  30.139 -  { NULL,DIJOFS_BUTTON(38),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  30.140 -  { NULL,DIJOFS_BUTTON(39),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  30.141 -  { NULL,DIJOFS_BUTTON(40),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  30.142 -  { NULL,DIJOFS_BUTTON(41),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  30.143 -  { NULL,DIJOFS_BUTTON(42),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  30.144 -  { NULL,DIJOFS_BUTTON(43),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  30.145 -  { NULL,DIJOFS_BUTTON(44),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  30.146 -  { NULL,DIJOFS_BUTTON(45),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  30.147 -  { NULL,DIJOFS_BUTTON(46),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  30.148 -  { NULL,DIJOFS_BUTTON(47),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  30.149 -  { NULL,DIJOFS_BUTTON(48),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  30.150 -  { NULL,DIJOFS_BUTTON(49),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  30.151 -  { NULL,DIJOFS_BUTTON(50),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  30.152 -  { NULL,DIJOFS_BUTTON(51),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  30.153 -  { NULL,DIJOFS_BUTTON(52),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  30.154 -  { NULL,DIJOFS_BUTTON(53),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  30.155 -  { NULL,DIJOFS_BUTTON(54),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  30.156 -  { NULL,DIJOFS_BUTTON(55),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  30.157 -  { NULL,DIJOFS_BUTTON(56),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  30.158 -  { NULL,DIJOFS_BUTTON(57),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  30.159 -  { NULL,DIJOFS_BUTTON(58),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  30.160 -  { NULL,DIJOFS_BUTTON(59),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  30.161 -  { NULL,DIJOFS_BUTTON(60),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  30.162 -  { NULL,DIJOFS_BUTTON(61),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  30.163 -  { NULL,DIJOFS_BUTTON(62),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  30.164 -  { NULL,DIJOFS_BUTTON(63),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  30.165 -  { NULL,DIJOFS_BUTTON(64),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  30.166 -  { NULL,DIJOFS_BUTTON(65),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  30.167 -  { NULL,DIJOFS_BUTTON(66),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  30.168 -  { NULL,DIJOFS_BUTTON(67),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  30.169 -  { NULL,DIJOFS_BUTTON(68),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  30.170 -  { NULL,DIJOFS_BUTTON(69),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  30.171 -  { NULL,DIJOFS_BUTTON(70),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  30.172 -  { NULL,DIJOFS_BUTTON(71),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  30.173 -  { NULL,DIJOFS_BUTTON(72),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  30.174 -  { NULL,DIJOFS_BUTTON(73),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  30.175 -  { NULL,DIJOFS_BUTTON(74),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  30.176 -  { NULL,DIJOFS_BUTTON(75),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  30.177 -  { NULL,DIJOFS_BUTTON(76),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  30.178 -  { NULL,DIJOFS_BUTTON(77),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  30.179 -  { NULL,DIJOFS_BUTTON(78),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  30.180 -  { NULL,DIJOFS_BUTTON(79),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  30.181 -  { NULL,DIJOFS_BUTTON(80),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  30.182 -  { NULL,DIJOFS_BUTTON(81),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  30.183 -  { NULL,DIJOFS_BUTTON(82),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  30.184 -  { NULL,DIJOFS_BUTTON(83),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  30.185 -  { NULL,DIJOFS_BUTTON(84),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  30.186 -  { NULL,DIJOFS_BUTTON(85),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  30.187 -  { NULL,DIJOFS_BUTTON(86),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  30.188 -  { NULL,DIJOFS_BUTTON(87),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  30.189 -  { NULL,DIJOFS_BUTTON(88),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  30.190 -  { NULL,DIJOFS_BUTTON(89),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  30.191 -  { NULL,DIJOFS_BUTTON(90),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  30.192 -  { NULL,DIJOFS_BUTTON(91),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  30.193 -  { NULL,DIJOFS_BUTTON(92),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  30.194 -  { NULL,DIJOFS_BUTTON(93),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  30.195 -  { NULL,DIJOFS_BUTTON(94),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  30.196 -  { NULL,DIJOFS_BUTTON(95),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  30.197 -  { NULL,DIJOFS_BUTTON(96),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  30.198 -  { NULL,DIJOFS_BUTTON(97),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  30.199 -  { NULL,DIJOFS_BUTTON(98),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  30.200 -  { NULL,DIJOFS_BUTTON(99),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  30.201 -  { NULL,DIJOFS_BUTTON(100),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  30.202 -  { NULL,DIJOFS_BUTTON(101),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  30.203 -  { NULL,DIJOFS_BUTTON(102),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  30.204 -  { NULL,DIJOFS_BUTTON(103),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  30.205 -  { NULL,DIJOFS_BUTTON(104),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  30.206 -  { NULL,DIJOFS_BUTTON(105),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  30.207 -  { NULL,DIJOFS_BUTTON(106),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  30.208 -  { NULL,DIJOFS_BUTTON(107),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  30.209 -  { NULL,DIJOFS_BUTTON(108),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  30.210 -  { NULL,DIJOFS_BUTTON(109),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  30.211 -  { NULL,DIJOFS_BUTTON(110),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  30.212 -  { NULL,DIJOFS_BUTTON(111),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  30.213 -  { NULL,DIJOFS_BUTTON(112),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  30.214 -  { NULL,DIJOFS_BUTTON(113),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  30.215 -  { NULL,DIJOFS_BUTTON(114),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  30.216 -  { NULL,DIJOFS_BUTTON(115),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  30.217 -  { NULL,DIJOFS_BUTTON(116),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  30.218 -  { NULL,DIJOFS_BUTTON(117),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  30.219 -  { NULL,DIJOFS_BUTTON(118),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  30.220 -  { NULL,DIJOFS_BUTTON(119),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  30.221 -  { NULL,DIJOFS_BUTTON(120),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  30.222 -  { NULL,DIJOFS_BUTTON(121),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  30.223 -  { NULL,DIJOFS_BUTTON(122),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  30.224 -  { NULL,DIJOFS_BUTTON(123),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  30.225 -  { NULL,DIJOFS_BUTTON(124),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  30.226 -  { NULL,DIJOFS_BUTTON(125),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  30.227 -  { NULL,DIJOFS_BUTTON(126),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  30.228 -  { NULL,DIJOFS_BUTTON(127),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  30.229 -  { &GUID_XAxis,FIELD_OFFSET(DIJOYSTATE2,lVX),DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
  30.230 -  { &GUID_YAxis,FIELD_OFFSET(DIJOYSTATE2,lVY),DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
  30.231 -  { &GUID_ZAxis,FIELD_OFFSET(DIJOYSTATE2,lVZ),DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
  30.232 -  { &GUID_RxAxis,FIELD_OFFSET(DIJOYSTATE2,lVRx),DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
  30.233 -  { &GUID_RyAxis,FIELD_OFFSET(DIJOYSTATE2,lVRy),DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
  30.234 -  { &GUID_RzAxis,FIELD_OFFSET(DIJOYSTATE2,lVRz),DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
  30.235 -  { &GUID_Slider,FIELD_OFFSET(DIJOYSTATE2,rglVSlider[0]),DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
  30.236 -  { &GUID_Slider,FIELD_OFFSET(DIJOYSTATE2,rglVSlider[1]),DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
  30.237 -  { &GUID_XAxis,FIELD_OFFSET(DIJOYSTATE2,lAX),DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
  30.238 -  { &GUID_YAxis,FIELD_OFFSET(DIJOYSTATE2,lAY),DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
  30.239 -  { &GUID_ZAxis,FIELD_OFFSET(DIJOYSTATE2,lAZ),DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
  30.240 -  { &GUID_RxAxis,FIELD_OFFSET(DIJOYSTATE2,lARx),DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
  30.241 -  { &GUID_RyAxis,FIELD_OFFSET(DIJOYSTATE2,lARy),DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
  30.242 -  { &GUID_RzAxis,FIELD_OFFSET(DIJOYSTATE2,lARz),DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
  30.243 -  { &GUID_Slider,FIELD_OFFSET(DIJOYSTATE2,rglASlider[0]),DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
  30.244 -  { &GUID_Slider,FIELD_OFFSET(DIJOYSTATE2,rglASlider[1]),DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
  30.245 -  { &GUID_XAxis,FIELD_OFFSET(DIJOYSTATE2,lFX),DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
  30.246 -  { &GUID_YAxis,FIELD_OFFSET(DIJOYSTATE2,lFY),DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
  30.247 -  { &GUID_ZAxis,FIELD_OFFSET(DIJOYSTATE2,lFZ),DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
  30.248 -  { &GUID_RxAxis,FIELD_OFFSET(DIJOYSTATE2,lFRx),DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
  30.249 -  { &GUID_RyAxis,FIELD_OFFSET(DIJOYSTATE2,lFRy),DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
  30.250 -  { &GUID_RzAxis,FIELD_OFFSET(DIJOYSTATE2,lFRz),DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
  30.251 -  { &GUID_Slider,FIELD_OFFSET(DIJOYSTATE2,rglFSlider[0]),DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
  30.252 -  { &GUID_Slider,FIELD_OFFSET(DIJOYSTATE2,rglFSlider[1]),DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
  30.253 -};
  30.254 -
  30.255 -const DIDATAFORMAT c_dfDIJoystick2 = {
  30.256 -    sizeof(DIDATAFORMAT),
  30.257 -    sizeof(DIOBJECTDATAFORMAT),
  30.258 -    DIDF_ABSAXIS,
  30.259 -    sizeof(DIJOYSTATE2),
  30.260 -    SDL_arraysize(dfDIJoystick2),
  30.261 -    dfDIJoystick2
  30.262 -};
  30.263 -
  30.264 -
  30.265 -/* Convert a DirectInput return code to a text message */
  30.266 -static void
  30.267 -SetDIerror(const char *function, HRESULT code)
  30.268 -{
  30.269 -    /*
  30.270 -    SDL_SetError("%s() [%s]: %s", function,
  30.271 -                 DXGetErrorString9A(code), DXGetErrorDescription9A(code));
  30.272 -     */
  30.273 -    SDL_SetError("%s() DirectX error %d", function, code);
  30.274 -}
  30.275 -
  30.276 -
  30.277 -/* Function to scan the system for joysticks.
  30.278 - * This function should set SDL_numjoysticks to the number of available
  30.279 - * joysticks.  Joystick 0 should be the system default joystick.
  30.280 - * It should return 0, or -1 on an unrecoverable fatal error.
  30.281 - */
  30.282 -int
  30.283 -SDL_SYS_JoystickInit(void)
  30.284 -{
  30.285 -    HRESULT result;
  30.286 -    HINSTANCE instance;
  30.287 -
  30.288 -    SYS_NumJoysticks = 0;
  30.289 -
  30.290 -    result = CoInitialize(NULL);
  30.291 -    if (FAILED(result)) {
  30.292 -        SetDIerror("CoInitialize", result);
  30.293 -        return (-1);
  30.294 -    }
  30.295 -
  30.296 -    result = CoCreateInstance(&CLSID_DirectInput, NULL, CLSCTX_INPROC_SERVER,
  30.297 -                              &IID_IDirectInput, (LPVOID)&dinput);
  30.298 -
  30.299 -    if (FAILED(result)) {
  30.300 -        SetDIerror("CoCreateInstance", result);
  30.301 -        return (-1);
  30.302 -    }
  30.303 -
  30.304 -    /* Because we used CoCreateInstance, we need to Initialize it, first. */
  30.305 -    instance = GetModuleHandle(NULL);
  30.306 -    if (instance == NULL) {
  30.307 -        SDL_SetError("GetModuleHandle() failed with error code %d.",
  30.308 -                     GetLastError());
  30.309 -        return (-1);
  30.310 -    }
  30.311 -    result = IDirectInput_Initialize(dinput, instance, DIRECTINPUT_VERSION);
  30.312 -
  30.313 -    if (FAILED(result)) {
  30.314 -        SetDIerror("IDirectInput::Initialize", result);
  30.315 -        return (-1);
  30.316 -    }
  30.317 -
  30.318 -    /* Look for joysticks, wheels, head trackers, gamepads, etc.. */
  30.319 -    result = IDirectInput_EnumDevices(dinput,
  30.320 -                                      DIDEVTYPE_JOYSTICK,
  30.321 -                                      EnumJoysticksCallback,
  30.322 -                                      NULL, DIEDFL_ATTACHEDONLY);
  30.323 -
  30.324 -    return SYS_NumJoysticks;
  30.325 -}
  30.326 -
  30.327 -static BOOL CALLBACK
  30.328 -EnumJoysticksCallback(const DIDEVICEINSTANCE * pdidInstance, VOID * pContext)
  30.329 -{
  30.330 -    SDL_memcpy(&SYS_Joystick[SYS_NumJoysticks], pdidInstance,
  30.331 -               sizeof(DIDEVICEINSTANCE));
  30.332 -    SYS_NumJoysticks++;
  30.333 -
  30.334 -    if (SYS_NumJoysticks >= MAX_JOYSTICKS)
  30.335 -        return DIENUM_STOP;
  30.336 -
  30.337 -    return DIENUM_CONTINUE;
  30.338 -}
  30.339 -
  30.340 -/* Function to get the device-dependent name of a joystick */
  30.341 -const char *
  30.342 -SDL_SYS_JoystickName(int index)
  30.343 -{
  30.344 -        /***-> test for invalid index ? */
  30.345 -    return (SYS_Joystick[index].tszProductName);
  30.346 -}
  30.347 -
  30.348 -/* Function to open a joystick for use.
  30.349 -   The joystick to open is specified by the index field of the joystick.
  30.350 -   This should fill the nbuttons and naxes fields of the joystick structure.
  30.351 -   It returns 0, or -1 if there is an error.
  30.352 - */
  30.353 -int
  30.354 -SDL_SYS_JoystickOpen(SDL_Joystick * joystick)
  30.355 -{
  30.356 -    HRESULT result;
  30.357 -    LPDIRECTINPUTDEVICE device;
  30.358 -    DIPROPDWORD dipdw;
  30.359 -
  30.360 -    SDL_memset(&dipdw, 0, sizeof(DIPROPDWORD));
  30.361 -    dipdw.diph.dwSize = sizeof(DIPROPDWORD);
  30.362 -    dipdw.diph.dwHeaderSize = sizeof(DIPROPHEADER);
  30.363 -
  30.364 -
  30.365 -    /* allocate memory for system specific hardware data */
  30.366 -    joystick->hwdata =
  30.367 -        (struct joystick_hwdata *) SDL_malloc(sizeof(struct joystick_hwdata));
  30.368 -    if (joystick->hwdata == NULL) {
  30.369 -        SDL_OutOfMemory();
  30.370 -        return (-1);
  30.371 -    }
  30.372 -    SDL_memset(joystick->hwdata, 0, sizeof(struct joystick_hwdata));
  30.373 -    joystick->hwdata->buffered = 1;
  30.374 -    joystick->hwdata->Capabilities.dwSize = sizeof(DIDEVCAPS);
  30.375 -
  30.376 -    result =
  30.377 -        IDirectInput_CreateDevice(dinput,
  30.378 -                                  &SYS_Joystick[joystick->index].
  30.379 -                                  guidInstance, &device, NULL);
  30.380 -    if (FAILED(result)) {
  30.381 -        SetDIerror("IDirectInput::CreateDevice", result);
  30.382 -        return (-1);
  30.383 -    }
  30.384 -
  30.385 -    /* Now get the IDirectInputDevice2 interface, instead. */
  30.386 -    result = IDirectInputDevice_QueryInterface(device,
  30.387 -                                               &IID_IDirectInputDevice2,
  30.388 -                                               (LPVOID *) & joystick->
  30.389 -                                               hwdata->InputDevice);
  30.390 -    /* We are done with this object.  Use the stored one from now on. */
  30.391 -    IDirectInputDevice_Release(device);
  30.392 -
  30.393 -    if (FAILED(result)) {
  30.394 -        SetDIerror("IDirectInputDevice::QueryInterface", result);
  30.395 -        return (-1);
  30.396 -    }
  30.397 -
  30.398 -    /* Aquire shared access. Exclusive access is required for forces,
  30.399 -     * though. */
  30.400 -    result =
  30.401 -        IDirectInputDevice2_SetCooperativeLevel(joystick->hwdata->
  30.402 -                                                InputDevice, SDL_HelperWindow,
  30.403 -                                                DISCL_EXCLUSIVE |
  30.404 -                                                DISCL_BACKGROUND);
  30.405 -    if (FAILED(result)) {
  30.406 -        SetDIerror("IDirectInputDevice2::SetCooperativeLevel", result);
  30.407 -        return (-1);
  30.408 -    }
  30.409 -
  30.410 -    /* Use the extended data structure: DIJOYSTATE2. */
  30.411 -    result =
  30.412 -        IDirectInputDevice2_SetDataFormat(joystick->hwdata->InputDevice,
  30.413 -                                          &c_dfDIJoystick2);
  30.414 -    if (FAILED(result)) {
  30.415 -        SetDIerror("IDirectInputDevice2::SetDataFormat", result);
  30.416 -        return (-1);
  30.417 -    }
  30.418 -
  30.419 -    /* Get device capabilities */
  30.420 -    result =
  30.421 -        IDirectInputDevice2_GetCapabilities(joystick->hwdata->InputDevice,
  30.422 -                                            &joystick->hwdata->Capabilities);
  30.423 -
  30.424 -    if (FAILED(result)) {
  30.425 -        SetDIerror("IDirectInputDevice2::GetCapabilities", result);
  30.426 -        return (-1);
  30.427 -    }
  30.428 -
  30.429 -    /* Force capable? */
  30.430 -    if (joystick->hwdata->Capabilities.dwFlags & DIDC_FORCEFEEDBACK) {
  30.431 -
  30.432 -        result = IDirectInputDevice2_Acquire(joystick->hwdata->InputDevice);
  30.433 -
  30.434 -        if (FAILED(result)) {
  30.435 -            SetDIerror("IDirectInputDevice2::Acquire", result);
  30.436 -            return (-1);
  30.437 -        }
  30.438 -
  30.439 -        /* reset all accuators. */
  30.440 -        result =
  30.441 -            IDirectInputDevice2_SendForceFeedbackCommand(joystick->hwdata->
  30.442 -                                                         InputDevice,
  30.443 -                                                         DISFFC_RESET);
  30.444 -
  30.445 -        /* Not necessarily supported, ignore if not supported.
  30.446 -        if (FAILED(result)) {
  30.447 -            SetDIerror("IDirectInputDevice2::SendForceFeedbackCommand",
  30.448 -                       result);
  30.449 -            return (-1);
  30.450 -        }
  30.451 -        */
  30.452 -
  30.453 -        result = IDirectInputDevice2_Unacquire(joystick->hwdata->InputDevice);
  30.454 -
  30.455 -        if (FAILED(result)) {
  30.456 -            SetDIerror("IDirectInputDevice2::Unacquire", result);
  30.457 -            return (-1);
  30.458 -        }
  30.459 -
  30.460 -        /* Turn on auto-centering for a ForceFeedback device (until told
  30.461 -         * otherwise). */
  30.462 -        dipdw.diph.dwObj = 0;
  30.463 -        dipdw.diph.dwHow = DIPH_DEVICE;
  30.464 -        dipdw.dwData = DIPROPAUTOCENTER_ON;
  30.465 -
  30.466 -        result =
  30.467 -            IDirectInputDevice2_SetProperty(joystick->hwdata->InputDevice,
  30.468 -                                            DIPROP_AUTOCENTER, &dipdw.diph);
  30.469 -
  30.470 -        /* Not necessarily supported, ignore if not supported.
  30.471 -        if (FAILED(result)) {
  30.472 -            SetDIerror("IDirectInputDevice2::SetProperty", result);
  30.473 -            return (-1);
  30.474 -        }
  30.475 -        */
  30.476 -    }
  30.477 -
  30.478 -    /* What buttons and axes does it have? */
  30.479 -    IDirectInputDevice2_EnumObjects(joystick->hwdata->InputDevice,
  30.480 -                                    EnumDevObjectsCallback, joystick,
  30.481 -                                    DIDFT_BUTTON | DIDFT_AXIS | DIDFT_POV);
  30.482 -
  30.483 -    dipdw.diph.dwObj = 0;
  30.484 -    dipdw.diph.dwHow = DIPH_DEVICE;
  30.485 -    dipdw.dwData = INPUT_QSIZE;
  30.486 -
  30.487 -    /* Set the buffer size */
  30.488 -    result =
  30.489 -        IDirectInputDevice2_SetProperty(joystick->hwdata->InputDevice,
  30.490 -                                        DIPROP_BUFFERSIZE, &dipdw.diph);
  30.491 -
  30.492 -    if (result == DI_POLLEDDEVICE) {
  30.493 -        /* This device doesn't support buffering, so we're forced
  30.494 -         * to use less reliable polling. */
  30.495 -        joystick->hwdata->buffered = 0;
  30.496 -    } else if (FAILED(result)) {
  30.497 -        SetDIerror("IDirectInputDevice2::SetProperty", result);
  30.498 -        return (-1);
  30.499 -    }
  30.500 -
  30.501 -    return (0);
  30.502 -}
  30.503 -
  30.504 -static BOOL CALLBACK
  30.505 -EnumDevObjectsCallback(LPCDIDEVICEOBJECTINSTANCE dev, LPVOID pvRef)
  30.506 -{
  30.507 -    SDL_Joystick *joystick = (SDL_Joystick *) pvRef;
  30.508 -    HRESULT result;
  30.509 -    input_t *in = &joystick->hwdata->Inputs[joystick->hwdata->NumInputs];
  30.510 -
  30.511 -    in->ofs = dev->dwOfs;
  30.512 -
  30.513 -    if (dev->dwType & DIDFT_BUTTON) {
  30.514 -        in->type = BUTTON;
  30.515 -        in->num = joystick->nbuttons;
  30.516 -        joystick->nbuttons++;
  30.517 -    } else if (dev->dwType & DIDFT_POV) {
  30.518 -        in->type = HAT;
  30.519 -        in->num = joystick->nhats;
  30.520 -        joystick->nhats++;
  30.521 -    } else if (dev->dwType & DIDFT_AXIS) {
  30.522 -        DIPROPRANGE diprg;
  30.523 -        DIPROPDWORD dilong;
  30.524 -
  30.525 -        in->type = AXIS;
  30.526 -        in->num = joystick->naxes;
  30.527 -
  30.528 -        diprg.diph.dwSize = sizeof(diprg);
  30.529 -        diprg.diph.dwHeaderSize = sizeof(diprg.diph);
  30.530 -        diprg.diph.dwObj = dev->dwOfs;
  30.531 -        diprg.diph.dwHow = DIPH_BYOFFSET;
  30.532 -        diprg.lMin = AXIS_MIN;
  30.533 -        diprg.lMax = AXIS_MAX;
  30.534 -
  30.535 -        result =
  30.536 -            IDirectInputDevice2_SetProperty(joystick->hwdata->InputDevice,
  30.537 -                                            DIPROP_RANGE, &diprg.diph);
  30.538 -        if (FAILED(result)) {
  30.539 -            return DIENUM_CONTINUE;     /* don't use this axis */
  30.540 -        }
  30.541 -
  30.542 -        /* Set dead zone to 0. */
  30.543 -        dilong.diph.dwSize = sizeof(dilong);
  30.544 -        dilong.diph.dwHeaderSize = sizeof(dilong.diph);
  30.545 -        dilong.diph.dwObj = dev->dwOfs;
  30.546 -        dilong.diph.dwHow = DIPH_BYOFFSET;
  30.547 -        dilong.dwData = 0;
  30.548 -        result =
  30.549 -            IDirectInputDevice2_SetProperty(joystick->hwdata->InputDevice,
  30.550 -                                            DIPROP_DEADZONE, &dilong.diph);
  30.551 -        if (FAILED(result)) {
  30.552 -            return DIENUM_CONTINUE;     /* don't use this axis */
  30.553 -        }
  30.554 -
  30.555 -        joystick->naxes++;
  30.556 -    } else {
  30.557 -        /* not supported at this time */
  30.558 -        return DIENUM_CONTINUE;
  30.559 -    }
  30.560 -
  30.561 -    joystick->hwdata->NumInputs++;
  30.562 -
  30.563 -    if (joystick->hwdata->NumInputs == MAX_INPUTS) {
  30.564 -        return DIENUM_STOP;     /* too many */
  30.565 -    }
  30.566 -
  30.567 -    return DIENUM_CONTINUE;
  30.568 -}
  30.569 -
  30.570 -/* Function to update the state of a joystick - called as a device poll.
  30.571 - * This function shouldn't update the joystick structure directly,
  30.572 - * but instead should call SDL_PrivateJoystick*() to deliver events
  30.573 - * and update joystick device state.
  30.574 - */
  30.575 -void
  30.576 -SDL_SYS_JoystickUpdate_Polled(SDL_Joystick * joystick)
  30.577 -{
  30.578 -    DIJOYSTATE2 state;
  30.579 -    HRESULT result;
  30.580 -    int i;
  30.581 -
  30.582 -    result =
  30.583 -        IDirectInputDevice2_GetDeviceState(joystick->hwdata->InputDevice,
  30.584 -                                           sizeof(DIJOYSTATE2), &state);
  30.585 -    if (result == DIERR_INPUTLOST || result == DIERR_NOTACQUIRED) {
  30.586 -        IDirectInputDevice2_Acquire(joystick->hwdata->InputDevice);
  30.587 -        result =
  30.588 -            IDirectInputDevice2_GetDeviceState(joystick->hwdata->InputDevice,
  30.589 -                                               sizeof(DIJOYSTATE2), &state);
  30.590 -    }
  30.591 -
  30.592 -    /* Set each known axis, button and POV. */
  30.593 -    for (i = 0; i < joystick->hwdata->NumInputs; ++i) {
  30.594 -        const input_t *in = &joystick->hwdata->Inputs[i];
  30.595 -
  30.596 -        switch (in->type) {
  30.597 -        case AXIS:
  30.598 -            switch (in->ofs) {
  30.599 -            case DIJOFS_X:
  30.600 -                SDL_PrivateJoystickAxis_Int(joystick, in->num,
  30.601 -                                            (Sint16) state.lX);
  30.602 -                break;
  30.603 -            case DIJOFS_Y:
  30.604 -                SDL_PrivateJoystickAxis_Int(joystick, in->num,
  30.605 -                                            (Sint16) state.lY);
  30.606 -                break;
  30.607 -            case DIJOFS_Z:
  30.608 -                SDL_PrivateJoystickAxis_Int(joystick, in->num,
  30.609 -                                            (Sint16) state.lZ);
  30.610 -                break;
  30.611 -            case DIJOFS_RX:
  30.612 -                SDL_PrivateJoystickAxis_Int(joystick, in->num,
  30.613 -                                            (Sint16) state.lRx);
  30.614 -                break;
  30.615 -            case DIJOFS_RY:
  30.616 -                SDL_PrivateJoystickAxis_Int(joystick, in->num,
  30.617 -                                            (Sint16) state.lRy);
  30.618 -                break;
  30.619 -            case DIJOFS_RZ:
  30.620 -                SDL_PrivateJoystickAxis_Int(joystick, in->num,
  30.621 -                                            (Sint16) state.lRz);
  30.622 -                break;
  30.623 -            case DIJOFS_SLIDER(0):
  30.624 -                SDL_PrivateJoystickAxis_Int(joystick, in->num,
  30.625 -                                            (Sint16) state.rglSlider[0]);
  30.626 -                break;
  30.627 -            case DIJOFS_SLIDER(1):
  30.628 -                SDL_PrivateJoystickAxis_Int(joystick, in->num,
  30.629 -                                            (Sint16) state.rglSlider[1]);
  30.630 -                break;
  30.631 -            }
  30.632 -
  30.633 -            break;
  30.634 -
  30.635 -        case BUTTON:
  30.636 -            SDL_PrivateJoystickButton_Int(joystick, in->num,
  30.637 -                                          (Uint8) (state.
  30.638 -                                                   rgbButtons[in->ofs -
  30.639 -                                                              DIJOFS_BUTTON0]
  30.640 -                                                   ? SDL_PRESSED :
  30.641 -                                                   SDL_RELEASED));
  30.642 -            break;
  30.643 -        case HAT:
  30.644 -            {
  30.645 -                Uint8 pos = TranslatePOV(state.rgdwPOV[in->ofs -
  30.646 -                                                       DIJOFS_POV(0)]);
  30.647 -                SDL_PrivateJoystickHat_Int(joystick, in->num, pos);
  30.648 -                break;
  30.649 -            }
  30.650 -        }
  30.651 -    }
  30.652 -}
  30.653 -
  30.654 -void
  30.655 -SDL_SYS_JoystickUpdate_Buffered(SDL_Joystick * joystick)
  30.656 -{
  30.657 -    int i;
  30.658 -    HRESULT result;
  30.659 -    DWORD numevents;
  30.660 -    DIDEVICEOBJECTDATA evtbuf[INPUT_QSIZE];
  30.661 -
  30.662 -    numevents = INPUT_QSIZE;
  30.663 -    result =
  30.664 -        IDirectInputDevice2_GetDeviceData(joystick->hwdata->InputDevice,
  30.665 -                                          sizeof(DIDEVICEOBJECTDATA), evtbuf,
  30.666 -                                          &numevents, 0);
  30.667 -    if (result == DIERR_INPUTLOST || result == DIERR_NOTACQUIRED) {
  30.668 -        IDirectInputDevice2_Acquire(joystick->hwdata->InputDevice);
  30.669 -        result =
  30.670 -            IDirectInputDevice2_GetDeviceData(joystick->hwdata->InputDevice,
  30.671 -                                              sizeof(DIDEVICEOBJECTDATA),
  30.672 -                                              evtbuf, &numevents, 0);
  30.673 -    }
  30.674 -
  30.675 -    /* Handle the events or punt */
  30.676 -    if (FAILED(result))
  30.677 -        return;
  30.678 -
  30.679 -    for (i = 0; i < (int) numevents; ++i) {
  30.680 -        int j;
  30.681 -
  30.682 -        for (j = 0; j < joystick->hwdata->NumInputs; ++j) {
  30.683 -            const input_t *in = &joystick->hwdata->Inputs[j];
  30.684 -
  30.685 -            if (evtbuf[i].dwOfs != in->ofs)
  30.686 -                continue;
  30.687 -
  30.688 -            switch (in->type) {
  30.689 -            case AXIS:
  30.690 -                SDL_PrivateJoystickAxis(joystick, in->num,
  30.691 -                                        (Sint16) evtbuf[i].dwData);
  30.692 -                break;
  30.693 -            case BUTTON:
  30.694 -                SDL_PrivateJoystickButton(joystick, in->num,
  30.695 -                                          (Uint8) (evtbuf[i].
  30.696 -                                                   dwData ? SDL_PRESSED :
  30.697 -                                                   SDL_RELEASED));
  30.698 -                break;
  30.699 -            case HAT:
  30.700 -                {
  30.701 -                    Uint8 pos = TranslatePOV(evtbuf[i].dwData);
  30.702 -                    SDL_PrivateJoystickHat(joystick, in->num, pos);
  30.703 -                }
  30.704 -            }
  30.705 -        }
  30.706 -    }
  30.707 -}
  30.708 -
  30.709 -
  30.710 -static Uint8
  30.711 -TranslatePOV(DWORD value)
  30.712 -{
  30.713 -    const int HAT_VALS[] = {
  30.714 -        SDL_HAT_UP,
  30.715 -        SDL_HAT_UP | SDL_HAT_RIGHT,
  30.716 -        SDL_HAT_RIGHT,
  30.717 -        SDL_HAT_DOWN | SDL_HAT_RIGHT,
  30.718 -        SDL_HAT_DOWN,
  30.719 -        SDL_HAT_DOWN | SDL_HAT_LEFT,
  30.720 -        SDL_HAT_LEFT,
  30.721 -        SDL_HAT_UP | SDL_HAT_LEFT
  30.722 -    };
  30.723 -
  30.724 -    if (LOWORD(value) == 0xFFFF)
  30.725 -        return SDL_HAT_CENTERED;
  30.726 -
  30.727 -    /* Round the value up: */
  30.728 -    value += 4500 / 2;
  30.729 -    value %= 36000;
  30.730 -    value /= 4500;
  30.731 -
  30.732 -    if (value >= 8)
  30.733 -        return SDL_HAT_CENTERED;        /* shouldn't happen */
  30.734 -
  30.735 -    return HAT_VALS[value];
  30.736 -}
  30.737 -
  30.738 -/* SDL_PrivateJoystick* doesn't discard duplicate events, so we need to
  30.739 - * do it. */
  30.740 -static int
  30.741 -SDL_PrivateJoystickAxis_Int(SDL_Joystick * joystick, Uint8 axis, Sint16 value)
  30.742 -{
  30.743 -    if (joystick->axes[axis] != value)
  30.744 -        return SDL_PrivateJoystickAxis(joystick, axis, value);
  30.745 -    return 0;
  30.746 -}
  30.747 -
  30.748 -static int
  30.749 -SDL_PrivateJoystickHat_Int(SDL_Joystick * joystick, Uint8 hat, Uint8 value)
  30.750 -{
  30.751 -    if (joystick->hats[hat] != value)
  30.752 -        return SDL_PrivateJoystickHat(joystick, hat, value);
  30.753 -    return 0;
  30.754 -}
  30.755 -
  30.756 -static int
  30.757 -SDL_PrivateJoystickButton_Int(SDL_Joystick * joystick, Uint8 button,
  30.758 -                              Uint8 state)
  30.759 -{
  30.760 -    if (joystick->buttons[button] != state)
  30.761 -        return SDL_PrivateJoystickButton(joystick, button, state);
  30.762 -    return 0;
  30.763 -}
  30.764 -
  30.765 -void
  30.766 -SDL_SYS_JoystickUpdate(SDL_Joystick * joystick)
  30.767 -{
  30.768 -    HRESULT result;
  30.769 -
  30.770 -    result = IDirectInputDevice2_Poll(joystick->hwdata->InputDevice);
  30.771 -    if (result == DIERR_INPUTLOST || result == DIERR_NOTACQUIRED) {
  30.772 -        IDirectInputDevice2_Acquire(joystick->hwdata->InputDevice);
  30.773 -        IDirectInputDevice2_Poll(joystick->hwdata->InputDevice);
  30.774 -    }
  30.775 -
  30.776 -    if (joystick->hwdata->buffered)
  30.777 -        SDL_SYS_JoystickUpdate_Buffered(joystick);
  30.778 -    else
  30.779 -        SDL_SYS_JoystickUpdate_Polled(joystick);
  30.780 -}
  30.781 -
  30.782 -/* Function to close a joystick after use */
  30.783 -void
  30.784 -SDL_SYS_JoystickClose(SDL_Joystick * joystick)
  30.785 -{
  30.786 -    IDirectInputDevice2_Unacquire(joystick->hwdata->InputDevice);
  30.787 -    IDirectInputDevice2_Release(joystick->hwdata->InputDevice);
  30.788 -
  30.789 -    if (joystick->hwdata != NULL) {
  30.790 -        /* free system specific hardware data */
  30.791 -        SDL_free(joystick->hwdata);
  30.792 -    }
  30.793 -}
  30.794 -
  30.795 -/* Function to perform any system-specific joystick related cleanup */
  30.796 -void
  30.797 -SDL_SYS_JoystickQuit(void)
  30.798 -{
  30.799 -    IDirectInput_Release(dinput);
  30.800 -    dinput = NULL;
  30.801 -}
  30.802 -
  30.803 -#endif /* SDL_JOYSTICK_DINPUT */
  30.804 -
  30.805 -/* vi: set ts=4 sw=4 expandtab: */
    31.1 --- a/src/joystick/win32/SDL_dxjoystick_c.h	Thu Jan 20 17:33:06 2011 -0800
    31.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    31.3 @@ -1,73 +0,0 @@
    31.4 -/*
    31.5 -    SDL - Simple DirectMedia Layer
    31.6 -    Copyright (C) 1997-2010 Sam Lantinga
    31.7 -
    31.8 -    This library is free software; you can redistribute it and/or
    31.9 -    modify it under the terms of the GNU Lesser General Public
   31.10 -    License as published by the Free Software Foundation; either
   31.11 -    version 2.1 of the License, or (at your option) any later version.
   31.12 -
   31.13 -    This library is distributed in the hope that it will be useful,
   31.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
   31.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   31.16 -    Lesser General Public License for more details.
   31.17 -
   31.18 -    You should have received a copy of the GNU Lesser General Public
   31.19 -    License along with this library; if not, write to the Free Software
   31.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   31.21 -
   31.22 -    Sam Lantinga
   31.23 -    slouken@libsdl.org
   31.24 -*/
   31.25 -#include "SDL_config.h"
   31.26 -
   31.27 -#ifndef SDL_JOYSTICK_DINPUT_H
   31.28 -
   31.29 -/* DirectInput joystick driver; written by Glenn Maynard, based on Andrei de
   31.30 - * A. Formiga's WINMM driver. 
   31.31 - *
   31.32 - * Hats and sliders are completely untested; the app I'm writing this for mostly
   31.33 - * doesn't use them and I don't own any joysticks with them. 
   31.34 - *
   31.35 - * We don't bother to use event notification here.  It doesn't seem to work
   31.36 - * with polled devices, and it's fine to call IDirectInputDevice2_GetDeviceData and
   31.37 - * let it return 0 events. */
   31.38 -
   31.39 -#define WIN32_LEAN_AND_MEAN
   31.40 -#include <windows.h>
   31.41 -
   31.42 -#define DIRECTINPUT_VERSION 0x0700      /* Need version 7 for force feedback. */
   31.43 -#include <dinput.h>
   31.44 -
   31.45 -
   31.46 -#define MAX_INPUTS	256     /* each joystick can have up to 256 inputs */
   31.47 -
   31.48 -
   31.49 -/* local types */
   31.50 -typedef enum Type
   31.51 -{ BUTTON, AXIS, HAT } Type;
   31.52 -
   31.53 -typedef struct input_t
   31.54 -{
   31.55 -    /* DirectInput offset for this input type: */
   31.56 -    DWORD ofs;
   31.57 -
   31.58 -    /* Button, axis or hat: */
   31.59 -    Type type;
   31.60 -
   31.61 -    /* SDL input offset: */
   31.62 -    Uint8 num;
   31.63 -} input_t;
   31.64 -
   31.65 -/* The private structure used to keep track of a joystick */
   31.66 -struct joystick_hwdata
   31.67 -{
   31.68 -    LPDIRECTINPUTDEVICE2 InputDevice;
   31.69 -    DIDEVCAPS Capabilities;
   31.70 -    int buffered;
   31.71 -
   31.72 -    input_t Inputs[MAX_INPUTS];
   31.73 -    int NumInputs;
   31.74 -};
   31.75 -
   31.76 -#endif /* SDL_JOYSTICK_DINPUT_H */
    32.1 --- a/src/joystick/win32/SDL_mmjoystick.c	Thu Jan 20 17:33:06 2011 -0800
    32.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    32.3 @@ -1,428 +0,0 @@
    32.4 -/*
    32.5 -    SDL - Simple DirectMedia Layer
    32.6 -    Copyright (C) 1997-2010 Sam Lantinga
    32.7 -
    32.8 -    This library is free software; you can redistribute it and/or
    32.9 -    modify it under the terms of the GNU Lesser General Public
   32.10 -    License as published by the Free Software Foundation; either
   32.11 -    version 2.1 of the License, or (at your option) any later version.
   32.12 -
   32.13 -    This library is distributed in the hope that it will be useful,
   32.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
   32.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   32.16 -    Lesser General Public License for more details.
   32.17 -
   32.18 -    You should have received a copy of the GNU Lesser General Public
   32.19 -    License along with this library; if not, write to the Free Software
   32.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   32.21 -
   32.22 -    Sam Lantinga
   32.23 -    slouken@libsdl.org
   32.24 -*/
   32.25 -#include "SDL_config.h"
   32.26 -
   32.27 -#ifdef SDL_JOYSTICK_WINMM
   32.28 -
   32.29 -/* Win32 MultiMedia Joystick driver, contributed by Andrei de A. Formiga */
   32.30 -
   32.31 -#define WIN32_LEAN_AND_MEAN
   32.32 -#include <windows.h>
   32.33 -#include <mmsystem.h>
   32.34 -#include <regstr.h>
   32.35 -
   32.36 -#include "SDL_events.h"
   32.37 -#include "SDL_joystick.h"
   32.38 -#include "../SDL_sysjoystick.h"
   32.39 -#include "../SDL_joystick_c.h"
   32.40 -
   32.41 -#define MAX_JOYSTICKS	16
   32.42 -#define MAX_AXES	6       /* each joystick can have up to 6 axes */
   32.43 -#define MAX_BUTTONS	32      /* and 32 buttons                      */
   32.44 -#define AXIS_MIN	-32768  /* minimum value for axis coordinate */
   32.45 -#define AXIS_MAX	32767   /* maximum value for axis coordinate */
   32.46 -/* limit axis to 256 possible positions to filter out noise */
   32.47 -#define JOY_AXIS_THRESHOLD      (((AXIS_MAX)-(AXIS_MIN))/256)
   32.48 -#define JOY_BUTTON_FLAG(n)	(1<<n)
   32.49 -
   32.50 -
   32.51 -/* array to hold joystick ID values */
   32.52 -static UINT SYS_JoystickID[MAX_JOYSTICKS];
   32.53 -static JOYCAPS SYS_Joystick[MAX_JOYSTICKS];
   32.54 -static char *SYS_JoystickName[MAX_JOYSTICKS];
   32.55 -
   32.56 -/* The private structure used to keep track of a joystick */
   32.57 -struct joystick_hwdata
   32.58 -{
   32.59 -    /* joystick ID */
   32.60 -    UINT id;
   32.61 -
   32.62 -    /* values used to translate device-specific coordinates into
   32.63 -       SDL-standard ranges */
   32.64 -    struct _transaxis
   32.65 -    {
   32.66 -        int offset;
   32.67 -        float scale;
   32.68 -    } transaxis[6];
   32.69 -};
   32.70 -
   32.71 -/* Convert a win32 Multimedia API return code to a text message */
   32.72 -static void SetMMerror(char *function, int code);
   32.73 -
   32.74 -
   32.75 -static char *
   32.76 -GetJoystickName(int index, const char *szRegKey)
   32.77 -{
   32.78 -    /* added 7/24/2004 by Eckhard Stolberg */
   32.79 -    /*
   32.80 -       see if there is a joystick for the current
   32.81 -       index (1-16) listed in the registry
   32.82 -     */
   32.83 -    char *name = NULL;
   32.84 -    HKEY hTopKey;
   32.85 -    HKEY hKey;
   32.86 -    DWORD regsize;
   32.87 -    LONG regresult;
   32.88 -    char regkey[256];
   32.89 -    char regvalue[256];
   32.90 -    char regname[256];
   32.91 -
   32.92 -    SDL_snprintf(regkey, SDL_arraysize(regkey), "%s\\%s\\%s",
   32.93 -                 REGSTR_PATH_JOYCONFIG, szRegKey, REGSTR_KEY_JOYCURR);
   32.94 -    hTopKey = HKEY_LOCAL_MACHINE;
   32.95 -    regresult = RegOpenKeyExA(hTopKey, regkey, 0, KEY_READ, &hKey);
   32.96 -    if (regresult != ERROR_SUCCESS) {
   32.97 -        hTopKey = HKEY_CURRENT_USER;
   32.98 -        regresult = RegOpenKeyExA(hTopKey, regkey, 0, KEY_READ, &hKey);
   32.99 -    }
  32.100 -    if (regresult != ERROR_SUCCESS) {
  32.101 -        return NULL;
  32.102 -    }
  32.103 -
  32.104 -    /* find the registry key name for the joystick's properties */
  32.105 -    regsize = sizeof(regname);
  32.106 -    SDL_snprintf(regvalue, SDL_arraysize(regvalue), "Joystick%d%s", index + 1,
  32.107 -                 REGSTR_VAL_JOYOEMNAME);
  32.108 -    regresult =
  32.109 -        RegQueryValueExA(hKey, regvalue, 0, 0, (LPBYTE) regname, &regsize);
  32.110 -    RegCloseKey(hKey);
  32.111 -
  32.112 -    if (regresult != ERROR_SUCCESS) {
  32.113 -        return NULL;
  32.114 -    }
  32.115 -
  32.116 -    /* open that registry key */
  32.117 -    SDL_snprintf(regkey, SDL_arraysize(regkey), "%s\\%s", REGSTR_PATH_JOYOEM,
  32.118 -                 regname);
  32.119 -    regresult = RegOpenKeyExA(hTopKey, regkey, 0, KEY_READ, &hKey);
  32.120 -    if (regresult != ERROR_SUCCESS) {
  32.121 -        return NULL;
  32.122 -    }
  32.123 -
  32.124 -    /* find the size for the OEM name text */
  32.125 -    regsize = sizeof(regvalue);
  32.126 -    regresult =
  32.127 -        RegQueryValueExA(hKey, REGSTR_VAL_JOYOEMNAME, 0, 0, NULL, &regsize);
  32.128 -    if (regresult == ERROR_SUCCESS) {
  32.129 -        /* allocate enough memory for the OEM name text ... */
  32.130 -        name = (char *) SDL_malloc(regsize);
  32.131 -        if (name) {
  32.132 -            /* ... and read it from the registry */
  32.133 -            regresult = RegQueryValueExA(hKey,
  32.134 -                                         REGSTR_VAL_JOYOEMNAME, 0, 0,
  32.135 -                                         (LPBYTE) name, &regsize);
  32.136 -        }
  32.137 -    }
  32.138 -    RegCloseKey(hKey);
  32.139 -
  32.140 -    return (name);
  32.141 -}
  32.142 -
  32.143 -/* Function to scan the system for joysticks.
  32.144 - * This function should set SDL_numjoysticks to the number of available
  32.145 - * joysticks.  Joystick 0 should be the system default joystick.
  32.146 - * It should return 0, or -1 on an unrecoverable fatal error.
  32.147 - */
  32.148 -int
  32.149 -SDL_SYS_JoystickInit(void)
  32.150 -{
  32.151 -    int i;
  32.152 -    int maxdevs;
  32.153 -    int numdevs;
  32.154 -    JOYINFOEX joyinfo;
  32.155 -    JOYCAPS joycaps;
  32.156 -    MMRESULT result;
  32.157 -
  32.158 -    /* Reset the joystick ID & name mapping tables */
  32.159 -    for (i = 0; i < MAX_JOYSTICKS; ++i) {
  32.160 -        SYS_JoystickID[i] = 0;
  32.161 -        SYS_JoystickName[i] = NULL;
  32.162 -    }
  32.163 -
  32.164 -    /* Loop over all potential joystick devices */
  32.165 -    numdevs = 0;
  32.166 -    maxdevs = joyGetNumDevs();
  32.167 -    for (i = JOYSTICKID1; i < maxdevs && numdevs < MAX_JOYSTICKS; ++i) {
  32.168 -
  32.169 -        joyinfo.dwSize = sizeof(joyinfo);
  32.170 -        joyinfo.dwFlags = JOY_RETURNALL;
  32.171 -        result = joyGetPosEx(i, &joyinfo);
  32.172 -        if (result == JOYERR_NOERROR) {
  32.173 -            result = joyGetDevCaps(i, &joycaps, sizeof(joycaps));
  32.174 -            if (result == JOYERR_NOERROR) {
  32.175 -                SYS_JoystickID[numdevs] = i;
  32.176 -                SYS_Joystick[numdevs] = joycaps;
  32.177 -                SYS_JoystickName[numdevs] =
  32.178 -                    GetJoystickName(i, joycaps.szRegKey);
  32.179 -                numdevs++;
  32.180 -            }
  32.181 -        }
  32.182 -    }
  32.183 -    return (numdevs);
  32.184 -}
  32.185 -
  32.186 -/* Function to get the device-dependent name of a joystick */
  32.187 -const char *
  32.188 -SDL_SYS_JoystickName(int index)
  32.189 -{
  32.190 -    if (SYS_JoystickName[index] != NULL) {
  32.191 -        return (SYS_JoystickName[index]);
  32.192 -    } else {
  32.193 -        return (SYS_Joystick[index].szPname);
  32.194 -    }
  32.195 -}
  32.196 -
  32.197 -/* Function to open a joystick for use.
  32.198 -   The joystick to open is specified by the index field of the joystick.
  32.199 -   This should fill the nbuttons and naxes fields of the joystick structure.
  32.200 -   It returns 0, or -1 if there is an error.
  32.201 - */
  32.202 -int
  32.203 -SDL_SYS_JoystickOpen(SDL_Joystick * joystick)
  32.204 -{
  32.205 -    int index, i;
  32.206 -    int caps_flags[MAX_AXES - 2] =
  32.207 -        { JOYCAPS_HASZ, JOYCAPS_HASR, JOYCAPS_HASU, JOYCAPS_HASV };
  32.208 -    int axis_min[MAX_AXES], axis_max[MAX_AXES];
  32.209 -
  32.210 -
  32.211 -    /* shortcut */
  32.212 -    index = joystick->index;
  32.213 -    axis_min[0] = SYS_Joystick[index].wXmin;
  32.214 -    axis_max[0] = SYS_Joystick[index].wXmax;
  32.215 -    axis_min[1] = SYS_Joystick[index].wYmin;
  32.216 -    axis_max[1] = SYS_Joystick[index].wYmax;
  32.217 -    axis_min[2] = SYS_Joystick[index].wZmin;
  32.218 -    axis_max[2] = SYS_Joystick[index].wZmax;
  32.219 -    axis_min[3] = SYS_Joystick[index].wRmin;
  32.220 -    axis_max[3] = SYS_Joystick[index].wRmax;
  32.221 -    axis_min[4] = SYS_Joystick[index].wUmin;
  32.222 -    axis_max[4] = SYS_Joystick[index].wUmax;
  32.223 -    axis_min[5] = SYS_Joystick[index].wVmin;
  32.224 -    axis_max[5] = SYS_Joystick[index].wVmax;
  32.225 -
  32.226 -    /* allocate memory for system specific hardware data */
  32.227 -    joystick->hwdata =
  32.228 -        (struct joystick_hwdata *) SDL_malloc(sizeof(*joystick->hwdata));
  32.229 -    if (joystick->hwdata == NULL) {
  32.230 -        SDL_OutOfMemory();
  32.231 -        return (-1);
  32.232 -    }
  32.233 -    SDL_memset(joystick->hwdata, 0, sizeof(*joystick->hwdata));
  32.234 -
  32.235 -    /* set hardware data */
  32.236 -    joystick->hwdata->id = SYS_JoystickID[index];
  32.237 -    for (i = 0; i < MAX_AXES; ++i) {
  32.238 -        if ((i < 2) || (SYS_Joystick[index].wCaps & caps_flags[i - 2])) {
  32.239 -            joystick->hwdata->transaxis[i].offset = AXIS_MIN - axis_min[i];
  32.240 -            joystick->hwdata->transaxis[i].scale =
  32.241 -                (float) (AXIS_MAX - AXIS_MIN) / (axis_max[i] - axis_min[i]);
  32.242 -        } else {
  32.243 -            joystick->hwdata->transaxis[i].offset = 0;
  32.244 -            joystick->hwdata->transaxis[i].scale = 1.0; /* Just in case */
  32.245 -        }
  32.246 -    }
  32.247 -
  32.248 -    /* fill nbuttons, naxes, and nhats fields */
  32.249 -    joystick->nbuttons = SYS_Joystick[index].wNumButtons;
  32.250 -    joystick->naxes = SYS_Joystick[index].wNumAxes;
  32.251 -    if (SYS_Joystick[index].wCaps & JOYCAPS_HASPOV) {
  32.252 -        joystick->nhats = 1;
  32.253 -    } else {
  32.254 -        joystick->nhats = 0;
  32.255 -    }
  32.256 -    return (0);
  32.257 -}
  32.258 -
  32.259 -static Uint8
  32.260 -TranslatePOV(DWORD value)
  32.261 -{
  32.262 -    Uint8 pos;
  32.263 -
  32.264 -    pos = SDL_HAT_CENTERED;
  32.265 -    if (value != JOY_POVCENTERED) {
  32.266 -        if ((value > JOY_POVLEFT) || (value < JOY_POVRIGHT)) {
  32.267 -            pos |= SDL_HAT_UP;
  32.268 -        }
  32.269 -        if ((value > JOY_POVFORWARD) && (value < JOY_POVBACKWARD)) {
  32.270 -            pos |= SDL_HAT_RIGHT;
  32.271 -        }
  32.272 -        if ((value > JOY_POVRIGHT) && (value < JOY_POVLEFT)) {
  32.273 -            pos |= SDL_HAT_DOWN;
  32.274 -        }
  32.275 -        if (value > JOY_POVBACKWARD) {
  32.276 -            pos |= SDL_HAT_LEFT;
  32.277 -        }
  32.278 -    }
  32.279 -    return (pos);
  32.280 -}
  32.281 -
  32.282 -/* Function to update the state of a joystick - called as a device poll.
  32.283 - * This function shouldn't update the joystick structure directly,
  32.284 - * but instead should call SDL_PrivateJoystick*() to deliver events
  32.285 - * and update joystick device state.
  32.286 - */
  32.287 -void
  32.288 -SDL_SYS_JoystickUpdate(SDL_Joystick * joystick)
  32.289 -{
  32.290 -    MMRESULT result;
  32.291 -    int i;
  32.292 -    DWORD flags[MAX_AXES] = { JOY_RETURNX, JOY_RETURNY, JOY_RETURNZ,
  32.293 -        JOY_RETURNR, JOY_RETURNU, JOY_RETURNV
  32.294 -    };
  32.295 -    DWORD pos[MAX_AXES];
  32.296 -    struct _transaxis *transaxis;
  32.297 -    int value, change;
  32.298 -    JOYINFOEX joyinfo;
  32.299 -
  32.300 -    joyinfo.dwSize = sizeof(joyinfo);
  32.301 -    joyinfo.dwFlags = JOY_RETURNALL | JOY_RETURNPOVCTS;
  32.302 -    if (!joystick->hats) {
  32.303 -        joyinfo.dwFlags &= ~(JOY_RETURNPOV | JOY_RETURNPOVCTS);
  32.304 -    }
  32.305 -    result = joyGetPosEx(joystick->hwdata->id, &joyinfo);
  32.306 -    if (result != JOYERR_NOERROR) {
  32.307 -        SetMMerror("joyGetPosEx", result);
  32.308 -        return;
  32.309 -    }
  32.310 -
  32.311 -    /* joystick motion events */
  32.312 -    pos[0] = joyinfo.dwXpos;
  32.313 -    pos[1] = joyinfo.dwYpos;
  32.314 -    pos[2] = joyinfo.dwZpos;
  32.315 -    pos[3] = joyinfo.dwRpos;
  32.316 -    pos[4] = joyinfo.dwUpos;
  32.317 -    pos[5] = joyinfo.dwVpos;
  32.318 -
  32.319 -    transaxis = joystick->hwdata->transaxis;
  32.320 -    for (i = 0; i < joystick->naxes; i++) {
  32.321 -        if (joyinfo.dwFlags & flags[i]) {
  32.322 -            value =
  32.323 -                (int) (((float) pos[i] +
  32.324 -                        transaxis[i].offset) * transaxis[i].scale);
  32.325 -            change = (value - joystick->axes[i]);
  32.326 -            if ((change < -JOY_AXIS_THRESHOLD)
  32.327 -                || (change > JOY_AXIS_THRESHOLD)) {
  32.328 -                SDL_PrivateJoystickAxis(joystick, (Uint8) i, (Sint16) value);
  32.329 -            }
  32.330 -        }
  32.331 -    }
  32.332 -
  32.333 -    /* joystick button events */
  32.334 -    if (joyinfo.dwFlags & JOY_RETURNBUTTONS) {
  32.335 -        for (i = 0; i < joystick->nbuttons; ++i) {
  32.336 -            if (joyinfo.dwButtons & JOY_BUTTON_FLAG(i)) {
  32.337 -                if (!joystick->buttons[i]) {
  32.338 -                    SDL_PrivateJoystickButton(joystick, (Uint8) i,
  32.339 -                                              SDL_PRESSED);
  32.340 -                }
  32.341 -            } else {
  32.342 -                if (joystick->buttons[i]) {
  32.343 -                    SDL_PrivateJoystickButton(joystick, (Uint8) i,
  32.344 -                                              SDL_RELEASED);
  32.345 -                }
  32.346 -            }
  32.347 -        }
  32.348 -    }
  32.349 -
  32.350 -    /* joystick hat events */
  32.351 -    if (joyinfo.dwFlags & JOY_RETURNPOV) {
  32.352 -        Uint8 pos;
  32.353 -
  32.354 -        pos = TranslatePOV(joyinfo.dwPOV);
  32.355 -        if (pos != joystick->hats[0]) {
  32.356 -            SDL_PrivateJoystickHat(joystick, 0, pos);
  32.357 -        }
  32.358 -    }
  32.359 -}
  32.360 -
  32.361 -/* Function to close a joystick after use */
  32.362 -void
  32.363 -SDL_SYS_JoystickClose(SDL_Joystick * joystick)
  32.364 -{
  32.365 -    if (joystick->hwdata != NULL) {
  32.366 -        /* free system specific hardware data */
  32.367 -        SDL_free(joystick->hwdata);
  32.368 -        joystick->hwdata = NULL;
  32.369 -    }
  32.370 -}
  32.371 -
  32.372 -/* Function to perform any system-specific joystick related cleanup */
  32.373 -void
  32.374 -SDL_SYS_JoystickQuit(void)
  32.375 -{
  32.376 -    int i;
  32.377 -    for (i = 0; i < MAX_JOYSTICKS; i++) {
  32.378 -        if (SYS_JoystickName[i] != NULL) {
  32.379 -            SDL_free(SYS_JoystickName[i]);
  32.380 -            SYS_JoystickName[i] = NULL;
  32.381 -        }
  32.382 -    }
  32.383 -}
  32.384 -
  32.385 -
  32.386 -/* implementation functions */
  32.387 -void
  32.388 -SetMMerror(char *function, int code)
  32.389 -{
  32.390 -    static char *error;
  32.391 -    static char errbuf[1024];
  32.392 -
  32.393 -    errbuf[0] = 0;
  32.394 -    switch (code) {
  32.395 -    case MMSYSERR_NODRIVER:
  32.396 -        error = "Joystick driver not present";
  32.397 -        break;
  32.398 -
  32.399 -    case MMSYSERR_INVALPARAM:
  32.400 -    case JOYERR_PARMS:
  32.401 -        error = "Invalid parameter(s)";
  32.402 -        break;
  32.403 -
  32.404 -    case MMSYSERR_BADDEVICEID:
  32.405 -        error = "Bad device ID";
  32.406 -        break;
  32.407 -
  32.408 -    case JOYERR_UNPLUGGED:
  32.409 -        error = "Joystick not attached";
  32.410 -        break;
  32.411 -
  32.412 -    case JOYERR_NOCANDO:
  32.413 -        error = "Can't capture joystick input";
  32.414 -        break;
  32.415 -
  32.416 -    default:
  32.417 -        SDL_snprintf(errbuf, SDL_arraysize(errbuf),
  32.418 -                     "%s: Unknown Multimedia system error: 0x%x",
  32.419 -                     function, code);
  32.420 -        break;
  32.421 -    }
  32.422 -
  32.423 -    if (!errbuf[0]) {
  32.424 -        SDL_snprintf(errbuf, SDL_arraysize(errbuf), "%s: %s", function,
  32.425 -                     error);
  32.426 -    }
  32.427 -    SDL_SetError("%s", errbuf);
  32.428 -}
  32.429 -
  32.430 -#endif /* SDL_JOYSTICK_WINMM */
  32.431 -/* vi: set ts=4 sw=4 expandtab: */
    33.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    33.2 +++ b/src/joystick/windows/SDL_dxjoystick.c	Thu Jan 20 18:04:05 2011 -0800
    33.3 @@ -0,0 +1,802 @@
    33.4 +/*
    33.5 +    SDL - Simple DirectMedia Layer
    33.6 +    Copyright (C) 1997-2010 Sam Lantinga
    33.7 +
    33.8 +    This library is free software; you can redistribute it and/or
    33.9 +    modify it under the terms of the GNU Lesser General Public
   33.10 +    License as published by the Free Software Foundation; either
   33.11 +    version 2.1 of the License, or (at your option) any later version.
   33.12 +
   33.13 +    This library is distributed in the hope that it will be useful,
   33.14 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
   33.15 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   33.16 +    Lesser General Public License for more details.
   33.17 +
   33.18 +    You should have received a copy of the GNU Lesser General Public
   33.19 +    License along with this library; if not, write to the Free Software
   33.20 +    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   33.21 +
   33.22 +    Sam Lantinga
   33.23 +    slouken@libsdl.org
   33.24 +*/
   33.25 +#include "SDL_config.h"
   33.26 +
   33.27 +#ifdef SDL_JOYSTICK_DINPUT
   33.28 +
   33.29 +/* DirectInput joystick driver; written by Glenn Maynard, based on Andrei de
   33.30 + * A. Formiga's WINMM driver. 
   33.31 + *
   33.32 + * Hats and sliders are completely untested; the app I'm writing this for mostly
   33.33 + * doesn't use them and I don't own any joysticks with them. 
   33.34 + *
   33.35 + * We don't bother to use event notification here.  It doesn't seem to work
   33.36 + * with polled devices, and it's fine to call IDirectInputDevice2_GetDeviceData and
   33.37 + * let it return 0 events. */
   33.38 +
   33.39 +#include "SDL_error.h"
   33.40 +#include "SDL_events.h"
   33.41 +#include "SDL_joystick.h"
   33.42 +#include "../SDL_sysjoystick.h"
   33.43 +#include "../SDL_joystick_c.h"
   33.44 +#define INITGUID /* Only set here, if set twice will cause mingw32 to break. */
   33.45 +#include "SDL_dxjoystick_c.h"
   33.46 +
   33.47 +
   33.48 +#ifndef DIDFT_OPTIONAL
   33.49 +#define DIDFT_OPTIONAL		0x80000000
   33.50 +#endif
   33.51 +
   33.52 +
   33.53 +#define INPUT_QSIZE	32      /* Buffer up to 32 input messages */
   33.54 +#define MAX_JOYSTICKS	8
   33.55 +#define AXIS_MIN	-32768  /* minimum value for axis coordinate */
   33.56 +#define AXIS_MAX	32767   /* maximum value for axis coordinate */
   33.57 +#define JOY_AXIS_THRESHOLD	(((AXIS_MAX)-(AXIS_MIN))/100)   /* 1% motion */
   33.58 +
   33.59 +/* external variables referenced. */
   33.60 +extern HWND SDL_HelperWindow;
   33.61 +
   33.62 +
   33.63 +/* local variables */
   33.64 +static LPDIRECTINPUT dinput = NULL;
   33.65 +extern HRESULT(WINAPI * DInputCreate) (HINSTANCE hinst, DWORD dwVersion,
   33.66 +                                       LPDIRECTINPUT * ppDI,
   33.67 +                                       LPUNKNOWN punkOuter);
   33.68 +static DIDEVICEINSTANCE SYS_Joystick[MAX_JOYSTICKS];    /* array to hold joystick ID values */
   33.69 +static int SYS_NumJoysticks;
   33.70 +static HINSTANCE DInputDLL = NULL;
   33.71 +
   33.72 +
   33.73 +/* local prototypes */
   33.74 +static void SetDIerror(const char *function, HRESULT code);
   33.75 +static BOOL CALLBACK EnumJoysticksCallback(const DIDEVICEINSTANCE *
   33.76 +                                           pdidInstance, VOID * pContext);
   33.77 +static BOOL CALLBACK EnumDevObjectsCallback(LPCDIDEVICEOBJECTINSTANCE dev,
   33.78 +                                            LPVOID pvRef);
   33.79 +static Uint8 TranslatePOV(DWORD value);
   33.80 +static int SDL_PrivateJoystickAxis_Int(SDL_Joystick * joystick, Uint8 axis,
   33.81 +                                       Sint16 value);
   33.82 +static int SDL_PrivateJoystickHat_Int(SDL_Joystick * joystick, Uint8 hat,
   33.83 +                                      Uint8 value);
   33.84 +static int SDL_PrivateJoystickButton_Int(SDL_Joystick * joystick,
   33.85 +                                         Uint8 button, Uint8 state);
   33.86 +
   33.87 +/* Taken from Wine - Thanks! */
   33.88 +DIOBJECTDATAFORMAT dfDIJoystick2[] = {
   33.89 +  { &GUID_XAxis,DIJOFS_X,DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
   33.90 +  { &GUID_YAxis,DIJOFS_Y,DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
   33.91 +  { &GUID_ZAxis,DIJOFS_Z,DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
   33.92 +  { &GUID_RxAxis,DIJOFS_RX,DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
   33.93 +  { &GUID_RyAxis,DIJOFS_RY,DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
   33.94 +  { &GUID_RzAxis,DIJOFS_RZ,DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
   33.95 +  { &GUID_Slider,DIJOFS_SLIDER(0),DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
   33.96 +  { &GUID_Slider,DIJOFS_SLIDER(1),DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
   33.97 +  { &GUID_POV,DIJOFS_POV(0),DIDFT_OPTIONAL|DIDFT_POV|DIDFT_ANYINSTANCE,0},
   33.98 +  { &GUID_POV,DIJOFS_POV(1),DIDFT_OPTIONAL|DIDFT_POV|DIDFT_ANYINSTANCE,0},
   33.99 +  { &GUID_POV,DIJOFS_POV(2),DIDFT_OPTIONAL|DIDFT_POV|DIDFT_ANYINSTANCE,0},
  33.100 +  { &GUID_POV,DIJOFS_POV(3),DIDFT_OPTIONAL|DIDFT_POV|DIDFT_ANYINSTANCE,0},
  33.101 +  { NULL,DIJOFS_BUTTON(0),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  33.102 +  { NULL,DIJOFS_BUTTON(1),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  33.103 +  { NULL,DIJOFS_BUTTON(2),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  33.104 +  { NULL,DIJOFS_BUTTON(3),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  33.105 +  { NULL,DIJOFS_BUTTON(4),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  33.106 +  { NULL,DIJOFS_BUTTON(5),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  33.107 +  { NULL,DIJOFS_BUTTON(6),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  33.108 +  { NULL,DIJOFS_BUTTON(7),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  33.109 +  { NULL,DIJOFS_BUTTON(8),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  33.110 +  { NULL,DIJOFS_BUTTON(9),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  33.111 +  { NULL,DIJOFS_BUTTON(10),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  33.112 +  { NULL,DIJOFS_BUTTON(11),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  33.113 +  { NULL,DIJOFS_BUTTON(12),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  33.114 +  { NULL,DIJOFS_BUTTON(13),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  33.115 +  { NULL,DIJOFS_BUTTON(14),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  33.116 +  { NULL,DIJOFS_BUTTON(15),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  33.117 +  { NULL,DIJOFS_BUTTON(16),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  33.118 +  { NULL,DIJOFS_BUTTON(17),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  33.119 +  { NULL,DIJOFS_BUTTON(18),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  33.120 +  { NULL,DIJOFS_BUTTON(19),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  33.121 +  { NULL,DIJOFS_BUTTON(20),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  33.122 +  { NULL,DIJOFS_BUTTON(21),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  33.123 +  { NULL,DIJOFS_BUTTON(22),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  33.124 +  { NULL,DIJOFS_BUTTON(23),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  33.125 +  { NULL,DIJOFS_BUTTON(24),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  33.126 +  { NULL,DIJOFS_BUTTON(25),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  33.127 +  { NULL,DIJOFS_BUTTON(26),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  33.128 +  { NULL,DIJOFS_BUTTON(27),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  33.129 +  { NULL,DIJOFS_BUTTON(28),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  33.130 +  { NULL,DIJOFS_BUTTON(29),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  33.131 +  { NULL,DIJOFS_BUTTON(30),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  33.132 +  { NULL,DIJOFS_BUTTON(31),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  33.133 +  { NULL,DIJOFS_BUTTON(32),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  33.134 +  { NULL,DIJOFS_BUTTON(33),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  33.135 +  { NULL,DIJOFS_BUTTON(34),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  33.136 +  { NULL,DIJOFS_BUTTON(35),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  33.137 +  { NULL,DIJOFS_BUTTON(36),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  33.138 +  { NULL,DIJOFS_BUTTON(37),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  33.139 +  { NULL,DIJOFS_BUTTON(38),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  33.140 +  { NULL,DIJOFS_BUTTON(39),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  33.141 +  { NULL,DIJOFS_BUTTON(40),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  33.142 +  { NULL,DIJOFS_BUTTON(41),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  33.143 +  { NULL,DIJOFS_BUTTON(42),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  33.144 +  { NULL,DIJOFS_BUTTON(43),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  33.145 +  { NULL,DIJOFS_BUTTON(44),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  33.146 +  { NULL,DIJOFS_BUTTON(45),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  33.147 +  { NULL,DIJOFS_BUTTON(46),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  33.148 +  { NULL,DIJOFS_BUTTON(47),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  33.149 +  { NULL,DIJOFS_BUTTON(48),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  33.150 +  { NULL,DIJOFS_BUTTON(49),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  33.151 +  { NULL,DIJOFS_BUTTON(50),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  33.152 +  { NULL,DIJOFS_BUTTON(51),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  33.153 +  { NULL,DIJOFS_BUTTON(52),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  33.154 +  { NULL,DIJOFS_BUTTON(53),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  33.155 +  { NULL,DIJOFS_BUTTON(54),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  33.156 +  { NULL,DIJOFS_BUTTON(55),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  33.157 +  { NULL,DIJOFS_BUTTON(56),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  33.158 +  { NULL,DIJOFS_BUTTON(57),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  33.159 +  { NULL,DIJOFS_BUTTON(58),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  33.160 +  { NULL,DIJOFS_BUTTON(59),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  33.161 +  { NULL,DIJOFS_BUTTON(60),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  33.162 +  { NULL,DIJOFS_BUTTON(61),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  33.163 +  { NULL,DIJOFS_BUTTON(62),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  33.164 +  { NULL,DIJOFS_BUTTON(63),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  33.165 +  { NULL,DIJOFS_BUTTON(64),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  33.166 +  { NULL,DIJOFS_BUTTON(65),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  33.167 +  { NULL,DIJOFS_BUTTON(66),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  33.168 +  { NULL,DIJOFS_BUTTON(67),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  33.169 +  { NULL,DIJOFS_BUTTON(68),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  33.170 +  { NULL,DIJOFS_BUTTON(69),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  33.171 +  { NULL,DIJOFS_BUTTON(70),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  33.172 +  { NULL,DIJOFS_BUTTON(71),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  33.173 +  { NULL,DIJOFS_BUTTON(72),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  33.174 +  { NULL,DIJOFS_BUTTON(73),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  33.175 +  { NULL,DIJOFS_BUTTON(74),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  33.176 +  { NULL,DIJOFS_BUTTON(75),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  33.177 +  { NULL,DIJOFS_BUTTON(76),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  33.178 +  { NULL,DIJOFS_BUTTON(77),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  33.179 +  { NULL,DIJOFS_BUTTON(78),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  33.180 +  { NULL,DIJOFS_BUTTON(79),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  33.181 +  { NULL,DIJOFS_BUTTON(80),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  33.182 +  { NULL,DIJOFS_BUTTON(81),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  33.183 +  { NULL,DIJOFS_BUTTON(82),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  33.184 +  { NULL,DIJOFS_BUTTON(83),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  33.185 +  { NULL,DIJOFS_BUTTON(84),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  33.186 +  { NULL,DIJOFS_BUTTON(85),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  33.187 +  { NULL,DIJOFS_BUTTON(86),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  33.188 +  { NULL,DIJOFS_BUTTON(87),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  33.189 +  { NULL,DIJOFS_BUTTON(88),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  33.190 +  { NULL,DIJOFS_BUTTON(89),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  33.191 +  { NULL,DIJOFS_BUTTON(90),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  33.192 +  { NULL,DIJOFS_BUTTON(91),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  33.193 +  { NULL,DIJOFS_BUTTON(92),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  33.194 +  { NULL,DIJOFS_BUTTON(93),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  33.195 +  { NULL,DIJOFS_BUTTON(94),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  33.196 +  { NULL,DIJOFS_BUTTON(95),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  33.197 +  { NULL,DIJOFS_BUTTON(96),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  33.198 +  { NULL,DIJOFS_BUTTON(97),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  33.199 +  { NULL,DIJOFS_BUTTON(98),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  33.200 +  { NULL,DIJOFS_BUTTON(99),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  33.201 +  { NULL,DIJOFS_BUTTON(100),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  33.202 +  { NULL,DIJOFS_BUTTON(101),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  33.203 +  { NULL,DIJOFS_BUTTON(102),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  33.204 +  { NULL,DIJOFS_BUTTON(103),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  33.205 +  { NULL,DIJOFS_BUTTON(104),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  33.206 +  { NULL,DIJOFS_BUTTON(105),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  33.207 +  { NULL,DIJOFS_BUTTON(106),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  33.208 +  { NULL,DIJOFS_BUTTON(107),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  33.209 +  { NULL,DIJOFS_BUTTON(108),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  33.210 +  { NULL,DIJOFS_BUTTON(109),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  33.211 +  { NULL,DIJOFS_BUTTON(110),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  33.212 +  { NULL,DIJOFS_BUTTON(111),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  33.213 +  { NULL,DIJOFS_BUTTON(112),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  33.214 +  { NULL,DIJOFS_BUTTON(113),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  33.215 +  { NULL,DIJOFS_BUTTON(114),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  33.216 +  { NULL,DIJOFS_BUTTON(115),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  33.217 +  { NULL,DIJOFS_BUTTON(116),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  33.218 +  { NULL,DIJOFS_BUTTON(117),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  33.219 +  { NULL,DIJOFS_BUTTON(118),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  33.220 +  { NULL,DIJOFS_BUTTON(119),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  33.221 +  { NULL,DIJOFS_BUTTON(120),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  33.222 +  { NULL,DIJOFS_BUTTON(121),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  33.223 +  { NULL,DIJOFS_BUTTON(122),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  33.224 +  { NULL,DIJOFS_BUTTON(123),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  33.225 +  { NULL,DIJOFS_BUTTON(124),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  33.226 +  { NULL,DIJOFS_BUTTON(125),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  33.227 +  { NULL,DIJOFS_BUTTON(126),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  33.228 +  { NULL,DIJOFS_BUTTON(127),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
  33.229 +  { &GUID_XAxis,FIELD_OFFSET(DIJOYSTATE2,lVX),DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
  33.230 +  { &GUID_YAxis,FIELD_OFFSET(DIJOYSTATE2,lVY),DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
  33.231 +  { &GUID_ZAxis,FIELD_OFFSET(DIJOYSTATE2,lVZ),DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
  33.232 +  { &GUID_RxAxis,FIELD_OFFSET(DIJOYSTATE2,lVRx),DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
  33.233 +  { &GUID_RyAxis,FIELD_OFFSET(DIJOYSTATE2,lVRy),DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
  33.234 +  { &GUID_RzAxis,FIELD_OFFSET(DIJOYSTATE2,lVRz),DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
  33.235 +  { &GUID_Slider,FIELD_OFFSET(DIJOYSTATE2,rglVSlider[0]),DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
  33.236 +  { &GUID_Slider,FIELD_OFFSET(DIJOYSTATE2,rglVSlider[1]),DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
  33.237 +  { &GUID_XAxis,FIELD_OFFSET(DIJOYSTATE2,lAX),DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
  33.238 +  { &GUID_YAxis,FIELD_OFFSET(DIJOYSTATE2,lAY),DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
  33.239 +  { &GUID_ZAxis,FIELD_OFFSET(DIJOYSTATE2,lAZ),DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
  33.240 +  { &GUID_RxAxis,FIELD_OFFSET(DIJOYSTATE2,lARx),DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
  33.241 +  { &GUID_RyAxis,FIELD_OFFSET(DIJOYSTATE2,lARy),DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
  33.242 +  { &GUID_RzAxis,FIELD_OFFSET(DIJOYSTATE2,lARz),DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
  33.243 +  { &GUID_Slider,FIELD_OFFSET(DIJOYSTATE2,rglASlider[0]),DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
  33.244 +  { &GUID_Slider,FIELD_OFFSET(DIJOYSTATE2,rglASlider[1]),DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
  33.245 +  { &GUID_XAxis,FIELD_OFFSET(DIJOYSTATE2,lFX),DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
  33.246 +  { &GUID_YAxis,FIELD_OFFSET(DIJOYSTATE2,lFY),DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
  33.247 +  { &GUID_ZAxis,FIELD_OFFSET(DIJOYSTATE2,lFZ),DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
  33.248 +  { &GUID_RxAxis,FIELD_OFFSET(DIJOYSTATE2,lFRx),DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
  33.249 +  { &GUID_RyAxis,FIELD_OFFSET(DIJOYSTATE2,lFRy),DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
  33.250 +  { &GUID_RzAxis,FIELD_OFFSET(DIJOYSTATE2,lFRz),DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
  33.251 +  { &GUID_Slider,FIELD_OFFSET(DIJOYSTATE2,rglFSlider[0]),DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
  33.252 +  { &GUID_Slider,FIELD_OFFSET(DIJOYSTATE2,rglFSlider[1]),DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
  33.253 +};
  33.254 +
  33.255 +const DIDATAFORMAT c_dfDIJoystick2 = {
  33.256 +    sizeof(DIDATAFORMAT),
  33.257 +    sizeof(DIOBJECTDATAFORMAT),
  33.258 +    DIDF_ABSAXIS,
  33.259 +    sizeof(DIJOYSTATE2),
  33.260 +    SDL_arraysize(dfDIJoystick2),
  33.261 +    dfDIJoystick2
  33.262 +};
  33.263 +
  33.264 +
  33.265 +/* Convert a DirectInput return code to a text message */
  33.266 +static void
  33.267 +SetDIerror(const char *function, HRESULT code)
  33.268 +{
  33.269 +    /*
  33.270 +    SDL_SetError("%s() [%s]: %s", function,
  33.271 +                 DXGetErrorString9A(code), DXGetErrorDescription9A(code));
  33.272 +     */
  33.273 +    SDL_SetError("%s() DirectX error %d", function, code);
  33.274 +}
  33.275 +
  33.276 +
  33.277 +/* Function to scan the system for joysticks.
  33.278 + * This function should set SDL_numjoysticks to the number of available
  33.279 + * joysticks.  Joystick 0 should be the system default joystick.
  33.280 + * It should return 0, or -1 on an unrecoverable fatal error.
  33.281 + */
  33.282 +int
  33.283 +SDL_SYS_JoystickInit(void)
  33.284 +{
  33.285 +    HRESULT result;
  33.286 +    HINSTANCE instance;
  33.287 +
  33.288 +    SYS_NumJoysticks = 0;
  33.289 +
  33.290 +    result = CoInitialize(NULL);
  33.291 +    if (FAILED(result)) {
  33.292 +        SetDIerror("CoInitialize", result);
  33.293 +        return (-1);
  33.294 +    }
  33.295 +
  33.296 +    result = CoCreateInstance(&CLSID_DirectInput, NULL, CLSCTX_INPROC_SERVER,
  33.297 +                              &IID_IDirectInput, (LPVOID)&dinput);
  33.298 +
  33.299 +    if (FAILED(result)) {
  33.300 +        SetDIerror("CoCreateInstance", result);
  33.301 +        return (-1);
  33.302 +    }
  33.303 +
  33.304 +    /* Because we used CoCreateInstance, we need to Initialize it, first. */
  33.305 +    instance = GetModuleHandle(NULL);
  33.306 +    if (instance == NULL) {
  33.307 +        SDL_SetError("GetModuleHandle() failed with error code %d.",
  33.308 +                     GetLastError());
  33.309 +        return (-1);
  33.310 +    }
  33.311 +    result = IDirectInput_Initialize(dinput, instance, DIRECTINPUT_VERSION);
  33.312 +
  33.313 +    if (FAILED(result)) {
  33.314 +        SetDIerror("IDirectInput::Initialize", result);
  33.315 +        return (-1);
  33.316 +    }
  33.317 +
  33.318 +    /* Look for joysticks, wheels, head trackers, gamepads, etc.. */
  33.319 +    result = IDirectInput_EnumDevices(dinput,
  33.320 +                                      DIDEVTYPE_JOYSTICK,
  33.321 +                                      EnumJoysticksCallback,
  33.322 +                                      NULL, DIEDFL_ATTACHEDONLY);
  33.323 +
  33.324 +    return SYS_NumJoysticks;
  33.325 +}
  33.326 +
  33.327 +static BOOL CALLBACK
  33.328 +EnumJoysticksCallback(const DIDEVICEINSTANCE * pdidInstance, VOID * pContext)
  33.329 +{
  33.330 +    SDL_memcpy(&SYS_Joystick[SYS_NumJoysticks], pdidInstance,
  33.331 +               sizeof(DIDEVICEINSTANCE));
  33.332 +    SYS_NumJoysticks++;
  33.333 +
  33.334 +    if (SYS_NumJoysticks >= MAX_JOYSTICKS)
  33.335 +        return DIENUM_STOP;
  33.336 +
  33.337 +    return DIENUM_CONTINUE;
  33.338 +}
  33.339 +
  33.340 +/* Function to get the device-dependent name of a joystick */
  33.341 +const char *
  33.342 +SDL_SYS_JoystickName(int index)
  33.343 +{
  33.344 +        /***-> test for invalid index ? */
  33.345 +    return (SYS_Joystick[index].tszProductName);
  33.346 +}
  33.347 +
  33.348 +/* Function to open a joystick for use.
  33.349 +   The joystick to open is specified by the index field of the joystick.
  33.350 +   This should fill the nbuttons and naxes fields of the joystick structure.
  33.351 +   It returns 0, or -1 if there is an error.
  33.352 + */
  33.353 +int
  33.354 +SDL_SYS_JoystickOpen(SDL_Joystick * joystick)
  33.355 +{
  33.356 +    HRESULT result;
  33.357 +    LPDIRECTINPUTDEVICE device;
  33.358 +    DIPROPDWORD dipdw;
  33.359 +
  33.360 +    SDL_memset(&dipdw, 0, sizeof(DIPROPDWORD));
  33.361 +    dipdw.diph.dwSize = sizeof(DIPROPDWORD);
  33.362 +    dipdw.diph.dwHeaderSize = sizeof(DIPROPHEADER);
  33.363 +
  33.364 +
  33.365 +    /* allocate memory for system specific hardware data */
  33.366 +    joystick->hwdata =
  33.367 +        (struct joystick_hwdata *) SDL_malloc(sizeof(struct joystick_hwdata));
  33.368 +    if (joystick->hwdata == NULL) {
  33.369 +        SDL_OutOfMemory();
  33.370 +        return (-1);
  33.371 +    }
  33.372 +    SDL_memset(joystick->hwdata, 0, sizeof(struct joystick_hwdata));
  33.373 +    joystick->hwdata->buffered = 1;
  33.374 +    joystick->hwdata->Capabilities.dwSize = sizeof(DIDEVCAPS);
  33.375 +
  33.376 +    result =
  33.377 +        IDirectInput_CreateDevice(dinput,
  33.378 +                                  &SYS_Joystick[joystick->index].
  33.379 +                                  guidInstance, &device, NULL);
  33.380 +    if (FAILED(result)) {
  33.381 +        SetDIerror("IDirectInput::CreateDevice", result);
  33.382 +        return (-1);
  33.383 +    }
  33.384 +
  33.385 +    /* Now get the IDirectInputDevice2 interface, instead. */
  33.386 +    result = IDirectInputDevice_QueryInterface(device,
  33.387 +                                               &IID_IDirectInputDevice2,
  33.388 +                                               (LPVOID *) & joystick->
  33.389 +                                               hwdata->InputDevice);
  33.390 +    /* We are done with this object.  Use the stored one from now on. */
  33.391 +    IDirectInputDevice_Release(device);
  33.392 +
  33.393 +    if (FAILED(result)) {
  33.394 +        SetDIerror("IDirectInputDevice::QueryInterface", result);
  33.395 +        return (-1);
  33.396 +    }
  33.397 +
  33.398 +    /* Aquire shared access. Exclusive access is required for forces,
  33.399 +     * though. */
  33.400 +    result =
  33.401 +        IDirectInputDevice2_SetCooperativeLevel(joystick->hwdata->
  33.402 +                                                InputDevice, SDL_HelperWindow,
  33.403 +                                                DISCL_EXCLUSIVE |
  33.404 +                                                DISCL_BACKGROUND);
  33.405 +    if (FAILED(result)) {
  33.406 +        SetDIerror("IDirectInputDevice2::SetCooperativeLevel", result);
  33.407 +        return (-1);
  33.408 +    }
  33.409 +
  33.410 +    /* Use the extended data structure: DIJOYSTATE2. */
  33.411 +    result =
  33.412 +        IDirectInputDevice2_SetDataFormat(joystick->hwdata->InputDevice,
  33.413 +                                          &c_dfDIJoystick2);
  33.414 +    if (FAILED(result)) {
  33.415 +        SetDIerror("IDirectInputDevice2::SetDataFormat", result);
  33.416 +        return (-1);
  33.417 +    }
  33.418 +
  33.419 +    /* Get device capabilities */
  33.420 +    result =
  33.421 +        IDirectInputDevice2_GetCapabilities(joystick->hwdata->InputDevice,
  33.422 +                                            &joystick->hwdata->Capabilities);
  33.423 +
  33.424 +    if (FAILED(result)) {
  33.425 +        SetDIerror("IDirectInputDevice2::GetCapabilities", result);
  33.426 +        return (-1);
  33.427 +    }
  33.428 +
  33.429 +    /* Force capable? */
  33.430 +    if (joystick->hwdata->Capabilities.dwFlags & DIDC_FORCEFEEDBACK) {
  33.431 +
  33.432 +        result = IDirectInputDevice2_Acquire(joystick->hwdata->InputDevice);
  33.433 +
  33.434 +        if (FAILED(result)) {
  33.435 +            SetDIerror("IDirectInputDevice2::Acquire", result);
  33.436 +            return (-1);
  33.437 +        }
  33.438 +
  33.439 +        /* reset all accuators. */
  33.440 +        result =
  33.441 +            IDirectInputDevice2_SendForceFeedbackCommand(joystick->hwdata->
  33.442 +                                                         InputDevice,
  33.443 +                                                         DISFFC_RESET);
  33.444 +
  33.445 +        /* Not necessarily supported, ignore if not supported.
  33.446 +        if (FAILED(result)) {
  33.447 +            SetDIerror("IDirectInputDevice2::SendForceFeedbackCommand",
  33.448 +                       result);
  33.449 +            return (-1);
  33.450 +        }
  33.451 +        */
  33.452 +
  33.453 +        result = IDirectInputDevice2_Unacquire(joystick->hwdata->InputDevice);
  33.454 +
  33.455 +        if (FAILED(result)) {
  33.456 +            SetDIerror("IDirectInputDevice2::Unacquire", result);
  33.457 +            return (-1);
  33.458 +        }
  33.459 +
  33.460 +        /* Turn on auto-centering for a ForceFeedback device (until told
  33.461 +         * otherwise). */
  33.462 +        dipdw.diph.dwObj = 0;
  33.463 +        dipdw.diph.dwHow = DIPH_DEVICE;
  33.464 +        dipdw.dwData = DIPROPAUTOCENTER_ON;
  33.465 +
  33.466 +        result =
  33.467 +            IDirectInputDevice2_SetProperty(joystick->hwdata->InputDevice,
  33.468 +                                            DIPROP_AUTOCENTER, &dipdw.diph);
  33.469 +
  33.470 +        /* Not necessarily supported, ignore if not supported.
  33.471 +        if (FAILED(result)) {
  33.472 +            SetDIerror("IDirectInputDevice2::SetProperty", result);
  33.473 +            return (-1);
  33.474 +        }
  33.475 +        */
  33.476 +    }
  33.477 +
  33.478 +    /* What buttons and axes does it have? */
  33.479 +    IDirectInputDevice2_EnumObjects(joystick->hwdata->InputDevice,
  33.480 +                                    EnumDevObjectsCallback, joystick,
  33.481 +                                    DIDFT_BUTTON | DIDFT_AXIS | DIDFT_POV);
  33.482 +
  33.483 +    dipdw.diph.dwObj = 0;
  33.484 +    dipdw.diph.dwHow = DIPH_DEVICE;
  33.485 +    dipdw.dwData = INPUT_QSIZE;
  33.486 +
  33.487 +    /* Set the buffer size */
  33.488 +    result =
  33.489 +        IDirectInputDevice2_SetProperty(joystick->hwdata->InputDevice,
  33.490 +                                        DIPROP_BUFFERSIZE, &dipdw.diph);
  33.491 +
  33.492 +    if (result == DI_POLLEDDEVICE) {
  33.493 +        /* This device doesn't support buffering, so we're forced
  33.494 +         * to use less reliable polling. */
  33.495 +        joystick->hwdata->buffered = 0;
  33.496 +    } else if (FAILED(result)) {
  33.497 +        SetDIerror("IDirectInputDevice2::SetProperty", result);
  33.498 +        return (-1);
  33.499 +    }
  33.500 +
  33.501 +    return (0);
  33.502 +}
  33.503 +
  33.504 +static BOOL CALLBACK
  33.505 +EnumDevObjectsCallback(LPCDIDEVICEOBJECTINSTANCE dev, LPVOID pvRef)
  33.506 +{
  33.507 +    SDL_Joystick *joystick = (SDL_Joystick *) pvRef;
  33.508 +    HRESULT result;
  33.509 +    input_t *in = &joystick->hwdata->Inputs[joystick->hwdata->NumInputs];
  33.510 +
  33.511 +    in->ofs = dev->dwOfs;
  33.512 +
  33.513 +    if (dev->dwType & DIDFT_BUTTON) {
  33.514 +        in->type = BUTTON;
  33.515 +        in->num = joystick->nbuttons;
  33.516 +        joystick->nbuttons++;
  33.517 +    } else if (dev->dwType & DIDFT_POV) {
  33.518 +        in->type = HAT;
  33.519 +        in->num = joystick->nhats;
  33.520 +        joystick->nhats++;
  33.521 +    } else if (dev->dwType & DIDFT_AXIS) {
  33.522 +        DIPROPRANGE diprg;
  33.523 +        DIPROPDWORD dilong;
  33.524 +
  33.525 +        in->type = AXIS;
  33.526 +        in->num = joystick->naxes;
  33.527 +
  33.528 +        diprg.diph.dwSize = sizeof(diprg);
  33.529 +        diprg.diph.dwHeaderSize = sizeof(diprg.diph);
  33.530 +        diprg.diph.dwObj = dev->dwOfs;
  33.531 +        diprg.diph.dwHow = DIPH_BYOFFSET;
  33.532 +        diprg.lMin = AXIS_MIN;
  33.533 +        diprg.lMax = AXIS_MAX;
  33.534 +
  33.535 +        result =
  33.536 +            IDirectInputDevice2_SetProperty(joystick->hwdata->InputDevice,
  33.537 +                                            DIPROP_RANGE, &diprg.diph);
  33.538 +        if (FAILED(result)) {
  33.539 +            return DIENUM_CONTINUE;     /* don't use this axis */
  33.540 +        }
  33.541 +
  33.542 +        /* Set dead zone to 0. */
  33.543 +        dilong.diph.dwSize = sizeof(dilong);
  33.544 +        dilong.diph.dwHeaderSize = sizeof(dilong.diph);
  33.545 +        dilong.diph.dwObj = dev->dwOfs;
  33.546 +        dilong.diph.dwHow = DIPH_BYOFFSET;
  33.547 +        dilong.dwData = 0;
  33.548 +        result =
  33.549 +            IDirectInputDevice2_SetProperty(joystick->hwdata->InputDevice,
  33.550 +                                            DIPROP_DEADZONE, &dilong.diph);
  33.551 +        if (FAILED(result)) {
  33.552 +            return DIENUM_CONTINUE;     /* don't use this axis */
  33.553 +        }
  33.554 +
  33.555 +        joystick->naxes++;
  33.556 +    } else {
  33.557 +        /* not supported at this time */
  33.558 +        return DIENUM_CONTINUE;
  33.559 +    }
  33.560 +
  33.561 +    joystick->hwdata->NumInputs++;
  33.562 +
  33.563 +    if (joystick->hwdata->NumInputs == MAX_INPUTS) {
  33.564 +        return DIENUM_STOP;     /* too many */
  33.565 +    }
  33.566 +
  33.567 +    return DIENUM_CONTINUE;
  33.568 +}
  33.569 +
  33.570 +/* Function to update the state of a joystick - called as a device poll.
  33.571 + * This function shouldn't update the joystick structure directly,
  33.572 + * but instead should call SDL_PrivateJoystick*() to deliver events
  33.573 + * and update joystick device state.
  33.574 + */
  33.575 +void
  33.576 +SDL_SYS_JoystickUpdate_Polled(SDL_Joystick * joystick)
  33.577 +{
  33.578 +    DIJOYSTATE2 state;
  33.579 +    HRESULT result;
  33.580 +    int i;
  33.581 +
  33.582 +    result =
  33.583 +        IDirectInputDevice2_GetDeviceState(joystick->hwdata->InputDevice,
  33.584 +                                           sizeof(DIJOYSTATE2), &state);
  33.585 +    if (result == DIERR_INPUTLOST || result == DIERR_NOTACQUIRED) {
  33.586 +        IDirectInputDevice2_Acquire(joystick->hwdata->InputDevice);
  33.587 +        result =
  33.588 +            IDirectInputDevice2_GetDeviceState(joystick->hwdata->InputDevice,
  33.589 +                                               sizeof(DIJOYSTATE2), &state);
  33.590 +    }
  33.591 +
  33.592 +    /* Set each known axis, button and POV. */
  33.593 +    for (i = 0; i < joystick->hwdata->NumInputs; ++i) {
  33.594 +        const input_t *in = &joystick->hwdata->Inputs[i];
  33.595 +
  33.596 +        switch (in->type) {
  33.597 +        case AXIS:
  33.598 +            switch (in->ofs) {
  33.599 +            case DIJOFS_X:
  33.600 +                SDL_PrivateJoystickAxis_Int(joystick, in->num,
  33.601 +                                            (Sint16) state.lX);
  33.602 +                break;
  33.603 +            case DIJOFS_Y:
  33.604 +                SDL_PrivateJoystickAxis_Int(joystick, in->num,
  33.605 +                                            (Sint16) state.lY);
  33.606 +                break;
  33.607 +            case DIJOFS_Z:
  33.608 +                SDL_PrivateJoystickAxis_Int(joystick, in->num,
  33.609 +                                            (Sint16) state.lZ);
  33.610 +                break;
  33.611 +            case DIJOFS_RX:
  33.612 +                SDL_PrivateJoystickAxis_Int(joystick, in->num,
  33.613 +                                            (Sint16) state.lRx);
  33.614 +                break;
  33.615 +            case DIJOFS_RY:
  33.616 +                SDL_PrivateJoystickAxis_Int(joystick, in->num,
  33.617 +                                            (Sint16) state.lRy);
  33.618 +                break;
  33.619 +            case DIJOFS_RZ:
  33.620 +                SDL_PrivateJoystickAxis_Int(joystick, in->num,
  33.621 +                                            (Sint16) state.lRz);
  33.622 +                break;
  33.623 +            case DIJOFS_SLIDER(0):
  33.624 +                SDL_PrivateJoystickAxis_Int(joystick, in->num,
  33.625 +                                            (Sint16) state.rglSlider[0]);
  33.626 +                break;
  33.627 +            case DIJOFS_SLIDER(1):
  33.628 +                SDL_PrivateJoystickAxis_Int(joystick, in->num,
  33.629 +                                            (Sint16) state.rglSlider[1]);
  33.630 +                break;
  33.631 +            }
  33.632 +
  33.633 +            break;
  33.634 +
  33.635 +        case BUTTON:
  33.636 +            SDL_PrivateJoystickButton_Int(joystick, in->num,
  33.637 +                                          (Uint8) (state.
  33.638 +                                                   rgbButtons[in->ofs -
  33.639 +                                                              DIJOFS_BUTTON0]
  33.640 +                                                   ? SDL_PRESSED :
  33.641 +                                                   SDL_RELEASED));
  33.642 +            break;
  33.643 +        case HAT:
  33.644 +            {
  33.645 +                Uint8 pos = TranslatePOV(state.rgdwPOV[in->ofs -
  33.646 +                                                       DIJOFS_POV(0)]);
  33.647 +                SDL_PrivateJoystickHat_Int(joystick, in->num, pos);
  33.648 +                break;
  33.649 +            }
  33.650 +        }
  33.651 +    }
  33.652 +}
  33.653 +
  33.654 +void
  33.655 +SDL_SYS_JoystickUpdate_Buffered(SDL_Joystick * joystick)
  33.656 +{
  33.657 +    int i;
  33.658 +    HRESULT result;
  33.659 +    DWORD numevents;
  33.660 +    DIDEVICEOBJECTDATA evtbuf[INPUT_QSIZE];
  33.661 +
  33.662 +    numevents = INPUT_QSIZE;
  33.663 +    result =
  33.664 +        IDirectInputDevice2_GetDeviceData(joystick->hwdata->InputDevice,
  33.665 +                                          sizeof(DIDEVICEOBJECTDATA), evtbuf,
  33.666 +                                          &numevents, 0);
  33.667 +    if (result == DIERR_INPUTLOST || result == DIERR_NOTACQUIRED) {
  33.668 +        IDirectInputDevice2_Acquire(joystick->hwdata->InputDevice);
  33.669 +        result =
  33.670 +            IDirectInputDevice2_GetDeviceData(joystick->hwdata->InputDevice,
  33.671 +                                              sizeof(DIDEVICEOBJECTDATA),
  33.672 +                                              evtbuf, &numevents, 0);
  33.673 +    }
  33.674 +
  33.675 +    /* Handle the events or punt */
  33.676 +    if (FAILED(result))
  33.677 +        return;
  33.678 +
  33.679 +    for (i = 0; i < (int) numevents; ++i) {
  33.680 +        int j;
  33.681 +
  33.682 +        for (j = 0; j < joystick->hwdata->NumInputs; ++j) {
  33.683 +            const input_t *in = &joystick->hwdata->Inputs[j];
  33.684 +
  33.685 +            if (evtbuf[i].dwOfs != in->ofs)
  33.686 +                continue;
  33.687 +
  33.688 +            switch (in->type) {
  33.689 +            case AXIS:
  33.690 +                SDL_PrivateJoystickAxis(joystick, in->num,
  33.691 +                                        (Sint16) evtbuf[i].dwData);
  33.692 +                break;
  33.693 +            case BUTTON:
  33.694 +                SDL_PrivateJoystickButton(joystick, in->num,
  33.695 +                                          (Uint8) (evtbuf[i].
  33.696 +                                                   dwData ? SDL_PRESSED :
  33.697 +                                                   SDL_RELEASED));
  33.698 +                break;
  33.699 +            case HAT:
  33.700 +                {
  33.701 +                    Uint8 pos = TranslatePOV(evtbuf[i].dwData);
  33.702 +                    SDL_PrivateJoystickHat(joystick, in->num, pos);
  33.703 +                }
  33.704 +            }
  33.705 +        }
  33.706 +    }
  33.707 +}
  33.708 +
  33.709 +
  33.710 +static Uint8
  33.711 +TranslatePOV(DWORD value)
  33.712 +{
  33.713 +    const int HAT_VALS[] = {
  33.714 +        SDL_HAT_UP,
  33.715 +        SDL_HAT_UP | SDL_HAT_RIGHT,
  33.716 +        SDL_HAT_RIGHT,
  33.717 +        SDL_HAT_DOWN | SDL_HAT_RIGHT,
  33.718 +        SDL_HAT_DOWN,
  33.719 +        SDL_HAT_DOWN | SDL_HAT_LEFT,
  33.720 +        SDL_HAT_LEFT,
  33.721 +        SDL_HAT_UP | SDL_HAT_LEFT
  33.722 +    };
  33.723 +
  33.724 +    if (LOWORD(value) == 0xFFFF)
  33.725 +        return SDL_HAT_CENTERED;
  33.726 +
  33.727 +    /* Round the value up: */
  33.728 +    value += 4500 / 2;
  33.729 +    value %= 36000;
  33.730 +    value /= 4500;
  33.731 +
  33.732 +    if (value >= 8)
  33.733 +        return SDL_HAT_CENTERED;        /* shouldn't happen */
  33.734 +
  33.735 +    return HAT_VALS[value];
  33.736 +}
  33.737 +
  33.738 +/* SDL_PrivateJoystick* doesn't discard duplicate events, so we need to
  33.739 + * do it. */
  33.740 +static int
  33.741 +SDL_PrivateJoystickAxis_Int(SDL_Joystick * joystick, Uint8 axis, Sint16 value)
  33.742 +{
  33.743 +    if (joystick->axes[axis] != value)
  33.744 +        return SDL_PrivateJoystickAxis(joystick, axis, value);
  33.745 +    return 0;
  33.746 +}
  33.747 +
  33.748 +static int
  33.749 +SDL_PrivateJoystickHat_Int(SDL_Joystick * joystick, Uint8 hat, Uint8 value)
  33.750 +{
  33.751 +    if (joystick->hats[hat] != value)
  33.752 +        return SDL_PrivateJoystickHat(joystick, hat, value);
  33.753 +    return 0;
  33.754 +}
  33.755 +
  33.756 +static int
  33.757 +SDL_PrivateJoystickButton_Int(SDL_Joystick * joystick, Uint8 button,
  33.758 +                              Uint8 state)
  33.759 +{
  33.760 +    if (joystick->buttons[button] != state)
  33.761 +        return SDL_PrivateJoystickButton(joystick, button, state);
  33.762 +    return 0;
  33.763 +}
  33.764 +
  33.765 +void
  33.766 +SDL_SYS_JoystickUpdate(SDL_Joystick * joystick)
  33.767 +{
  33.768 +    HRESULT result;
  33.769 +
  33.770 +    result = IDirectInputDevice2_Poll(joystick->hwdata->InputDevice);
  33.771 +    if (result == DIERR_INPUTLOST || result == DIERR_NOTACQUIRED) {
  33.772 +        IDirectInputDevice2_Acquire(joystick->hwdata->InputDevice);
  33.773 +        IDirectInputDevice2_Poll(joystick->hwdata->InputDevice);
  33.774 +    }
  33.775 +
  33.776 +    if (joystick->hwdata->buffered)
  33.777 +        SDL_SYS_JoystickUpdate_Buffered(joystick);
  33.778 +    else
  33.779 +        SDL_SYS_JoystickUpdate_Polled(joystick);
  33.780 +}
  33.781 +
  33.782 +/* Function to close a joystick after use */
  33.783 +void
  33.784 +SDL_SYS_JoystickClose(SDL_Joystick * joystick)
  33.785 +{
  33.786 +    IDirectInputDevice2_Unacquire(joystick->hwdata->InputDevice);
  33.787 +    IDirectInputDevice2_Release(joystick->hwdata->InputDevice);
  33.788 +
  33.789 +    if (joystick->hwdata != NULL) {
  33.790 +        /* free system specific hardware data */
  33.791 +        SDL_free(joystick->hwdata);
  33.792 +    }
  33.793 +}
  33.794 +
  33.795 +/* Function to perform any system-specific joystick related cleanup */
  33.796 +void
  33.797 +SDL_SYS_JoystickQuit(void)
  33.798 +{
  33.799 +    IDirectInput_Release(dinput);
  33.800 +    dinput = NULL;
  33.801 +}
  33.802 +
  33.803 +#endif /* SDL_JOYSTICK_DINPUT */
  33.804 +
  33.805 +/* vi: set ts=4 sw=4 expandtab: */
    34.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    34.2 +++ b/src/joystick/windows/SDL_dxjoystick_c.h	Thu Jan 20 18:04:05 2011 -0800
    34.3 @@ -0,0