Fixed bug #925
authorSam Lantinga <slouken@libsdl.org>
Thu, 20 Jan 2011 18:04:05 -0800
changeset 5062 e8916fe9cfc8
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
--- a/VisualC/SDL/SDL_VS2005.vcproj	Thu Jan 20 17:33:06 2011 -0800
+++ b/VisualC/SDL/SDL_VS2005.vcproj	Thu Jan 20 18:04:05 2011 -0800
@@ -29,7 +29,7 @@
 			<Tool
 				Name="VCPreBuildEventTool"
 				Description="Making sure basic SDL headers are in place..."
-				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;"
+				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;"
 			/>
 			<Tool
 				Name="VCCustomBuildTool"
@@ -207,7 +207,7 @@
 			<Tool
 				Name="VCPreBuildEventTool"
 				Description="Making sure basic SDL headers are in place..."
-				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;"
+				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;"
 			/>
 			<Tool
 				Name="VCCustomBuildTool"
@@ -411,7 +411,7 @@
 				>
 			</File>
 			<File
-				RelativePath="..\..\include\SDL_config_win32.h"
+				RelativePath="..\..\include\SDL_config_windows.h"
 				>
 			</File>
 			<File
@@ -768,11 +768,11 @@
 			>
 		</File>
 		<File
-			RelativePath="..\..\src\video\win32\SDL_d3drender.c"
+			RelativePath="..\..\src\video\windows\SDL_d3drender.c"
 			>
 		</File>
 		<File
-			RelativePath="..\..\src\video\win32\SDL_d3drender.h"
+			RelativePath="..\..\src\video\windows\SDL_d3drender.h"
 			>
 		</File>
 		<File
@@ -824,7 +824,7 @@
 			>
 		</File>
 		<File
-			RelativePath="..\..\src\joystick\win32\SDL_dxjoystick.c"
+			RelativePath="..\..\src\joystick\windows\SDL_dxjoystick.c"
 			>
 		</File>
 		<File
@@ -860,11 +860,11 @@
 			>
 		</File>
 		<File
-			RelativePath="..\..\src\video\win32\SDL_gdirender.c"
+			RelativePath="..\..\src\video\windows\SDL_gdirender.c"
 			>
 		</File>
 		<File
-			RelativePath="..\..\src\video\win32\SDL_gdirender.h"
+			RelativePath="..\..\src\video\windows\SDL_gdirender.h"
 			>
 		</File>
 		<File
@@ -948,7 +948,7 @@
 			>
 		</File>
 		<File
-			RelativePath="..\..\src\joystick\win32\SDL_mmjoystick.c"
+			RelativePath="..\..\src\joystick\windows\SDL_mmjoystick.c"
 			>
 		</File>
 		<File
@@ -1072,7 +1072,7 @@
 			>
 		</File>
 		<File
-			RelativePath="..\..\src\haptic\win32\SDL_syshaptic.c"
+			RelativePath="..\..\src\haptic\windows\SDL_syshaptic.c"
 			>
 		</File>
 		<File
@@ -1084,11 +1084,11 @@
 			>
 		</File>
 		<File
-			RelativePath="..\..\src\loadso\win32\SDL_sysloadso.c"
+			RelativePath="..\..\src\loadso\windows\SDL_sysloadso.c"
 			>
 		</File>
 		<File
-			RelativePath="..\..\src\thread\win32\SDL_sysmutex.c"
+			RelativePath="..\..\src\thread\windows\SDL_sysmutex.c"
 			>
 		</File>
 		<File
@@ -1096,11 +1096,11 @@
 			>
 		</File>
 		<File
-			RelativePath="..\..\src\thread\win32\SDL_syssem.c"
+			RelativePath="..\..\src\thread\windows\SDL_syssem.c"
 			>
 		</File>
 		<File
-			RelativePath="..\..\src\thread\win32\SDL_systhread.c"
+			RelativePath="..\..\src\thread\windows\SDL_systhread.c"
 			>
 		</File>
 		<File
@@ -1108,11 +1108,11 @@
 			>
 		</File>
 		<File
-			RelativePath="..\..\src\thread\win32\SDL_systhread_c.h"
+			RelativePath="..\..\src\thread\windows\SDL_systhread_c.h"
 			>
 		</File>
 		<File
-			RelativePath="..\..\src\timer\win32\SDL_systimer.c"
+			RelativePath="..\..\src\timer\windows\SDL_systimer.c"
 			>
 		</File>
 		<File
@@ -1152,7 +1152,7 @@
 			>
 		</File>
 		<File
-			RelativePath="..\..\src\video\win32\SDL_vkeys.h"
+			RelativePath="..\..\src\video\windows\SDL_vkeys.h"
 			>
 		</File>
 		<File
@@ -1164,83 +1164,83 @@
 			>
 		</File>
 		<File
-			RelativePath="..\..\src\video\win32\SDL_win32clipboard.c"
+			RelativePath="..\..\src\video\windows\SDL_windowsclipboard.c"
 			>
 		</File>
 		<File
-			RelativePath="..\..\src\video\win32\SDL_win32clipboard.h"
+			RelativePath="..\..\src\video\windows\SDL_windowsclipboard.h"
 			>
 		</File>
 		<File
-			RelativePath="..\..\src\video\win32\SDL_win32events.c"
+			RelativePath="..\..\src\video\windows\SDL_windowsevents.c"
 			>
 		</File>
 		<File
-			RelativePath="..\..\src\video\win32\SDL_win32events.h"
+			RelativePath="..\..\src\video\windows\SDL_windowsevents.h"
 			>
 		</File>
 		<File
-			RelativePath="..\..\src\video\win32\SDL_win32gamma.c"
+			RelativePath="..\..\src\video\windows\SDL_windowsgamma.c"
 			>
 		</File>
 		<File
-			RelativePath="..\..\src\video\win32\SDL_win32gamma.h"
+			RelativePath="..\..\src\video\windows\SDL_windowsgamma.h"
 			>
 		</File>
 		<File
-			RelativePath="..\..\src\video\win32\SDL_win32keyboard.c"
+			RelativePath="..\..\src\video\windows\SDL_windowskeyboard.c"
 			>
 		</File>
 		<File
-			RelativePath="..\..\src\video\win32\SDL_win32keyboard.h"
+			RelativePath="..\..\src\video\windows\SDL_windowskeyboard.h"
 			>
 		</File>
 		<File
-			RelativePath="..\..\src\video\win32\SDL_win32modes.c"
+			RelativePath="..\..\src\video\windows\SDL_windowsmodes.c"
 			>
 		</File>
 		<File
-			RelativePath="..\..\src\video\win32\SDL_win32modes.h"
+			RelativePath="..\..\src\video\windows\SDL_windowsmodes.h"
 			>
 		</File>
 		<File
-			RelativePath="..\..\src\video\win32\SDL_win32mouse.c"
+			RelativePath="..\..\src\video\windows\SDL_windowsmouse.c"
 			>
 		</File>
 		<File
-			RelativePath="..\..\src\video\win32\SDL_win32mouse.h"
+			RelativePath="..\..\src\video\windows\SDL_windowsmouse.h"
 			>
 		</File>
 		<File
-			RelativePath="..\..\src\video\win32\SDL_win32opengl.c"
+			RelativePath="..\..\src\video\windows\SDL_windowsopengl.c"
 			>
 		</File>
 		<File
-			RelativePath="..\..\src\video\win32\SDL_win32opengl.h"
+			RelativePath="..\..\src\video\windows\SDL_windowsopengl.h"
 			>
 		</File>
 		<File
-			RelativePath="..\..\src\video\win32\SDL_win32shape.c"
+			RelativePath="..\..\src\video\windows\SDL_windowsshape.c"
 			>
 		</File>
 		<File
-			RelativePath="..\..\src\video\win32\SDL_win32shape.h"
+			RelativePath="..\..\src\video\windows\SDL_windowsshape.h"
 			>
 		</File>
 		<File
-			RelativePath="..\..\src\video\win32\SDL_win32video.c"
+			RelativePath="..\..\src\video\windows\SDL_windowsvideo.c"
 			>
 		</File>
 		<File
-			RelativePath="..\..\src\video\win32\SDL_win32video.h"
+			RelativePath="..\..\src\video\windows\SDL_windowsvideo.h"
 			>
 		</File>
 		<File
-			RelativePath="..\..\src\video\win32\SDL_win32window.c"
+			RelativePath="..\..\src\video\windows\SDL_windowswindow.c"
 			>
 		</File>
 		<File
-			RelativePath="..\..\src\video\win32\SDL_win32window.h"
+			RelativePath="..\..\src\video\windows\SDL_windowswindow.h"
 			>
 		</File>
 		<File
@@ -1264,7 +1264,7 @@
 			>
 		</File>
 		<File
-			RelativePath="..\..\src\video\win32\wmmsg.h"
+			RelativePath="..\..\src\video\windows\wmmsg.h"
 			>
 		</File>
 	</Files>
--- a/VisualC/SDL/SDL_VS2008.vcproj	Thu Jan 20 17:33:06 2011 -0800
+++ b/VisualC/SDL/SDL_VS2008.vcproj	Thu Jan 20 18:04:05 2011 -0800
@@ -30,7 +30,7 @@
 			<Tool
 				Name="VCPreBuildEventTool"
 				Description="Making sure basic SDL headers are in place..."
-				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;"
+				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;"
 			/>
 			<Tool
 				Name="VCCustomBuildTool"
@@ -201,7 +201,7 @@
 			<Tool
 				Name="VCPreBuildEventTool"
 				Description="Making sure basic SDL headers are in place..."
-				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;"
+				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;"
 			/>
 			<Tool
 				Name="VCCustomBuildTool"
@@ -398,7 +398,7 @@
 				>
 			</File>
 			<File
-				RelativePath="..\..\include\SDL_config_win32.h"
+				RelativePath="..\..\include\SDL_config_windows.h"
 				>
 			</File>
 			<File
@@ -751,11 +751,11 @@
 			>
 		</File>
 		<File
-			RelativePath="..\..\src\video\win32\SDL_d3drender.c"
+			RelativePath="..\..\src\video\windows\SDL_d3drender.c"
 			>
 		</File>
 		<File
-			RelativePath="..\..\src\video\win32\SDL_d3drender.h"
+			RelativePath="..\..\src\video\windows\SDL_d3drender.h"
 			>
 		</File>
 		<File
@@ -807,7 +807,7 @@
 			>
 		</File>
 		<File
-			RelativePath="..\..\src\joystick\win32\SDL_dxjoystick.c"
+			RelativePath="..\..\src\joystick\windows\SDL_dxjoystick.c"
 			>
 		</File>
 		<File
@@ -843,11 +843,11 @@
 			>
 		</File>
 		<File
-			RelativePath="..\..\src\video\win32\SDL_gdirender.c"
+			RelativePath="..\..\src\video\windows\SDL_gdirender.c"
 			>
 		</File>
 		<File
-			RelativePath="..\..\src\video\win32\SDL_gdirender.h"
+			RelativePath="..\..\src\video\windows\SDL_gdirender.h"
 			>
 		</File>
 		<File
@@ -931,7 +931,7 @@
 			>
 		</File>
 		<File
-			RelativePath="..\..\src\joystick\win32\SDL_mmjoystick.c"
+			RelativePath="..\..\src\joystick\windows\SDL_mmjoystick.c"
 			>
 		</File>
 		<File
@@ -1059,7 +1059,7 @@
 			>
 		</File>
 		<File
-			RelativePath="..\..\src\haptic\win32\SDL_syshaptic.c"
+			RelativePath="..\..\src\haptic\windows\SDL_syshaptic.c"
 			>
 		</File>
 		<File
@@ -1071,11 +1071,11 @@
 			>
 		</File>
 		<File
-			RelativePath="..\..\src\loadso\win32\SDL_sysloadso.c"
+			RelativePath="..\..\src\loadso\windows\SDL_sysloadso.c"
 			>
 		</File>
 		<File
-			RelativePath="..\..\src\thread\win32\SDL_sysmutex.c"
+			RelativePath="..\..\src\thread\windows\SDL_sysmutex.c"
 			>
 		</File>
 		<File
@@ -1083,11 +1083,11 @@
 			>
 		</File>
 		<File
-			RelativePath="..\..\src\thread\win32\SDL_syssem.c"
+			RelativePath="..\..\src\thread\windows\SDL_syssem.c"
 			>
 		</File>
 		<File
-			RelativePath="..\..\src\thread\win32\SDL_systhread.c"
+			RelativePath="..\..\src\thread\windows\SDL_systhread.c"
 			>
 		</File>
 		<File
@@ -1095,11 +1095,11 @@
 			>
 		</File>
 		<File
-			RelativePath="..\..\src\thread\win32\SDL_systhread_c.h"
+			RelativePath="..\..\src\thread\windows\SDL_systhread_c.h"
 			>
 		</File>
 		<File
-			RelativePath="..\..\src\timer\win32\SDL_systimer.c"
+			RelativePath="..\..\src\timer\windows\SDL_systimer.c"
 			>
 		</File>
 		<File
@@ -1139,7 +1139,7 @@
 			>
 		</File>
 		<File
-			RelativePath="..\..\src\video\win32\SDL_vkeys.h"
+			RelativePath="..\..\src\video\windows\SDL_vkeys.h"
 			>
 		</File>
 		<File
@@ -1151,83 +1151,83 @@
 			>
 		</File>
 		<File
-			RelativePath="..\..\src\video\win32\SDL_win32clipboard.c"
+			RelativePath="..\..\src\video\windows\SDL_windowsclipboard.c"
 			>
 		</File>
 		<File
-			RelativePath="..\..\src\video\win32\SDL_win32clipboard.h"
+			RelativePath="..\..\src\video\windows\SDL_windowsclipboard.h"
 			>
 		</File>
 		<File
-			RelativePath="..\..\src\video\win32\SDL_win32events.c"
+			RelativePath="..\..\src\video\windows\SDL_windowsevents.c"
 			>
 		</File>
 		<File
-			RelativePath="..\..\src\video\win32\SDL_win32events.h"
+			RelativePath="..\..\src\video\windows\SDL_windowsevents.h"
 			>
 		</File>
 		<File
-			RelativePath="..\..\src\video\win32\SDL_win32gamma.c"
+			RelativePath="..\..\src\video\windows\SDL_windowsgamma.c"
 			>
 		</File>
 		<File
-			RelativePath="..\..\src\video\win32\SDL_win32gamma.h"
+			RelativePath="..\..\src\video\windows\SDL_windowsgamma.h"
 			>
 		</File>
 		<File
-			RelativePath="..\..\src\video\win32\SDL_win32keyboard.c"
+			RelativePath="..\..\src\video\windows\SDL_windowskeyboard.c"
 			>
 		</File>
 		<File
-			RelativePath="..\..\src\video\win32\SDL_win32keyboard.h"
+			RelativePath="..\..\src\video\windows\SDL_windowskeyboard.h"
 			>
 		</File>
 		<File
-			RelativePath="..\..\src\video\win32\SDL_win32modes.c"
+			RelativePath="..\..\src\video\windows\SDL_windowsmodes.c"
 			>
 		</File>
 		<File
-			RelativePath="..\..\src\video\win32\SDL_win32modes.h"
+			RelativePath="..\..\src\video\windows\SDL_windowsmodes.h"
 			>
 		</File>
 		<File
-			RelativePath="..\..\src\video\win32\SDL_win32mouse.c"
+			RelativePath="..\..\src\video\windows\SDL_windowsmouse.c"
 			>
 		</File>
 		<File
-			RelativePath="..\..\src\video\win32\SDL_win32mouse.h"
+			RelativePath="..\..\src\video\windows\SDL_windowsmouse.h"
 			>
 		</File>
 		<File
-			RelativePath="..\..\src\video\win32\SDL_win32opengl.c"
+			RelativePath="..\..\src\video\windows\SDL_windowsopengl.c"
 			>
 		</File>
 		<File
-			RelativePath="..\..\src\video\win32\SDL_win32opengl.h"
+			RelativePath="..\..\src\video\windows\SDL_windowsopengl.h"
 			>
 		</File>
 		<File
-			RelativePath="..\..\src\video\win32\SDL_win32shape.c"
+			RelativePath="..\..\src\video\windows\SDL_windowsshape.c"
 			>
 		</File>
 		<File
-			RelativePath="..\..\src\video\win32\SDL_win32shape.h"
+			RelativePath="..\..\src\video\windows\SDL_windowsshape.h"
 			>
 		</File>
 		<File
-			RelativePath="..\..\src\video\win32\SDL_win32video.c"
+			RelativePath="..\..\src\video\windows\SDL_windowsvideo.c"
 			>
 		</File>
 		<File
-			RelativePath="..\..\src\video\win32\SDL_win32video.h"
+			RelativePath="..\..\src\video\windows\SDL_windowsvideo.h"
 			>
 		</File>
 		<File
-			RelativePath="..\..\src\video\win32\SDL_win32window.c"
+			RelativePath="..\..\src\video\windows\SDL_windowswindow.c"
 			>
 		</File>
 		<File
-			RelativePath="..\..\src\video\win32\SDL_win32window.h"
+			RelativePath="..\..\src\video\windows\SDL_windowswindow.h"
 			>
 		</File>
 		<File
@@ -1251,7 +1251,7 @@
 			>
 		</File>
 		<File
-			RelativePath="..\..\src\video\win32\wmmsg.h"
+			RelativePath="..\..\src\video\windows\wmmsg.h"
 			>
 		</File>
 	</Files>
--- a/VisualC/SDL/SDL_VS2010.vcxproj	Thu Jan 20 17:33:06 2011 -0800
+++ b/VisualC/SDL/SDL_VS2010.vcxproj	Thu Jan 20 18:04:05 2011 -0800
@@ -75,8 +75,8 @@
     <PreBuildEvent>
       <Message>Making sure basic SDL headers are in place...</Message>
       <Command>if exist "$(ProjectDir)\..\..\include\SDL_config.h" goto SDLCONFIGOKAY
-echo Copying SDL_config_win32.h to SDL_config.h...
-copy "$(ProjectDir)\..\..\include\SDL_config_win32.h" "$(ProjectDir)\..\..\include\SDL_config.h"
+echo Copying SDL_config_windows.h to SDL_config.h...
+copy "$(ProjectDir)\..\..\include\SDL_config_windows.h" "$(ProjectDir)\..\..\include\SDL_config.h"
 :SDLCONFIGOKAY
 
 if exist "$(ProjectDir)\..\..\include\SDL_revision.h" goto SDLREVISIONOKAY
@@ -155,8 +155,8 @@
     <PreBuildEvent>
       <Message>Making sure basic SDL headers are in place...</Message>
       <Command>if exist "$(ProjectDir)\..\..\include\SDL_config.h" goto SDLCONFIGOKAY
-echo Copying SDL_config_win32.h to SDL_config.h...
-copy "$(ProjectDir)\..\..\include\SDL_config_win32.h" "$(ProjectDir)\..\..\include\SDL_config.h"
+echo Copying SDL_config_windows.h to SDL_config.h...
+copy "$(ProjectDir)\..\..\include\SDL_config_windows.h" "$(ProjectDir)\..\..\include\SDL_config.h"
 :SDLCONFIGOKAY
 
 if exist "$(ProjectDir)\..\..\include\SDL_revision.h" goto SDLREVISIONOKAY
@@ -238,7 +238,7 @@
     <ClInclude Include="..\..\include\SDL_clipboard.h" />
     <ClInclude Include="..\..\include\SDL_compat.h" />
     <ClInclude Include="..\..\include\SDL_config.h" />
-    <ClInclude Include="..\..\include\SDL_config_win32.h" />
+    <ClInclude Include="..\..\include\SDL_config_windows.h" />
     <ClInclude Include="..\..\include\SDL_copying.h" />
     <ClInclude Include="..\..\include\SDL_cpuinfo.h" />
     <ClInclude Include="..\..\include\SDL_endian.h" />
@@ -290,7 +290,7 @@
     <ClInclude Include="..\..\src\video\SDL_blit_copy.h" />
     <ClInclude Include="..\..\src\video\SDL_blit_slow.h" />
     <ClInclude Include="..\..\src\video\SDL_shape_internals.h" />
-    <ClInclude Include="..\..\src\video\win32\SDL_d3drender.h" />
+    <ClInclude Include="..\..\src\video\windows\SDL_d3drender.h" />
     <ClInclude Include="..\..\src\audio\windib\SDL_dibaudio.h" />
     <ClInclude Include="..\..\src\audio\disk\SDL_diskaudio.h" />
     <ClInclude Include="..\..\src\video\SDL_draw.h" />
@@ -299,7 +299,7 @@
     <ClInclude Include="..\..\src\SDL_error_c.h" />
     <ClInclude Include="..\..\src\events\SDL_events_c.h" />
     <ClInclude Include="..\..\src\SDL_fatal.h" />
-    <ClInclude Include="..\..\src\video\win32\SDL_gdirender.h" />
+    <ClInclude Include="..\..\src\video\windows\SDL_gdirender.h" />
     <ClInclude Include="..\..\src\video\SDL_glesfuncs.h" />
     <ClInclude Include="..\..\src\video\SDL_glfuncs.h" />
     <ClInclude Include="..\..\src\joystick\SDL_joystick_c.h" />
@@ -323,26 +323,26 @@
     <ClInclude Include="..\..\src\haptic\SDL_syshaptic.h" />
     <ClInclude Include="..\..\src\joystick\SDL_sysjoystick.h" />
     <ClInclude Include="..\..\src\thread\SDL_systhread.h" />
-    <ClInclude Include="..\..\src\thread\win32\SDL_systhread_c.h" />
+    <ClInclude Include="..\..\src\thread\windows\SDL_systhread_c.h" />
     <ClInclude Include="..\..\src\timer\SDL_systimer.h" />
     <ClInclude Include="..\..\src\video\SDL_sysvideo.h" />
     <ClInclude Include="..\..\src\thread\SDL_thread_c.h" />
     <ClInclude Include="..\..\src\timer\SDL_timer_c.h" />
-    <ClInclude Include="..\..\src\video\win32\SDL_vkeys.h" />
+    <ClInclude Include="..\..\src\video\windows\SDL_vkeys.h" />
     <ClInclude Include="..\..\src\audio\SDL_wave.h" />
-    <ClInclude Include="..\..\src\video\win32\SDL_win32clipboard.h" />
-    <ClInclude Include="..\..\src\video\win32\SDL_win32events.h" />
-    <ClInclude Include="..\..\src\video\win32\SDL_win32gamma.h" />
-    <ClInclude Include="..\..\src\video\win32\SDL_win32keyboard.h" />
-    <ClInclude Include="..\..\src\video\win32\SDL_win32modes.h" />
-    <ClInclude Include="..\..\src\video\win32\SDL_win32mouse.h" />
-    <ClInclude Include="..\..\src\video\win32\SDL_win32opengl.h" />
-    <ClInclude Include="..\..\src\video\win32\SDL_win32shape.h" />
-    <ClInclude Include="..\..\src\video\win32\SDL_win32video.h" />
-    <ClInclude Include="..\..\src\video\win32\SDL_win32window.h" />
+    <ClInclude Include="..\..\src\video\windows\SDL_windowsclipboard.h" />
+    <ClInclude Include="..\..\src\video\windows\SDL_windowsevents.h" />
+    <ClInclude Include="..\..\src\video\windows\SDL_windowsgamma.h" />
+    <ClInclude Include="..\..\src\video\windows\SDL_windowskeyboard.h" />
+    <ClInclude Include="..\..\src\video\windows\SDL_windowsmodes.h" />
+    <ClInclude Include="..\..\src\video\windows\SDL_windowsmouse.h" />
+    <ClInclude Include="..\..\src\video\windows\SDL_windowsopengl.h" />
+    <ClInclude Include="..\..\src\video\windows\SDL_windowsshape.h" />
+    <ClInclude Include="..\..\src\video\windows\SDL_windowsvideo.h" />
+    <ClInclude Include="..\..\src\video\windows\SDL_windowswindow.h" />
     <ClInclude Include="..\..\src\events\SDL_windowevents_c.h" />
     <ClInclude Include="..\..\src\video\SDL_yuv_sw_c.h" />
-    <ClInclude Include="..\..\src\video\win32\wmmsg.h" />
+    <ClInclude Include="..\..\src\video\windows\wmmsg.h" />
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include="..\..\src\events\SDL_clipboardevents.c" />
@@ -389,7 +389,7 @@
     <ClCompile Include="..\..\src\cpuinfo\SDL_cpuinfo.c" />
     <ClCompile Include="..\..\src\video\SDL_clipboard.c" />
     <ClCompile Include="..\..\src\video\SDL_shape.c" />
-    <ClCompile Include="..\..\src\video\win32\SDL_d3drender.c" />
+    <ClCompile Include="..\..\src\video\windows\SDL_d3drender.c" />
     <ClCompile Include="..\..\src\audio\windib\SDL_dibaudio.c" />
     <ClCompile Include="..\..\src\audio\disk\SDL_diskaudio.c" />
     <ClCompile Include="..\..\src\video\SDL_drawline.c" />
@@ -397,13 +397,13 @@
     <ClCompile Include="..\..\src\video\SDL_drawrect.c" />
     <ClCompile Include="..\..\src\audio\dummy\SDL_dummyaudio.c" />
     <ClCompile Include="..\..\src\audio\windx5\SDL_dx5audio.c" />
-    <ClCompile Include="..\..\src\joystick\win32\SDL_dxjoystick.c" />
+    <ClCompile Include="..\..\src\joystick\windows\SDL_dxjoystick.c" />
     <ClCompile Include="..\..\src\SDL_error.c" />
     <ClCompile Include="..\..\src\events\SDL_events.c" />
     <ClCompile Include="..\..\src\SDL_fatal.c" />
     <ClCompile Include="..\..\src\video\SDL_fillrect.c" />
     <ClCompile Include="..\..\src\video\SDL_gamma.c" />
-    <ClCompile Include="..\..\src\video\win32\SDL_gdirender.c" />
+    <ClCompile Include="..\..\src\video\windows\SDL_gdirender.c" />
     <ClCompile Include="..\..\src\stdlib\SDL_getenv.c" />
     <ClCompile Include="..\..\src\haptic\SDL_haptic.c" />
     <ClCompile Include="..\..\src\stdlib\SDL_iconv.c" />
@@ -414,7 +414,7 @@
     <ClCompile Include="..\..\src\audio\SDL_mixer_m68k.c" />
     <ClCompile Include="..\..\src\audio\SDL_mixer_MMX.c" />
     <ClCompile Include="..\..\src\audio\SDL_mixer_MMX_VC.c" />
-    <ClCompile Include="..\..\src\joystick\win32\SDL_mmjoystick.c" />
+    <ClCompile Include="..\..\src\joystick\windows\SDL_mmjoystick.c" />
     <ClCompile Include="..\..\src\events\SDL_mouse.c" />
     <ClCompile Include="..\..\src\video\dummy\SDL_nullevents.c" />
     <ClCompile Include="..\..\src\video\dummy\SDL_nullrender.c" />
@@ -432,27 +432,27 @@
     <ClCompile Include="..\..\src\video\SDL_stretch.c" />
     <ClCompile Include="..\..\src\stdlib\SDL_string.c" />
     <ClCompile Include="..\..\src\video\SDL_surface.c" />
-    <ClCompile Include="..\..\src\haptic\win32\SDL_syshaptic.c" />
-    <ClCompile Include="..\..\src\loadso\win32\SDL_sysloadso.c" />
-    <ClCompile Include="..\..\src\thread\win32\SDL_sysmutex.c" />
+    <ClCompile Include="..\..\src\haptic\windows\SDL_syshaptic.c" />
+    <ClCompile Include="..\..\src\loadso\windows\SDL_sysloadso.c" />
+    <ClCompile Include="..\..\src\thread\windows\SDL_sysmutex.c" />
     <ClCompile Include="..\..\src\power\windows\SDL_syspower.c" />
-    <ClCompile Include="..\..\src\thread\win32\SDL_syssem.c" />
-    <ClCompile Include="..\..\src\thread\win32\SDL_systhread.c" />
-    <ClCompile Include="..\..\src\timer\win32\SDL_systimer.c" />
+    <ClCompile Include="..\..\src\thread\windows\SDL_syssem.c" />
+    <ClCompile Include="..\..\src\thread\windows\SDL_systhread.c" />
+    <ClCompile Include="..\..\src\timer\windows\SDL_systimer.c" />
     <ClCompile Include="..\..\src\thread\SDL_thread.c" />
     <ClCompile Include="..\..\src\timer\SDL_timer.c" />
     <ClCompile Include="..\..\src\video\SDL_video.c" />
     <ClCompile Include="..\..\src\audio\SDL_wave.c" />
-    <ClCompile Include="..\..\src\video\win32\SDL_win32clipboard.c" />
-    <ClCompile Include="..\..\src\video\win32\SDL_win32events.c" />
-    <ClCompile Include="..\..\src\video\win32\SDL_win32gamma.c" />
-    <ClCompile Include="..\..\src\video\win32\SDL_win32keyboard.c" />
-    <ClCompile Include="..\..\src\video\win32\SDL_win32modes.c" />
-    <ClCompile Include="..\..\src\video\win32\SDL_win32mouse.c" />
-    <ClCompile Include="..\..\src\video\win32\SDL_win32opengl.c" />
-    <ClCompile Include="..\..\src\video\win32\SDL_win32shape.c" />
-    <ClCompile Include="..\..\src\video\win32\SDL_win32video.c" />
-    <ClCompile Include="..\..\src\video\win32\SDL_win32window.c" />
+    <ClCompile Include="..\..\src\video\windows\SDL_windowsclipboard.c" />
+    <ClCompile Include="..\..\src\video\windows\SDL_windowsevents.c" />
+    <ClCompile Include="..\..\src\video\windows\SDL_windowsgamma.c" />
+    <ClCompile Include="..\..\src\video\windows\SDL_windowskeyboard.c" />
+    <ClCompile Include="..\..\src\video\windows\SDL_windowsmodes.c" />
+    <ClCompile Include="..\..\src\video\windows\SDL_windowsmouse.c" />
+    <ClCompile Include="..\..\src\video\windows\SDL_windowsopengl.c" />
+    <ClCompile Include="..\..\src\video\windows\SDL_windowsshape.c" />
+    <ClCompile Include="..\..\src\video\windows\SDL_windowsvideo.c" />
+    <ClCompile Include="..\..\src\video\windows\SDL_windowswindow.c" />
     <ClCompile Include="..\..\src\events\SDL_windowevents.c" />
     <ClCompile Include="..\..\src\video\SDL_yuv_mmx.c" />
     <ClCompile Include="..\..\src\video\SDL_yuv_sw.c" />
@@ -460,4 +460,4 @@
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
   <ImportGroup Label="ExtensionTargets">
   </ImportGroup>
-</Project>
\ No newline at end of file
+</Project>
--- a/VisualC/SDLmain/SDLmain_VS2005.vcproj	Thu Jan 20 17:33:06 2011 -0800
+++ b/VisualC/SDLmain/SDLmain_VS2005.vcproj	Thu Jan 20 18:04:05 2011 -0800
@@ -29,7 +29,7 @@
 			<Tool
 				Name="VCPreBuildEventTool"
 				Description="Making sure basic SDL headers are in place..."
-				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;"
+				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;"
 			/>
 			<Tool
 				Name="VCCustomBuildTool"
@@ -164,7 +164,7 @@
 			<Tool
 				Name="VCPreBuildEventTool"
 				Description="Making sure basic SDL headers are in place..."
-				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;"
+				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;"
 			/>
 			<Tool
 				Name="VCCustomBuildTool"
@@ -299,7 +299,7 @@
 			<Tool
 				Name="VCPreBuildEventTool"
 				Description="Making sure basic SDL headers are in place..."
-				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;"
+				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;"
 			/>
 			<Tool
 				Name="VCCustomBuildTool"
@@ -425,7 +425,7 @@
 	</References>
 	<Files>
 		<File
-			RelativePath="..\..\Src\Main\Win32\SDL_win32_main.c"
+			RelativePath="..\..\src\main\windows\SDL_windows_main.c"
 			>
 		</File>
 	</Files>
--- a/VisualC/SDLmain/SDLmain_VS2008.vcproj	Thu Jan 20 17:33:06 2011 -0800
+++ b/VisualC/SDLmain/SDLmain_VS2008.vcproj	Thu Jan 20 18:04:05 2011 -0800
@@ -30,7 +30,7 @@
 			<Tool
 				Name="VCPreBuildEventTool"
 				Description="Making sure basic SDL headers are in place..."
-				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;"
+				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;"
 			/>
 			<Tool
 				Name="VCCustomBuildTool"
@@ -165,7 +165,7 @@
 			<Tool
 				Name="VCPreBuildEventTool"
 				Description="Making sure basic SDL headers are in place..."
-				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;"
+				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;"
 			/>
 			<Tool
 				Name="VCCustomBuildTool"
@@ -300,7 +300,7 @@
 			<Tool
 				Name="VCPreBuildEventTool"
 				Description="Making sure basic SDL headers are in place..."
-				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;"
+				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;"
 			/>
 			<Tool
 				Name="VCCustomBuildTool"
@@ -426,7 +426,7 @@
 	</References>
 	<Files>
 		<File
-			RelativePath="..\..\Src\Main\Win32\SDL_win32_main.c"
+			RelativePath="..\..\src\main\windows\SDL_windows_main.c"
 			>
 		</File>
 	</Files>
--- a/VisualC/SDLmain/SDLmain_VS2010.vcxproj	Thu Jan 20 17:33:06 2011 -0800
+++ b/VisualC/SDLmain/SDLmain_VS2010.vcxproj	Thu Jan 20 18:04:05 2011 -0800
@@ -102,8 +102,8 @@
     <PreBuildEvent>
       <Message>Making sure basic SDL headers are in place...</Message>
       <Command>if exist "$(ProjectDir)\..\..\include\SDL_config.h" goto SDLCONFIGOKAY
-echo Copying SDL_config_win32.h to SDL_config.h...
-copy "$(ProjectDir)\..\..\include\SDL_config_win32.h" "$(ProjectDir)\..\..\include\SDL_config.h"
+echo Copying SDL_config_windows.h to SDL_config.h...
+copy "$(ProjectDir)\..\..\include\SDL_config_windows.h" "$(ProjectDir)\..\..\include\SDL_config.h"
 :SDLCONFIGOKAY
 
 if exist "$(ProjectDir)\..\..\include\SDL_revision.h" goto SDLREVISIONOKAY
@@ -155,8 +155,8 @@
     <PreBuildEvent>
       <Message>Making sure basic SDL headers are in place...</Message>
       <Command>if exist "$(ProjectDir)\..\..\include\SDL_config.h" goto SDLCONFIGOKAY
-echo Copying SDL_config_win32.h to SDL_config.h...
-copy "$(ProjectDir)\..\..\include\SDL_config_win32.h" "$(ProjectDir)\..\..\include\SDL_config.h"
+echo Copying SDL_config_windows.h to SDL_config.h...
+copy "$(ProjectDir)\..\..\include\SDL_config_windows.h" "$(ProjectDir)\..\..\include\SDL_config.h"
 :SDLCONFIGOKAY
 
 if exist "$(ProjectDir)\..\..\include\SDL_revision.h" goto SDLREVISIONOKAY
@@ -208,8 +208,8 @@
     <PreBuildEvent>
       <Message>Making sure basic SDL headers are in place...</Message>
       <Command>if exist "$(ProjectDir)\..\..\include\SDL_config.h" goto SDLCONFIGOKAY
-echo Copying SDL_config_win32.h to SDL_config.h...
-copy "$(ProjectDir)\..\..\include\SDL_config_win32.h" "$(ProjectDir)\..\..\include\SDL_config.h"
+echo Copying SDL_config_windows.h to SDL_config.h...
+copy "$(ProjectDir)\..\..\include\SDL_config_windows.h" "$(ProjectDir)\..\..\include\SDL_config.h"
 :SDLCONFIGOKAY
 
 if exist "$(ProjectDir)\..\..\include\SDL_revision.h" goto SDLREVISIONOKAY
@@ -256,9 +256,9 @@
     </Lib>
   </ItemDefinitionGroup>
   <ItemGroup>
-    <ClCompile Include="..\..\Src\Main\Win32\SDL_win32_main.c" />
+    <ClCompile Include="..\..\src\main\windows\SDL_windows_main.c" />
   </ItemGroup>
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
   <ImportGroup Label="ExtensionTargets">
   </ImportGroup>
-</Project>
\ No newline at end of file
+</Project>
--- a/configure.in	Thu Jan 20 17:33:06 2011 -0800
+++ b/configure.in	Thu Jan 20 18:04:05 2011 -0800
@@ -1645,8 +1645,8 @@
 }
 
 
-dnl Check for Win32 OpenGL
-CheckWIN32GL()
+dnl Check for Windows OpenGL
+CheckWINDOWSGL()
 {
     if test x$enable_video = xyes -a x$enable_video_opengl = xyes; then
         AC_DEFINE(SDL_VIDEO_OPENGL)
@@ -1906,10 +1906,10 @@
     fi
 }
 
-dnl Determine whether the compiler can produce Win32 executables
-CheckWIN32()
+dnl Determine whether the compiler can produce Windows executables
+CheckWINDOWS()
 {
-    AC_MSG_CHECKING(Win32 compiler)
+    AC_MSG_CHECKING(Windows compiler)
     have_win32_gcc=no
     AC_TRY_COMPILE([
      #include <windows.h>
@@ -1920,7 +1920,7 @@
     AC_MSG_RESULT($have_win32_gcc)
     if test x$have_win32_gcc != xyes; then
        AC_MSG_ERROR([
-*** Your compiler ($CC) does not produce Win32 executables!
+*** Your compiler ($CC) does not produce Windows executables!
        ])
     fi
 
@@ -1938,7 +1938,7 @@
 
     dnl See if the user wants to redirect standard output to files
     AC_ARG_ENABLE(stdio-redirect,
-AC_HELP_STRING([--enable-stdio-redirect], [Redirect STDIO to files on Win32 [[default=yes]]]),
+AC_HELP_STRING([--enable-stdio-redirect], [Redirect STDIO to files on Windows [[default=yes]]]),
                   , enable_stdio_redirect=yes)
     if test x$enable_stdio_redirect != xyes; then
         EXTRA_CFLAGS="$EXTRA_CFLAGS -DNO_STDIO_REDIRECT"
@@ -1949,7 +1949,7 @@
 CheckDIRECTX()
 {
     AC_ARG_ENABLE(directx,
-AC_HELP_STRING([--enable-directx], [use DirectX for Win32 audio/video [[default=yes]]]),
+AC_HELP_STRING([--enable-directx], [use DirectX for Windows audio/video [[default=yes]]]),
                   , enable_directx=yes)
     if test x$enable_directx = xyes; then
         AC_CHECK_HEADER(d3d9.h, have_d3d=yes)
@@ -2332,10 +2332,10 @@
         CheckDummyVideo
         CheckDiskAudio
         CheckDummyAudio
-        CheckWIN32
+        CheckWINDOWS
         if test x$enable_video = xyes; then
-            AC_DEFINE(SDL_VIDEO_DRIVER_WIN32)
-            SOURCES="$SOURCES $srcdir/src/video/win32/*.c"
+            AC_DEFINE(SDL_VIDEO_DRIVER_WINDOWS)
+            SOURCES="$SOURCES $srcdir/src/video/windows/*.c"
             have_video=yes
             AC_ARG_ENABLE(render-gdi,
 AC_HELP_STRING([--enable-render-gdi], [enable the GDI render driver [[default=yes]]]),
@@ -2381,10 +2381,10 @@
         fi
         # Set up files for the thread library
         if test x$enable_threads = xyes; then
-            AC_DEFINE(SDL_THREAD_WIN32)
-            SOURCES="$SOURCES $srcdir/src/thread/win32/SDL_sysmutex.c"
-            SOURCES="$SOURCES $srcdir/src/thread/win32/SDL_syssem.c"
-            SOURCES="$SOURCES $srcdir/src/thread/win32/SDL_systhread.c"
+            AC_DEFINE(SDL_THREAD_WINDOWS)
+            SOURCES="$SOURCES $srcdir/src/thread/windows/SDL_sysmutex.c"
+            SOURCES="$SOURCES $srcdir/src/thread/windows/SDL_syssem.c"
+            SOURCES="$SOURCES $srcdir/src/thread/windows/SDL_systhread.c"
             SOURCES="$SOURCES $srcdir/src/thread/generic/SDL_syscond.c"
             have_threads=yes
         fi
@@ -2396,8 +2396,8 @@
         fi
         # Set up files for the shared object loading library
         if test x$enable_loadso = xyes; then
-            AC_DEFINE(SDL_LOADSO_WIN32)
-            SOURCES="$SOURCES $srcdir/src/loadso/win32/*.c"
+            AC_DEFINE(SDL_LOADSO_WINDOWS)
+            SOURCES="$SOURCES $srcdir/src/loadso/windows/*.c"
             have_loadso=yes
         fi
         # Set up the system libraries we need
@@ -2412,8 +2412,8 @@
         	;;
 	esac
 
-        # The Win32 platform requires special setup
-        SDLMAIN_SOURCES="$srcdir/src/main/win32/*.c"
+        # The Windows platform requires special setup
+        SDLMAIN_SOURCES="$srcdir/src/main/windows/*.c"
         EXTRA_CFLAGS="$EXTRA_CFLAGS -Dmain=SDL_main -D_WIN32_WCE=0x420"
         EXTRA_LDFLAGS="-lSDLmain $EXTRA_LDFLAGS"
         ;;
@@ -2431,13 +2431,13 @@
         CheckDummyVideo
         CheckDiskAudio
         CheckDummyAudio
-        CheckWIN32
-        CheckWIN32GL
+        CheckWINDOWS
+        CheckWINDOWSGL
         CheckDIRECTX
         # Set up files for the video library
         if test x$enable_video = xyes; then
-            AC_DEFINE(SDL_VIDEO_DRIVER_WIN32)
-            SOURCES="$SOURCES $srcdir/src/video/win32/*.c"
+            AC_DEFINE(SDL_VIDEO_DRIVER_WINDOWS)
+            SOURCES="$SOURCES $srcdir/src/video/windows/*.c"
             have_video=yes
             AC_ARG_ENABLE(render-gdi,
 AC_HELP_STRING([--enable-render-gdi], [enable the GDI render driver [[default=yes]]]),
@@ -2466,18 +2466,18 @@
         if test x$enable_joystick = xyes; then
             if test x$have_dinput = xyes; then
                 AC_DEFINE(SDL_JOYSTICK_DINPUT)
-                SOURCES="$SOURCES $srcdir/src/joystick/win32/SDL_dxjoystick.c"
+                SOURCES="$SOURCES $srcdir/src/joystick/windows/SDL_dxjoystick.c"
                 EXTRA_LDFLAGS="$EXTRA_LDFLAGS -ldinput8 -ldxguid -ldxerr8"
             else
                 AC_DEFINE(SDL_JOYSTICK_WINMM)
-                SOURCES="$SOURCES $srcdir/src/joystick/win32/SDL_mmjoystick.c"
+                SOURCES="$SOURCES $srcdir/src/joystick/windows/SDL_mmjoystick.c"
             fi
             have_joystick=yes
         fi
         if test x$enable_haptic = xyes; then
             if test x$have_dinput = xyes; then
                 AC_DEFINE(SDL_HAPTIC_DINPUT)
-                SOURCES="$SOURCES $srcdir/src/haptic/win32/SDL_syshaptic.c"
+                SOURCES="$SOURCES $srcdir/src/haptic/windows/SDL_syshaptic.c"
                 have_haptic=yes
             fi
         fi
@@ -2488,23 +2488,23 @@
         fi
         # Set up files for the thread library
         if test x$enable_threads = xyes; then
-            AC_DEFINE(SDL_THREAD_WIN32)
-            SOURCES="$SOURCES $srcdir/src/thread/win32/SDL_sysmutex.c"
-            SOURCES="$SOURCES $srcdir/src/thread/win32/SDL_syssem.c"
-            SOURCES="$SOURCES $srcdir/src/thread/win32/SDL_systhread.c"
+            AC_DEFINE(SDL_THREAD_WINDOWS)
+            SOURCES="$SOURCES $srcdir/src/thread/windows/SDL_sysmutex.c"
+            SOURCES="$SOURCES $srcdir/src/thread/windows/SDL_syssem.c"
+            SOURCES="$SOURCES $srcdir/src/thread/windows/SDL_systhread.c"
             SOURCES="$SOURCES $srcdir/src/thread/generic/SDL_syscond.c"
             have_threads=yes
         fi
         # Set up files for the timer library
         if test x$enable_timers = xyes; then
-            AC_DEFINE(SDL_TIMER_WIN32)
-            SOURCES="$SOURCES $srcdir/src/timer/win32/*.c"
+            AC_DEFINE(SDL_TIMER_WINDOWS)
+            SOURCES="$SOURCES $srcdir/src/timer/windows/*.c"
             have_timers=yes
         fi
         # Set up files for the shared object loading library
         if test x$enable_loadso = xyes; then
-            AC_DEFINE(SDL_LOADSO_WIN32)
-            SOURCES="$SOURCES $srcdir/src/loadso/win32/*.c"
+            AC_DEFINE(SDL_LOADSO_WINDOWS)
+            SOURCES="$SOURCES $srcdir/src/loadso/windows/*.c"
             have_loadso=yes
         fi
         # Set up the system libraries we need
@@ -2512,9 +2512,9 @@
         # You can get this here: http://libunicows.sourceforge.net/
         #EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lunicows"
         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -luser32 -lgdi32 -lmsimg32 -lwinmm -limm32 -lole32 -loleaut32 -lversion -luuid"
-        # The Win32 platform requires special setup
-        VERSION_SOURCES="$srcdir/src/main/win32/*.rc"
-        SDLMAIN_SOURCES="$srcdir/src/main/win32/*.c"
+        # The Windows platform requires special setup
+        VERSION_SOURCES="$srcdir/src/main/windows/*.rc"
+        SDLMAIN_SOURCES="$srcdir/src/main/windows/*.c"
         SDL_CFLAGS="$SDL_CFLAGS -Dmain=SDL_main"
         SDL_LIBS="-lmingw32 -lSDLmain $SDL_LIBS -mwindows"
         ;;
--- a/include/SDL_compat.h	Thu Jan 20 17:33:06 2011 -0800
+++ b/include/SDL_compat.h	Thu Jan 20 18:04:05 2011 -0800
@@ -64,6 +64,12 @@
  */
 /*@{*/
 
+/* Platform */
+#ifdef __WINDOWS__
+#undef __WIN32__
+#define __WIN32__   1
+#endif
+
 /**
  *  \name Surface flags
  */
--- a/include/SDL_config.h.default	Thu Jan 20 17:33:06 2011 -0800
+++ b/include/SDL_config.h.default	Thu Jan 20 18:04:05 2011 -0800
@@ -40,8 +40,8 @@
 #include "SDL_config_iphoneos.h"
 #elif defined(__MACOSX__)
 #include "SDL_config_macosx.h"
-#elif defined(__WIN32__)
-#include "SDL_config_win32.h"
+#elif defined(__WINDOWS__)
+#include "SDL_config_windows.h"
 #else
 #include "SDL_config_minimal.h"
 #endif /* platform config */
--- a/include/SDL_config.h.in	Thu Jan 20 17:33:06 2011 -0800
+++ b/include/SDL_config.h.in	Thu Jan 20 18:04:05 2011 -0800
@@ -89,7 +89,7 @@
 #undef HAVE_REALLOC
 #undef HAVE_FREE
 #undef HAVE_ALLOCA
-#ifndef _WIN32 /* Don't use C runtime versions of these on Windows */
+#ifndef __WINDOWS__ /* Don't use C runtime versions of these on Windows */
 #undef HAVE_GETENV
 #undef HAVE_SETENV
 #undef HAVE_PUTENV
@@ -235,7 +235,7 @@
 #undef SDL_LOADSO_DLOPEN
 #undef SDL_LOADSO_DUMMY
 #undef SDL_LOADSO_LDG
-#undef SDL_LOADSO_WIN32
+#undef SDL_LOADSO_WINDOWS
 
 /* Enable various threading systems */
 #undef SDL_THREAD_BEOS
@@ -244,7 +244,7 @@
 #undef SDL_THREAD_PTHREAD_RECURSIVE_MUTEX
 #undef SDL_THREAD_PTHREAD_RECURSIVE_MUTEX_NP
 #undef SDL_THREAD_SPROC
-#undef SDL_THREAD_WIN32
+#undef SDL_THREAD_WINDOWS
 
 /* Enable various timer systems */
 #undef SDL_TIMER_BEOS
@@ -252,7 +252,7 @@
 #undef SDL_TIMER_NDS
 #undef SDL_TIMER_RISCOS
 #undef SDL_TIMER_UNIX
-#undef SDL_TIMER_WIN32
+#undef SDL_TIMER_WINDOWS
 #undef SDL_TIMER_WINCE
 
 /* Enable various video drivers */
@@ -265,7 +265,7 @@
 #undef SDL_VIDEO_DRIVER_PHOTON
 #undef SDL_VIDEO_DRIVER_QNXGF
 #undef SDL_VIDEO_DRIVER_RISCOS
-#undef SDL_VIDEO_DRIVER_WIN32
+#undef SDL_VIDEO_DRIVER_WINDOWS
 #undef SDL_VIDEO_DRIVER_X11
 #undef SDL_VIDEO_DRIVER_X11_DYNAMIC
 #undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT
--- a/include/SDL_config_win32.h	Thu Jan 20 17:33:06 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,199 +0,0 @@
-/*
-    SDL - Simple DirectMedia Layer
-    Copyright (C) 1997-2010 Sam Lantinga
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Lesser General Public
-    License as published by the Free Software Foundation; either
-    version 2.1 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Lesser General Public License for more details.
-
-    You should have received a copy of the GNU Lesser General Public
-    License along with this library; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-
-    Sam Lantinga
-    slouken@libsdl.org
-*/
-
-#ifndef _SDL_config_win32_h
-#define _SDL_config_win32_h
-
-#include "SDL_platform.h"
-
-/* This is a set of defines to configure the SDL features */
-
-#if !defined(_STDINT_H_) && (!defined(HAVE_STDINT_H) || !_HAVE_STDINT_H)
-#if defined(__GNUC__) || defined(__DMC__) || defined(__WATCOMC__)
-#define HAVE_STDINT_H	1
-#elif defined(_MSC_VER)
-typedef signed __int8 int8_t;
-typedef unsigned __int8 uint8_t;
-typedef signed __int16 int16_t;
-typedef unsigned __int16 uint16_t;
-typedef signed __int32 int32_t;
-typedef unsigned __int32 uint32_t;
-typedef signed __int64 int64_t;
-typedef unsigned __int64 uint64_t;
-#ifndef _UINTPTR_T_DEFINED
-#ifdef  _WIN64
-typedef unsigned __int64 uintptr_t;
-#else
-typedef unsigned int uintptr_t;
-#endif
-#define _UINTPTR_T_DEFINED
-#endif
-/* Older Visual C++ headers don't have the Win64-compatible typedefs... */
-#if ((_MSC_VER <= 1200) && (!defined(DWORD_PTR)))
-#define DWORD_PTR DWORD
-#endif
-#if ((_MSC_VER <= 1200) && (!defined(LONG_PTR)))
-#define LONG_PTR LONG
-#endif
-#else /* !__GNUC__ && !_MSC_VER */
-typedef signed char int8_t;
-typedef unsigned char uint8_t;
-typedef signed short int16_t;
-typedef unsigned short uint16_t;
-typedef signed int int32_t;
-typedef unsigned int uint32_t;
-typedef signed long long int64_t;
-typedef unsigned long long uint64_t;
-#ifndef _SIZE_T_DEFINED_
-#define _SIZE_T_DEFINED_
-typedef unsigned int size_t;
-#endif
-typedef unsigned int uintptr_t;
-#endif /* __GNUC__ || _MSC_VER */
-#endif /* !_STDINT_H_ && !HAVE_STDINT_H */
-
-#ifdef _WIN64
-# define SIZEOF_VOIDP 8
-#else
-# define SIZEOF_VOIDP 4
-#endif
-#define SDL_HAS_64BIT_TYPE	1
-
-/* Enabled for SDL 1.2 (binary compatibility) */
-//#define HAVE_LIBC     1
-#ifdef HAVE_LIBC
-/* Useful headers */
-#define HAVE_STDIO_H 1
-#define STDC_HEADERS 1
-#define HAVE_STRING_H 1
-#define HAVE_CTYPE_H 1
-#define HAVE_MATH_H 1
-#ifndef _WIN32_WCE
-#define HAVE_SIGNAL_H 1
-#endif
-
-/* C library functions */
-#define HAVE_MALLOC 1
-#define HAVE_CALLOC 1
-#define HAVE_REALLOC 1
-#define HAVE_FREE 1
-#define HAVE_ALLOCA 1
-#define HAVE_QSORT 1
-#define HAVE_ABS 1
-#define HAVE_MEMSET 1
-#define HAVE_MEMCPY 1
-#define HAVE_MEMMOVE 1
-#define HAVE_MEMCMP 1
-#define HAVE_STRLEN 1
-#define HAVE__STRREV 1
-#define HAVE__STRUPR 1
-#define HAVE__STRLWR 1
-#define HAVE_STRCHR 1
-#define HAVE_STRRCHR 1
-#define HAVE_STRSTR 1
-#define HAVE_ITOA 1
-#define HAVE__LTOA 1
-#define HAVE__ULTOA 1
-#define HAVE_STRTOL 1
-#define HAVE_STRTOUL 1
-#define HAVE_STRTOLL 1
-#define HAVE_STRTOD 1
-#define HAVE_ATOI 1
-#define HAVE_ATOF 1
-#define HAVE_STRCMP 1
-#define HAVE_STRNCMP 1
-#define HAVE__STRICMP 1
-#define HAVE__STRNICMP 1
-#define HAVE_SSCANF 1
-#define HAVE_M_PI 1
-#define HAVE_ATAN 1
-#define HAVE_ATAN2 1
-#define HAVE_CEIL 1
-#define HAVE_COPYSIGN 1
-#define HAVE_COS 1
-#define HAVE_COSF 1
-#define HAVE_FABS 1
-#define HAVE_FLOOR 1
-#define HAVE_LOG 1
-#define HAVE_POW 1
-#define HAVE_SCALBN 1
-#define HAVE_SIN 1
-#define HAVE_SINF 1
-#define HAVE_SQRT 1
-#else
-#define HAVE_STDARG_H	1
-#define HAVE_STDDEF_H	1
-#endif
-
-/* Enable various audio drivers */
-#ifndef _WIN32_WCE
-#define SDL_AUDIO_DRIVER_DSOUND	1
-#endif
-#define SDL_AUDIO_DRIVER_WINWAVEOUT	1
-#define SDL_AUDIO_DRIVER_DISK	1
-#define SDL_AUDIO_DRIVER_DUMMY	1
-
-/* Enable various input drivers */
-#ifdef _WIN32_WCE
-#define SDL_JOYSTICK_DISABLED	1
-#define SDL_HAPTIC_DUMMY	1
-#else
-#define SDL_JOYSTICK_DINPUT	1
-#define SDL_HAPTIC_DINPUT	1
-#endif
-
-/* Enable various shared object loading systems */
-#define SDL_LOADSO_WIN32	1
-
-/* Enable various threading systems */
-#define SDL_THREAD_WIN32	1
-
-/* Enable various timer systems */
-#ifdef _WIN32_WCE
-#define SDL_TIMER_WINCE	1
-#else
-#define SDL_TIMER_WIN32	1
-#endif
-
-/* Enable various video drivers */
-#define SDL_VIDEO_DRIVER_DUMMY	1
-#define SDL_VIDEO_DRIVER_WIN32	1
-
-#define SDL_VIDEO_RENDER_D3D	1
-#define SDL_VIDEO_RENDER_GDI	1
-
-/* Enable OpenGL support */
-#ifndef _WIN32_WCE
-#define SDL_VIDEO_OPENGL	1
-#define SDL_VIDEO_OPENGL_WGL	1
-#define SDL_VIDEO_RENDER_OGL	1
-#endif
-
-/* Enable system power support */
-#define SDL_POWER_WINDOWS 1
-
-/* Enable assembly routines (Win64 doesn't have inline asm) */
-#ifndef _WIN64
-#define SDL_ASSEMBLY_ROUTINES	1
-#endif
-
-#endif /* _SDL_config_win32_h */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/include/SDL_config_windows.h	Thu Jan 20 18:04:05 2011 -0800
@@ -0,0 +1,199 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997-2010 Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+
+    Sam Lantinga
+    slouken@libsdl.org
+*/
+
+#ifndef _SDL_config_windows2_h
+#define _SDL_config_windows2_h
+
+#include "SDL_platform.h"
+
+/* This is a set of defines to configure the SDL features */
+
+#if !defined(_STDINT_H_) && (!defined(HAVE_STDINT_H) || !_HAVE_STDINT_H)
+#if defined(__GNUC__) || defined(__DMC__) || defined(__WATCOMC__)
+#define HAVE_STDINT_H	1
+#elif defined(_MSC_VER)
+typedef signed __int8 int8_t;
+typedef unsigned __int8 uint8_t;
+typedef signed __int16 int16_t;
+typedef unsigned __int16 uint16_t;
+typedef signed __int32 int32_t;
+typedef unsigned __int32 uint32_t;
+typedef signed __int64 int64_t;
+typedef unsigned __int64 uint64_t;
+#ifndef _UINTPTR_T_DEFINED
+#ifdef  _WIN64
+typedef unsigned __int64 uintptr_t;
+#else
+typedef unsigned int uintptr_t;
+#endif
+#define _UINTPTR_T_DEFINED
+#endif
+/* Older Visual C++ headers don't have the Win64-compatible typedefs... */
+#if ((_MSC_VER <= 1200) && (!defined(DWORD_PTR)))
+#define DWORD_PTR DWORD
+#endif
+#if ((_MSC_VER <= 1200) && (!defined(LONG_PTR)))
+#define LONG_PTR LONG
+#endif
+#else /* !__GNUC__ && !_MSC_VER */
+typedef signed char int8_t;
+typedef unsigned char uint8_t;
+typedef signed short int16_t;
+typedef unsigned short uint16_t;
+typedef signed int int32_t;
+typedef unsigned int uint32_t;
+typedef signed long long int64_t;
+typedef unsigned long long uint64_t;
+#ifndef _SIZE_T_DEFINED_
+#define _SIZE_T_DEFINED_
+typedef unsigned int size_t;
+#endif
+typedef unsigned int uintptr_t;
+#endif /* __GNUC__ || _MSC_VER */
+#endif /* !_STDINT_H_ && !HAVE_STDINT_H */
+
+#ifdef _WIN64
+# define SIZEOF_VOIDP 8
+#else
+# define SIZEOF_VOIDP 4
+#endif
+#define SDL_HAS_64BIT_TYPE	1
+
+/* Enabled for SDL 1.2 (binary compatibility) */
+//#define HAVE_LIBC     1
+#ifdef HAVE_LIBC
+/* Useful headers */
+#define HAVE_STDIO_H 1
+#define STDC_HEADERS 1
+#define HAVE_STRING_H 1
+#define HAVE_CTYPE_H 1
+#define HAVE_MATH_H 1
+#ifndef _WIN32_WCE
+#define HAVE_SIGNAL_H 1
+#endif
+
+/* C library functions */
+#define HAVE_MALLOC 1
+#define HAVE_CALLOC 1
+#define HAVE_REALLOC 1
+#define HAVE_FREE 1
+#define HAVE_ALLOCA 1
+#define HAVE_QSORT 1
+#define HAVE_ABS 1
+#define HAVE_MEMSET 1
+#define HAVE_MEMCPY 1
+#define HAVE_MEMMOVE 1
+#define HAVE_MEMCMP 1
+#define HAVE_STRLEN 1
+#define HAVE__STRREV 1
+#define HAVE__STRUPR 1
+#define HAVE__STRLWR 1
+#define HAVE_STRCHR 1
+#define HAVE_STRRCHR 1
+#define HAVE_STRSTR 1
+#define HAVE_ITOA 1
+#define HAVE__LTOA 1
+#define HAVE__ULTOA 1
+#define HAVE_STRTOL 1
+#define HAVE_STRTOUL 1
+#define HAVE_STRTOLL 1
+#define HAVE_STRTOD 1
+#define HAVE_ATOI 1
+#define HAVE_ATOF 1
+#define HAVE_STRCMP 1
+#define HAVE_STRNCMP 1
+#define HAVE__STRICMP 1
+#define HAVE__STRNICMP 1
+#define HAVE_SSCANF 1
+#define HAVE_M_PI 1
+#define HAVE_ATAN 1
+#define HAVE_ATAN2 1
+#define HAVE_CEIL 1
+#define HAVE_COPYSIGN 1
+#define HAVE_COS 1
+#define HAVE_COSF 1
+#define HAVE_FABS 1
+#define HAVE_FLOOR 1
+#define HAVE_LOG 1
+#define HAVE_POW 1
+#define HAVE_SCALBN 1
+#define HAVE_SIN 1
+#define HAVE_SINF 1
+#define HAVE_SQRT 1
+#else
+#define HAVE_STDARG_H	1
+#define HAVE_STDDEF_H	1
+#endif
+
+/* Enable various audio drivers */
+#ifndef _WIN32_WCE
+#define SDL_AUDIO_DRIVER_DSOUND	1
+#endif
+#define SDL_AUDIO_DRIVER_WINWAVEOUT	1
+#define SDL_AUDIO_DRIVER_DISK	1
+#define SDL_AUDIO_DRIVER_DUMMY	1
+
+/* Enable various input drivers */
+#ifdef _WIN32_WCE
+#define SDL_JOYSTICK_DISABLED	1
+#define SDL_HAPTIC_DUMMY	1
+#else
+#define SDL_JOYSTICK_DINPUT	1
+#define SDL_HAPTIC_DINPUT	1
+#endif
+
+/* Enable various shared object loading systems */
+#define SDL_LOADSO_WINDOWS	1
+
+/* Enable various threading systems */
+#define SDL_THREAD_WINDOWS	1
+
+/* Enable various timer systems */
+#ifdef _WIN32_WCE
+#define SDL_TIMER_WINCE	1
+#else
+#define SDL_TIMER_WINDOWS	1
+#endif
+
+/* Enable various video drivers */
+#define SDL_VIDEO_DRIVER_DUMMY	1
+#define SDL_VIDEO_DRIVER_WINDOWS	1
+
+#define SDL_VIDEO_RENDER_D3D	1
+#define SDL_VIDEO_RENDER_GDI	1
+
+/* Enable OpenGL support */
+#ifndef _WIN32_WCE
+#define SDL_VIDEO_OPENGL	1
+#define SDL_VIDEO_OPENGL_WGL	1
+#define SDL_VIDEO_RENDER_OGL	1
+#endif
+
+/* Enable system power support */
+#define SDL_POWER_WINDOWS 1
+
+/* Enable assembly routines (Win64 doesn't have inline asm) */
+#ifndef _WIN64
+#define SDL_ASSEMBLY_ROUTINES	1
+#endif
+
+#endif /* _SDL_config_windows2_h */
--- a/include/SDL_main.h	Thu Jan 20 17:33:06 2011 -0800
+++ b/include/SDL_main.h	Thu Jan 20 18:04:05 2011 -0800
@@ -31,7 +31,7 @@
  *  Redefine main() on some platforms so that it is called by SDL.
  */
 
-#if defined(__WIN32__) || \
+#if defined(__WINDOWS__) || \
     (defined(__MWERKS__) && !defined(__BEOS__)) || \
     defined(__SYMBIAN32__) || defined(__IPHONEOS__) || \
     defined(__ANDROID__)
@@ -66,7 +66,7 @@
 
 
 /* From the SDL library code -- needed for registering the app on Win32 */
-#ifdef __WIN32__
+#ifdef __WINDOWS__
 
 #include "begin_code.h"
 #ifdef __cplusplus
--- a/include/SDL_opengl.h	Thu Jan 20 17:33:06 2011 -0800
+++ b/include/SDL_opengl.h	Thu Jan 20 18:04:05 2011 -0800
@@ -31,7 +31,7 @@
 
 #include "SDL_config.h"
 
-#ifdef __WIN32__
+#ifdef __WINDOWS__
 #define WIN32_LEAN_AND_MEAN
 #ifndef NOMINMAX
 #define NOMINMAX                /* Don't defined min() and max() */
--- a/include/SDL_platform.h	Thu Jan 20 17:33:06 2011 -0800
+++ b/include/SDL_platform.h	Thu Jan 20 18:04:05 2011 -0800
@@ -125,8 +125,8 @@
 #define __SOLARIS__	1
 #endif
 #if defined(WIN32) || defined(_WIN32)
-#undef __WIN32__
-#define __WIN32__	1
+#undef __WINDOWS__
+#define __WINDOWS__	1
 #endif
 
 #if defined(__NDS__)
--- a/include/SDL_rwops.h	Thu Jan 20 17:33:06 2011 -0800
+++ b/include/SDL_rwops.h	Thu Jan 20 18:04:05 2011 -0800
@@ -83,7 +83,7 @@
     Uint32 type;
     union
     {
-#ifdef __WIN32__
+#ifdef __WINDOWS__
         struct
         {
             SDL_bool append;
@@ -94,7 +94,7 @@
                 size_t size;
                 size_t left;
             } buffer;
-        } win32io;
+        } windowsio;
 #endif
 #ifdef HAVE_STDIO_H
         struct
--- a/include/SDL_syswm.h	Thu Jan 20 17:33:06 2011 -0800
+++ b/include/SDL_syswm.h	Thu Jan 20 18:04:05 2011 -0800
@@ -54,7 +54,7 @@
 struct SDL_SysWMinfo;
 #else
 
-#if defined(SDL_VIDEO_DRIVER_WIN32)
+#if defined(SDL_VIDEO_DRIVER_WINDOWS)
 #define WIN32_LEAN_AND_MEAN
 #include <windows.h>
 #endif
@@ -118,7 +118,7 @@
     SDL_SYSWM_TYPE subsystem;
     union
     {
-#if defined(SDL_VIDEO_DRIVER_WIN32)
+#if defined(SDL_VIDEO_DRIVER_WINDOWS)
         struct {
             HWND hwnd;                  /**< The window for the message */
             UINT msg;                   /**< The type of message */
@@ -163,7 +163,7 @@
     SDL_SYSWM_TYPE subsystem;
     union
     {
-#if defined(SDL_VIDEO_DRIVER_WIN32)
+#if defined(SDL_VIDEO_DRIVER_WINDOWS)
         struct
         {
             HWND window;                /**< The window handle */
--- a/include/SDL_thread.h	Thu Jan 20 17:33:06 2011 -0800
+++ b/include/SDL_thread.h	Thu Jan 20 18:04:05 2011 -0800
@@ -55,7 +55,7 @@
  */
 typedef int (SDLCALL * SDL_ThreadFunction) (void *data);
 
-#if defined(__WIN32__) && !defined(HAVE_LIBC)
+#if defined(__WINDOWS__) && !defined(HAVE_LIBC)
 /**
  *  \file SDL_thread.h
  *  
--- a/include/begin_code.h	Thu Jan 20 17:33:06 2011 -0800
+++ b/include/begin_code.h	Thu Jan 20 18:04:05 2011 -0800
@@ -42,7 +42,7 @@
 #  else
 #   define DECLSPEC	__declspec(export)
 #  endif
-# elif defined(__WIN32__)
+# elif defined(__WINDOWS__)
 #  ifdef __BORLANDC__
 #   ifdef BUILD_SDL
 #    define DECLSPEC
@@ -63,7 +63,7 @@
 
 /* By default SDL uses the C calling convention */
 #ifndef SDLCALL
-#if defined(__WIN32__) && !defined(__GNUC__)
+#if defined(__WINDOWS__) && !defined(__GNUC__)
 #define SDLCALL __cdecl
 #else
 #define SDLCALL
--- a/src/SDL.c	Thu Jan 20 17:33:06 2011 -0800
+++ b/src/SDL.c	Thu Jan 20 18:04:05 2011 -0800
@@ -39,7 +39,7 @@
 extern int SDL_TimerInit(void);
 extern void SDL_TimerQuit(void);
 #endif
-#if defined(__WIN32__)
+#if defined(__WINDOWS__)
 extern int SDL_HelperWindowCreate(void);
 extern int SDL_HelperWindowDestroy(void);
 #endif
@@ -147,7 +147,7 @@
     /* Clear the error message */
     SDL_ClearError();
 
-#if defined(__WIN32__)
+#if defined(__WINDOWS__)
     if (SDL_HelperWindowCreate() < 0) {
         return -1;
     }
@@ -220,7 +220,7 @@
     fflush(stdout);
 #endif
 
-#if defined(__WIN32__)
+#if defined(__WINDOWS__)
     SDL_HelperWindowDestroy();
 #endif
     SDL_QuitSubSystem(SDL_INIT_EVERYTHING);
@@ -312,7 +312,7 @@
     return "RISC OS";
 #elif __SOLARIS__
     return "Solaris";
-#elif __WIN32__
+#elif __WINDOWS__
 #ifdef _WIN32_WCE
     return "Windows CE";
 #else
@@ -325,7 +325,7 @@
 #endif
 }
 
-#if defined(__WIN32__)
+#if defined(__WINDOWS__)
 
 #if !defined(HAVE_LIBC) || (defined(__WATCOMC__) && defined(BUILD_DLL))
 /* Need to include DllMain() on Watcom C for some reason.. */
@@ -347,6 +347,6 @@
 }
 #endif /* building DLL with Watcom C */
 
-#endif /* __WIN32__ */
+#endif /* __WINDOWS__ */
 
 /* vi: set ts=4 sw=4 expandtab: */
--- a/src/audio/SDL_audio.c	Thu Jan 20 17:33:06 2011 -0800
+++ b/src/audio/SDL_audio.c	Thu Jan 20 18:04:05 2011 -0800
@@ -971,7 +971,7 @@
     if (!current_audio.impl.ProvidesOwnCallbackThread) {
         /* Start the audio thread */
 /* !!! FIXME: this is nasty. */
-#if (defined(__WIN32__) && !defined(_WIN32_WCE)) && !defined(HAVE_LIBC)
+#if (defined(__WINDOWS__) && !defined(_WIN32_WCE)) && !defined(HAVE_LIBC)
 #undef SDL_CreateThread
         device->thread = SDL_CreateThread(SDL_RunAudio, device, NULL, NULL);
 #else
--- a/src/cpuinfo/SDL_cpuinfo.c	Thu Jan 20 17:33:06 2011 -0800
+++ b/src/cpuinfo/SDL_cpuinfo.c	Thu Jan 20 18:04:05 2011 -0800
@@ -38,7 +38,7 @@
 #include <signal.h>
 #include <setjmp.h>
 #endif
-#ifdef __WIN32__
+#ifdef __WINDOWS__
 #define WIN32_LEAN_AND_MEAN
 #include <windows.h>
 #endif
@@ -319,7 +319,7 @@
             sysctlbyname("hw.ncpu", &SDL_CPUCount, &size, NULL, 0);
         }
 #endif
-#ifdef __WIN32__
+#ifdef __WINDOWS__
         if (SDL_CPUCount <= 0) {
             SYSTEM_INFO info;
             GetSystemInfo(&info);
--- a/src/events/SDL_events.c	Thu Jan 20 17:33:06 2011 -0800
+++ b/src/events/SDL_events.c	Thu Jan 20 18:04:05 2011 -0800
@@ -170,7 +170,7 @@
 
         /* The event thread will handle timers too */
         SDL_SetTimerThreaded(2);
-#if (defined(__WIN32__) && !defined(_WIN32_WCE)) && !defined(HAVE_LIBC)
+#if (defined(__WINDOWS__) && !defined(_WIN32_WCE)) && !defined(HAVE_LIBC)
 #undef SDL_CreateThread
         SDL_EventThread =
             SDL_CreateThread(SDL_GobbleEvents, NULL, NULL, NULL);
--- a/src/events/SDL_sysevents.h	Thu Jan 20 17:33:06 2011 -0800
+++ b/src/events/SDL_sysevents.h	Thu Jan 20 18:04:05 2011 -0800
@@ -29,7 +29,7 @@
 #define MUST_THREAD_EVENTS
 #endif
 
-#ifdef __WIN32__                /* Win32 doesn't allow a separate event thread */
+#ifdef __WINDOWS__              /* Windows doesn't allow a separate event thread */
 #define CANT_THREAD_EVENTS
 #endif
 
--- a/src/events/scancodes_win32.h	Thu Jan 20 17:33:06 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,287 +0,0 @@
-/*
-    SDL - Simple DirectMedia Layer
-    Copyright (C) 1997-2010 Sam Lantinga
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Lesser General Public
-    License as published by the Free Software Foundation; either
-    version 2.1 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Lesser General Public License for more details.
-
-    You should have received a copy of the GNU Lesser General Public
-    License along with this library; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-
-    Sam Lantinga
-    slouken@libsdl.org
-*/
-#include "../../include/SDL_scancode.h"
-
-/* Win32 virtual key code to SDL scancode mapping table
-   Sources:
-   - msdn.microsoft.com
-*/
-/* *INDENT-OFF* */
-static const SDL_scancode win32_scancode_table[] = {
-    /*  0, 0x00 */      SDL_SCANCODE_UNKNOWN,
-    /*  1, 0x01 */      SDL_SCANCODE_UNKNOWN,
-    /*  2, 0x02 */      SDL_SCANCODE_UNKNOWN,
-    /*  3, 0x03 */      SDL_SCANCODE_UNKNOWN,
-    /*  4, 0x04 */      SDL_SCANCODE_UNKNOWN,
-    /*  5, 0x05 */      SDL_SCANCODE_UNKNOWN,
-    /*  6, 0x06 */      SDL_SCANCODE_UNKNOWN,
-    /*  7, 0x07 */      SDL_SCANCODE_UNKNOWN,
-    /*  8, 0x08 */      SDL_SCANCODE_BACKSPACE,
-    /*  9, 0x09 */      SDL_SCANCODE_TAB,
-    /*  10, 0x0a */     SDL_SCANCODE_KP_ENTER, /* Not a VKEY, SDL specific */
-    /*  11, 0x0b */     SDL_SCANCODE_UNKNOWN,
-    /*  12, 0x0c */     SDL_SCANCODE_CLEAR,
-    /*  13, 0x0d */     SDL_SCANCODE_RETURN,
-    /*  14, 0x0e */     SDL_SCANCODE_UNKNOWN,
-    /*  15, 0x0f */     SDL_SCANCODE_UNKNOWN,
-    /*  16, 0x10 */     SDL_SCANCODE_UNKNOWN,
-    /*  17, 0x11 */     SDL_SCANCODE_UNKNOWN,
-    /*  18, 0x12 */     SDL_SCANCODE_APPLICATION,
-    /*  19, 0x13 */     SDL_SCANCODE_PAUSE,
-    /*  20, 0x14 */     SDL_SCANCODE_CAPSLOCK,
-    /*  21, 0x15 */     SDL_SCANCODE_UNKNOWN,
-    /*  22, 0x16 */     SDL_SCANCODE_UNKNOWN,
-    /*  23, 0x17 */     SDL_SCANCODE_UNKNOWN,
-    /*  24, 0x18 */     SDL_SCANCODE_UNKNOWN,
-    /*  25, 0x19 */     SDL_SCANCODE_UNKNOWN,
-    /*  26, 0x1a */     SDL_SCANCODE_UNKNOWN,
-    /*  27, 0x1b */     SDL_SCANCODE_ESCAPE,
-    /*  28, 0x1c */     SDL_SCANCODE_UNKNOWN,
-    /*  29, 0x1d */     SDL_SCANCODE_UNKNOWN,
-    /*  30, 0x1e */     SDL_SCANCODE_UNKNOWN,
-    /*  31, 0x1f */     SDL_SCANCODE_MODE,
-    /*  32, 0x20 */     SDL_SCANCODE_SPACE,
-    /*  33, 0x21 */     SDL_SCANCODE_PAGEUP,
-    /*  34, 0x22 */     SDL_SCANCODE_PAGEDOWN,
-    /*  35, 0x23 */     SDL_SCANCODE_END,
-    /*  36, 0x24 */     SDL_SCANCODE_HOME,
-    /*  37, 0x25 */     SDL_SCANCODE_LEFT,
-    /*  38, 0x26 */     SDL_SCANCODE_UP,
-    /*  39, 0x27 */     SDL_SCANCODE_RIGHT,
-    /*  40, 0x28 */     SDL_SCANCODE_DOWN,
-    /*  41, 0x29 */     SDL_SCANCODE_SELECT,
-    /*  42, 0x2a */     SDL_SCANCODE_UNKNOWN, /* VK_PRINT */
-    /*  43, 0x2b */     SDL_SCANCODE_EXECUTE,
-    /*  44, 0x2c */     SDL_SCANCODE_PRINTSCREEN,
-    /*  45, 0x2d */     SDL_SCANCODE_INSERT,
-    /*  46, 0x2e */     SDL_SCANCODE_DELETE,
-    /*  47, 0x2f */     SDL_SCANCODE_HELP,
-    /*  48, 0x30 */     SDL_SCANCODE_0,
-    /*  49, 0x31 */     SDL_SCANCODE_1,
-    /*  50, 0x32 */     SDL_SCANCODE_2,
-    /*  51, 0x33 */     SDL_SCANCODE_3,
-    /*  52, 0x34 */     SDL_SCANCODE_4,
-    /*  53, 0x35 */     SDL_SCANCODE_5,
-    /*  54, 0x36 */     SDL_SCANCODE_6,
-    /*  55, 0x37 */     SDL_SCANCODE_7,
-    /*  56, 0x38 */     SDL_SCANCODE_8,
-    /*  57, 0x39 */     SDL_SCANCODE_9,
-    /*  58, 0x3a */     SDL_SCANCODE_UNKNOWN,
-    /*  59, 0x3b */     SDL_SCANCODE_UNKNOWN,
-    /*  60, 0x3c */     SDL_SCANCODE_UNKNOWN,
-    /*  61, 0x3d */     SDL_SCANCODE_UNKNOWN,
-    /*  62, 0x3e */     SDL_SCANCODE_UNKNOWN,
-    /*  63, 0x3f */     SDL_SCANCODE_UNKNOWN,
-    /*  64, 0x40 */     SDL_SCANCODE_UNKNOWN,
-    /*  65, 0x41 */     SDL_SCANCODE_A,
-    /*  66, 0x42 */     SDL_SCANCODE_B,
-    /*  67, 0x43 */     SDL_SCANCODE_C,
-    /*  68, 0x44 */     SDL_SCANCODE_D,
-    /*  69, 0x45 */     SDL_SCANCODE_E,
-    /*  70, 0x46 */     SDL_SCANCODE_F,
-    /*  71, 0x47 */     SDL_SCANCODE_G,
-    /*  72, 0x48 */     SDL_SCANCODE_H,
-    /*  73, 0x49 */     SDL_SCANCODE_I,
-    /*  74, 0x4a */     SDL_SCANCODE_J,
-    /*  75, 0x4b */     SDL_SCANCODE_K,
-    /*  76, 0x4c */     SDL_SCANCODE_L,
-    /*  77, 0x4d */     SDL_SCANCODE_M,
-    /*  78, 0x4e */     SDL_SCANCODE_N,
-    /*  79, 0x4f */     SDL_SCANCODE_O,
-    /*  80, 0x50 */     SDL_SCANCODE_P,
-    /*  81, 0x51 */     SDL_SCANCODE_Q,
-    /*  82, 0x52 */     SDL_SCANCODE_R,
-    /*  83, 0x53 */     SDL_SCANCODE_S,
-    /*  84, 0x54 */     SDL_SCANCODE_T,
-    /*  85, 0x55 */     SDL_SCANCODE_U,
-    /*  86, 0x56 */     SDL_SCANCODE_V,
-    /*  87, 0x57 */     SDL_SCANCODE_W,
-    /*  88, 0x58 */     SDL_SCANCODE_X,
-    /*  89, 0x59 */     SDL_SCANCODE_Y,
-    /*  90, 0x5a */     SDL_SCANCODE_Z,
-    /*  91, 0x5b */     SDL_SCANCODE_LGUI,
-    /*  92, 0x5c */     SDL_SCANCODE_RGUI,
-    /*  93, 0x5d */     SDL_SCANCODE_APPLICATION,
-    /*  94, 0x5e */     SDL_SCANCODE_UNKNOWN,
-    /*  95, 0x5f */     SDL_SCANCODE_UNKNOWN,
-    /*  96, 0x60 */     SDL_SCANCODE_KP_0,
-    /*  97, 0x61 */     SDL_SCANCODE_KP_1,
-    /*  98, 0x62 */     SDL_SCANCODE_KP_2,
-    /*  99, 0x63 */     SDL_SCANCODE_KP_3,
-    /*  100, 0x64 */    SDL_SCANCODE_KP_4,
-    /*  101, 0x65 */    SDL_SCANCODE_KP_5,
-    /*  102, 0x66 */    SDL_SCANCODE_KP_6,
-    /*  103, 0x67 */    SDL_SCANCODE_KP_7,
-    /*  104, 0x68 */    SDL_SCANCODE_KP_8,
-    /*  105, 0x69 */    SDL_SCANCODE_KP_9,
-    /*  106, 0x6a */    SDL_SCANCODE_KP_MULTIPLY,
-    /*  107, 0x6b */    SDL_SCANCODE_KP_PLUS,
-    /*  108, 0x6c */    SDL_SCANCODE_SEPARATOR,
-    /*  109, 0x6d */    SDL_SCANCODE_KP_MINUS,
-    /*  110, 0x6e */    SDL_SCANCODE_KP_DECIMAL,
-    /*  111, 0x6f */    SDL_SCANCODE_KP_DIVIDE,
-    /*  112, 0x70 */    SDL_SCANCODE_F1,
-    /*  113, 0x71 */    SDL_SCANCODE_F2,
-    /*  114, 0x72 */    SDL_SCANCODE_F3,
-    /*  115, 0x73 */    SDL_SCANCODE_F4,
-    /*  116, 0x74 */    SDL_SCANCODE_F5,
-    /*  117, 0x75 */    SDL_SCANCODE_F6,
-    /*  118, 0x76 */    SDL_SCANCODE_F7,
-    /*  119, 0x77 */    SDL_SCANCODE_F8,
-    /*  120, 0x78 */    SDL_SCANCODE_F9,
-    /*  121, 0x79 */    SDL_SCANCODE_F10,
-    /*  122, 0x7a */    SDL_SCANCODE_F11,
-    /*  123, 0x7b */    SDL_SCANCODE_F12,
-    /*  124, 0x7c */    SDL_SCANCODE_F13,
-    /*  125, 0x7d */    SDL_SCANCODE_F14,
-    /*  126, 0x7e */    SDL_SCANCODE_F15,
-    /*  127, 0x7f */    SDL_SCANCODE_F16,
-    /*  128, 0x80 */    SDL_SCANCODE_F17, /* or SDL_SCANCODE_AUDIONEXT */
-    /*  129, 0x81 */    SDL_SCANCODE_F18, /* or SDL_SCANCODE_AUDIOPREV */
-    /*  130, 0x82 */    SDL_SCANCODE_F19, /* or SDL_SCANCODE_AUDIOSTOP */
-    /*  131, 0x83 */    SDL_SCANCODE_F20, /* or SDL_SCANCODE_AUDIOPLAY */
-    /*  132, 0x84 */    SDL_SCANCODE_F21, /* or SDL_SCANCODE_MAIL */
-    /*  133, 0x85 */    SDL_SCANCODE_F22, /* or SDL_SCANCODE_MEDIASELECT */
-    /*  134, 0x86 */    SDL_SCANCODE_F23, /* or SDL_SCANCODE_WWW */
-    /*  135, 0x87 */    SDL_SCANCODE_F24, /* or SDL_SCANCODE_CALCULATOR */
-    /*  136, 0x88 */    SDL_SCANCODE_UNKNOWN,
-    /*  137, 0x89 */    SDL_SCANCODE_UNKNOWN,
-    /*  138, 0x8a */    SDL_SCANCODE_UNKNOWN,
-    /*  139, 0x8b */    SDL_SCANCODE_UNKNOWN,
-    /*  140, 0x8c */    SDL_SCANCODE_UNKNOWN,
-    /*  141, 0x8d */    SDL_SCANCODE_UNKNOWN,
-    /*  142, 0x8e */    SDL_SCANCODE_UNKNOWN,
-    /*  143, 0x8f */    SDL_SCANCODE_UNKNOWN,
-    /*  144, 0x90 */    SDL_SCANCODE_NUMLOCKCLEAR,
-    /*  145, 0x91 */    SDL_SCANCODE_SCROLLLOCK,
-    /*  146, 0x92 */    SDL_SCANCODE_KP_EQUALS,
-    /*  147, 0x93 */    SDL_SCANCODE_UNKNOWN,
-    /*  148, 0x94 */    SDL_SCANCODE_UNKNOWN,
-    /*  149, 0x95 */    SDL_SCANCODE_UNKNOWN,
-    /*  150, 0x96 */    SDL_SCANCODE_UNKNOWN,
-    /*  151, 0x97 */    SDL_SCANCODE_UNKNOWN,
-    /*  152, 0x98 */    SDL_SCANCODE_UNKNOWN,
-    /*  153, 0x99 */    SDL_SCANCODE_UNKNOWN,
-    /*  154, 0x9a */    SDL_SCANCODE_UNKNOWN,
-    /*  155, 0x9b */    SDL_SCANCODE_UNKNOWN,
-    /*  156, 0x9c */    SDL_SCANCODE_UNKNOWN,
-    /*  157, 0x9d */    SDL_SCANCODE_UNKNOWN,
-    /*  158, 0x9e */    SDL_SCANCODE_UNKNOWN,
-    /*  159, 0x9f */    SDL_SCANCODE_UNKNOWN,
-    /*  160, 0xa0 */    SDL_SCANCODE_LSHIFT,
-    /*  161, 0xa1 */    SDL_SCANCODE_RSHIFT,
-    /*  162, 0xa2 */    SDL_SCANCODE_LCTRL,
-    /*  163, 0xa3 */    SDL_SCANCODE_RCTRL,
-    /*  164, 0xa4 */    SDL_SCANCODE_LALT,
-    /*  165, 0xa5 */    SDL_SCANCODE_RALT,
-    /*  166, 0xa6 */    SDL_SCANCODE_AC_BACK,
-    /*  167, 0xa7 */    SDL_SCANCODE_AC_FORWARD,
-    /*  168, 0xa8 */    SDL_SCANCODE_AC_REFRESH,
-    /*  169, 0xa9 */    SDL_SCANCODE_AC_STOP,
-    /*  170, 0xaa */    SDL_SCANCODE_AC_SEARCH,
-    /*  171, 0xab */    SDL_SCANCODE_AC_BOOKMARKS,
-    /*  172, 0xac */    SDL_SCANCODE_AC_HOME,
-    /*  173, 0xad */    SDL_SCANCODE_AUDIOMUTE,
-    /*  174, 0xae */    SDL_SCANCODE_VOLUMEDOWN,
-    /*  175, 0xaf */    SDL_SCANCODE_VOLUMEUP,
-    /*  176, 0xb0 */    SDL_SCANCODE_AUDIONEXT,
-    /*  177, 0xb1 */    SDL_SCANCODE_AUDIOPREV,
-    /*  178, 0xb2 */    SDL_SCANCODE_AUDIOSTOP,
-    /*  179, 0xb3 */    SDL_SCANCODE_AUDIOPLAY,
-    /*  180, 0xb4 */    SDL_SCANCODE_MAIL,
-    /*  181, 0xb5 */    SDL_SCANCODE_MEDIASELECT,
-    /*  182, 0xb6 */    SDL_SCANCODE_UNKNOWN, /* VK_LAUNCH_APP1 */
-    /*  183, 0xb7 */    SDL_SCANCODE_UNKNOWN, /* VK_LAUNCH_APP2 */
-    /*  184, 0xb8 */    SDL_SCANCODE_UNKNOWN,
-    /*  185, 0xb9 */    SDL_SCANCODE_UNKNOWN,
-    /*  186, 0xba */    SDL_SCANCODE_SEMICOLON,
-    /*  187, 0xbb */    SDL_SCANCODE_EQUALS,
-    /*  188, 0xbc */    SDL_SCANCODE_COMMA,
-    /*  189, 0xbd */    SDL_SCANCODE_MINUS,
-    /*  190, 0xbe */    SDL_SCANCODE_PERIOD,
-    /*  191, 0xbf */    SDL_SCANCODE_SLASH,
-    /*  192, 0xc0 */    SDL_SCANCODE_GRAVE,
-    /*  193, 0xc1 */    SDL_SCANCODE_UNKNOWN,
-    /*  194, 0xc2 */    SDL_SCANCODE_UNKNOWN,
-    /*  195, 0xc3 */    SDL_SCANCODE_UNKNOWN,
-    /*  196, 0xc4 */    SDL_SCANCODE_UNKNOWN,
-    /*  197, 0xc5 */    SDL_SCANCODE_UNKNOWN,
-    /*  198, 0xc6 */    SDL_SCANCODE_UNKNOWN,
-    /*  199, 0xc7 */    SDL_SCANCODE_UNKNOWN,
-    /*  200, 0xc8 */    SDL_SCANCODE_UNKNOWN,
-    /*  201, 0xc9 */    SDL_SCANCODE_UNKNOWN,
-    /*  202, 0xca */    SDL_SCANCODE_UNKNOWN,
-    /*  203, 0xcb */    SDL_SCANCODE_UNKNOWN,
-    /*  204, 0xcc */    SDL_SCANCODE_UNKNOWN,
-    /*  205, 0xcd */    SDL_SCANCODE_UNKNOWN,
-    /*  206, 0xce */    SDL_SCANCODE_UNKNOWN,
-    /*  207, 0xcf */    SDL_SCANCODE_UNKNOWN,
-    /*  208, 0xd0 */    SDL_SCANCODE_UNKNOWN,
-    /*  209, 0xd1 */    SDL_SCANCODE_UNKNOWN,
-    /*  210, 0xd2 */    SDL_SCANCODE_UNKNOWN,
-    /*  211, 0xd3 */    SDL_SCANCODE_UNKNOWN,
-    /*  212, 0xd4 */    SDL_SCANCODE_UNKNOWN,
-    /*  213, 0xd5 */    SDL_SCANCODE_UNKNOWN,
-    /*  214, 0xd6 */    SDL_SCANCODE_UNKNOWN,
-    /*  215, 0xd7 */    SDL_SCANCODE_UNKNOWN,
-    /*  216, 0xd8 */    SDL_SCANCODE_UNKNOWN,
-    /*  217, 0xd9 */    SDL_SCANCODE_UNKNOWN,
-    /*  218, 0xda */    SDL_SCANCODE_UNKNOWN,
-    /*  219, 0xdb */    SDL_SCANCODE_LEFTBRACKET,
-    /*  220, 0xdc */    SDL_SCANCODE_BACKSLASH,
-    /*  221, 0xdd */    SDL_SCANCODE_RIGHTBRACKET,
-    /*  222, 0xde */    SDL_SCANCODE_APOSTROPHE,
-    /*  223, 0xdf */    SDL_SCANCODE_UNKNOWN,
-    /*  224, 0xe0 */    SDL_SCANCODE_UNKNOWN,
-    /*  225, 0xe1 */    SDL_SCANCODE_UNKNOWN,
-    /*  226, 0xe2 */    SDL_SCANCODE_NONUSBACKSLASH,
-    /*  227, 0xe3 */    SDL_SCANCODE_UNKNOWN,
-    /*  228, 0xe4 */    SDL_SCANCODE_UNKNOWN,
-    /*  229, 0xe5 */    SDL_SCANCODE_UNKNOWN,
-    /*  230, 0xe6 */    SDL_SCANCODE_UNKNOWN,
-    /*  231, 0xe7 */    SDL_SCANCODE_UNKNOWN,
-    /*  232, 0xe8 */    SDL_SCANCODE_UNKNOWN,
-    /*  233, 0xe9 */    SDL_SCANCODE_UNKNOWN,
-    /*  234, 0xea */    SDL_SCANCODE_UNKNOWN,
-    /*  235, 0xeb */    SDL_SCANCODE_UNKNOWN,
-    /*  236, 0xec */    SDL_SCANCODE_UNKNOWN,
-    /*  237, 0xed */    SDL_SCANCODE_UNKNOWN,
-    /*  238, 0xee */    SDL_SCANCODE_UNKNOWN,
-    /*  239, 0xef */    SDL_SCANCODE_UNKNOWN,
-    /*  240, 0xf0 */    SDL_SCANCODE_UNKNOWN,
-    /*  241, 0xf1 */    SDL_SCANCODE_UNKNOWN,
-    /*  242, 0xf2 */    SDL_SCANCODE_UNKNOWN,
-    /*  243, 0xf3 */    SDL_SCANCODE_UNKNOWN,
-    /*  244, 0xf4 */    SDL_SCANCODE_UNKNOWN,
-    /*  245, 0xf5 */    SDL_SCANCODE_UNKNOWN,
-    /*  246, 0xf6 */    SDL_SCANCODE_SYSREQ,
-    /*  247, 0xf7 */    SDL_SCANCODE_CRSEL,
-    /*  248, 0xf8 */    SDL_SCANCODE_EXSEL,
-    /*  249, 0xf9 */    SDL_SCANCODE_UNKNOWN, /* VK_EREOF */
-    /*  250, 0xfa */    SDL_SCANCODE_UNKNOWN, /* VK_PLAY */
-    /*  251, 0xfb */    SDL_SCANCODE_UNKNOWN, /* VK_ZOOM */
-    /*  252, 0xfc */    SDL_SCANCODE_UNKNOWN,
-    /*  253, 0xfd */    SDL_SCANCODE_UNKNOWN, /* VK_PA1 */
-    /*  254, 0xfe */    SDL_SCANCODE_CLEAR,
-    /*  255, 0xff */    SDL_SCANCODE_UNKNOWN,
-};
-/* *INDENT-ON* */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/events/scancodes_windows.h	Thu Jan 20 18:04:05 2011 -0800
@@ -0,0 +1,287 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997-2010 Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+
+    Sam Lantinga
+    slouken@libsdl.org
+*/
+#include "../../include/SDL_scancode.h"
+
+/* Win32 virtual key code to SDL scancode mapping table
+   Sources:
+   - msdn.microsoft.com
+*/
+/* *INDENT-OFF* */
+static const SDL_scancode windows_scancode_table[] = {
+    /*  0, 0x00 */      SDL_SCANCODE_UNKNOWN,
+    /*  1, 0x01 */      SDL_SCANCODE_UNKNOWN,
+    /*  2, 0x02 */      SDL_SCANCODE_UNKNOWN,
+    /*  3, 0x03 */      SDL_SCANCODE_UNKNOWN,
+    /*  4, 0x04 */      SDL_SCANCODE_UNKNOWN,
+    /*  5, 0x05 */      SDL_SCANCODE_UNKNOWN,
+    /*  6, 0x06 */      SDL_SCANCODE_UNKNOWN,
+    /*  7, 0x07 */      SDL_SCANCODE_UNKNOWN,
+    /*  8, 0x08 */      SDL_SCANCODE_BACKSPACE,
+    /*  9, 0x09 */      SDL_SCANCODE_TAB,
+    /*  10, 0x0a */     SDL_SCANCODE_KP_ENTER, /* Not a VKEY, SDL specific */
+    /*  11, 0x0b */     SDL_SCANCODE_UNKNOWN,
+    /*  12, 0x0c */     SDL_SCANCODE_CLEAR,
+    /*  13, 0x0d */     SDL_SCANCODE_RETURN,
+    /*  14, 0x0e */     SDL_SCANCODE_UNKNOWN,
+    /*  15, 0x0f */     SDL_SCANCODE_UNKNOWN,
+    /*  16, 0x10 */     SDL_SCANCODE_UNKNOWN,
+    /*  17, 0x11 */     SDL_SCANCODE_UNKNOWN,
+    /*  18, 0x12 */     SDL_SCANCODE_APPLICATION,
+    /*  19, 0x13 */     SDL_SCANCODE_PAUSE,
+    /*  20, 0x14 */     SDL_SCANCODE_CAPSLOCK,
+    /*  21, 0x15 */     SDL_SCANCODE_UNKNOWN,
+    /*  22, 0x16 */     SDL_SCANCODE_UNKNOWN,
+    /*  23, 0x17 */     SDL_SCANCODE_UNKNOWN,
+    /*  24, 0x18 */     SDL_SCANCODE_UNKNOWN,
+    /*  25, 0x19 */     SDL_SCANCODE_UNKNOWN,
+    /*  26, 0x1a */     SDL_SCANCODE_UNKNOWN,
+    /*  27, 0x1b */     SDL_SCANCODE_ESCAPE,
+    /*  28, 0x1c */     SDL_SCANCODE_UNKNOWN,
+    /*  29, 0x1d */     SDL_SCANCODE_UNKNOWN,
+    /*  30, 0x1e */     SDL_SCANCODE_UNKNOWN,
+    /*  31, 0x1f */     SDL_SCANCODE_MODE,
+    /*  32, 0x20 */     SDL_SCANCODE_SPACE,
+    /*  33, 0x21 */     SDL_SCANCODE_PAGEUP,
+    /*  34, 0x22 */     SDL_SCANCODE_PAGEDOWN,
+    /*  35, 0x23 */     SDL_SCANCODE_END,
+    /*  36, 0x24 */     SDL_SCANCODE_HOME,
+    /*  37, 0x25 */     SDL_SCANCODE_LEFT,
+    /*  38, 0x26 */     SDL_SCANCODE_UP,
+    /*  39, 0x27 */     SDL_SCANCODE_RIGHT,
+    /*  40, 0x28 */     SDL_SCANCODE_DOWN,
+    /*  41, 0x29 */     SDL_SCANCODE_SELECT,
+    /*  42, 0x2a */     SDL_SCANCODE_UNKNOWN, /* VK_PRINT */
+    /*  43, 0x2b */     SDL_SCANCODE_EXECUTE,
+    /*  44, 0x2c */     SDL_SCANCODE_PRINTSCREEN,
+    /*  45, 0x2d */     SDL_SCANCODE_INSERT,
+    /*  46, 0x2e */     SDL_SCANCODE_DELETE,
+    /*  47, 0x2f */     SDL_SCANCODE_HELP,
+    /*  48, 0x30 */     SDL_SCANCODE_0,
+    /*  49, 0x31 */     SDL_SCANCODE_1,
+    /*  50, 0x32 */     SDL_SCANCODE_2,
+    /*  51, 0x33 */     SDL_SCANCODE_3,
+    /*  52, 0x34 */     SDL_SCANCODE_4,
+    /*  53, 0x35 */     SDL_SCANCODE_5,
+    /*  54, 0x36 */     SDL_SCANCODE_6,
+    /*  55, 0x37 */     SDL_SCANCODE_7,
+    /*  56, 0x38 */     SDL_SCANCODE_8,
+    /*  57, 0x39 */     SDL_SCANCODE_9,
+    /*  58, 0x3a */     SDL_SCANCODE_UNKNOWN,
+    /*  59, 0x3b */     SDL_SCANCODE_UNKNOWN,
+    /*  60, 0x3c */     SDL_SCANCODE_UNKNOWN,
+    /*  61, 0x3d */     SDL_SCANCODE_UNKNOWN,
+    /*  62, 0x3e */     SDL_SCANCODE_UNKNOWN,
+    /*  63, 0x3f */     SDL_SCANCODE_UNKNOWN,
+    /*  64, 0x40 */     SDL_SCANCODE_UNKNOWN,
+    /*  65, 0x41 */     SDL_SCANCODE_A,
+    /*  66, 0x42 */     SDL_SCANCODE_B,
+    /*  67, 0x43 */     SDL_SCANCODE_C,
+    /*  68, 0x44 */     SDL_SCANCODE_D,
+    /*  69, 0x45 */     SDL_SCANCODE_E,
+    /*  70, 0x46 */     SDL_SCANCODE_F,
+    /*  71, 0x47 */     SDL_SCANCODE_G,
+    /*  72, 0x48 */     SDL_SCANCODE_H,
+    /*  73, 0x49 */     SDL_SCANCODE_I,
+    /*  74, 0x4a */     SDL_SCANCODE_J,
+    /*  75, 0x4b */     SDL_SCANCODE_K,
+    /*  76, 0x4c */     SDL_SCANCODE_L,
+    /*  77, 0x4d */     SDL_SCANCODE_M,
+    /*  78, 0x4e */     SDL_SCANCODE_N,
+    /*  79, 0x4f */     SDL_SCANCODE_O,
+    /*  80, 0x50 */     SDL_SCANCODE_P,
+    /*  81, 0x51 */     SDL_SCANCODE_Q,
+    /*  82, 0x52 */     SDL_SCANCODE_R,
+    /*  83, 0x53 */     SDL_SCANCODE_S,
+    /*  84, 0x54 */     SDL_SCANCODE_T,
+    /*  85, 0x55 */     SDL_SCANCODE_U,
+    /*  86, 0x56 */     SDL_SCANCODE_V,
+    /*  87, 0x57 */     SDL_SCANCODE_W,
+    /*  88, 0x58 */     SDL_SCANCODE_X,
+    /*  89, 0x59 */     SDL_SCANCODE_Y,
+    /*  90, 0x5a */     SDL_SCANCODE_Z,
+    /*  91, 0x5b */     SDL_SCANCODE_LGUI,
+    /*  92, 0x5c */     SDL_SCANCODE_RGUI,
+    /*  93, 0x5d */     SDL_SCANCODE_APPLICATION,
+    /*  94, 0x5e */     SDL_SCANCODE_UNKNOWN,
+    /*  95, 0x5f */     SDL_SCANCODE_UNKNOWN,
+    /*  96, 0x60 */     SDL_SCANCODE_KP_0,
+    /*  97, 0x61 */     SDL_SCANCODE_KP_1,
+    /*  98, 0x62 */     SDL_SCANCODE_KP_2,
+    /*  99, 0x63 */     SDL_SCANCODE_KP_3,
+    /*  100, 0x64 */    SDL_SCANCODE_KP_4,
+    /*  101, 0x65 */    SDL_SCANCODE_KP_5,
+    /*  102, 0x66 */    SDL_SCANCODE_KP_6,
+    /*  103, 0x67 */    SDL_SCANCODE_KP_7,
+    /*  104, 0x68 */    SDL_SCANCODE_KP_8,
+    /*  105, 0x69 */    SDL_SCANCODE_KP_9,
+    /*  106, 0x6a */    SDL_SCANCODE_KP_MULTIPLY,
+    /*  107, 0x6b */    SDL_SCANCODE_KP_PLUS,
+    /*  108, 0x6c */    SDL_SCANCODE_SEPARATOR,
+    /*  109, 0x6d */    SDL_SCANCODE_KP_MINUS,
+    /*  110, 0x6e */    SDL_SCANCODE_KP_DECIMAL,
+    /*  111, 0x6f */    SDL_SCANCODE_KP_DIVIDE,
+    /*  112, 0x70 */    SDL_SCANCODE_F1,
+    /*  113, 0x71 */    SDL_SCANCODE_F2,
+    /*  114, 0x72 */    SDL_SCANCODE_F3,
+    /*  115, 0x73 */    SDL_SCANCODE_F4,
+    /*  116, 0x74 */    SDL_SCANCODE_F5,
+    /*  117, 0x75 */    SDL_SCANCODE_F6,
+    /*  118, 0x76 */    SDL_SCANCODE_F7,
+    /*  119, 0x77 */    SDL_SCANCODE_F8,
+    /*  120, 0x78 */    SDL_SCANCODE_F9,
+    /*  121, 0x79 */    SDL_SCANCODE_F10,
+    /*  122, 0x7a */    SDL_SCANCODE_F11,
+    /*  123, 0x7b */    SDL_SCANCODE_F12,
+    /*  124, 0x7c */    SDL_SCANCODE_F13,
+    /*  125, 0x7d */    SDL_SCANCODE_F14,
+    /*  126, 0x7e */    SDL_SCANCODE_F15,
+    /*  127, 0x7f */    SDL_SCANCODE_F16,
+    /*  128, 0x80 */    SDL_SCANCODE_F17, /* or SDL_SCANCODE_AUDIONEXT */
+    /*  129, 0x81 */    SDL_SCANCODE_F18, /* or SDL_SCANCODE_AUDIOPREV */
+    /*  130, 0x82 */    SDL_SCANCODE_F19, /* or SDL_SCANCODE_AUDIOSTOP */
+    /*  131, 0x83 */    SDL_SCANCODE_F20, /* or SDL_SCANCODE_AUDIOPLAY */
+    /*  132, 0x84 */    SDL_SCANCODE_F21, /* or SDL_SCANCODE_MAIL */
+    /*  133, 0x85 */    SDL_SCANCODE_F22, /* or SDL_SCANCODE_MEDIASELECT */
+    /*  134, 0x86 */    SDL_SCANCODE_F23, /* or SDL_SCANCODE_WWW */
+    /*  135, 0x87 */    SDL_SCANCODE_F24, /* or SDL_SCANCODE_CALCULATOR */
+    /*  136, 0x88 */    SDL_SCANCODE_UNKNOWN,
+    /*  137, 0x89 */    SDL_SCANCODE_UNKNOWN,
+    /*  138, 0x8a */    SDL_SCANCODE_UNKNOWN,
+    /*  139, 0x8b */    SDL_SCANCODE_UNKNOWN,
+    /*  140, 0x8c */    SDL_SCANCODE_UNKNOWN,
+    /*  141, 0x8d */    SDL_SCANCODE_UNKNOWN,
+    /*  142, 0x8e */    SDL_SCANCODE_UNKNOWN,
+    /*  143, 0x8f */    SDL_SCANCODE_UNKNOWN,
+    /*  144, 0x90 */    SDL_SCANCODE_NUMLOCKCLEAR,
+    /*  145, 0x91 */    SDL_SCANCODE_SCROLLLOCK,
+    /*  146, 0x92 */    SDL_SCANCODE_KP_EQUALS,
+    /*  147, 0x93 */    SDL_SCANCODE_UNKNOWN,
+    /*  148, 0x94 */    SDL_SCANCODE_UNKNOWN,
+    /*  149, 0x95 */    SDL_SCANCODE_UNKNOWN,
+    /*  150, 0x96 */    SDL_SCANCODE_UNKNOWN,
+    /*  151, 0x97 */    SDL_SCANCODE_UNKNOWN,
+    /*  152, 0x98 */    SDL_SCANCODE_UNKNOWN,
+    /*  153, 0x99 */    SDL_SCANCODE_UNKNOWN,
+    /*  154, 0x9a */    SDL_SCANCODE_UNKNOWN,
+    /*  155, 0x9b */    SDL_SCANCODE_UNKNOWN,
+    /*  156, 0x9c */    SDL_SCANCODE_UNKNOWN,
+    /*  157, 0x9d */    SDL_SCANCODE_UNKNOWN,
+    /*  158, 0x9e */    SDL_SCANCODE_UNKNOWN,
+    /*  159, 0x9f */    SDL_SCANCODE_UNKNOWN,
+    /*  160, 0xa0 */    SDL_SCANCODE_LSHIFT,
+    /*  161, 0xa1 */    SDL_SCANCODE_RSHIFT,
+    /*  162, 0xa2 */    SDL_SCANCODE_LCTRL,
+    /*  163, 0xa3 */    SDL_SCANCODE_RCTRL,
+    /*  164, 0xa4 */    SDL_SCANCODE_LALT,
+    /*  165, 0xa5 */    SDL_SCANCODE_RALT,
+    /*  166, 0xa6 */    SDL_SCANCODE_AC_BACK,
+    /*  167, 0xa7 */    SDL_SCANCODE_AC_FORWARD,
+    /*  168, 0xa8 */    SDL_SCANCODE_AC_REFRESH,
+    /*  169, 0xa9 */    SDL_SCANCODE_AC_STOP,
+    /*  170, 0xaa */    SDL_SCANCODE_AC_SEARCH,
+    /*  171, 0xab */    SDL_SCANCODE_AC_BOOKMARKS,
+    /*  172, 0xac */    SDL_SCANCODE_AC_HOME,
+    /*  173, 0xad */    SDL_SCANCODE_AUDIOMUTE,
+    /*  174, 0xae */    SDL_SCANCODE_VOLUMEDOWN,
+    /*  175, 0xaf */    SDL_SCANCODE_VOLUMEUP,
+    /*  176, 0xb0 */    SDL_SCANCODE_AUDIONEXT,
+    /*  177, 0xb1 */    SDL_SCANCODE_AUDIOPREV,
+    /*  178, 0xb2 */    SDL_SCANCODE_AUDIOSTOP,
+    /*  179, 0xb3 */    SDL_SCANCODE_AUDIOPLAY,
+    /*  180, 0xb4 */    SDL_SCANCODE_MAIL,
+    /*  181, 0xb5 */    SDL_SCANCODE_MEDIASELECT,
+    /*  182, 0xb6 */    SDL_SCANCODE_UNKNOWN, /* VK_LAUNCH_APP1 */
+    /*  183, 0xb7 */    SDL_SCANCODE_UNKNOWN, /* VK_LAUNCH_APP2 */
+    /*  184, 0xb8 */    SDL_SCANCODE_UNKNOWN,
+    /*  185, 0xb9 */    SDL_SCANCODE_UNKNOWN,
+    /*  186, 0xba */    SDL_SCANCODE_SEMICOLON,
+    /*  187, 0xbb */    SDL_SCANCODE_EQUALS,
+    /*  188, 0xbc */    SDL_SCANCODE_COMMA,
+    /*  189, 0xbd */    SDL_SCANCODE_MINUS,
+    /*  190, 0xbe */    SDL_SCANCODE_PERIOD,
+    /*  191, 0xbf */    SDL_SCANCODE_SLASH,
+    /*  192, 0xc0 */    SDL_SCANCODE_GRAVE,
+    /*  193, 0xc1 */    SDL_SCANCODE_UNKNOWN,
+    /*  194, 0xc2 */    SDL_SCANCODE_UNKNOWN,
+    /*  195, 0xc3 */    SDL_SCANCODE_UNKNOWN,
+    /*  196, 0xc4 */    SDL_SCANCODE_UNKNOWN,
+    /*  197, 0xc5 */    SDL_SCANCODE_UNKNOWN,
+    /*  198, 0xc6 */    SDL_SCANCODE_UNKNOWN,
+    /*  199, 0xc7 */    SDL_SCANCODE_UNKNOWN,
+    /*  200, 0xc8 */    SDL_SCANCODE_UNKNOWN,
+    /*  201, 0xc9 */    SDL_SCANCODE_UNKNOWN,
+    /*  202, 0xca */    SDL_SCANCODE_UNKNOWN,
+    /*  203, 0xcb */    SDL_SCANCODE_UNKNOWN,
+    /*  204, 0xcc */    SDL_SCANCODE_UNKNOWN,
+    /*  205, 0xcd */    SDL_SCANCODE_UNKNOWN,
+    /*  206, 0xce */    SDL_SCANCODE_UNKNOWN,
+    /*  207, 0xcf */    SDL_SCANCODE_UNKNOWN,
+    /*  208, 0xd0 */    SDL_SCANCODE_UNKNOWN,
+    /*  209, 0xd1 */    SDL_SCANCODE_UNKNOWN,
+    /*  210, 0xd2 */    SDL_SCANCODE_UNKNOWN,
+    /*  211, 0xd3 */    SDL_SCANCODE_UNKNOWN,
+    /*  212, 0xd4 */    SDL_SCANCODE_UNKNOWN,
+    /*  213, 0xd5 */    SDL_SCANCODE_UNKNOWN,
+    /*  214, 0xd6 */    SDL_SCANCODE_UNKNOWN,
+    /*  215, 0xd7 */    SDL_SCANCODE_UNKNOWN,
+    /*  216, 0xd8 */    SDL_SCANCODE_UNKNOWN,
+    /*  217, 0xd9 */    SDL_SCANCODE_UNKNOWN,
+    /*  218, 0xda */    SDL_SCANCODE_UNKNOWN,
+    /*  219, 0xdb */    SDL_SCANCODE_LEFTBRACKET,
+    /*  220, 0xdc */    SDL_SCANCODE_BACKSLASH,
+    /*  221, 0xdd */    SDL_SCANCODE_RIGHTBRACKET,
+    /*  222, 0xde */    SDL_SCANCODE_APOSTROPHE,
+    /*  223, 0xdf */    SDL_SCANCODE_UNKNOWN,
+    /*  224, 0xe0 */    SDL_SCANCODE_UNKNOWN,
+    /*  225, 0xe1 */    SDL_SCANCODE_UNKNOWN,
+    /*  226, 0xe2 */    SDL_SCANCODE_NONUSBACKSLASH,
+    /*  227, 0xe3 */    SDL_SCANCODE_UNKNOWN,
+    /*  228, 0xe4 */    SDL_SCANCODE_UNKNOWN,
+    /*  229, 0xe5 */    SDL_SCANCODE_UNKNOWN,
+    /*  230, 0xe6 */    SDL_SCANCODE_UNKNOWN,
+    /*  231, 0xe7 */    SDL_SCANCODE_UNKNOWN,
+    /*  232, 0xe8 */    SDL_SCANCODE_UNKNOWN,
+    /*  233, 0xe9 */    SDL_SCANCODE_UNKNOWN,
+    /*  234, 0xea */    SDL_SCANCODE_UNKNOWN,
+    /*  235, 0xeb */    SDL_SCANCODE_UNKNOWN,
+    /*  236, 0xec */    SDL_SCANCODE_UNKNOWN,
+    /*  237, 0xed */    SDL_SCANCODE_UNKNOWN,
+    /*  238, 0xee */    SDL_SCANCODE_UNKNOWN,
+    /*  239, 0xef */    SDL_SCANCODE_UNKNOWN,
+    /*  240, 0xf0 */    SDL_SCANCODE_UNKNOWN,
+    /*  241, 0xf1 */    SDL_SCANCODE_UNKNOWN,
+    /*  242, 0xf2 */    SDL_SCANCODE_UNKNOWN,
+    /*  243, 0xf3 */    SDL_SCANCODE_UNKNOWN,
+    /*  244, 0xf4 */    SDL_SCANCODE_UNKNOWN,
+    /*  245, 0xf5 */    SDL_SCANCODE_UNKNOWN,
+    /*  246, 0xf6 */    SDL_SCANCODE_SYSREQ,
+    /*  247, 0xf7 */    SDL_SCANCODE_CRSEL,
+    /*  248, 0xf8 */    SDL_SCANCODE_EXSEL,
+    /*  249, 0xf9 */    SDL_SCANCODE_UNKNOWN, /* VK_EREOF */
+    /*  250, 0xfa */    SDL_SCANCODE_UNKNOWN, /* VK_PLAY */
+    /*  251, 0xfb */    SDL_SCANCODE_UNKNOWN, /* VK_ZOOM */
+    /*  252, 0xfc */    SDL_SCANCODE_UNKNOWN,
+    /*  253, 0xfd */    SDL_SCANCODE_UNKNOWN, /* VK_PA1 */
+    /*  254, 0xfe */    SDL_SCANCODE_CLEAR,
+    /*  255, 0xff */    SDL_SCANCODE_UNKNOWN,
+};
+/* *INDENT-ON* */
--- a/src/file/SDL_rwops.c	Thu Jan 20 17:33:06 2011 -0800
+++ b/src/file/SDL_rwops.c	Thu Jan 20 18:04:05 2011 -0800
@@ -37,7 +37,7 @@
 #include <fat.h>
 #endif /* __NDS__ */
 
-#ifdef __WIN32__
+#ifdef __WINDOWS__
 
 /* Functions to read/write Win32 API file pointers */
 /* Will not use it on WinCE because stdio is buffered, it means
@@ -54,7 +54,7 @@
 #define READAHEAD_BUFFER_SIZE	1024
 
 static int SDLCALL
-win32_file_open(SDL_RWops * context, const char *filename, const char *mode)
+windows_file_open(SDL_RWops * context, const char *filename, const char *mode)
 {
 #ifndef _WIN32_WCE
     UINT old_error_mode;
@@ -67,10 +67,10 @@
     if (!context)
         return -1;              /* failed (invalid call) */
 
-    context->hidden.win32io.h = INVALID_HANDLE_VALUE;   /* mark this as unusable */
-    context->hidden.win32io.buffer.data = NULL;
-    context->hidden.win32io.buffer.size = 0;
-    context->hidden.win32io.buffer.left = 0;
+    context->hidden.windowsio.h = INVALID_HANDLE_VALUE;   /* mark this as unusable */
+    context->hidden.windowsio.buffer.data = NULL;
+    context->hidden.windowsio.buffer.size = 0;
+    context->hidden.windowsio.buffer.left = 0;
 
     /* "r" = reading, file must exist */
     /* "w" = writing, truncate existing, file may not exist */
@@ -90,9 +90,9 @@
     if (!r_right && !w_right)   /* inconsistent mode */
         return -1;              /* failed (invalid call) */
 
-    context->hidden.win32io.buffer.data =
+    context->hidden.windowsio.buffer.data =
         (char *) SDL_malloc(READAHEAD_BUFFER_SIZE);
-    if (!context->hidden.win32io.buffer.data) {
+    if (!context->hidden.windowsio.buffer.data) {
         SDL_OutOfMemory();
         return -1;
     }
@@ -104,8 +104,8 @@
         if (MultiByteToWideChar(CP_UTF8, 0, filename, -1, filenameW, size) ==
             0) {
             SDL_stack_free(filenameW);
-            SDL_free(context->hidden.win32io.buffer.data);
-            context->hidden.win32io.buffer.data = NULL;
+            SDL_free(context->hidden.windowsio.buffer.data);
+            context->hidden.windowsio.buffer.data = NULL;
             SDL_SetError("Unable to convert filename to Unicode");
             return -1;
         }
@@ -130,51 +130,51 @@
 #endif /* _WIN32_WCE */
 
     if (h == INVALID_HANDLE_VALUE) {
-        SDL_free(context->hidden.win32io.buffer.data);
-        context->hidden.win32io.buffer.data = NULL;
+        SDL_free(context->hidden.windowsio.buffer.data);
+        context->hidden.windowsio.buffer.data = NULL;
         SDL_SetError("Couldn't open %s", filename);
         return -2;              /* failed (CreateFile) */
     }
-    context->hidden.win32io.h = h;
-    context->hidden.win32io.append = a_mode ? SDL_TRUE : SDL_FALSE;
+    context->hidden.windowsio.h = h;
+    context->hidden.windowsio.append = a_mode ? SDL_TRUE : SDL_FALSE;
 
     return 0;                   /* ok */
 }
 
 static long SDLCALL
-win32_file_seek(SDL_RWops * context, long offset, int whence)
+windows_file_seek(SDL_RWops * context, long offset, int whence)
 {
-    DWORD win32whence;
+    DWORD windowswhence;
     long file_pos;
 
-    if (!context || context->hidden.win32io.h == INVALID_HANDLE_VALUE) {
-        SDL_SetError("win32_file_seek: invalid context/file not opened");
+    if (!context || context->hidden.windowsio.h == INVALID_HANDLE_VALUE) {
+        SDL_SetError("windows_file_seek: invalid context/file not opened");
         return -1;
     }
 
     /* FIXME: We may be able to satisfy the seek within buffered data */
-    if (whence == RW_SEEK_CUR && context->hidden.win32io.buffer.left) {
-        offset -= (long)context->hidden.win32io.buffer.left;
+    if (whence == RW_SEEK_CUR && context->hidden.windowsio.buffer.left) {
+        offset -= (long)context->hidden.windowsio.buffer.left;
     }
-    context->hidden.win32io.buffer.left = 0;
+    context->hidden.windowsio.buffer.left = 0;
 
     switch (whence) {
     case RW_SEEK_SET:
-        win32whence = FILE_BEGIN;
+        windowswhence = FILE_BEGIN;
         break;
     case RW_SEEK_CUR:
-        win32whence = FILE_CURRENT;
+        windowswhence = FILE_CURRENT;
         break;
     case RW_SEEK_END:
-        win32whence = FILE_END;
+        windowswhence = FILE_END;
         break;
     default:
-        SDL_SetError("win32_file_seek: Unknown value for 'whence'");
+        SDL_SetError("windows_file_seek: Unknown value for 'whence'");
         return -1;
     }
 
     file_pos =
-        SetFilePointer(context->hidden.win32io.h, offset, NULL, win32whence);
+        SetFilePointer(context->hidden.windowsio.h, offset, NULL, windowswhence);
 
     if (file_pos != INVALID_SET_FILE_POINTER)
         return file_pos;        /* success */
@@ -184,7 +184,7 @@
 }
 
 static size_t SDLCALL
-win32_file_read(SDL_RWops * context, void *ptr, size_t size, size_t maxnum)
+windows_file_read(SDL_RWops * context, void *ptr, size_t size, size_t maxnum)
 {
     size_t total_need;
     size_t total_read = 0;
@@ -193,18 +193,18 @@
 
     total_need = size * maxnum;
 
-    if (!context || context->hidden.win32io.h == INVALID_HANDLE_VALUE
+    if (!context || context->hidden.windowsio.h == INVALID_HANDLE_VALUE
         || !total_need)
         return 0;
 
-    if (context->hidden.win32io.buffer.left > 0) {
-        void *data = (char *) context->hidden.win32io.buffer.data +
-            context->hidden.win32io.buffer.size -
-            context->hidden.win32io.buffer.left;
+    if (context->hidden.windowsio.buffer.left > 0) {
+        void *data = (char *) context->hidden.windowsio.buffer.data +
+            context->hidden.windowsio.buffer.size -
+            context->hidden.windowsio.buffer.left;
         read_ahead =
-            SDL_min(total_need, context->hidden.win32io.buffer.left);
+            SDL_min(total_need, context->hidden.windowsio.buffer.left);
         SDL_memcpy(ptr, data, read_ahead);
-        context->hidden.win32io.buffer.left -= read_ahead;
+        context->hidden.windowsio.buffer.left -= read_ahead;
 
         if (read_ahead == total_need) {
             return maxnum;
@@ -216,19 +216,19 @@
 
     if (total_need < READAHEAD_BUFFER_SIZE) {
         if (!ReadFile
-            (context->hidden.win32io.h, context->hidden.win32io.buffer.data,
+            (context->hidden.windowsio.h, context->hidden.windowsio.buffer.data,
              READAHEAD_BUFFER_SIZE, &byte_read, NULL)) {
             SDL_Error(SDL_EFREAD);
             return 0;
         }
         read_ahead = SDL_min(total_need, (int) byte_read);
-        SDL_memcpy(ptr, context->hidden.win32io.buffer.data, read_ahead);
-        context->hidden.win32io.buffer.size = byte_read;
-        context->hidden.win32io.buffer.left = byte_read - read_ahead;
+        SDL_memcpy(ptr, context->hidden.windowsio.buffer.data, read_ahead);
+        context->hidden.windowsio.buffer.size = byte_read;
+        context->hidden.windowsio.buffer.left = byte_read - read_ahead;
         total_read += read_ahead;
     } else {
         if (!ReadFile
-            (context->hidden.win32io.h, ptr, (DWORD)total_need, &byte_read, NULL)) {
+            (context->hidden.windowsio.h, ptr, (DWORD)total_need, &byte_read, NULL)) {
             SDL_Error(SDL_EFREAD);
             return 0;
         }
@@ -238,7 +238,7 @@
 }
 
 static size_t SDLCALL
-win32_file_write(SDL_RWops * context, const void *ptr, size_t size,
+windows_file_write(SDL_RWops * context, const void *ptr, size_t size,
                  size_t num)
 {
 
@@ -248,20 +248,20 @@
 
     total_bytes = size * num;
 
-    if (!context || context->hidden.win32io.h == INVALID_HANDLE_VALUE
+    if (!context || context->hidden.windowsio.h == INVALID_HANDLE_VALUE
         || total_bytes <= 0 || !size)
         return 0;
 
-    if (context->hidden.win32io.buffer.left) {
-        SetFilePointer(context->hidden.win32io.h,
-                       -(LONG)context->hidden.win32io.buffer.left, NULL,
+    if (context->hidden.windowsio.buffer.left) {
+        SetFilePointer(context->hidden.windowsio.h,
+                       -(LONG)context->hidden.windowsio.buffer.left, NULL,
                        FILE_CURRENT);
-        context->hidden.win32io.buffer.left = 0;
+        context->hidden.windowsio.buffer.left = 0;
     }
 
     /* if in append mode, we must go to the EOF before write */
-    if (context->hidden.win32io.append) {
-        if (SetFilePointer(context->hidden.win32io.h, 0L, NULL, FILE_END) ==
+    if (context->hidden.windowsio.append) {
+        if (SetFilePointer(context->hidden.windowsio.h, 0L, NULL, FILE_END) ==
             INVALID_SET_FILE_POINTER) {
             SDL_Error(SDL_EFWRITE);
             return 0;
@@ -269,7 +269,7 @@
     }
 
     if (!WriteFile
-        (context->hidden.win32io.h, ptr, (DWORD)total_bytes, &byte_written, NULL)) {
+        (context->hidden.windowsio.h, ptr, (DWORD)total_bytes, &byte_written, NULL)) {
         SDL_Error(SDL_EFWRITE);
         return 0;
     }
@@ -279,23 +279,23 @@
 }
 
 static int SDLCALL
-win32_file_close(SDL_RWops * context)
+windows_file_close(SDL_RWops * context)
 {
 
     if (context) {
-        if (context->hidden.win32io.h != INVALID_HANDLE_VALUE) {
-            CloseHandle(context->hidden.win32io.h);
-            context->hidden.win32io.h = INVALID_HANDLE_VALUE;   /* to be sure */
+        if (context->hidden.windowsio.h != INVALID_HANDLE_VALUE) {
+            CloseHandle(context->hidden.windowsio.h);
+            context->hidden.windowsio.h = INVALID_HANDLE_VALUE;   /* to be sure */
         }
-        if (context->hidden.win32io.buffer.data) {
-            SDL_free(context->hidden.win32io.buffer.data);
-            context->hidden.win32io.buffer.data = NULL;
+        if (context->hidden.windowsio.buffer.data) {
+            SDL_free(context->hidden.windowsio.buffer.data);
+            context->hidden.windowsio.buffer.data = NULL;
         }
         SDL_FreeRW(context);
     }
     return (0);
 }
-#endif /* __WIN32__ */
+#endif /* __WINDOWS__ */
 
 #ifdef HAVE_STDIO_H
 
@@ -449,18 +449,18 @@
         SDL_SetError("SDL_RWFromFile(): No file or no mode specified");
         return NULL;
     }
-#if defined(__WIN32__)
+#if defined(__WINDOWS__)
     rwops = SDL_AllocRW();
     if (!rwops)
         return NULL;            /* SDL_SetError already setup by SDL_AllocRW() */
-    if (win32_file_open(rwops, file, mode) < 0) {
+    if (windows_file_open(rwops, file, mode) < 0) {
         SDL_FreeRW(rwops);
         return NULL;
     }
-    rwops->seek = win32_file_seek;
-    rwops->read = win32_file_read;
-    rwops->write = win32_file_write;
-    rwops->close = win32_file_close;
+    rwops->seek = windows_file_seek;
+    rwops->read = windows_file_read;
+    rwops->write = windows_file_write;
+    rwops->close = windows_file_close;
 
 #elif HAVE_STDIO_H
 	#ifdef __APPLE__
--- a/src/haptic/win32/SDL_syshaptic.c	Thu Jan 20 17:33:06 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1379 +0,0 @@
-/*
-    SDL - Simple DirectMedia Layer
-    Copyright (C) 2008 Edgar Simo
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Lesser General Public
-    License as published by the Free Software Foundation; either
-    version 2.1 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Lesser General Public License for more details.
-
-    You should have received a copy of the GNU Lesser General Public
-    License along with this library; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-
-    Sam Lantinga
-    slouken@libsdl.org
-*/
-#include "SDL_config.h"
-
-#ifdef SDL_HAPTIC_DINPUT
-
-#include "SDL_haptic.h"
-#include "../SDL_syshaptic.h"
-#include "SDL_joystick.h"
-#include "../../joystick/SDL_sysjoystick.h"     /* For the real SDL_Joystick */
-#include "../../joystick/win32/SDL_dxjoystick_c.h"      /* For joystick hwdata */
-
-
-#define MAX_HAPTICS  32
-
-
-/*
- * List of available haptic devices.
- */
-static struct
-{
-    DIDEVICEINSTANCE instance;
-    SDL_Haptic *haptic;
-    DIDEVCAPS capabilities;
-} SDL_hapticlist[MAX_HAPTICS];
-
-
-/*
- * Haptic system hardware data.
- */
-struct haptic_hwdata
-{
-    LPDIRECTINPUTDEVICE2 device;
-    DWORD axes[3];              /* Axes to use. */
-    int is_joystick;            /* Device is loaded as joystick. */
-};
-
-
-/*
- * Haptic system effect data.
- */
-struct haptic_hweffect
-{
-    DIEFFECT effect;
-    LPDIRECTINPUTEFFECT ref;
-};
-
-
-/*
- * Internal stuff.
- */
-static LPDIRECTINPUT dinput = NULL;
-
-
-/*
- * External stuff.
- */
-extern HWND SDL_HelperWindow;
-
-
-/*
- * Prototypes.
- */
-static void DI_SetError(const char *str, HRESULT err);
-static int DI_GUIDIsSame(const GUID * a, const GUID * b);
-static int SDL_SYS_HapticOpenFromInstance(SDL_Haptic * haptic,
-                                          DIDEVICEINSTANCE instance);
-static int SDL_SYS_HapticOpenFromDevice2(SDL_Haptic * haptic,
-                                         LPDIRECTINPUTDEVICE2 device2);
-static DWORD DIGetTriggerButton(Uint16 button);
-static int SDL_SYS_SetDirection(DIEFFECT * effect, SDL_HapticDirection * dir,
-                                int naxes);
-static int SDL_SYS_ToDIEFFECT(SDL_Haptic * haptic, DIEFFECT * dest,
-                              SDL_HapticEffect * src);
-static void SDL_SYS_HapticFreeDIEFFECT(DIEFFECT * effect, int type);
-static REFGUID SDL_SYS_HapticEffectType(SDL_HapticEffect * effect);
-/* Callbacks. */
-static BOOL CALLBACK EnumHapticsCallback(const DIDEVICEINSTANCE *
-                                         pdidInstance, VOID * pContext);
-static BOOL CALLBACK DI_EffectCallback(LPCDIEFFECTINFO pei, LPVOID pv);
-
-
-/* 
- * Like SDL_SetError but for DX error codes.
- */
-static void
-DI_SetError(const char *str, HRESULT err)
-{
-    /*
-       SDL_SetError("Haptic: %s - %s: %s", str,
-       DXGetErrorString8A(err), DXGetErrorDescription8A(err));
-     */
-    SDL_SetError("Haptic error %s", str);
-}
-
-
-/*
- * Checks to see if two GUID are the same.
- */
-static int
-DI_GUIDIsSame(const GUID * a, const GUID * b)
-{
-    if (((a)->Data1 == (b)->Data1) &&
-        ((a)->Data2 == (b)->Data2) &&
-        ((a)->Data3 == (b)->Data3) &&
-        (SDL_strcmp((a)->Data4, (b)->Data4) == 0))
-        return 1;
-    return 0;
-}
-
-
-/*
- * Initializes the haptic subsystem.
- */
-int
-SDL_SYS_HapticInit(void)
-{
-    HRESULT ret;
-    HINSTANCE instance;
-
-    if (dinput != NULL) {       /* Already open. */
-        SDL_SetError("Haptic: SubSystem already open.");
-        return -1;
-    }
-
-    /* Clear all the memory. */
-    SDL_memset(SDL_hapticlist, 0, sizeof(SDL_hapticlist));
-
-    SDL_numhaptics = 0;
-
-    ret = CoInitialize(NULL);
-    if (FAILED(ret)) {
-        DI_SetError("Coinitialize", ret);
-        return -1;
-    }
-
-    ret = CoCreateInstance(&CLSID_DirectInput, NULL, CLSCTX_INPROC_SERVER,
-                           &IID_IDirectInput, (LPVOID) & dinput);
-    if (FAILED(ret)) {
-        DI_SetError("CoCreateInstance", ret);
-        return -1;
-    }
-
-    /* Because we used CoCreateInstance, we need to Initialize it, first. */
-    instance = GetModuleHandle(NULL);
-    if (instance == NULL) {
-        SDL_SetError("GetModuleHandle() failed with error code %d.",
-                     GetLastError());
-        return -1;
-    }
-    ret = IDirectInput_Initialize(dinput, instance, DIRECTINPUT_VERSION);
-    if (FAILED(ret)) {
-        DI_SetError("Initializing DirectInput device", ret);
-        return -1;
-    }
-
-    /* Look for haptic devices. */
-    ret = IDirectInput_EnumDevices(dinput,
-                                   0,
-                                   EnumHapticsCallback,
-                                   NULL,
-                                   DIEDFL_FORCEFEEDBACK |
-                                   DIEDFL_ATTACHEDONLY);
-    if (FAILED(ret)) {
-        DI_SetError("Enumerating DirectInput devices", ret);
-        return -1;
-    }
-
-    return SDL_numhaptics;
-}
-
-/*
- * Callback to find the haptic devices.
- */
-static BOOL CALLBACK
-EnumHapticsCallback(const DIDEVICEINSTANCE * pdidInstance, VOID * pContext)
-{
-    HRESULT ret;
-    LPDIRECTINPUTDEVICE device;
-
-    /* Copy the instance over, useful for creating devices. */
-    SDL_memcpy(&SDL_hapticlist[SDL_numhaptics].instance, pdidInstance,
-               sizeof(DIDEVICEINSTANCE));
-
-    /* Open the device */
-    ret = IDirectInput_CreateDevice(dinput, &pdidInstance->guidInstance,
-                                    &device, NULL);
-    if (FAILED(ret)) {
-        /* DI_SetError("Creating DirectInput device",ret); */
-        return DIENUM_CONTINUE;
-    }
-
-    /* Get capabilities. */
-    SDL_hapticlist[SDL_numhaptics].capabilities.dwSize = sizeof(DIDEVCAPS);
-    ret = IDirectInputDevice_GetCapabilities(device,
-                                             &SDL_hapticlist[SDL_numhaptics].
-                                             capabilities);
-    if (FAILED(ret)) {
-        /* DI_SetError("Getting device capabilities",ret); */
-        IDirectInputDevice_Release(device);
-        return DIENUM_CONTINUE;
-    }
-
-    /* Close up device and count it. */
-    IDirectInputDevice_Release(device);
-    SDL_numhaptics++;
-
-    /* Watch out for hard limit. */
-    if (SDL_numhaptics >= MAX_HAPTICS)
-        return DIENUM_STOP;
-
-    return DIENUM_CONTINUE;
-}
-
-
-/*
- * Return the name of a haptic device, does not need to be opened.
- */
-const char *
-SDL_SYS_HapticName(int index)
-{
-    return SDL_hapticlist[index].instance.tszProductName;
-}
-
-
-/*
- * Callback to get all supported effects.
- */
-#define EFFECT_TEST(e,s)               \
-if (DI_GUIDIsSame(&pei->guid, &(e)))   \
-   haptic->supported |= (s)
-static BOOL CALLBACK
-DI_EffectCallback(LPCDIEFFECTINFO pei, LPVOID pv)
-{
-    /* Prepare the haptic device. */
-    SDL_Haptic *haptic = (SDL_Haptic *) pv;
-
-    /* Get supported. */
-    EFFECT_TEST(GUID_Spring, SDL_HAPTIC_SPRING);
-    EFFECT_TEST(GUID_Damper, SDL_HAPTIC_DAMPER);
-    EFFECT_TEST(GUID_Inertia, SDL_HAPTIC_INERTIA);
-    EFFECT_TEST(GUID_Friction, SDL_HAPTIC_FRICTION);
-    EFFECT_TEST(GUID_ConstantForce, SDL_HAPTIC_CONSTANT);
-    EFFECT_TEST(GUID_CustomForce, SDL_HAPTIC_CUSTOM);
-    EFFECT_TEST(GUID_Sine, SDL_HAPTIC_SINE);
-    EFFECT_TEST(GUID_Square, SDL_HAPTIC_SQUARE);
-    EFFECT_TEST(GUID_Triangle, SDL_HAPTIC_TRIANGLE);
-    EFFECT_TEST(GUID_SawtoothUp, SDL_HAPTIC_SAWTOOTHUP);
-    EFFECT_TEST(GUID_SawtoothDown, SDL_HAPTIC_SAWTOOTHDOWN);
-    EFFECT_TEST(GUID_RampForce, SDL_HAPTIC_RAMP);
-
-    /* Check for more. */
-    return DIENUM_CONTINUE;
-}
-
-
-/*
- * Callback to get supported axes.
- */
-static BOOL CALLBACK
-DI_DeviceObjectCallback(LPCDIDEVICEOBJECTINSTANCE dev, LPVOID pvRef)
-{
-    SDL_Haptic *haptic = (SDL_Haptic *) pvRef;
-
-    if ((dev->dwType & DIDFT_AXIS) && (dev->dwFlags & DIDOI_FFACTUATOR)) {
-
-        haptic->hwdata->axes[haptic->naxes] = dev->dwOfs;
-        haptic->naxes++;
-
-        /* Currently using the artificial limit of 3 axes. */
-        if (haptic->naxes >= 3) {
-            return DIENUM_STOP;
-        }
-    }
-
-    return DIENUM_CONTINUE;
-}
-
-
-/*
- * Opens the haptic device from the file descriptor.
- *
- *    Steps:
- *       - Open temporary DirectInputDevice interface.
- *       - Create DirectInputDevice2 interface.
- *       - Release DirectInputDevice interface.
- *       - Call SDL_SYS_HapticOpenFromDevice2
- */
-static int
-SDL_SYS_HapticOpenFromInstance(SDL_Haptic * haptic, DIDEVICEINSTANCE instance)
-{
-    HRESULT ret;
-    int ret2;
-    LPDIRECTINPUTDEVICE device;
-
-    /* Allocate the hwdata */
-    haptic->hwdata = (struct haptic_hwdata *)
-        SDL_malloc(sizeof(*haptic->hwdata));
-    if (haptic->hwdata == NULL) {
-        SDL_OutOfMemory();
-        goto creat_err;
-    }
-    SDL_memset(haptic->hwdata, 0, sizeof(*haptic->hwdata));
-
-    /* Open the device */
-    ret = IDirectInput_CreateDevice(dinput, &instance.guidInstance,
-                                    &device, NULL);
-    if (FAILED(ret)) {
-        DI_SetError("Creating DirectInput device", ret);
-        goto creat_err;
-    }
-
-    /* Now get the IDirectInputDevice2 interface, instead. */
-    ret = IDirectInputDevice_QueryInterface(device,
-                                            &IID_IDirectInputDevice2,
-                                            (LPVOID *) & haptic->hwdata->
-                                            device);
-    /* Done with the temporary one now. */
-    IDirectInputDevice_Release(device);
-    if (FAILED(ret)) {
-        DI_SetError("Querying DirectInput interface", ret);
-        goto creat_err;
-    }
-
-    ret2 = SDL_SYS_HapticOpenFromDevice2(haptic, haptic->hwdata->device);
-    if (ret2 < 0) {
-        goto query_err;
-    }
-
-    return 0;
-
-  query_err:
-    IDirectInputDevice2_Release(haptic->hwdata->device);
-  creat_err:
-    if (haptic->hwdata != NULL) {
-        SDL_free(haptic->hwdata);
-        haptic->hwdata = NULL;
-    }
-    return -1;
-}
-
-
-/*
- * Opens the haptic device from the file descriptor.
- *
- *    Steps:
- *       - Set cooperative level.
- *       - Set data format.
- *       - Acquire exclusiveness.
- *       - Reset actuators.
- *       - Get supported featuers.
- */
-static int
-SDL_SYS_HapticOpenFromDevice2(SDL_Haptic * haptic,
-                              LPDIRECTINPUTDEVICE2 device2)
-{
-    HRESULT ret;
-    DIPROPDWORD dipdw;
-
-    /* We'll use the device2 from now on. */
-    haptic->hwdata->device = device2;
-
-    /* Grab it exclusively to use force feedback stuff. */
-    ret = IDirectInputDevice2_SetCooperativeLevel(haptic->hwdata->device,
-                                                  SDL_HelperWindow,
-                                                  DISCL_EXCLUSIVE |
-                                                  DISCL_BACKGROUND);
-    if (FAILED(ret)) {
-        DI_SetError("Setting cooperative level to exclusive", ret);
-        goto acquire_err;
-    }
-
-    /* Set data format. */
-    ret = IDirectInputDevice2_SetDataFormat(haptic->hwdata->device,
-                                            &c_dfDIJoystick2);
-    if (FAILED(ret)) {
-        DI_SetError("Setting data format", ret);
-        goto acquire_err;
-    }
-
-    /* Get number of axes. */
-    ret = IDirectInputDevice2_EnumObjects(haptic->hwdata->device,
-                                          DI_DeviceObjectCallback,
-                                          haptic, DIDFT_AXIS);
-    if (FAILED(ret)) {
-        DI_SetError("Getting device axes", ret);
-        goto acquire_err;
-    }
-
-    /* Acquire the device. */
-    ret = IDirectInputDevice2_Acquire(haptic->hwdata->device);
-    if (FAILED(ret)) {
-        DI_SetError("Acquiring DirectInput device", ret);
-        goto acquire_err;
-    }
-
-    /* Reset all actuators - just in case. */
-    ret = IDirectInputDevice2_SendForceFeedbackCommand(haptic->hwdata->device,
-                                                       DISFFC_RESET);
-    if (FAILED(ret)) {
-        DI_SetError("Resetting device", ret);
-        goto acquire_err;
-    }
-
-    /* Enabling actuators. */
-    ret = IDirectInputDevice2_SendForceFeedbackCommand(haptic->hwdata->device,
-                                                       DISFFC_SETACTUATORSON);
-    if (FAILED(ret)) {
-        DI_SetError("Enabling actuators", ret);
-        goto acquire_err;
-    }
-
-    /* Get supported effects. */
-    ret = IDirectInputDevice2_EnumEffects(haptic->hwdata->device,
-                                          DI_EffectCallback, haptic,
-                                          DIEFT_ALL);
-    if (FAILED(ret)) {
-        DI_SetError("Enumerating supported effects", ret);
-        goto acquire_err;
-    }
-    if (haptic->supported == 0) {       /* Error since device supports nothing. */
-        SDL_SetError("Haptic: Internal error on finding supported effects.");
-        goto acquire_err;
-    }
-
-    /* Check autogain and autocenter. */
-    dipdw.diph.dwSize = sizeof(DIPROPDWORD);
-    dipdw.diph.dwHeaderSize = sizeof(DIPROPHEADER);
-    dipdw.diph.dwObj = 0;
-    dipdw.diph.dwHow = DIPH_DEVICE;
-    dipdw.dwData = 10000;
-    ret = IDirectInputDevice2_SetProperty(haptic->hwdata->device,
-                                          DIPROP_FFGAIN, &dipdw.diph);
-    if (!FAILED(ret)) {         /* Gain is supported. */
-        haptic->supported |= SDL_HAPTIC_GAIN;
-    }
-    dipdw.diph.dwObj = 0;
-    dipdw.diph.dwHow = DIPH_DEVICE;
-    dipdw.dwData = DIPROPAUTOCENTER_OFF;
-    ret = IDirectInputDevice2_SetProperty(haptic->hwdata->device,
-                                          DIPROP_AUTOCENTER, &dipdw.diph);
-    if (!FAILED(ret)) {         /* Autocenter is supported. */
-        haptic->supported |= SDL_HAPTIC_AUTOCENTER;
-    }
-
-    /* Status is always supported. */
-    haptic->supported |= SDL_HAPTIC_STATUS | SDL_HAPTIC_PAUSE;
-
-    /* Check maximum effects. */
-    haptic->neffects = 128;     /* This is not actually supported as thus under windows,
-                                   there is no way to tell the number of EFFECTS that a
-                                   device can hold, so we'll just use a "random" number
-                                   instead and put warnings in SDL_haptic.h */
-    haptic->nplaying = 128;     /* Even more impossible to get this then neffects. */
-
-    /* Prepare effects memory. */
-    haptic->effects = (struct haptic_effect *)
-        SDL_malloc(sizeof(struct haptic_effect) * haptic->neffects);
-    if (haptic->effects == NULL) {
-        SDL_OutOfMemory();
-        goto acquire_err;
-    }
-    /* Clear the memory */
-    SDL_memset(haptic->effects, 0,
-               sizeof(struct haptic_effect) * haptic->neffects);
-
-    return 0;
-
-    /* Error handling */
-  acquire_err:
-    IDirectInputDevice2_Unacquire(haptic->hwdata->device);
-    return -1;
-
-}
-
-
-/*
- * Opens a haptic device for usage.
- */
-int
-SDL_SYS_HapticOpen(SDL_Haptic * haptic)
-{
-    return SDL_SYS_HapticOpenFromInstance(haptic,
-                                          SDL_hapticlist[haptic->index].
-                                          instance);
-}
-
-
-/*
- * Opens a haptic device from first mouse it finds for usage.
- */
-int
-SDL_SYS_HapticMouse(void)
-{
-    int i;
-
-    /* Grab the first mouse haptic device we find. */
-    for (i = 0; i < SDL_numhaptics; i++) {
-        if (SDL_hapticlist[i].capabilities.dwDevType == DIDEVTYPE_MOUSE) {
-            return i;
-        }
-    }
-
-    return -1;
-}
-
-
-/*
- * Checks to see if a joystick has haptic features.
- */
-int
-SDL_SYS_JoystickIsHaptic(SDL_Joystick * joystick)
-{
-    if (joystick->hwdata->Capabilities.dwFlags & DIDC_FORCEFEEDBACK) {
-        return SDL_TRUE;
-    }
-
-    return SDL_FALSE;
-}
-
-
-/*
- * Checks to see if the haptic device and joystick and in reality the same.
- */
-int
-SDL_SYS_JoystickSameHaptic(SDL_Haptic * haptic, SDL_Joystick * joystick)
-{
-    HRESULT ret;
-    DIDEVICEINSTANCE hap_instance, joy_instance;
-
-    /* Get the device instances. */
-    ret = IDirectInputDevice2_GetDeviceInfo(haptic->hwdata->device,
-                                            &hap_instance);
-    if (FAILED(ret)) {
-        return 0;
-    }
-    ret = IDirectInputDevice2_GetDeviceInfo(joystick->hwdata->InputDevice,
-                                            &joy_instance);
-    if (FAILED(ret)) {
-        return 0;
-    }
-
-    if (DI_GUIDIsSame(&hap_instance.guidInstance, &joy_instance.guidInstance))
-        return 1;
-
-    return 0;
-}
-
-
-/*
- * Opens a SDL_Haptic from a SDL_Joystick.
- */
-int
-SDL_SYS_HapticOpenFromJoystick(SDL_Haptic * haptic, SDL_Joystick * joystick)
-{
-    int ret;
-
-    /* Allocate the hwdata */
-    haptic->hwdata = (struct haptic_hwdata *)
-        SDL_malloc(sizeof(*haptic->hwdata));
-    if (haptic->hwdata == NULL) {
-        SDL_OutOfMemory();
-        return -1;
-    }
-    SDL_memset(haptic->hwdata, 0, sizeof(*haptic->hwdata));
-
-    /* Now open the device. */
-    ret =
-        SDL_SYS_HapticOpenFromDevice2(haptic, joystick->hwdata->InputDevice);
-    if (ret < 0) {
-        return -1;
-    }
-
-    /* It's using the joystick device. */
-    haptic->hwdata->is_joystick = 1;
-
-    return 0;
-}
-
-
-/*
- * Closes the haptic device.
- */
-void
-SDL_SYS_HapticClose(SDL_Haptic * haptic)
-{
-    if (haptic->hwdata) {
-
-        /* Free effects. */
-        SDL_free(haptic->effects);
-        haptic->effects = NULL;
-        haptic->neffects = 0;
-
-        /* Clean up */
-        IDirectInputDevice2_Unacquire(haptic->hwdata->device);
-        /* Only release if isn't grabbed by a joystick. */
-        if (haptic->hwdata->is_joystick == 0) {
-            IDirectInputDevice2_Release(haptic->hwdata->device);
-        }
-
-        /* Free */
-        SDL_free(haptic->hwdata);
-        haptic->hwdata = NULL;
-    }
-}
-
-
-/* 
- * Clean up after system specific haptic stuff
- */
-void
-SDL_SYS_HapticQuit(void)
-{
-    IDirectInput_Release(dinput);
-    dinput = NULL;
-}
-
-
-/*
- * Converts an SDL trigger button to an DIEFFECT trigger button.
- */
-static DWORD
-DIGetTriggerButton(Uint16 button)
-{
-    DWORD dwTriggerButton;
-
-    dwTriggerButton = DIEB_NOTRIGGER;
-
-    if (button != 0) {
-        dwTriggerButton = DIJOFS_BUTTON(button - 1);
-    }
-
-    return dwTriggerButton;
-}
-
-
-/*
- * Sets the direction.
- */
-static int
-SDL_SYS_SetDirection(DIEFFECT * effect, SDL_HapticDirection * dir, int naxes)
-{
-    LONG *rglDir;
-
-    /* Handle no axes a part. */
-    if (naxes == 0) {
-        effect->dwFlags |= DIEFF_SPHERICAL;     /* Set as default. */
-        effect->rglDirection = NULL;
-        return 0;
-    }
-
-    /* Has axes. */
-    rglDir = SDL_malloc(sizeof(LONG) * naxes);
-    if (rglDir == NULL) {
-        SDL_OutOfMemory();
-        return -1;
-    }
-    SDL_memset(rglDir, 0, sizeof(LONG) * naxes);
-    effect->rglDirection = rglDir;
-
-    switch (dir->type) {
-    case SDL_HAPTIC_POLAR:
-        effect->dwFlags |= DIEFF_POLAR;
-        rglDir[0] = dir->dir[0];
-        return 0;
-    case SDL_HAPTIC_CARTESIAN:
-        effect->dwFlags |= DIEFF_CARTESIAN;
-        rglDir[0] = dir->dir[0];
-        if (naxes > 1)
-            rglDir[1] = dir->dir[1];
-        if (naxes > 2)
-            rglDir[2] = dir->dir[2];
-        return 0;
-    case SDL_HAPTIC_SPHERICAL:
-        effect->dwFlags |= DIEFF_SPHERICAL;
-        rglDir[0] = dir->dir[0];
-        if (naxes > 1)
-            rglDir[1] = dir->dir[1];
-        if (naxes > 2)
-            rglDir[2] = dir->dir[2];
-        return 0;
-
-    default:
-        SDL_SetError("Haptic: Unknown direction type.");
-        return -1;
-    }
-}
-
-#define CONVERT(x)   (((x) > 0x7FFF) ? 10000 : ((x)*10000) / 0x7FFF)
-/*
- * Creates the DIEFFECT from a SDL_HapticEffect.
- */
-static int
-SDL_SYS_ToDIEFFECT(SDL_Haptic * haptic, DIEFFECT * dest,
-                   SDL_HapticEffect * src)
-{
-    int i;
-    DICONSTANTFORCE *constant;
-    DIPERIODIC *periodic;
-    DICONDITION *condition;     /* Actually an array of conditions - one per axis. */
-    DIRAMPFORCE *ramp;
-    DICUSTOMFORCE *custom;
-    DIENVELOPE *envelope;
-    SDL_HapticConstant *hap_constant;
-    SDL_HapticPeriodic *hap_periodic;
-    SDL_HapticCondition *hap_condition;
-    SDL_HapticRamp *hap_ramp;
-    SDL_HapticCustom *hap_custom;
-    DWORD *axes;
-
-    /* Set global stuff. */
-    SDL_memset(dest, 0, sizeof(DIEFFECT));
-    dest->dwSize = sizeof(DIEFFECT);    /* Set the structure size. */
-    dest->dwSamplePeriod = 0;   /* Not used by us. */
-    dest->dwGain = 10000;       /* Gain is set globally, not locally. */
-    dest->dwFlags = DIEFF_OBJECTOFFSETS;        /* Seems obligatory. */
-
-    /* Envelope. */
-    envelope = SDL_malloc(sizeof(DIENVELOPE));
-    if (envelope == NULL) {
-        SDL_OutOfMemory();
-        return -1;
-    }
-    SDL_memset(envelope, 0, sizeof(DIENVELOPE));
-    dest->lpEnvelope = envelope;
-    envelope->dwSize = sizeof(DIENVELOPE);      /* Always should be this. */
-
-    /* Axes. */
-    dest->cAxes = haptic->naxes;
-    if (dest->cAxes > 0) {
-        axes = SDL_malloc(sizeof(DWORD) * dest->cAxes);
-        if (axes == NULL) {
-            SDL_OutOfMemory();
-            return -1;
-        }
-        axes[0] = haptic->hwdata->axes[0];      /* Always at least one axis. */
-        if (dest->cAxes > 1) {
-            axes[1] = haptic->hwdata->axes[1];
-        }
-        if (dest->cAxes > 2) {
-            axes[2] = haptic->hwdata->axes[2];
-        }
-        dest->rgdwAxes = axes;
-    }
-
-
-    /* The big type handling switch, even bigger then linux's version. */
-    switch (src->type) {
-    case SDL_HAPTIC_CONSTANT:
-        hap_constant = &src->constant;
-        constant = SDL_malloc(sizeof(DICONSTANTFORCE));
-        if (constant == NULL) {
-            SDL_OutOfMemory();
-            return -1;
-        }
-        SDL_memset(constant, 0, sizeof(DICONSTANTFORCE));
-
-        /* Specifics */
-        constant->lMagnitude = CONVERT(hap_constant->level);
-        dest->cbTypeSpecificParams = sizeof(DICONSTANTFORCE);
-        dest->lpvTypeSpecificParams = constant;
-
-        /* Generics */
-        dest->dwDuration = hap_constant->length * 1000; /* In microseconds. */
-        dest->dwTriggerButton = DIGetTriggerButton(hap_constant->button);
-        dest->dwTriggerRepeatInterval = hap_constant->interval;
-        dest->dwStartDelay = hap_constant->delay * 1000;        /* In microseconds. */
-
-        /* Direction. */
-        if (SDL_SYS_SetDirection(dest, &hap_constant->direction, dest->cAxes)
-            < 0) {
-            return -1;
-        }
-
-        /* Envelope */
-        if ((hap_constant->attack_length == 0)
-            && (hap_constant->fade_length == 0)) {
-            SDL_free(dest->lpEnvelope);
-            dest->lpEnvelope = NULL;
-        } else {
-            envelope->dwAttackLevel = CONVERT(hap_constant->attack_level);
-            envelope->dwAttackTime = hap_constant->attack_length * 1000;
-            envelope->dwFadeLevel = CONVERT(hap_constant->fade_level);
-            envelope->dwFadeTime = hap_constant->fade_length * 1000;
-        }
-
-        break;
-
-    case SDL_HAPTIC_SINE:
-    case SDL_HAPTIC_SQUARE:
-    case SDL_HAPTIC_TRIANGLE:
-    case SDL_HAPTIC_SAWTOOTHUP:
-    case SDL_HAPTIC_SAWTOOTHDOWN:
-        hap_periodic = &src->periodic;
-        periodic = SDL_malloc(sizeof(DIPERIODIC));
-        if (periodic == NULL) {
-            SDL_OutOfMemory();
-            return -1;
-        }
-        SDL_memset(periodic, 0, sizeof(DIPERIODIC));
-
-        /* Specifics */
-        periodic->dwMagnitude = CONVERT(hap_periodic->magnitude);
-        periodic->lOffset = CONVERT(hap_periodic->offset);
-        periodic->dwPhase = hap_periodic->phase;
-        periodic->dwPeriod = hap_periodic->period * 1000;
-        dest->cbTypeSpecificParams = sizeof(DIPERIODIC);
-        dest->lpvTypeSpecificParams = periodic;
-
-        /* Generics */
-        dest->dwDuration = hap_periodic->length * 1000; /* In microseconds. */
-        dest->dwTriggerButton = DIGetTriggerButton(hap_periodic->button);
-        dest->dwTriggerRepeatInterval = hap_periodic->interval;
-        dest->dwStartDelay = hap_periodic->delay * 1000;        /* In microseconds. */
-
-        /* Direction. */
-        if (SDL_SYS_SetDirection(dest, &hap_periodic->direction, dest->cAxes)
-            < 0) {
-            return -1;
-        }
-
-        /* Envelope */
-        if ((hap_periodic->attack_length == 0)
-            && (hap_periodic->fade_length == 0)) {
-            SDL_free(dest->lpEnvelope);
-            dest->lpEnvelope = NULL;
-        } else {
-            envelope->dwAttackLevel = CONVERT(hap_periodic->attack_level);
-            envelope->dwAttackTime = hap_periodic->attack_length * 1000;
-            envelope->dwFadeLevel = CONVERT(hap_periodic->fade_level);
-            envelope->dwFadeTime = hap_periodic->fade_length * 1000;
-        }
-
-        break;
-
-    case SDL_HAPTIC_SPRING:
-    case SDL_HAPTIC_DAMPER:
-    case SDL_HAPTIC_INERTIA:
-    case SDL_HAPTIC_FRICTION:
-        hap_condition = &src->condition;
-        condition = SDL_malloc(sizeof(DICONDITION) * dest->cAxes);
-        if (condition == NULL) {
-            SDL_OutOfMemory();
-            return -1;
-        }
-        SDL_memset(condition, 0, sizeof(DICONDITION));
-
-        /* Specifics */
-        for (i = 0; i < (int) dest->cAxes; i++) {
-            condition[i].lOffset = CONVERT(hap_condition->center[i]);
-            condition[i].lPositiveCoefficient =
-                CONVERT(hap_condition->right_coeff[i]);
-            condition[i].lNegativeCoefficient =
-                CONVERT(hap_condition->left_coeff[i]);
-            condition[i].dwPositiveSaturation =
-                CONVERT(hap_condition->right_sat[i]);
-            condition[i].dwNegativeSaturation =
-                CONVERT(hap_condition->left_sat[i]);
-            condition[i].lDeadBand = CONVERT(hap_condition->deadband[i]);
-        }
-        dest->cbTypeSpecificParams = sizeof(DICONDITION) * dest->cAxes;
-        dest->lpvTypeSpecificParams = condition;
-
-        /* Generics */
-        dest->dwDuration = hap_condition->length * 1000;        /* In microseconds. */
-        dest->dwTriggerButton = DIGetTriggerButton(hap_condition->button);
-        dest->dwTriggerRepeatInterval = hap_condition->interval;
-        dest->dwStartDelay = hap_condition->delay * 1000;       /* In microseconds. */
-
-        /* Direction. */
-        if (SDL_SYS_SetDirection(dest, &hap_condition->direction, dest->cAxes)
-            < 0) {
-            return -1;
-        }
-
-        /* Envelope - Not actually supported by most CONDITION implementations. */
-        SDL_free(dest->lpEnvelope);
-        dest->lpEnvelope = NULL;
-
-        break;
-
-    case SDL_HAPTIC_RAMP:
-        hap_ramp = &src->ramp;
-        ramp = SDL_malloc(sizeof(DIRAMPFORCE));
-        if (ramp == NULL) {
-            SDL_OutOfMemory();
-            return -1;
-        }
-        SDL_memset(ramp, 0, sizeof(DIRAMPFORCE));
-
-        /* Specifics */
-        ramp->lStart = CONVERT(hap_ramp->start);
-        ramp->lEnd = CONVERT(hap_ramp->end);
-        dest->cbTypeSpecificParams = sizeof(DIRAMPFORCE);
-        dest->lpvTypeSpecificParams = ramp;
-
-        /* Generics */
-        dest->dwDuration = hap_ramp->length * 1000;     /* In microseconds. */
-        dest->dwTriggerButton = DIGetTriggerButton(hap_ramp->button);
-        dest->dwTriggerRepeatInterval = hap_ramp->interval;
-        dest->dwStartDelay = hap_ramp->delay * 1000;    /* In microseconds. */
-
-        /* Direction. */
-        if (SDL_SYS_SetDirection(dest, &hap_ramp->direction, dest->cAxes) < 0) {
-            return -1;
-        }
-
-        /* Envelope */
-        if ((hap_ramp->attack_length == 0) && (hap_ramp->fade_length == 0)) {
-            SDL_free(dest->lpEnvelope);
-            dest->lpEnvelope = NULL;
-        } else {
-            envelope->dwAttackLevel = CONVERT(hap_ramp->attack_level);
-            envelope->dwAttackTime = hap_ramp->attack_length * 1000;
-            envelope->dwFadeLevel = CONVERT(hap_ramp->fade_level);
-            envelope->dwFadeTime = hap_ramp->fade_length * 1000;
-        }
-
-        break;
-
-    case SDL_HAPTIC_CUSTOM:
-        hap_custom = &src->custom;
-        custom = SDL_malloc(sizeof(DICUSTOMFORCE));
-        if (custom == NULL) {
-            SDL_OutOfMemory();
-            return -1;
-        }
-        SDL_memset(custom, 0, sizeof(DICUSTOMFORCE));
-
-        /* Specifics */
-        custom->cChannels = hap_custom->channels;
-        custom->dwSamplePeriod = hap_custom->period * 1000;
-        custom->cSamples = hap_custom->samples;
-        custom->rglForceData =
-            SDL_malloc(sizeof(LONG) * custom->cSamples * custom->cChannels);
-        for (i = 0; i < hap_custom->samples * hap_custom->channels; i++) {      /* Copy data. */
-            custom->rglForceData[i] = CONVERT(hap_custom->data[i]);
-        }
-        dest->cbTypeSpecificParams = sizeof(DICUSTOMFORCE);
-        dest->lpvTypeSpecificParams = custom;
-
-        /* Generics */
-        dest->dwDuration = hap_custom->length * 1000;   /* In microseconds. */
-        dest->dwTriggerButton = DIGetTriggerButton(hap_custom->button);
-        dest->dwTriggerRepeatInterval = hap_custom->interval;
-        dest->dwStartDelay = hap_custom->delay * 1000;  /* In microseconds. */
-
-        /* Direction. */
-        if (SDL_SYS_SetDirection(dest, &hap_custom->direction, dest->cAxes) <
-            0) {
-            return -1;
-        }
-
-        /* Envelope */
-        if ((hap_custom->attack_length == 0)
-            && (hap_custom->fade_length == 0)) {
-            SDL_free(dest->lpEnvelope);
-            dest->lpEnvelope = NULL;
-        } else {
-            envelope->dwAttackLevel = CONVERT(hap_custom->attack_level);
-            envelope->dwAttackTime = hap_custom->attack_length * 1000;
-            envelope->dwFadeLevel = CONVERT(hap_custom->fade_level);
-            envelope->dwFadeTime = hap_custom->fade_length * 1000;
-        }
-
-        break;
-
-
-    default:
-        SDL_SetError("Haptic: Unknown effect type.");
-        return -1;
-    }
-
-    return 0;
-}
-
-
-/*
- * Frees an DIEFFECT allocated by SDL_SYS_ToDIEFFECT.
- */
-static void
-SDL_SYS_HapticFreeDIEFFECT(DIEFFECT * effect, int type)
-{
-    DICUSTOMFORCE *custom;
-
-    if (effect->lpEnvelope != NULL) {
-        SDL_free(effect->lpEnvelope);
-        effect->lpEnvelope = NULL;
-    }
-    if (effect->rgdwAxes != NULL) {
-        SDL_free(effect->rgdwAxes);
-        effect->rgdwAxes = NULL;
-    }
-    if (effect->lpvTypeSpecificParams != NULL) {
-        if (type == SDL_HAPTIC_CUSTOM) {        /* Must free the custom data. */
-            custom = (DICUSTOMFORCE *) effect->lpvTypeSpecificParams;
-            SDL_free(custom->rglForceData);
-            custom->rglForceData = NULL;
-        }
-        SDL_free(effect->lpvTypeSpecificParams);
-        effect->lpvTypeSpecificParams = NULL;
-    }
-    if (effect->rglDirection != NULL) {
-        SDL_free(effect->rglDirection);
-        effect->rglDirection = NULL;
-    }
-}
-
-
-/*
- * Gets the effect type from the generic SDL haptic effect wrapper.
- */
-static REFGUID
-SDL_SYS_HapticEffectType(SDL_HapticEffect * effect)
-{
-    switch (effect->type) {
-    case SDL_HAPTIC_CONSTANT:
-        return &GUID_ConstantForce;
-
-    case SDL_HAPTIC_RAMP:
-        return &GUID_RampForce;
-
-    case SDL_HAPTIC_SQUARE:
-        return &GUID_Square;
-
-    case SDL_HAPTIC_SINE:
-        return &GUID_Sine;
-
-    case SDL_HAPTIC_TRIANGLE:
-        return &GUID_Triangle;
-
-    case SDL_HAPTIC_SAWTOOTHUP:
-        return &GUID_SawtoothUp;
-
-    case SDL_HAPTIC_SAWTOOTHDOWN:
-        return &GUID_SawtoothDown;
-
-    case SDL_HAPTIC_SPRING:
-        return &GUID_Spring;
-
-    case SDL_HAPTIC_DAMPER:
-        return &GUID_Damper;
-
-    case SDL_HAPTIC_INERTIA:
-        return &GUID_Inertia;
-
-    case SDL_HAPTIC_FRICTION:
-        return &GUID_Friction;
-
-    case SDL_HAPTIC_CUSTOM:
-        return &GUID_CustomForce;
-
-    default:
-        SDL_SetError("Haptic: Unknown effect type.");
-        return NULL;
-    }
-}
-
-
-/*
- * Creates a new haptic effect.
- */
-int
-SDL_SYS_HapticNewEffect(SDL_Haptic * haptic, struct haptic_effect *effect,
-                        SDL_HapticEffect * base)
-{
-    HRESULT ret;
-
-    /* Get the type. */
-    REFGUID type = SDL_SYS_HapticEffectType(base);
-    if (type == NULL) {
-        goto err_hweffect;
-    }
-
-    /* Alloc the effect. */
-    effect->hweffect = (struct haptic_hweffect *)
-        SDL_malloc(sizeof(struct haptic_hweffect));
-    if (effect->hweffect == NULL) {
-        SDL_OutOfMemory();
-        goto err_hweffect;
-    }
-
-    /* Get the effect. */
-    if (SDL_SYS_ToDIEFFECT(haptic, &effect->hweffect->effect, base) < 0) {
-        goto err_effectdone;
-    }
-
-    /* Create the actual effect. */
-    ret = IDirectInputDevice2_CreateEffect(haptic->hwdata->device, type,
-                                           &effect->hweffect->effect,
-                                           &effect->hweffect->ref, NULL);
-    if (FAILED(ret)) {
-        DI_SetError("Unable to create effect", ret);
-        goto err_effectdone;
-    }
-
-    return 0;
-
-  err_effectdone:
-    SDL_SYS_HapticFreeDIEFFECT(&effect->hweffect->effect, base->type);
-  err_hweffect:
-    if (effect->hweffect != NULL) {
-        SDL_free(effect->hweffect);
-        effect->hweffect = NULL;
-    }
-    return -1;
-}
-
-
-/*
- * Updates an effect.
- */
-int
-SDL_SYS_HapticUpdateEffect(SDL_Haptic * haptic,
-                           struct haptic_effect *effect,
-                           SDL_HapticEffect * data)
-{
-    HRESULT ret;
-    DWORD flags;
-    DIEFFECT temp;
-
-    /* Get the effect. */
-    SDL_memset(&temp, 0, sizeof(DIEFFECT));
-    if (SDL_SYS_ToDIEFFECT(haptic, &temp, data) < 0) {
-        goto err_update;
-    }
-
-    /* Set the flags.  Might be worthwhile to diff temp with loaded effect and
-     *  only change those parameters. */
-    flags = DIEP_DIRECTION |
-        DIEP_DURATION |
-        DIEP_ENVELOPE |
-        DIEP_STARTDELAY |
-        DIEP_TRIGGERBUTTON |
-        DIEP_TRIGGERREPEATINTERVAL | DIEP_TYPESPECIFICPARAMS;
-
-    /* Create the actual effect. */
-    ret =
-        IDirectInputEffect_SetParameters(effect->hweffect->ref, &temp, flags);
-    if (FAILED(ret)) {
-        DI_SetError("Unable to update effect", ret);
-        goto err_update;
-    }
-
-    /* Copy it over. */
-    SDL_SYS_HapticFreeDIEFFECT(&effect->hweffect->effect, data->type);
-    SDL_memcpy(&effect->hweffect->effect, &temp, sizeof(DIEFFECT));
-
-    return 0;
-
-  err_update:
-    SDL_SYS_HapticFreeDIEFFECT(&temp, data->type);
-    return -1;
-}
-
-
-/*
- * Runs an effect.
- */
-int
-SDL_SYS_HapticRunEffect(SDL_Haptic * haptic, struct haptic_effect *effect,
-                        Uint32 iterations)
-{
-    HRESULT ret;
-    DWORD iter;
-
-    /* Check if it's infinite. */
-    if (iterations == SDL_HAPTIC_INFINITY) {
-        iter = INFINITE;
-    } else
-        iter = iterations;
-
-    /* Run the effect. */
-    ret = IDirectInputEffect_Start(effect->hweffect->ref, iter, 0);
-    if (FAILED(ret)) {
-        DI_SetError("Running the effect", ret);
-        return -1;
-    }
-
-    return 0;
-}
-
-
-/*
- * Stops an effect.
- */
-int
-SDL_SYS_HapticStopEffect(SDL_Haptic * haptic, struct haptic_effect *effect)
-{
-    HRESULT ret;
-
-    ret = IDirectInputEffect_Stop(effect->hweffect->ref);
-    if (FAILED(ret)) {
-        DI_SetError("Unable to stop effect", ret);
-        return -1;
-    }
-
-    return 0;
-}
-
-
-/*
- * Frees the effect.
- */
-void
-SDL_SYS_HapticDestroyEffect(SDL_Haptic * haptic, struct haptic_effect *effect)
-{
-    HRESULT ret;
-
-    ret = IDirectInputEffect_Unload(effect->hweffect->ref);
-    if (FAILED(ret)) {
-        DI_SetError("Removing effect from the device", ret);
-    }
-    SDL_SYS_HapticFreeDIEFFECT(&effect->hweffect->effect,
-                               effect->effect.type);
-    SDL_free(effect->hweffect);
-    effect->hweffect = NULL;
-}
-
-
-/*
- * Gets the status of a haptic effect.
- */
-int
-SDL_SYS_HapticGetEffectStatus(SDL_Haptic * haptic,
-                              struct haptic_effect *effect)
-{
-    HRESULT ret;
-    DWORD status;
-
-    ret = IDirectInputEffect_GetEffectStatus(effect->hweffect->ref, &status);
-    if (FAILED(ret)) {
-        DI_SetError("Getting effect status", ret);
-        return -1;
-    }
-
-    if (status == 0)
-        return SDL_FALSE;
-    return SDL_TRUE;
-}
-
-
-/*
- * Sets the gain.
- */
-int
-SDL_SYS_HapticSetGain(SDL_Haptic * haptic, int gain)
-{
-    HRESULT ret;
-    DIPROPDWORD dipdw;
-
-    /* Create the weird structure thingy. */
-    dipdw.diph.dwSize = sizeof(DIPROPDWORD);
-    dipdw.diph.dwHeaderSize = sizeof(DIPROPHEADER);
-    dipdw.diph.dwObj = 0;
-    dipdw.diph.dwHow = DIPH_DEVICE;
-    dipdw.dwData = gain * 100;  /* 0 to 10,000 */
-
-    /* Try to set the autocenter. */
-    ret = IDirectInputDevice2_SetProperty(haptic->hwdata->device,
-                                          DIPROP_FFGAIN, &dipdw.diph);
-    if (FAILED(ret)) {
-        DI_SetError("Setting gain", ret);
-        return -1;
-    }
-
-    return 0;
-}
-
-
-/*
- * Sets the autocentering.
- */
-int
-SDL_SYS_HapticSetAutocenter(SDL_Haptic * haptic, int autocenter)
-{
-    HRESULT ret;
-    DIPROPDWORD dipdw;
-
-    /* Create the weird structure thingy. */
-    dipdw.diph.dwSize = sizeof(DIPROPDWORD);
-    dipdw.diph.dwHeaderSize = sizeof(DIPROPHEADER);
-    dipdw.diph.dwObj = 0;
-    dipdw.diph.dwHow = DIPH_DEVICE;
-    dipdw.dwData = (autocenter == 0) ? DIPROPAUTOCENTER_OFF :
-        DIPROPAUTOCENTER_ON;
-
-    /* Try to set the autocenter. */
-    ret = IDirectInputDevice2_SetProperty(haptic->hwdata->device,
-                                          DIPROP_AUTOCENTER, &dipdw.diph);
-    if (FAILED(ret)) {
-        DI_SetError("Setting autocenter", ret);
-        return -1;
-    }
-
-    return 0;
-}
-
-
-/*
- * Pauses the device.
- */
-int
-SDL_SYS_HapticPause(SDL_Haptic * haptic)
-{
-    HRESULT ret;
-
-    /* Pause the device. */
-    ret = IDirectInputDevice2_SendForceFeedbackCommand(haptic->hwdata->device,
-                                                       DISFFC_PAUSE);
-    if (FAILED(ret)) {
-        DI_SetError("Pausing the device", ret);
-        return -1;
-    }
-
-    return 0;
-}
-
-
-/*
- * Pauses the device.
- */
-int
-SDL_SYS_HapticUnpause(SDL_Haptic * haptic)
-{
-    HRESULT ret;
-
-    /* Unpause the device. */
-    ret = IDirectInputDevice2_SendForceFeedbackCommand(haptic->hwdata->device,
-                                                       DISFFC_CONTINUE);
-    if (FAILED(ret)) {
-        DI_SetError("Pausing the device", ret);
-        return -1;
-    }
-
-    return 0;
-}
-
-
-/*
- * Stops all the playing effects on the device.
- */
-int
-SDL_SYS_HapticStopAll(SDL_Haptic * haptic)
-{
-    HRESULT ret;
-
-    /* Try to stop the effects. */
-    ret = IDirectInputDevice2_SendForceFeedbackCommand(haptic->hwdata->device,
-                                                       DISFFC_STOPALL);
-    if (FAILED(ret)) {
-        DI_SetError("Stopping the device", ret);
-        return -1;
-    }
-
-    return 0;
-}
-
-
-#endif /* SDL_HAPTIC_DINPUT */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/haptic/windows/SDL_syshaptic.c	Thu Jan 20 18:04:05 2011 -0800
@@ -0,0 +1,1379 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 2008 Edgar Simo
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+
+    Sam Lantinga
+    slouken@libsdl.org
+*/
+#include "SDL_config.h"
+
+#ifdef SDL_HAPTIC_DINPUT
+
+#include "SDL_haptic.h"
+#include "../SDL_syshaptic.h"
+#include "SDL_joystick.h"
+#include "../../joystick/SDL_sysjoystick.h"     /* For the real SDL_Joystick */
+#include "../../joystick/windows/SDL_dxjoystick_c.h"      /* For joystick hwdata */
+
+
+#define MAX_HAPTICS  32
+
+
+/*
+ * List of available haptic devices.
+ */
+static struct
+{
+    DIDEVICEINSTANCE instance;
+    SDL_Haptic *haptic;
+    DIDEVCAPS capabilities;
+} SDL_hapticlist[MAX_HAPTICS];
+
+
+/*
+ * Haptic system hardware data.
+ */
+struct haptic_hwdata
+{
+    LPDIRECTINPUTDEVICE2 device;
+    DWORD axes[3];              /* Axes to use. */
+    int is_joystick;            /* Device is loaded as joystick. */
+};
+
+
+/*
+ * Haptic system effect data.
+ */
+struct haptic_hweffect
+{
+    DIEFFECT effect;
+    LPDIRECTINPUTEFFECT ref;
+};
+
+
+/*
+ * Internal stuff.
+ */
+static LPDIRECTINPUT dinput = NULL;
+
+
+/*
+ * External stuff.
+ */
+extern HWND SDL_HelperWindow;
+
+
+/*
+ * Prototypes.
+ */
+static void DI_SetError(const char *str, HRESULT err);
+static int DI_GUIDIsSame(const GUID * a, const GUID * b);
+static int SDL_SYS_HapticOpenFromInstance(SDL_Haptic * haptic,
+                                          DIDEVICEINSTANCE instance);
+static int SDL_SYS_HapticOpenFromDevice2(SDL_Haptic * haptic,
+                                         LPDIRECTINPUTDEVICE2 device2);
+static DWORD DIGetTriggerButton(Uint16 button);
+static int SDL_SYS_SetDirection(DIEFFECT * effect, SDL_HapticDirection * dir,
+                                int naxes);
+static int SDL_SYS_ToDIEFFECT(SDL_Haptic * haptic, DIEFFECT * dest,
+                              SDL_HapticEffect * src);
+static void SDL_SYS_HapticFreeDIEFFECT(DIEFFECT * effect, int type);
+static REFGUID SDL_SYS_HapticEffectType(SDL_HapticEffect * effect);
+/* Callbacks. */
+static BOOL CALLBACK EnumHapticsCallback(const DIDEVICEINSTANCE *
+                                         pdidInstance, VOID * pContext);
+static BOOL CALLBACK DI_EffectCallback(LPCDIEFFECTINFO pei, LPVOID pv);
+
+
+/* 
+ * Like SDL_SetError but for DX error codes.
+ */
+static void
+DI_SetError(const char *str, HRESULT err)
+{
+    /*
+       SDL_SetError("Haptic: %s - %s: %s", str,
+       DXGetErrorString8A(err), DXGetErrorDescription8A(err));
+     */
+    SDL_SetError("Haptic error %s", str);
+}
+
+
+/*
+ * Checks to see if two GUID are the same.
+ */
+static int
+DI_GUIDIsSame(const GUID * a, const GUID * b)
+{
+    if (((a)->Data1 == (b)->Data1) &&
+        ((a)->Data2 == (b)->Data2) &&
+        ((a)->Data3 == (b)->Data3) &&
+        (SDL_strcmp((a)->Data4, (b)->Data4) == 0))
+        return 1;
+    return 0;
+}
+
+
+/*
+ * Initializes the haptic subsystem.
+ */
+int
+SDL_SYS_HapticInit(void)
+{
+    HRESULT ret;
+    HINSTANCE instance;
+
+    if (dinput != NULL) {       /* Already open. */
+        SDL_SetError("Haptic: SubSystem already open.");
+        return -1;
+    }
+
+    /* Clear all the memory. */
+    SDL_memset(SDL_hapticlist, 0, sizeof(SDL_hapticlist));
+
+    SDL_numhaptics = 0;
+
+    ret = CoInitialize(NULL);
+    if (FAILED(ret)) {
+        DI_SetError("Coinitialize", ret);
+        return -1;
+    }
+
+    ret = CoCreateInstance(&CLSID_DirectInput, NULL, CLSCTX_INPROC_SERVER,
+                           &IID_IDirectInput, (LPVOID) & dinput);
+    if (FAILED(ret)) {
+        DI_SetError("CoCreateInstance", ret);
+        return -1;
+    }
+
+    /* Because we used CoCreateInstance, we need to Initialize it, first. */
+    instance = GetModuleHandle(NULL);
+    if (instance == NULL) {
+        SDL_SetError("GetModuleHandle() failed with error code %d.",
+                     GetLastError());
+        return -1;
+    }
+    ret = IDirectInput_Initialize(dinput, instance, DIRECTINPUT_VERSION);
+    if (FAILED(ret)) {
+        DI_SetError("Initializing DirectInput device", ret);
+        return -1;
+    }
+
+    /* Look for haptic devices. */
+    ret = IDirectInput_EnumDevices(dinput,
+                                   0,
+                                   EnumHapticsCallback,
+                                   NULL,
+                                   DIEDFL_FORCEFEEDBACK |
+                                   DIEDFL_ATTACHEDONLY);
+    if (FAILED(ret)) {
+        DI_SetError("Enumerating DirectInput devices", ret);
+        return -1;
+    }
+
+    return SDL_numhaptics;
+}
+
+/*
+ * Callback to find the haptic devices.
+ */
+static BOOL CALLBACK
+EnumHapticsCallback(const DIDEVICEINSTANCE * pdidInstance, VOID * pContext)
+{
+    HRESULT ret;
+    LPDIRECTINPUTDEVICE device;
+
+    /* Copy the instance over, useful for creating devices. */
+    SDL_memcpy(&SDL_hapticlist[SDL_numhaptics].instance, pdidInstance,
+               sizeof(DIDEVICEINSTANCE));
+
+    /* Open the device */
+    ret = IDirectInput_CreateDevice(dinput, &pdidInstance->guidInstance,
+                                    &device, NULL);
+    if (FAILED(ret)) {
+        /* DI_SetError("Creating DirectInput device",ret); */
+        return DIENUM_CONTINUE;
+    }
+
+    /* Get capabilities. */
+    SDL_hapticlist[SDL_numhaptics].capabilities.dwSize = sizeof(DIDEVCAPS);
+    ret = IDirectInputDevice_GetCapabilities(device,
+                                             &SDL_hapticlist[SDL_numhaptics].
+                                             capabilities);
+    if (FAILED(ret)) {
+        /* DI_SetError("Getting device capabilities",ret); */
+        IDirectInputDevice_Release(device);
+        return DIENUM_CONTINUE;
+    }
+
+    /* Close up device and count it. */
+    IDirectInputDevice_Release(device);
+    SDL_numhaptics++;
+
+    /* Watch out for hard limit. */
+    if (SDL_numhaptics >= MAX_HAPTICS)
+        return DIENUM_STOP;
+
+    return DIENUM_CONTINUE;
+}
+
+
+/*
+ * Return the name of a haptic device, does not need to be opened.
+ */
+const char *
+SDL_SYS_HapticName(int index)
+{
+    return SDL_hapticlist[index].instance.tszProductName;
+}
+
+
+/*
+ * Callback to get all supported effects.
+ */
+#define EFFECT_TEST(e,s)               \
+if (DI_GUIDIsSame(&pei->guid, &(e)))   \
+   haptic->supported |= (s)
+static BOOL CALLBACK
+DI_EffectCallback(LPCDIEFFECTINFO pei, LPVOID pv)
+{
+    /* Prepare the haptic device. */
+    SDL_Haptic *haptic = (SDL_Haptic *) pv;
+
+    /* Get supported. */
+    EFFECT_TEST(GUID_Spring, SDL_HAPTIC_SPRING);
+    EFFECT_TEST(GUID_Damper, SDL_HAPTIC_DAMPER);
+    EFFECT_TEST(GUID_Inertia, SDL_HAPTIC_INERTIA);
+    EFFECT_TEST(GUID_Friction, SDL_HAPTIC_FRICTION);
+    EFFECT_TEST(GUID_ConstantForce, SDL_HAPTIC_CONSTANT);
+    EFFECT_TEST(GUID_CustomForce, SDL_HAPTIC_CUSTOM);
+    EFFECT_TEST(GUID_Sine, SDL_HAPTIC_SINE);
+    EFFECT_TEST(GUID_Square, SDL_HAPTIC_SQUARE);
+    EFFECT_TEST(GUID_Triangle, SDL_HAPTIC_TRIANGLE);
+    EFFECT_TEST(GUID_SawtoothUp, SDL_HAPTIC_SAWTOOTHUP);
+    EFFECT_TEST(GUID_SawtoothDown, SDL_HAPTIC_SAWTOOTHDOWN);
+    EFFECT_TEST(GUID_RampForce, SDL_HAPTIC_RAMP);
+
+    /* Check for more. */
+    return DIENUM_CONTINUE;
+}
+
+
+/*
+ * Callback to get supported axes.
+ */
+static BOOL CALLBACK
+DI_DeviceObjectCallback(LPCDIDEVICEOBJECTINSTANCE dev, LPVOID pvRef)
+{
+    SDL_Haptic *haptic = (SDL_Haptic *) pvRef;
+
+    if ((dev->dwType & DIDFT_AXIS) && (dev->dwFlags & DIDOI_FFACTUATOR)) {
+
+        haptic->hwdata->axes[haptic->naxes] = dev->dwOfs;
+        haptic->naxes++;
+
+        /* Currently using the artificial limit of 3 axes. */
+        if (haptic->naxes >= 3) {
+            return DIENUM_STOP;
+        }
+    }
+
+    return DIENUM_CONTINUE;
+}
+
+
+/*
+ * Opens the haptic device from the file descriptor.
+ *
+ *    Steps:
+ *       - Open temporary DirectInputDevice interface.
+ *       - Create DirectInputDevice2 interface.
+ *       - Release DirectInputDevice interface.
+ *       - Call SDL_SYS_HapticOpenFromDevice2
+ */
+static int
+SDL_SYS_HapticOpenFromInstance(SDL_Haptic * haptic, DIDEVICEINSTANCE instance)
+{
+    HRESULT ret;
+    int ret2;
+    LPDIRECTINPUTDEVICE device;
+
+    /* Allocate the hwdata */
+    haptic->hwdata = (struct haptic_hwdata *)
+        SDL_malloc(sizeof(*haptic->hwdata));
+    if (haptic->hwdata == NULL) {
+        SDL_OutOfMemory();
+        goto creat_err;
+    }
+    SDL_memset(haptic->hwdata, 0, sizeof(*haptic->hwdata));
+
+    /* Open the device */
+    ret = IDirectInput_CreateDevice(dinput, &instance.guidInstance,
+                                    &device, NULL);
+    if (FAILED(ret)) {
+        DI_SetError("Creating DirectInput device", ret);
+        goto creat_err;
+    }
+
+    /* Now get the IDirectInputDevice2 interface, instead. */
+    ret = IDirectInputDevice_QueryInterface(device,
+                                            &IID_IDirectInputDevice2,
+                                            (LPVOID *) & haptic->hwdata->
+                                            device);
+    /* Done with the temporary one now. */
+    IDirectInputDevice_Release(device);
+    if (FAILED(ret)) {
+        DI_SetError("Querying DirectInput interface", ret);
+        goto creat_err;
+    }
+
+    ret2 = SDL_SYS_HapticOpenFromDevice2(haptic, haptic->hwdata->device);
+    if (ret2 < 0) {
+        goto query_err;
+    }
+
+    return 0;
+
+  query_err:
+    IDirectInputDevice2_Release(haptic->hwdata->device);
+  creat_err:
+    if (haptic->hwdata != NULL) {
+        SDL_free(haptic->hwdata);
+        haptic->hwdata = NULL;
+    }
+    return -1;
+}
+
+
+/*
+ * Opens the haptic device from the file descriptor.
+ *
+ *    Steps:
+ *       - Set cooperative level.
+ *       - Set data format.
+ *       - Acquire exclusiveness.
+ *       - Reset actuators.
+ *       - Get supported featuers.
+ */
+static int
+SDL_SYS_HapticOpenFromDevice2(SDL_Haptic * haptic,
+                              LPDIRECTINPUTDEVICE2 device2)
+{
+    HRESULT ret;
+    DIPROPDWORD dipdw;
+
+    /* We'll use the device2 from now on. */
+    haptic->hwdata->device = device2;
+
+    /* Grab it exclusively to use force feedback stuff. */
+    ret = IDirectInputDevice2_SetCooperativeLevel(haptic->hwdata->device,
+                                                  SDL_HelperWindow,
+                                                  DISCL_EXCLUSIVE |
+                                                  DISCL_BACKGROUND);
+    if (FAILED(ret)) {
+        DI_SetError("Setting cooperative level to exclusive", ret);
+        goto acquire_err;
+    }
+
+    /* Set data format. */
+    ret = IDirectInputDevice2_SetDataFormat(haptic->hwdata->device,
+                                            &c_dfDIJoystick2);
+    if (FAILED(ret)) {
+        DI_SetError("Setting data format", ret);
+        goto acquire_err;
+    }
+
+    /* Get number of axes. */
+    ret = IDirectInputDevice2_EnumObjects(haptic->hwdata->device,
+                                          DI_DeviceObjectCallback,
+                                          haptic, DIDFT_AXIS);
+    if (FAILED(ret)) {
+        DI_SetError("Getting device axes", ret);
+        goto acquire_err;
+    }
+
+    /* Acquire the device. */
+    ret = IDirectInputDevice2_Acquire(haptic->hwdata->device);
+    if (FAILED(ret)) {
+        DI_SetError("Acquiring DirectInput device", ret);
+        goto acquire_err;
+    }
+
+    /* Reset all actuators - just in case. */
+    ret = IDirectInputDevice2_SendForceFeedbackCommand(haptic->hwdata->device,
+                                                       DISFFC_RESET);
+    if (FAILED(ret)) {
+        DI_SetError("Resetting device", ret);
+        goto acquire_err;
+    }
+
+    /* Enabling actuators. */
+    ret = IDirectInputDevice2_SendForceFeedbackCommand(haptic->hwdata->device,
+                                                       DISFFC_SETACTUATORSON);
+    if (FAILED(ret)) {
+        DI_SetError("Enabling actuators", ret);
+        goto acquire_err;
+    }
+
+    /* Get supported effects. */
+    ret = IDirectInputDevice2_EnumEffects(haptic->hwdata->device,
+                                          DI_EffectCallback, haptic,
+                                          DIEFT_ALL);
+    if (FAILED(ret)) {
+        DI_SetError("Enumerating supported effects", ret);
+        goto acquire_err;
+    }
+    if (haptic->supported == 0) {       /* Error since device supports nothing. */
+        SDL_SetError("Haptic: Internal error on finding supported effects.");
+        goto acquire_err;
+    }
+
+    /* Check autogain and autocenter. */
+    dipdw.diph.dwSize = sizeof(DIPROPDWORD);
+    dipdw.diph.dwHeaderSize = sizeof(DIPROPHEADER);
+    dipdw.diph.dwObj = 0;
+    dipdw.diph.dwHow = DIPH_DEVICE;
+    dipdw.dwData = 10000;
+    ret = IDirectInputDevice2_SetProperty(haptic->hwdata->device,
+                                          DIPROP_FFGAIN, &dipdw.diph);
+    if (!FAILED(ret)) {         /* Gain is supported. */
+        haptic->supported |= SDL_HAPTIC_GAIN;
+    }
+    dipdw.diph.dwObj = 0;
+    dipdw.diph.dwHow = DIPH_DEVICE;
+    dipdw.dwData = DIPROPAUTOCENTER_OFF;
+    ret = IDirectInputDevice2_SetProperty(haptic->hwdata->device,
+                                          DIPROP_AUTOCENTER, &dipdw.diph);
+    if (!FAILED(ret)) {         /* Autocenter is supported. */
+        haptic->supported |= SDL_HAPTIC_AUTOCENTER;
+    }
+
+    /* Status is always supported. */
+    haptic->supported |= SDL_HAPTIC_STATUS | SDL_HAPTIC_PAUSE;
+
+    /* Check maximum effects. */
+    haptic->neffects = 128;     /* This is not actually supported as thus under windows,
+                                   there is no way to tell the number of EFFECTS that a
+                                   device can hold, so we'll just use a "random" number
+                                   instead and put warnings in SDL_haptic.h */
+    haptic->nplaying = 128;     /* Even more impossible to get this then neffects. */
+
+    /* Prepare effects memory. */
+    haptic->effects = (struct haptic_effect *)
+        SDL_malloc(sizeof(struct haptic_effect) * haptic->neffects);
+    if (haptic->effects == NULL) {
+        SDL_OutOfMemory();
+        goto acquire_err;
+    }
+    /* Clear the memory */
+    SDL_memset(haptic->effects, 0,
+               sizeof(struct haptic_effect) * haptic->neffects);
+
+    return 0;
+
+    /* Error handling */
+  acquire_err:
+    IDirectInputDevice2_Unacquire(haptic->hwdata->device);
+    return -1;
+
+}
+
+
+/*
+ * Opens a haptic device for usage.
+ */
+int
+SDL_SYS_HapticOpen(SDL_Haptic * haptic)
+{
+    return SDL_SYS_HapticOpenFromInstance(haptic,
+                                          SDL_hapticlist[haptic->index].
+                                          instance);
+}
+
+
+/*
+ * Opens a haptic device from first mouse it finds for usage.
+ */
+int
+SDL_SYS_HapticMouse(void)
+{
+    int i;
+
+    /* Grab the first mouse haptic device we find. */
+    for (i = 0; i < SDL_numhaptics; i++) {
+        if (SDL_hapticlist[i].capabilities.dwDevType == DIDEVTYPE_MOUSE) {
+            return i;
+        }
+    }
+
+    return -1;
+}
+
+
+/*
+ * Checks to see if a joystick has haptic features.
+ */
+int
+SDL_SYS_JoystickIsHaptic(SDL_Joystick * joystick)
+{
+    if (joystick->hwdata->Capabilities.dwFlags & DIDC_FORCEFEEDBACK) {
+        return SDL_TRUE;
+    }
+
+    return SDL_FALSE;
+}
+
+
+/*
+ * Checks to see if the haptic device and joystick and in reality the same.
+ */
+int
+SDL_SYS_JoystickSameHaptic(SDL_Haptic * haptic, SDL_Joystick * joystick)
+{
+    HRESULT ret;
+    DIDEVICEINSTANCE hap_instance, joy_instance;
+
+    /* Get the device instances. */
+    ret = IDirectInputDevice2_GetDeviceInfo(haptic->hwdata->device,
+                                            &hap_instance);
+    if (FAILED(ret)) {
+        return 0;
+    }
+    ret = IDirectInputDevice2_GetDeviceInfo(joystick->hwdata->InputDevice,
+                                            &joy_instance);
+    if (FAILED(ret)) {
+        return 0;
+    }
+
+    if (DI_GUIDIsSame(&hap_instance.guidInstance, &joy_instance.guidInstance))
+        return 1;
+
+    return 0;
+}
+
+
+/*
+ * Opens a SDL_Haptic from a SDL_Joystick.
+ */
+int
+SDL_SYS_HapticOpenFromJoystick(SDL_Haptic * haptic, SDL_Joystick * joystick)
+{
+    int ret;
+
+    /* Allocate the hwdata */
+    haptic->hwdata = (struct haptic_hwdata *)
+        SDL_malloc(sizeof(*haptic->hwdata));
+    if (haptic->hwdata == NULL) {
+        SDL_OutOfMemory();
+        return -1;
+    }
+    SDL_memset(haptic->hwdata, 0, sizeof(*haptic->hwdata));
+
+    /* Now open the device. */
+    ret =
+        SDL_SYS_HapticOpenFromDevice2(haptic, joystick->hwdata->InputDevice);
+    if (ret < 0) {
+        return -1;
+    }
+
+    /* It's using the joystick device. */
+    haptic->hwdata->is_joystick = 1;
+
+    return 0;
+}
+
+
+/*
+ * Closes the haptic device.
+ */
+void
+SDL_SYS_HapticClose(SDL_Haptic * haptic)
+{
+    if (haptic->hwdata) {
+
+        /* Free effects. */
+        SDL_free(haptic->effects);
+        haptic->effects = NULL;
+        haptic->neffects = 0;
+
+        /* Clean up */
+        IDirectInputDevice2_Unacquire(haptic->hwdata->device);
+        /* Only release if isn't grabbed by a joystick. */
+        if (haptic->hwdata->is_joystick == 0) {
+            IDirectInputDevice2_Release(haptic->hwdata->device);
+        }
+
+        /* Free */
+        SDL_free(haptic->hwdata);
+        haptic->hwdata = NULL;
+    }
+}
+
+
+/* 
+ * Clean up after system specific haptic stuff
+ */
+void
+SDL_SYS_HapticQuit(void)
+{
+    IDirectInput_Release(dinput);
+    dinput = NULL;
+}
+
+
+/*
+ * Converts an SDL trigger button to an DIEFFECT trigger button.
+ */
+static DWORD
+DIGetTriggerButton(Uint16 button)
+{
+    DWORD dwTriggerButton;
+
+    dwTriggerButton = DIEB_NOTRIGGER;
+
+    if (button != 0) {
+        dwTriggerButton = DIJOFS_BUTTON(button - 1);
+    }
+
+    return dwTriggerButton;
+}
+
+
+/*
+ * Sets the direction.
+ */
+static int
+SDL_SYS_SetDirection(DIEFFECT * effect, SDL_HapticDirection * dir, int naxes)
+{
+    LONG *rglDir;
+
+    /* Handle no axes a part. */
+    if (naxes == 0) {
+        effect->dwFlags |= DIEFF_SPHERICAL;     /* Set as default. */
+        effect->rglDirection = NULL;
+        return 0;
+    }
+
+    /* Has axes. */
+    rglDir = SDL_malloc(sizeof(LONG) * naxes);
+    if (rglDir == NULL) {
+        SDL_OutOfMemory();
+        return -1;
+    }
+    SDL_memset(rglDir, 0, sizeof(LONG) * naxes);
+    effect->rglDirection = rglDir;
+
+    switch (dir->type) {
+    case SDL_HAPTIC_POLAR:
+        effect->dwFlags |= DIEFF_POLAR;
+        rglDir[0] = dir->dir[0];
+        return 0;
+    case SDL_HAPTIC_CARTESIAN:
+        effect->dwFlags |= DIEFF_CARTESIAN;
+        rglDir[0] = dir->dir[0];
+        if (naxes > 1)
+            rglDir[1] = dir->dir[1];
+        if (naxes > 2)
+            rglDir[2] = dir->dir[2];
+        return 0;
+    case SDL_HAPTIC_SPHERICAL:
+        effect->dwFlags |= DIEFF_SPHERICAL;
+        rglDir[0] = dir->dir[0];
+        if (naxes > 1)
+            rglDir[1] = dir->dir[1];
+        if (naxes > 2)
+            rglDir[2] = dir->dir[2];
+        return 0;
+
+    default:
+        SDL_SetError("Haptic: Unknown direction type.");
+        return -1;
+    }
+}
+
+#define CONVERT(x)   (((x) > 0x7FFF) ? 10000 : ((x)*10000) / 0x7FFF)
+/*
+ * Creates the DIEFFECT from a SDL_HapticEffect.
+ */
+static int
+SDL_SYS_ToDIEFFECT(SDL_Haptic * haptic, DIEFFECT * dest,
+                   SDL_HapticEffect * src)
+{
+    int i;
+    DICONSTANTFORCE *constant;
+    DIPERIODIC *periodic;
+    DICONDITION *condition;     /* Actually an array of conditions - one per axis. */
+    DIRAMPFORCE *ramp;
+    DICUSTOMFORCE *custom;
+    DIENVELOPE *envelope;
+    SDL_HapticConstant *hap_constant;
+    SDL_HapticPeriodic *hap_periodic;
+    SDL_HapticCondition *hap_condition;
+    SDL_HapticRamp *hap_ramp;
+    SDL_HapticCustom *hap_custom;
+    DWORD *axes;
+
+    /* Set global stuff. */
+    SDL_memset(dest, 0, sizeof(DIEFFECT));
+    dest->dwSize = sizeof(DIEFFECT);    /* Set the structure size. */
+    dest->dwSamplePeriod = 0;   /* Not used by us. */
+    dest->dwGain = 10000;       /* Gain is set globally, not locally. */
+    dest->dwFlags = DIEFF_OBJECTOFFSETS;        /* Seems obligatory. */
+
+    /* Envelope. */
+    envelope = SDL_malloc(sizeof(DIENVELOPE));
+    if (envelope == NULL) {
+        SDL_OutOfMemory();
+        return -1;
+    }
+    SDL_memset(envelope, 0, sizeof(DIENVELOPE));
+    dest->lpEnvelope = envelope;
+    envelope->dwSize = sizeof(DIENVELOPE);      /* Always should be this. */
+
+    /* Axes. */
+    dest->cAxes = haptic->naxes;
+    if (dest->cAxes > 0) {
+        axes = SDL_malloc(sizeof(DWORD) * dest->cAxes);
+        if (axes == NULL) {
+            SDL_OutOfMemory();
+            return -1;
+        }
+        axes[0] = haptic->hwdata->axes[0];      /* Always at least one axis. */
+        if (dest->cAxes > 1) {
+            axes[1] = haptic->hwdata->axes[1];
+        }
+        if (dest->cAxes > 2) {
+            axes[2] = haptic->hwdata->axes[2];
+        }
+        dest->rgdwAxes = axes;
+    }
+
+
+    /* The big type handling switch, even bigger then linux's version. */
+    switch (src->type) {
+    case SDL_HAPTIC_CONSTANT:
+        hap_constant = &src->constant;
+        constant = SDL_malloc(sizeof(DICONSTANTFORCE));
+        if (constant == NULL) {
+            SDL_OutOfMemory();
+            return -1;
+        }
+        SDL_memset(constant, 0, sizeof(DICONSTANTFORCE));
+
+        /* Specifics */
+        constant->lMagnitude = CONVERT(hap_constant->level);
+        dest->cbTypeSpecificParams = sizeof(DICONSTANTFORCE);
+        dest->lpvTypeSpecificParams = constant;
+
+        /* Generics */
+        dest->dwDuration = hap_constant->length * 1000; /* In microseconds. */
+        dest->dwTriggerButton = DIGetTriggerButton(hap_constant->button);
+        dest->dwTriggerRepeatInterval = hap_constant->interval;
+        dest->dwStartDelay = hap_constant->delay * 1000;        /* In microseconds. */
+
+        /* Direction. */
+        if (SDL_SYS_SetDirection(dest, &hap_constant->direction, dest->cAxes)
+            < 0) {
+            return -1;
+        }
+
+        /* Envelope */
+        if ((hap_constant->attack_length == 0)
+            && (hap_constant->fade_length == 0)) {
+            SDL_free(dest->lpEnvelope);
+            dest->lpEnvelope = NULL;
+        } else {
+            envelope->dwAttackLevel = CONVERT(hap_constant->attack_level);
+            envelope->dwAttackTime = hap_constant->attack_length * 1000;
+            envelope->dwFadeLevel = CONVERT(hap_constant->fade_level);
+            envelope->dwFadeTime = hap_constant->fade_length * 1000;
+        }
+
+        break;
+
+    case SDL_HAPTIC_SINE:
+    case SDL_HAPTIC_SQUARE:
+    case SDL_HAPTIC_TRIANGLE:
+    case SDL_HAPTIC_SAWTOOTHUP:
+    case SDL_HAPTIC_SAWTOOTHDOWN:
+        hap_periodic = &src->periodic;
+        periodic = SDL_malloc(sizeof(DIPERIODIC));
+        if (periodic == NULL) {
+            SDL_OutOfMemory();
+            return -1;
+        }
+        SDL_memset(periodic, 0, sizeof(DIPERIODIC));
+
+        /* Specifics */
+        periodic->dwMagnitude = CONVERT(hap_periodic->magnitude);
+        periodic->lOffset = CONVERT(hap_periodic->offset);
+        periodic->dwPhase = hap_periodic->phase;
+        periodic->dwPeriod = hap_periodic->period * 1000;
+        dest->cbTypeSpecificParams = sizeof(DIPERIODIC);
+        dest->lpvTypeSpecificParams = periodic;
+
+        /* Generics */
+        dest->dwDuration = hap_periodic->length * 1000; /* In microseconds. */
+        dest->dwTriggerButton = DIGetTriggerButton(hap_periodic->button);
+        dest->dwTriggerRepeatInterval = hap_periodic->interval;
+        dest->dwStartDelay = hap_periodic->delay * 1000;        /* In microseconds. */
+
+        /* Direction. */
+        if (SDL_SYS_SetDirection(dest, &hap_periodic->direction, dest->cAxes)
+            < 0) {
+            return -1;
+        }
+
+        /* Envelope */
+        if ((hap_periodic->attack_length == 0)
+            && (hap_periodic->fade_length == 0)) {
+            SDL_free(dest->lpEnvelope);
+            dest->lpEnvelope = NULL;
+        } else {
+            envelope->dwAttackLevel = CONVERT(hap_periodic->attack_level);
+            envelope->dwAttackTime = hap_periodic->attack_length * 1000;
+            envelope->dwFadeLevel = CONVERT(hap_periodic->fade_level);
+            envelope->dwFadeTime = hap_periodic->fade_length * 1000;
+        }
+
+        break;
+
+    case SDL_HAPTIC_SPRING:
+    case SDL_HAPTIC_DAMPER:
+    case SDL_HAPTIC_INERTIA:
+    case SDL_HAPTIC_FRICTION:
+        hap_condition = &src->condition;
+        condition = SDL_malloc(sizeof(DICONDITION) * dest->cAxes);
+        if (condition == NULL) {
+            SDL_OutOfMemory();
+            return -1;
+        }
+        SDL_memset(condition, 0, sizeof(DICONDITION));
+
+        /* Specifics */
+        for (i = 0; i < (int) dest->cAxes; i++) {
+            condition[i].lOffset = CONVERT(hap_condition->center[i]);
+            condition[i].lPositiveCoefficient =
+                CONVERT(hap_condition->right_coeff[i]);
+            condition[i].lNegativeCoefficient =
+                CONVERT(hap_condition->left_coeff[i]);
+            condition[i].dwPositiveSaturation =
+                CONVERT(hap_condition->right_sat[i]);
+            condition[i].dwNegativeSaturation =
+                CONVERT(hap_condition->left_sat[i]);
+            condition[i].lDeadBand = CONVERT(hap_condition->deadband[i]);
+        }
+        dest->cbTypeSpecificParams = sizeof(DICONDITION) * dest->cAxes;
+        dest->lpvTypeSpecificParams = condition;
+
+        /* Generics */
+        dest->dwDuration = hap_condition->length * 1000;        /* In microseconds. */
+        dest->dwTriggerButton = DIGetTriggerButton(hap_condition->button);
+        dest->dwTriggerRepeatInterval = hap_condition->interval;
+        dest->dwStartDelay = hap_condition->delay * 1000;       /* In microseconds. */
+
+        /* Direction. */
+        if (SDL_SYS_SetDirection(dest, &hap_condition->direction, dest->cAxes)
+            < 0) {
+            return -1;
+        }
+
+        /* Envelope - Not actually supported by most CONDITION implementations. */
+        SDL_free(dest->lpEnvelope);
+        dest->lpEnvelope = NULL;
+
+        break;
+
+    case SDL_HAPTIC_RAMP:
+        hap_ramp = &src->ramp;
+        ramp = SDL_malloc(sizeof(DIRAMPFORCE));
+        if (ramp == NULL) {
+            SDL_OutOfMemory();
+            return -1;
+        }
+        SDL_memset(ramp, 0, sizeof(DIRAMPFORCE));
+
+        /* Specifics */
+        ramp->lStart = CONVERT(hap_ramp->start);
+        ramp->lEnd = CONVERT(hap_ramp->end);
+        dest->cbTypeSpecificParams = sizeof(DIRAMPFORCE);
+        dest->lpvTypeSpecificParams = ramp;
+
+        /* Generics */
+        dest->dwDuration = hap_ramp->length * 1000;     /* In microseconds. */
+        dest->dwTriggerButton = DIGetTriggerButton(hap_ramp->button);
+        dest->dwTriggerRepeatInterval = hap_ramp->interval;
+        dest->dwStartDelay = hap_ramp->delay * 1000;    /* In microseconds. */
+
+        /* Direction. */
+        if (SDL_SYS_SetDirection(dest, &hap_ramp->direction, dest->cAxes) < 0) {
+            return -1;
+        }
+
+        /* Envelope */
+        if ((hap_ramp->attack_length == 0) && (hap_ramp->fade_length == 0)) {
+            SDL_free(dest->lpEnvelope);
+            dest->lpEnvelope = NULL;
+        } else {
+            envelope->dwAttackLevel = CONVERT(hap_ramp->attack_level);
+            envelope->dwAttackTime = hap_ramp->attack_length * 1000;
+            envelope->dwFadeLevel = CONVERT(hap_ramp->fade_level);
+            envelope->dwFadeTime = hap_ramp->fade_length * 1000;
+        }
+
+        break;
+
+    case SDL_HAPTIC_CUSTOM:
+        hap_custom = &src->custom;
+        custom = SDL_malloc(sizeof(DICUSTOMFORCE));
+        if (custom == NULL) {
+            SDL_OutOfMemory();
+            return -1;
+        }
+        SDL_memset(custom, 0, sizeof(DICUSTOMFORCE));
+
+        /* Specifics */
+        custom->cChannels = hap_custom->channels;
+        custom->dwSamplePeriod = hap_custom->period * 1000;
+        custom->cSamples = hap_custom->samples;
+        custom->rglForceData =
+            SDL_malloc(sizeof(LONG) * custom->cSamples * custom->cChannels);
+        for (i = 0; i < hap_custom->samples * hap_custom->channels; i++) {      /* Copy data. */
+            custom->rglForceData[i] = CONVERT(hap_custom->data[i]);
+        }
+        dest->cbTypeSpecificParams = sizeof(DICUSTOMFORCE);
+        dest->lpvTypeSpecificParams = custom;
+
+        /* Generics */
+        dest->dwDuration = hap_custom->length * 1000;   /* In microseconds. */
+        dest->dwTriggerButton = DIGetTriggerButton(hap_custom->button);
+        dest->dwTriggerRepeatInterval = hap_custom->interval;
+        dest->dwStartDelay = hap_custom->delay * 1000;  /* In microseconds. */
+
+        /* Direction. */
+        if (SDL_SYS_SetDirection(dest, &hap_custom->direction, dest->cAxes) <
+            0) {
+            return -1;
+        }
+
+        /* Envelope */
+        if ((hap_custom->attack_length == 0)
+            && (hap_custom->fade_length == 0)) {
+            SDL_free(dest->lpEnvelope);
+            dest->lpEnvelope = NULL;
+        } else {
+            envelope->dwAttackLevel = CONVERT(hap_custom->attack_level);
+            envelope->dwAttackTime = hap_custom->attack_length * 1000;
+            envelope->dwFadeLevel = CONVERT(hap_custom->fade_level);
+            envelope->dwFadeTime = hap_custom->fade_length * 1000;
+        }
+
+        break;
+
+
+    default:
+        SDL_SetError("Haptic: Unknown effect type.");
+        return -1;
+    }
+
+    return 0;
+}
+
+
+/*
+ * Frees an DIEFFECT allocated by SDL_SYS_ToDIEFFECT.
+ */
+static void
+SDL_SYS_HapticFreeDIEFFECT(DIEFFECT * effect, int type)
+{
+    DICUSTOMFORCE *custom;
+
+    if (effect->lpEnvelope != NULL) {
+        SDL_free(effect->lpEnvelope);
+        effect->lpEnvelope = NULL;
+    }
+    if (effect->rgdwAxes != NULL) {
+        SDL_free(effect->rgdwAxes);
+        effect->rgdwAxes = NULL;
+    }
+    if (effect->lpvTypeSpecificParams != NULL) {
+        if (type == SDL_HAPTIC_CUSTOM) {        /* Must free the custom data. */
+            custom = (DICUSTOMFORCE *) effect->lpvTypeSpecificParams;
+            SDL_free(custom->rglForceData);
+            custom->rglForceData = NULL;
+        }
+        SDL_free(effect->lpvTypeSpecificParams);
+        effect->lpvTypeSpecificParams = NULL;
+    }
+    if (effect->rglDirection != NULL) {
+        SDL_free(effect->rglDirection);
+        effect->rglDirection = NULL;
+    }
+}
+
+
+/*
+ * Gets the effect type from the generic SDL haptic effect wrapper.
+ */
+static REFGUID
+SDL_SYS_HapticEffectType(SDL_HapticEffect * effect)
+{
+    switch (effect->type) {
+    case SDL_HAPTIC_CONSTANT:
+        return &GUID_ConstantForce;
+
+    case SDL_HAPTIC_RAMP:
+        return &GUID_RampForce;
+
+    case SDL_HAPTIC_SQUARE:
+        return &GUID_Square;
+
+    case SDL_HAPTIC_SINE:
+        return &GUID_Sine;
+
+    case SDL_HAPTIC_TRIANGLE:
+        return &GUID_Triangle;
+
+    case SDL_HAPTIC_SAWTOOTHUP:
+        return &GUID_SawtoothUp;
+
+    case SDL_HAPTIC_SAWTOOTHDOWN:
+        return &GUID_SawtoothDown;
+
+    case SDL_HAPTIC_SPRING:
+        return &GUID_Spring;
+
+    case SDL_HAPTIC_DAMPER:
+        return &GUID_Damper;
+
+    case SDL_HAPTIC_INERTIA:
+        return &GUID_Inertia;
+
+    case SDL_HAPTIC_FRICTION:
+        return &GUID_Friction;
+
+    case SDL_HAPTIC_CUSTOM:
+        return &GUID_CustomForce;
+
+    default:
+        SDL_SetError("Haptic: Unknown effect type.");
+        return NULL;
+    }
+}
+
+
+/*
+ * Creates a new haptic effect.
+ */
+int
+SDL_SYS_HapticNewEffect(SDL_Haptic * haptic, struct haptic_effect *effect,
+                        SDL_HapticEffect * base)
+{
+    HRESULT ret;
+
+    /* Get the type. */
+    REFGUID type = SDL_SYS_HapticEffectType(base);
+    if (type == NULL) {
+        goto err_hweffect;
+    }
+
+    /* Alloc the effect. */
+    effect->hweffect = (struct haptic_hweffect *)
+        SDL_malloc(sizeof(struct haptic_hweffect));
+    if (effect->hweffect == NULL) {
+        SDL_OutOfMemory();
+        goto err_hweffect;
+    }
+
+    /* Get the effect. */
+    if (SDL_SYS_ToDIEFFECT(haptic, &effect->hweffect->effect, base) < 0) {
+        goto err_effectdone;
+    }
+
+    /* Create the actual effect. */
+    ret = IDirectInputDevice2_CreateEffect(haptic->hwdata->device, type,
+                                           &effect->hweffect->effect,
+                                           &effect->hweffect->ref, NULL);
+    if (FAILED(ret)) {
+        DI_SetError("Unable to create effect", ret);
+        goto err_effectdone;
+    }
+
+    return 0;
+
+  err_effectdone:
+    SDL_SYS_HapticFreeDIEFFECT(&effect->hweffect->effect, base->type);
+  err_hweffect:
+    if (effect->hweffect != NULL) {
+        SDL_free(effect->hweffect);
+        effect->hweffect = NULL;
+    }
+    return -1;
+}
+
+
+/*
+ * Updates an effect.
+ */
+int
+SDL_SYS_HapticUpdateEffect(SDL_Haptic * haptic,
+                           struct haptic_effect *effect,
+                           SDL_HapticEffect * data)
+{
+    HRESULT ret;
+    DWORD flags;
+    DIEFFECT temp;
+
+    /* Get the effect. */
+    SDL_memset(&temp, 0, sizeof(DIEFFECT));
+    if (SDL_SYS_ToDIEFFECT(haptic, &temp, data) < 0) {
+        goto err_update;
+    }
+
+    /* Set the flags.  Might be worthwhile to diff temp with loaded effect and
+     *  only change those parameters. */
+    flags = DIEP_DIRECTION |
+        DIEP_DURATION |
+        DIEP_ENVELOPE |
+        DIEP_STARTDELAY |
+        DIEP_TRIGGERBUTTON |
+        DIEP_TRIGGERREPEATINTERVAL | DIEP_TYPESPECIFICPARAMS;
+
+    /* Create the actual effect. */
+    ret =
+        IDirectInputEffect_SetParameters(effect->hweffect->ref, &temp, flags);
+    if (FAILED(ret)) {
+        DI_SetError("Unable to update effect", ret);
+        goto err_update;
+    }
+
+    /* Copy it over. */
+    SDL_SYS_HapticFreeDIEFFECT(&effect->hweffect->effect, data->type);
+    SDL_memcpy(&effect->hweffect->effect, &temp, sizeof(DIEFFECT));
+
+    return 0;
+
+  err_update:
+    SDL_SYS_HapticFreeDIEFFECT(&temp, data->type);
+    return -1;
+}
+
+
+/*
+ * Runs an effect.
+ */
+int
+SDL_SYS_HapticRunEffect(SDL_Haptic * haptic, struct haptic_effect *effect,
+                        Uint32 iterations)
+{
+    HRESULT ret;
+    DWORD iter;
+
+    /* Check if it's infinite. */
+    if (iterations == SDL_HAPTIC_INFINITY) {
+        iter = INFINITE;
+    } else
+        iter = iterations;
+
+    /* Run the effect. */
+    ret = IDirectInputEffect_Start(effect->hweffect->ref, iter, 0);
+    if (FAILED(ret)) {
+        DI_SetError("Running the effect", ret);
+        return -1;
+    }
+
+    return 0;
+}
+
+
+/*
+ * Stops an effect.
+ */
+int
+SDL_SYS_HapticStopEffect(SDL_Haptic * haptic, struct haptic_effect *effect)
+{
+    HRESULT ret;
+
+    ret = IDirectInputEffect_Stop(effect->hweffect->ref);
+    if (FAILED(ret)) {
+        DI_SetError("Unable to stop effect", ret);
+        return -1;
+    }
+
+    return 0;
+}
+
+
+/*
+ * Frees the effect.
+ */
+void
+SDL_SYS_HapticDestroyEffect(SDL_Haptic * haptic, struct haptic_effect *effect)
+{
+    HRESULT ret;
+
+    ret = IDirectInputEffect_Unload(effect->hweffect->ref);
+    if (FAILED(ret)) {
+        DI_SetError("Removing effect from the device", ret);
+    }
+    SDL_SYS_HapticFreeDIEFFECT(&effect->hweffect->effect,
+                               effect->effect.type);
+    SDL_free(effect->hweffect);
+    effect->hweffect = NULL;
+}
+
+
+/*
+ * Gets the status of a haptic effect.
+ */
+int
+SDL_SYS_HapticGetEffectStatus(SDL_Haptic * haptic,
+                              struct haptic_effect *effect)
+{
+    HRESULT ret;
+    DWORD status;
+
+    ret = IDirectInputEffect_GetEffectStatus(effect->hweffect->ref, &status);
+    if (FAILED(ret)) {
+        DI_SetError("Getting effect status", ret);
+        return -1;
+    }
+
+    if (status == 0)
+        return SDL_FALSE;
+    return SDL_TRUE;
+}
+
+
+/*
+ * Sets the gain.
+ */
+int
+SDL_SYS_HapticSetGain(SDL_Haptic * haptic, int gain)
+{
+    HRESULT ret;
+    DIPROPDWORD dipdw;
+
+    /* Create the weird structure thingy. */
+    dipdw.diph.dwSize = sizeof(DIPROPDWORD);
+    dipdw.diph.dwHeaderSize = sizeof(DIPROPHEADER);
+    dipdw.diph.dwObj = 0;
+    dipdw.diph.dwHow = DIPH_DEVICE;
+    dipdw.dwData = gain * 100;  /* 0 to 10,000 */
+
+    /* Try to set the autocenter. */
+    ret = IDirectInputDevice2_SetProperty(haptic->hwdata->device,
+                                          DIPROP_FFGAIN, &dipdw.diph);
+    if (FAILED(ret)) {
+        DI_SetError("Setting gain", ret);
+        return -1;
+    }
+
+    return 0;
+}
+
+
+/*
+ * Sets the autocentering.
+ */
+int
+SDL_SYS_HapticSetAutocenter(SDL_Haptic * haptic, int autocenter)
+{
+    HRESULT ret;
+    DIPROPDWORD dipdw;
+
+    /* Create the weird structure thingy. */
+    dipdw.diph.dwSize = sizeof(DIPROPDWORD);
+    dipdw.diph.dwHeaderSize = sizeof(DIPROPHEADER);
+    dipdw.diph.dwObj = 0;
+    dipdw.diph.dwHow = DIPH_DEVICE;
+    dipdw.dwData = (autocenter == 0) ? DIPROPAUTOCENTER_OFF :
+        DIPROPAUTOCENTER_ON;
+
+    /* Try to set the autocenter. */
+    ret = IDirectInputDevice2_SetProperty(haptic->hwdata->device,
+                                          DIPROP_AUTOCENTER, &dipdw.diph);
+    if (FAILED(ret)) {
+        DI_SetError("Setting autocenter", ret);
+        return -1;
+    }
+
+    return 0;
+}
+
+
+/*
+ * Pauses the device.
+ */
+int
+SDL_SYS_HapticPause(SDL_Haptic * haptic)
+{
+    HRESULT ret;
+
+    /* Pause the device. */
+    ret = IDirectInputDevice2_SendForceFeedbackCommand(haptic->hwdata->device,
+                                                       DISFFC_PAUSE);
+    if (FAILED(ret)) {
+        DI_SetError("Pausing the device", ret);
+        return -1;
+    }
+
+    return 0;
+}
+
+
+/*
+ * Pauses the device.
+ */
+int
+SDL_SYS_HapticUnpause(SDL_Haptic * haptic)
+{
+    HRESULT ret;
+
+    /* Unpause the device. */
+    ret = IDirectInputDevice2_SendForceFeedbackCommand(haptic->hwdata->device,
+                                                       DISFFC_CONTINUE);
+    if (FAILED(ret)) {
+        DI_SetError("Pausing the device", ret);
+        return -1;
+    }
+
+    return 0;
+}
+
+
+/*
+ * Stops all the playing effects on the device.
+ */
+int
+SDL_SYS_HapticStopAll(SDL_Haptic * haptic)
+{
+    HRESULT ret;
+
+    /* Try to stop the effects. */
+    ret = IDirectInputDevice2_SendForceFeedbackCommand(haptic->hwdata->device,
+                                                       DISFFC_STOPALL);
+    if (FAILED(ret)) {
+        DI_SetError("Stopping the device", ret);
+        return -1;
+    }
+
+    return 0;
+}
+
+
+#endif /* SDL_HAPTIC_DINPUT */
--- a/src/joystick/win32/SDL_dxjoystick.c	Thu Jan 20 17:33:06 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,802 +0,0 @@
-/*
-    SDL - Simple DirectMedia Layer
-    Copyright (C) 1997-2010 Sam Lantinga
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Lesser General Public
-    License as published by the Free Software Foundation; either
-    version 2.1 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Lesser General Public License for more details.
-
-    You should have received a copy of the GNU Lesser General Public
-    License along with this library; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-
-    Sam Lantinga
-    slouken@libsdl.org
-*/
-#include "SDL_config.h"
-
-#ifdef SDL_JOYSTICK_DINPUT
-
-/* DirectInput joystick driver; written by Glenn Maynard, based on Andrei de
- * A. Formiga's WINMM driver. 
- *
- * Hats and sliders are completely untested; the app I'm writing this for mostly
- * doesn't use them and I don't own any joysticks with them. 
- *
- * We don't bother to use event notification here.  It doesn't seem to work
- * with polled devices, and it's fine to call IDirectInputDevice2_GetDeviceData and
- * let it return 0 events. */
-
-#include "SDL_error.h"
-#include "SDL_events.h"
-#include "SDL_joystick.h"
-#include "../SDL_sysjoystick.h"
-#include "../SDL_joystick_c.h"
-#define INITGUID /* Only set here, if set twice will cause mingw32 to break. */
-#include "SDL_dxjoystick_c.h"
-
-
-#ifndef DIDFT_OPTIONAL
-#define DIDFT_OPTIONAL		0x80000000
-#endif
-
-
-#define INPUT_QSIZE	32      /* Buffer up to 32 input messages */
-#define MAX_JOYSTICKS	8
-#define AXIS_MIN	-32768  /* minimum value for axis coordinate */
-#define AXIS_MAX	32767   /* maximum value for axis coordinate */
-#define JOY_AXIS_THRESHOLD	(((AXIS_MAX)-(AXIS_MIN))/100)   /* 1% motion */
-
-/* external variables referenced. */
-extern HWND SDL_HelperWindow;
-
-
-/* local variables */
-static LPDIRECTINPUT dinput = NULL;
-extern HRESULT(WINAPI * DInputCreate) (HINSTANCE hinst, DWORD dwVersion,
-                                       LPDIRECTINPUT * ppDI,
-                                       LPUNKNOWN punkOuter);
-static DIDEVICEINSTANCE SYS_Joystick[MAX_JOYSTICKS];    /* array to hold joystick ID values */
-static int SYS_NumJoysticks;
-static HINSTANCE DInputDLL = NULL;
-
-
-/* local prototypes */
-static void SetDIerror(const char *function, HRESULT code);
-static BOOL CALLBACK EnumJoysticksCallback(const DIDEVICEINSTANCE *
-                                           pdidInstance, VOID * pContext);
-static BOOL CALLBACK EnumDevObjectsCallback(LPCDIDEVICEOBJECTINSTANCE dev,
-                                            LPVOID pvRef);
-static Uint8 TranslatePOV(DWORD value);
-static int SDL_PrivateJoystickAxis_Int(SDL_Joystick * joystick, Uint8 axis,
-                                       Sint16 value);
-static int SDL_PrivateJoystickHat_Int(SDL_Joystick * joystick, Uint8 hat,
-                                      Uint8 value);
-static int SDL_PrivateJoystickButton_Int(SDL_Joystick * joystick,
-                                         Uint8 button, Uint8 state);
-
-/* Taken from Wine - Thanks! */
-DIOBJECTDATAFORMAT dfDIJoystick2[] = {
-  { &GUID_XAxis,DIJOFS_X,DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
-  { &GUID_YAxis,DIJOFS_Y,DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
-  { &GUID_ZAxis,DIJOFS_Z,DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
-  { &GUID_RxAxis,DIJOFS_RX,DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
-  { &GUID_RyAxis,DIJOFS_RY,DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
-  { &GUID_RzAxis,DIJOFS_RZ,DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
-  { &GUID_Slider,DIJOFS_SLIDER(0),DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
-  { &GUID_Slider,DIJOFS_SLIDER(1),DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
-  { &GUID_POV,DIJOFS_POV(0),DIDFT_OPTIONAL|DIDFT_POV|DIDFT_ANYINSTANCE,0},
-  { &GUID_POV,DIJOFS_POV(1),DIDFT_OPTIONAL|DIDFT_POV|DIDFT_ANYINSTANCE,0},
-  { &GUID_POV,DIJOFS_POV(2),DIDFT_OPTIONAL|DIDFT_POV|DIDFT_ANYINSTANCE,0},
-  { &GUID_POV,DIJOFS_POV(3),DIDFT_OPTIONAL|DIDFT_POV|DIDFT_ANYINSTANCE,0},
-  { NULL,DIJOFS_BUTTON(0),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
-  { NULL,DIJOFS_BUTTON(1),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
-  { NULL,DIJOFS_BUTTON(2),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
-  { NULL,DIJOFS_BUTTON(3),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
-  { NULL,DIJOFS_BUTTON(4),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
-  { NULL,DIJOFS_BUTTON(5),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
-  { NULL,DIJOFS_BUTTON(6),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
-  { NULL,DIJOFS_BUTTON(7),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
-  { NULL,DIJOFS_BUTTON(8),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
-  { NULL,DIJOFS_BUTTON(9),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
-  { NULL,DIJOFS_BUTTON(10),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
-  { NULL,DIJOFS_BUTTON(11),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
-  { NULL,DIJOFS_BUTTON(12),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
-  { NULL,DIJOFS_BUTTON(13),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
-  { NULL,DIJOFS_BUTTON(14),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
-  { NULL,DIJOFS_BUTTON(15),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
-  { NULL,DIJOFS_BUTTON(16),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
-  { NULL,DIJOFS_BUTTON(17),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
-  { NULL,DIJOFS_BUTTON(18),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
-  { NULL,DIJOFS_BUTTON(19),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
-  { NULL,DIJOFS_BUTTON(20),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
-  { NULL,DIJOFS_BUTTON(21),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
-  { NULL,DIJOFS_BUTTON(22),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
-  { NULL,DIJOFS_BUTTON(23),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
-  { NULL,DIJOFS_BUTTON(24),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
-  { NULL,DIJOFS_BUTTON(25),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
-  { NULL,DIJOFS_BUTTON(26),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
-  { NULL,DIJOFS_BUTTON(27),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
-  { NULL,DIJOFS_BUTTON(28),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
-  { NULL,DIJOFS_BUTTON(29),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
-  { NULL,DIJOFS_BUTTON(30),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
-  { NULL,DIJOFS_BUTTON(31),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
-  { NULL,DIJOFS_BUTTON(32),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
-  { NULL,DIJOFS_BUTTON(33),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
-  { NULL,DIJOFS_BUTTON(34),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
-  { NULL,DIJOFS_BUTTON(35),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
-  { NULL,DIJOFS_BUTTON(36),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
-  { NULL,DIJOFS_BUTTON(37),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
-  { NULL,DIJOFS_BUTTON(38),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
-  { NULL,DIJOFS_BUTTON(39),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
-  { NULL,DIJOFS_BUTTON(40),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
-  { NULL,DIJOFS_BUTTON(41),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
-  { NULL,DIJOFS_BUTTON(42),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
-  { NULL,DIJOFS_BUTTON(43),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
-  { NULL,DIJOFS_BUTTON(44),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
-  { NULL,DIJOFS_BUTTON(45),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
-  { NULL,DIJOFS_BUTTON(46),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
-  { NULL,DIJOFS_BUTTON(47),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
-  { NULL,DIJOFS_BUTTON(48),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
-  { NULL,DIJOFS_BUTTON(49),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
-  { NULL,DIJOFS_BUTTON(50),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
-  { NULL,DIJOFS_BUTTON(51),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
-  { NULL,DIJOFS_BUTTON(52),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
-  { NULL,DIJOFS_BUTTON(53),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
-  { NULL,DIJOFS_BUTTON(54),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
-  { NULL,DIJOFS_BUTTON(55),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
-  { NULL,DIJOFS_BUTTON(56),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
-  { NULL,DIJOFS_BUTTON(57),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
-  { NULL,DIJOFS_BUTTON(58),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
-  { NULL,DIJOFS_BUTTON(59),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
-  { NULL,DIJOFS_BUTTON(60),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
-  { NULL,DIJOFS_BUTTON(61),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
-  { NULL,DIJOFS_BUTTON(62),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
-  { NULL,DIJOFS_BUTTON(63),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
-  { NULL,DIJOFS_BUTTON(64),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
-  { NULL,DIJOFS_BUTTON(65),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
-  { NULL,DIJOFS_BUTTON(66),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
-  { NULL,DIJOFS_BUTTON(67),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
-  { NULL,DIJOFS_BUTTON(68),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
-  { NULL,DIJOFS_BUTTON(69),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
-  { NULL,DIJOFS_BUTTON(70),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
-  { NULL,DIJOFS_BUTTON(71),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
-  { NULL,DIJOFS_BUTTON(72),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
-  { NULL,DIJOFS_BUTTON(73),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
-  { NULL,DIJOFS_BUTTON(74),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
-  { NULL,DIJOFS_BUTTON(75),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
-  { NULL,DIJOFS_BUTTON(76),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
-  { NULL,DIJOFS_BUTTON(77),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
-  { NULL,DIJOFS_BUTTON(78),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
-  { NULL,DIJOFS_BUTTON(79),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
-  { NULL,DIJOFS_BUTTON(80),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
-  { NULL,DIJOFS_BUTTON(81),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
-  { NULL,DIJOFS_BUTTON(82),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
-  { NULL,DIJOFS_BUTTON(83),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
-  { NULL,DIJOFS_BUTTON(84),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
-  { NULL,DIJOFS_BUTTON(85),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
-  { NULL,DIJOFS_BUTTON(86),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
-  { NULL,DIJOFS_BUTTON(87),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
-  { NULL,DIJOFS_BUTTON(88),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
-  { NULL,DIJOFS_BUTTON(89),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
-  { NULL,DIJOFS_BUTTON(90),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
-  { NULL,DIJOFS_BUTTON(91),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
-  { NULL,DIJOFS_BUTTON(92),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
-  { NULL,DIJOFS_BUTTON(93),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
-  { NULL,DIJOFS_BUTTON(94),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
-  { NULL,DIJOFS_BUTTON(95),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
-  { NULL,DIJOFS_BUTTON(96),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
-  { NULL,DIJOFS_BUTTON(97),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
-  { NULL,DIJOFS_BUTTON(98),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
-  { NULL,DIJOFS_BUTTON(99),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
-  { NULL,DIJOFS_BUTTON(100),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
-  { NULL,DIJOFS_BUTTON(101),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
-  { NULL,DIJOFS_BUTTON(102),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
-  { NULL,DIJOFS_BUTTON(103),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
-  { NULL,DIJOFS_BUTTON(104),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
-  { NULL,DIJOFS_BUTTON(105),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
-  { NULL,DIJOFS_BUTTON(106),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
-  { NULL,DIJOFS_BUTTON(107),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
-  { NULL,DIJOFS_BUTTON(108),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
-  { NULL,DIJOFS_BUTTON(109),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
-  { NULL,DIJOFS_BUTTON(110),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
-  { NULL,DIJOFS_BUTTON(111),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
-  { NULL,DIJOFS_BUTTON(112),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
-  { NULL,DIJOFS_BUTTON(113),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
-  { NULL,DIJOFS_BUTTON(114),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
-  { NULL,DIJOFS_BUTTON(115),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
-  { NULL,DIJOFS_BUTTON(116),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
-  { NULL,DIJOFS_BUTTON(117),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
-  { NULL,DIJOFS_BUTTON(118),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
-  { NULL,DIJOFS_BUTTON(119),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
-  { NULL,DIJOFS_BUTTON(120),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
-  { NULL,DIJOFS_BUTTON(121),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
-  { NULL,DIJOFS_BUTTON(122),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
-  { NULL,DIJOFS_BUTTON(123),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
-  { NULL,DIJOFS_BUTTON(124),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
-  { NULL,DIJOFS_BUTTON(125),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
-  { NULL,DIJOFS_BUTTON(126),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
-  { NULL,DIJOFS_BUTTON(127),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
-  { &GUID_XAxis,FIELD_OFFSET(DIJOYSTATE2,lVX),DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
-  { &GUID_YAxis,FIELD_OFFSET(DIJOYSTATE2,lVY),DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
-  { &GUID_ZAxis,FIELD_OFFSET(DIJOYSTATE2,lVZ),DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
-  { &GUID_RxAxis,FIELD_OFFSET(DIJOYSTATE2,lVRx),DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
-  { &GUID_RyAxis,FIELD_OFFSET(DIJOYSTATE2,lVRy),DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
-  { &GUID_RzAxis,FIELD_OFFSET(DIJOYSTATE2,lVRz),DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
-  { &GUID_Slider,FIELD_OFFSET(DIJOYSTATE2,rglVSlider[0]),DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
-  { &GUID_Slider,FIELD_OFFSET(DIJOYSTATE2,rglVSlider[1]),DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
-  { &GUID_XAxis,FIELD_OFFSET(DIJOYSTATE2,lAX),DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
-  { &GUID_YAxis,FIELD_OFFSET(DIJOYSTATE2,lAY),DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
-  { &GUID_ZAxis,FIELD_OFFSET(DIJOYSTATE2,lAZ),DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
-  { &GUID_RxAxis,FIELD_OFFSET(DIJOYSTATE2,lARx),DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
-  { &GUID_RyAxis,FIELD_OFFSET(DIJOYSTATE2,lARy),DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
-  { &GUID_RzAxis,FIELD_OFFSET(DIJOYSTATE2,lARz),DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
-  { &GUID_Slider,FIELD_OFFSET(DIJOYSTATE2,rglASlider[0]),DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
-  { &GUID_Slider,FIELD_OFFSET(DIJOYSTATE2,rglASlider[1]),DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
-  { &GUID_XAxis,FIELD_OFFSET(DIJOYSTATE2,lFX),DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
-  { &GUID_YAxis,FIELD_OFFSET(DIJOYSTATE2,lFY),DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
-  { &GUID_ZAxis,FIELD_OFFSET(DIJOYSTATE2,lFZ),DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
-  { &GUID_RxAxis,FIELD_OFFSET(DIJOYSTATE2,lFRx),DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
-  { &GUID_RyAxis,FIELD_OFFSET(DIJOYSTATE2,lFRy),DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
-  { &GUID_RzAxis,FIELD_OFFSET(DIJOYSTATE2,lFRz),DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
-  { &GUID_Slider,FIELD_OFFSET(DIJOYSTATE2,rglFSlider[0]),DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
-  { &GUID_Slider,FIELD_OFFSET(DIJOYSTATE2,rglFSlider[1]),DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
-};
-
-const DIDATAFORMAT c_dfDIJoystick2 = {
-    sizeof(DIDATAFORMAT),
-    sizeof(DIOBJECTDATAFORMAT),
-    DIDF_ABSAXIS,
-    sizeof(DIJOYSTATE2),
-    SDL_arraysize(dfDIJoystick2),
-    dfDIJoystick2
-};
-
-
-/* Convert a DirectInput return code to a text message */
-static void
-SetDIerror(const char *function, HRESULT code)
-{
-    /*
-    SDL_SetError("%s() [%s]: %s", function,
-                 DXGetErrorString9A(code), DXGetErrorDescription9A(code));
-     */
-    SDL_SetError("%s() DirectX error %d", function, code);
-}
-
-
-/* Function to scan the system for joysticks.
- * This function should set SDL_numjoysticks to the number of available
- * joysticks.  Joystick 0 should be the system default joystick.
- * It should return 0, or -1 on an unrecoverable fatal error.
- */
-int
-SDL_SYS_JoystickInit(void)
-{
-    HRESULT result;
-    HINSTANCE instance;
-
-    SYS_NumJoysticks = 0;
-
-    result = CoInitialize(NULL);
-    if (FAILED(result)) {
-        SetDIerror("CoInitialize", result);
-        return (-1);
-    }
-
-    result = CoCreateInstance(&CLSID_DirectInput, NULL, CLSCTX_INPROC_SERVER,
-                              &IID_IDirectInput, (LPVOID)&dinput);
-
-    if (FAILED(result)) {
-        SetDIerror("CoCreateInstance", result);
-        return (-1);
-    }
-
-    /* Because we used CoCreateInstance, we need to Initialize it, first. */
-    instance = GetModuleHandle(NULL);
-    if (instance == NULL) {
-        SDL_SetError("GetModuleHandle() failed with error code %d.",
-                     GetLastError());
-        return (-1);
-    }
-    result = IDirectInput_Initialize(dinput, instance, DIRECTINPUT_VERSION);
-
-    if (FAILED(result)) {
-        SetDIerror("IDirectInput::Initialize", result);
-        return (-1);
-    }
-
-    /* Look for joysticks, wheels, head trackers, gamepads, etc.. */
-    result = IDirectInput_EnumDevices(dinput,
-                                      DIDEVTYPE_JOYSTICK,
-                                      EnumJoysticksCallback,
-                                      NULL, DIEDFL_ATTACHEDONLY);
-
-    return SYS_NumJoysticks;
-}
-
-static BOOL CALLBACK
-EnumJoysticksCallback(const DIDEVICEINSTANCE * pdidInstance, VOID * pContext)
-{
-    SDL_memcpy(&SYS_Joystick[SYS_NumJoysticks], pdidInstance,
-               sizeof(DIDEVICEINSTANCE));
-    SYS_NumJoysticks++;
-
-    if (SYS_NumJoysticks >= MAX_JOYSTICKS)
-        return DIENUM_STOP;
-
-    return DIENUM_CONTINUE;
-}
-
-/* Function to get the device-dependent name of a joystick */
-const char *
-SDL_SYS_JoystickName(int index)
-{
-        /***-> test for invalid index ? */
-    return (SYS_Joystick[index].tszProductName);
-}
-
-/* Function to open a joystick for use.
-   The joystick to open is specified by the index field of the joystick.
-   This should fill the nbuttons and naxes fields of the joystick structure.
-   It returns 0, or -1 if there is an error.
- */
-int
-SDL_SYS_JoystickOpen(SDL_Joystick * joystick)
-{
-    HRESULT result;
-    LPDIRECTINPUTDEVICE device;
-    DIPROPDWORD dipdw;
-
-    SDL_memset(&dipdw, 0, sizeof(DIPROPDWORD));
-    dipdw.diph.dwSize = sizeof(DIPROPDWORD);
-    dipdw.diph.dwHeaderSize = sizeof(DIPROPHEADER);
-
-
-    /* allocate memory for system specific hardware data */
-    joystick->hwdata =
-        (struct joystick_hwdata *) SDL_malloc(sizeof(struct joystick_hwdata));
-    if (joystick->hwdata == NULL) {
-        SDL_OutOfMemory();
-        return (-1);
-    }
-    SDL_memset(joystick->hwdata, 0, sizeof(struct joystick_hwdata));
-    joystick->hwdata->buffered = 1;
-    joystick->hwdata->Capabilities.dwSize = sizeof(DIDEVCAPS);
-
-    result =
-        IDirectInput_CreateDevice(dinput,
-                                  &SYS_Joystick[joystick->index].
-                                  guidInstance, &device, NULL);
-    if (FAILED(result)) {
-        SetDIerror("IDirectInput::CreateDevice", result);
-        return (-1);
-    }
-
-    /* Now get the IDirectInputDevice2 interface, instead. */
-    result = IDirectInputDevice_QueryInterface(device,
-                                               &IID_IDirectInputDevice2,
-                                               (LPVOID *) & joystick->
-                                               hwdata->InputDevice);
-    /* We are done with this object.  Use the stored one from now on. */
-    IDirectInputDevice_Release(device);
-
-    if (FAILED(result)) {
-        SetDIerror("IDirectInputDevice::QueryInterface", result);
-        return (-1);
-    }
-
-    /* Aquire shared access. Exclusive access is required for forces,
-     * though. */
-    result =
-        IDirectInputDevice2_SetCooperativeLevel(joystick->hwdata->
-                                                InputDevice, SDL_HelperWindow,
-                                                DISCL_EXCLUSIVE |
-                                                DISCL_BACKGROUND);
-    if (FAILED(result)) {
-        SetDIerror("IDirectInputDevice2::SetCooperativeLevel", result);
-        return (-1);
-    }
-
-    /* Use the extended data structure: DIJOYSTATE2. */
-    result =
-        IDirectInputDevice2_SetDataFormat(joystick->hwdata->InputDevice,
-                                          &c_dfDIJoystick2);
-    if (FAILED(result)) {
-        SetDIerror("IDirectInputDevice2::SetDataFormat", result);
-        return (-1);
-    }
-
-    /* Get device capabilities */
-    result =
-        IDirectInputDevice2_GetCapabilities(joystick->hwdata->InputDevice,
-                                            &joystick->hwdata->Capabilities);
-
-    if (FAILED(result)) {
-        SetDIerror("IDirectInputDevice2::GetCapabilities", result);
-        return (-1);
-    }
-
-    /* Force capable? */
-    if (joystick->hwdata->Capabilities.dwFlags & DIDC_FORCEFEEDBACK) {
-
-        result = IDirectInputDevice2_Acquire(joystick->hwdata->InputDevice);
-
-        if (FAILED(result)) {
-            SetDIerror("IDirectInputDevice2::Acquire", result);
-            return (-1);
-        }
-
-        /* reset all accuators. */
-        result =
-            IDirectInputDevice2_SendForceFeedbackCommand(joystick->hwdata->
-                                                         InputDevice,
-                                                         DISFFC_RESET);
-
-        /* Not necessarily supported, ignore if not supported.
-        if (FAILED(result)) {
-            SetDIerror("IDirectInputDevice2::SendForceFeedbackCommand",
-                       result);
-            return (-1);
-        }
-        */
-
-        result = IDirectInputDevice2_Unacquire(joystick->hwdata->InputDevice);
-
-        if (FAILED(result)) {
-            SetDIerror("IDirectInputDevice2::Unacquire", result);
-            return (-1);
-        }
-
-        /* Turn on auto-centering for a ForceFeedback device (until told
-         * otherwise). */
-        dipdw.diph.dwObj = 0;
-        dipdw.diph.dwHow = DIPH_DEVICE;
-        dipdw.dwData = DIPROPAUTOCENTER_ON;
-
-        result =
-            IDirectInputDevice2_SetProperty(joystick->hwdata->InputDevice,
-                                            DIPROP_AUTOCENTER, &dipdw.diph);
-
-        /* Not necessarily supported, ignore if not supported.
-        if (FAILED(result)) {
-            SetDIerror("IDirectInputDevice2::SetProperty", result);
-            return (-1);
-        }
-        */
-    }
-
-    /* What buttons and axes does it have? */
-    IDirectInputDevice2_EnumObjects(joystick->hwdata->InputDevice,
-                                    EnumDevObjectsCallback, joystick,
-                                    DIDFT_BUTTON | DIDFT_AXIS | DIDFT_POV);
-
-    dipdw.diph.dwObj = 0;
-    dipdw.diph.dwHow = DIPH_DEVICE;
-    dipdw.dwData = INPUT_QSIZE;
-
-    /* Set the buffer size */
-    result =
-        IDirectInputDevice2_SetProperty(joystick->hwdata->InputDevice,
-                                        DIPROP_BUFFERSIZE, &dipdw.diph);
-
-    if (result == DI_POLLEDDEVICE) {
-        /* This device doesn't support buffering, so we're forced
-         * to use less reliable polling. */
-        joystick->hwdata->buffered = 0;
-    } else if (FAILED(result)) {
-        SetDIerror("IDirectInputDevice2::SetProperty", result);
-        return (-1);
-    }
-
-    return (0);
-}
-
-static BOOL CALLBACK
-EnumDevObjectsCallback(LPCDIDEVICEOBJECTINSTANCE dev, LPVOID pvRef)
-{
-    SDL_Joystick *joystick = (SDL_Joystick *) pvRef;
-    HRESULT result;
-    input_t *in = &joystick->hwdata->Inputs[joystick->hwdata->NumInputs];
-
-    in->ofs = dev->dwOfs;
-
-    if (dev->dwType & DIDFT_BUTTON) {
-        in->type = BUTTON;
-        in->num = joystick->nbuttons;
-        joystick->nbuttons++;
-    } else if (dev->dwType & DIDFT_POV) {
-        in->type = HAT;
-        in->num = joystick->nhats;
-        joystick->nhats++;
-    } else if (dev->dwType & DIDFT_AXIS) {
-        DIPROPRANGE diprg;
-        DIPROPDWORD dilong;
-
-        in->type = AXIS;
-        in->num = joystick->naxes;
-
-        diprg.diph.dwSize = sizeof(diprg);
-        diprg.diph.dwHeaderSize = sizeof(diprg.diph);
-        diprg.diph.dwObj = dev->dwOfs;
-        diprg.diph.dwHow = DIPH_BYOFFSET;
-        diprg.lMin = AXIS_MIN;
-        diprg.lMax = AXIS_MAX;
-
-        result =
-            IDirectInputDevice2_SetProperty(joystick->hwdata->InputDevice,
-                                            DIPROP_RANGE, &diprg.diph);
-        if (FAILED(result)) {
-            return DIENUM_CONTINUE;     /* don't use this axis */
-        }
-
-        /* Set dead zone to 0. */
-        dilong.diph.dwSize = sizeof(dilong);
-        dilong.diph.dwHeaderSize = sizeof(dilong.diph);
-        dilong.diph.dwObj = dev->dwOfs;
-        dilong.diph.dwHow = DIPH_BYOFFSET;
-        dilong.dwData = 0;
-        result =
-            IDirectInputDevice2_SetProperty(joystick->hwdata->InputDevice,
-                                            DIPROP_DEADZONE, &dilong.diph);
-        if (FAILED(result)) {
-            return DIENUM_CONTINUE;     /* don't use this axis */
-        }
-
-        joystick->naxes++;
-    } else {
-        /* not supported at this time */
-        return DIENUM_CONTINUE;
-    }
-
-    joystick->hwdata->NumInputs++;
-
-    if (joystick->hwdata->NumInputs == MAX_INPUTS) {
-        return DIENUM_STOP;     /* too many */
-    }
-
-    return DIENUM_CONTINUE;
-}
-
-/* Function to update the state of a joystick - called as a device poll.
- * This function shouldn't update the joystick structure directly,
- * but instead should call SDL_PrivateJoystick*() to deliver events
- * and update joystick device state.
- */
-void
-SDL_SYS_JoystickUpdate_Polled(SDL_Joystick * joystick)
-{
-    DIJOYSTATE2 state;
-    HRESULT result;
-    int i;
-
-    result =
-        IDirectInputDevice2_GetDeviceState(joystick->hwdata->InputDevice,
-                                           sizeof(DIJOYSTATE2), &state);
-    if (result == DIERR_INPUTLOST || result == DIERR_NOTACQUIRED) {
-        IDirectInputDevice2_Acquire(joystick->hwdata->InputDevice);
-        result =
-            IDirectInputDevice2_GetDeviceState(joystick->hwdata->InputDevice,
-                                               sizeof(DIJOYSTATE2), &state);
-    }
-
-    /* Set each known axis, button and POV. */
-    for (i = 0; i < joystick->hwdata->NumInputs; ++i) {
-        const input_t *in = &joystick->hwdata->Inputs[i];
-
-        switch (in->type) {
-        case AXIS:
-            switch (in->ofs) {
-            case DIJOFS_X:
-                SDL_PrivateJoystickAxis_Int(joystick, in->num,
-                                            (Sint16) state.lX);
-                break;
-            case DIJOFS_Y:
-                SDL_PrivateJoystickAxis_Int(joystick, in->num,
-                                            (Sint16) state.lY);
-                break;
-            case DIJOFS_Z:
-                SDL_PrivateJoystickAxis_Int(joystick, in->num,
-                                            (Sint16) state.lZ);
-                break;
-            case DIJOFS_RX:
-                SDL_PrivateJoystickAxis_Int(joystick, in->num,
-                                            (Sint16) state.lRx);
-                break;
-            case DIJOFS_RY:
-                SDL_PrivateJoystickAxis_Int(joystick, in->num,
-                                            (Sint16) state.lRy);
-                break;
-            case DIJOFS_RZ:
-                SDL_PrivateJoystickAxis_Int(joystick, in->num,
-                                            (Sint16) state.lRz);
-                break;
-            case DIJOFS_SLIDER(0):
-                SDL_PrivateJoystickAxis_Int(joystick, in->num,
-                                            (Sint16) state.rglSlider[0]);
-                break;
-            case DIJOFS_SLIDER(1):
-                SDL_PrivateJoystickAxis_Int(joystick, in->num,
-                                            (Sint16) state.rglSlider[1]);
-                break;
-            }
-
-            break;
-
-        case BUTTON:
-            SDL_PrivateJoystickButton_Int(joystick, in->num,
-                                          (Uint8) (state.
-                                                   rgbButtons[in->ofs -
-                                                              DIJOFS_BUTTON0]
-                                                   ? SDL_PRESSED :
-                                                   SDL_RELEASED));
-            break;
-        case HAT:
-            {
-                Uint8 pos = TranslatePOV(state.rgdwPOV[in->ofs -
-                                                       DIJOFS_POV(0)]);
-                SDL_PrivateJoystickHat_Int(joystick, in->num, pos);
-                break;
-            }
-        }
-    }
-}
-
-void
-SDL_SYS_JoystickUpdate_Buffered(SDL_Joystick * joystick)
-{
-    int i;
-    HRESULT result;
-    DWORD numevents;
-    DIDEVICEOBJECTDATA evtbuf[INPUT_QSIZE];
-
-    numevents = INPUT_QSIZE;
-    result =
-        IDirectInputDevice2_GetDeviceData(joystick->hwdata->InputDevice,
-                                          sizeof(DIDEVICEOBJECTDATA), evtbuf,
-                                          &numevents, 0);
-    if (result == DIERR_INPUTLOST || result == DIERR_NOTACQUIRED) {
-        IDirectInputDevice2_Acquire(joystick->hwdata->InputDevice);
-        result =
-            IDirectInputDevice2_GetDeviceData(joystick->hwdata->InputDevice,
-                                              sizeof(DIDEVICEOBJECTDATA),
-                                              evtbuf, &numevents, 0);
-    }
-
-    /* Handle the events or punt */
-    if (FAILED(result))
-        return;
-
-    for (i = 0; i < (int) numevents; ++i) {
-        int j;
-
-        for (j = 0; j < joystick->hwdata->NumInputs; ++j) {
-            const input_t *in = &joystick->hwdata->Inputs[j];
-
-            if (evtbuf[i].dwOfs != in->ofs)
-                continue;
-
-            switch (in->type) {
-            case AXIS:
-                SDL_PrivateJoystickAxis(joystick, in->num,
-                                        (Sint16) evtbuf[i].dwData);
-                break;
-            case BUTTON:
-                SDL_PrivateJoystickButton(joystick, in->num,
-                                          (Uint8) (evtbuf[i].
-                                                   dwData ? SDL_PRESSED :
-                                                   SDL_RELEASED));
-                break;
-            case HAT:
-                {
-                    Uint8 pos = TranslatePOV(evtbuf[i].dwData);
-                    SDL_PrivateJoystickHat(joystick, in->num, pos);
-                }
-            }
-        }
-    }
-}
-
-
-static Uint8
-TranslatePOV(DWORD value)
-{
-    const int HAT_VALS[] = {
-        SDL_HAT_UP,
-        SDL_HAT_UP | SDL_HAT_RIGHT,
-        SDL_HAT_RIGHT,
-        SDL_HAT_DOWN | SDL_HAT_RIGHT,
-        SDL_HAT_DOWN,
-        SDL_HAT_DOWN | SDL_HAT_LEFT,
-        SDL_HAT_LEFT,
-        SDL_HAT_UP | SDL_HAT_LEFT
-    };
-
-    if (LOWORD(value) == 0xFFFF)
-        return SDL_HAT_CENTERED;
-
-    /* Round the value up: */
-    value += 4500 / 2;
-    value %= 36000;
-    value /= 4500;
-
-    if (value >= 8)
-        return SDL_HAT_CENTERED;        /* shouldn't happen */
-
-    return HAT_VALS[value];
-}
-
-/* SDL_PrivateJoystick* doesn't discard duplicate events, so we need to
- * do it. */
-static int
-SDL_PrivateJoystickAxis_Int(SDL_Joystick * joystick, Uint8 axis, Sint16 value)
-{
-    if (joystick->axes[axis] != value)
-        return SDL_PrivateJoystickAxis(joystick, axis, value);
-    return 0;
-}
-
-static int
-SDL_PrivateJoystickHat_Int(SDL_Joystick * joystick, Uint8 hat, Uint8 value)
-{
-    if (joystick->hats[hat] != value)
-        return SDL_PrivateJoystickHat(joystick, hat, value);
-    return 0;
-}
-
-static int
-SDL_PrivateJoystickButton_Int(SDL_Joystick * joystick, Uint8 button,
-                              Uint8 state)
-{
-    if (joystick->buttons[button] != state)
-        return SDL_PrivateJoystickButton(joystick, button, state);
-    return 0;
-}
-
-void
-SDL_SYS_JoystickUpdate(SDL_Joystick * joystick)
-{
-    HRESULT result;
-
-    result = IDirectInputDevice2_Poll(joystick->hwdata->InputDevice);
-    if (result == DIERR_INPUTLOST || result == DIERR_NOTACQUIRED) {
-        IDirectInputDevice2_Acquire(joystick->hwdata->InputDevice);
-        IDirectInputDevice2_Poll(joystick->hwdata->InputDevice);
-    }
-
-    if (joystick->hwdata->buffered)
-        SDL_SYS_JoystickUpdate_Buffered(joystick);
-    else
-        SDL_SYS_JoystickUpdate_Polled(joystick);
-}
-
-/* Function to close a joystick after use */
-void
-SDL_SYS_JoystickClose(SDL_Joystick * joystick)
-{
-    IDirectInputDevice2_Unacquire(joystick->hwdata->InputDevice);
-    IDirectInputDevice2_Release(joystick->hwdata->InputDevice);
-
-    if (joystick->hwdata != NULL) {
-        /* free system specific hardware data */
-        SDL_free(joystick->hwdata);
-    }
-}
-
-/* Function to perform any system-specific joystick related cleanup */
-void
-SDL_SYS_JoystickQuit(void)
-{
-    IDirectInput_Release(dinput);
-    dinput = NULL;
-}
-
-#endif /* SDL_JOYSTICK_DINPUT */
-
-/* vi: set ts=4 sw=4 expandtab: */
--- a/src/joystick/win32/SDL_dxjoystick_c.h	Thu Jan 20 17:33:06 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,73 +0,0 @@
-/*
-    SDL - Simple DirectMedia Layer
-    Copyright (C) 1997-2010 Sam Lantinga
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Lesser General Public
-    License as published by the Free Software Foundation; either
-    version 2.1 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Lesser General Public License for more details.
-
-    You should have received a copy of the GNU Lesser General Public
-    License along with this library; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-
-    Sam Lantinga
-    slouken@libsdl.org
-*/
-#include "SDL_config.h"
-
-#ifndef SDL_JOYSTICK_DINPUT_H
-
-/* DirectInput joystick driver; written by Glenn Maynard, based on Andrei de
- * A. Formiga's WINMM driver. 
- *
- * Hats and sliders are completely untested; the app I'm writing this for mostly
- * doesn't use them and I don't own any joysticks with them. 
- *
- * We don't bother to use event notification here.  It doesn't seem to work
- * with polled devices, and it's fine to call IDirectInputDevice2_GetDeviceData and
- * let it return 0 events. */
-
-#define WIN32_LEAN_AND_MEAN
-#include <windows.h>
-
-#define DIRECTINPUT_VERSION 0x0700      /* Need version 7 for force feedback. */
-#include <dinput.h>
-
-
-#define MAX_INPUTS	256     /* each joystick can have up to 256 inputs */
-
-
-/* local types */
-typedef enum Type
-{ BUTTON, AXIS, HAT } Type;
-
-typedef struct input_t
-{
-    /* DirectInput offset for this input type: */
-    DWORD ofs;
-
-    /* Button, axis or hat: */
-    Type type;
-
-    /* SDL input offset: */
-    Uint8 num;
-} input_t;
-
-/* The private structure used to keep track of a joystick */
-struct joystick_hwdata
-{
-    LPDIRECTINPUTDEVICE2 InputDevice;
-    DIDEVCAPS Capabilities;
-    int buffered;
-
-    input_t Inputs[MAX_INPUTS];
-    int NumInputs;
-};
-
-#endif /* SDL_JOYSTICK_DINPUT_H */
--- a/src/joystick/win32/SDL_mmjoystick.c	Thu Jan 20 17:33:06 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,428 +0,0 @@
-/*
-    SDL - Simple DirectMedia Layer
-    Copyright (C) 1997-2010 Sam Lantinga
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Lesser General Public
-    License as published by the Free Software Foundation; either
-    version 2.1 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Lesser General Public License for more details.
-
-    You should have received a copy of the GNU Lesser General Public
-    License along with this library; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-
-    Sam Lantinga
-    slouken@libsdl.org
-*/
-#include "SDL_config.h"
-
-#ifdef SDL_JOYSTICK_WINMM
-
-/* Win32 MultiMedia Joystick driver, contributed by Andrei de A. Formiga */
-
-#define WIN32_LEAN_AND_MEAN
-#include <windows.h>
-#include <mmsystem.h>
-#include <regstr.h>
-
-#include "SDL_events.h"
-#include "SDL_joystick.h"
-#include "../SDL_sysjoystick.h"
-#include "../SDL_joystick_c.h"
-
-#define MAX_JOYSTICKS	16
-#define MAX_AXES	6       /* each joystick can have up to 6 axes */
-#define MAX_BUTTONS	32      /* and 32 buttons                      */
-#define AXIS_MIN	-32768  /* minimum value for axis coordinate */
-#define AXIS_MAX	32767   /* maximum value for axis coordinate */
-/* limit axis to 256 possible positions to filter out noise */
-#define JOY_AXIS_THRESHOLD      (((AXIS_MAX)-(AXIS_MIN))/256)
-#define JOY_BUTTON_FLAG(n)	(1<<n)
-
-
-/* array to hold joystick ID values */
-static UINT SYS_JoystickID[MAX_JOYSTICKS];
-static JOYCAPS SYS_Joystick[MAX_JOYSTICKS];
-static char *SYS_JoystickName[MAX_JOYSTICKS];
-
-/* The private structure used to keep track of a joystick */
-struct joystick_hwdata
-{
-    /* joystick ID */
-    UINT id;
-
-    /* values used to translate device-specific coordinates into
-       SDL-standard ranges */
-    struct _transaxis
-    {
-        int offset;
-        float scale;
-    } transaxis[6];
-};
-
-/* Convert a win32 Multimedia API return code to a text message */
-static void SetMMerror(char *function, int code);
-
-
-static char *
-GetJoystickName(int index, const char *szRegKey)
-{
-    /* added 7/24/2004 by Eckhard Stolberg */
-    /*
-       see if there is a joystick for the current
-       index (1-16) listed in the registry
-     */
-    char *name = NULL;
-    HKEY hTopKey;
-    HKEY hKey;
-    DWORD regsize;
-    LONG regresult;
-    char regkey[256];
-    char regvalue[256];
-    char regname[256];
-
-    SDL_snprintf(regkey, SDL_arraysize(regkey), "%s\\%s\\%s",
-                 REGSTR_PATH_JOYCONFIG, szRegKey, REGSTR_KEY_JOYCURR);
-    hTopKey = HKEY_LOCAL_MACHINE;
-    regresult = RegOpenKeyExA(hTopKey, regkey, 0, KEY_READ, &hKey);
-    if (regresult != ERROR_SUCCESS) {
-        hTopKey = HKEY_CURRENT_USER;
-        regresult = RegOpenKeyExA(hTopKey, regkey, 0, KEY_READ, &hKey);
-    }
-    if (regresult != ERROR_SUCCESS) {
-        return NULL;
-    }
-
-    /* find the registry key name for the joystick's properties */
-    regsize = sizeof(regname);
-    SDL_snprintf(regvalue, SDL_arraysize(regvalue), "Joystick%d%s", index + 1,
-                 REGSTR_VAL_JOYOEMNAME);
-    regresult =
-        RegQueryValueExA(hKey, regvalue, 0, 0, (LPBYTE) regname, &regsize);
-    RegCloseKey(hKey);
-
-    if (regresult != ERROR_SUCCESS) {
-        return NULL;
-    }
-
-    /* open that registry key */
-    SDL_snprintf(regkey, SDL_arraysize(regkey), "%s\\%s", REGSTR_PATH_JOYOEM,
-                 regname);
-    regresult = RegOpenKeyExA(hTopKey, regkey, 0, KEY_READ, &hKey);
-    if (regresult != ERROR_SUCCESS) {
-        return NULL;
-    }
-
-    /* find the size for the OEM name text */
-    regsize = sizeof(regvalue);
-    regresult =
-        RegQueryValueExA(hKey, REGSTR_VAL_JOYOEMNAME, 0, 0, NULL, &regsize);
-    if (regresult == ERROR_SUCCESS) {
-        /* allocate enough memory for the OEM name text ... */
-        name = (char *) SDL_malloc(regsize);
-        if (name) {
-            /* ... and read it from the registry */
-            regresult = RegQueryValueExA(hKey,
-                                         REGSTR_VAL_JOYOEMNAME, 0, 0,
-                                         (LPBYTE) name, &regsize);
-        }
-    }
-    RegCloseKey(hKey);
-
-    return (name);
-}
-
-/* Function to scan the system for joysticks.
- * This function should set SDL_numjoysticks to the number of available
- * joysticks.  Joystick 0 should be the system default joystick.
- * It should return 0, or -1 on an unrecoverable fatal error.
- */
-int
-SDL_SYS_JoystickInit(void)
-{
-    int i;
-    int maxdevs;
-    int numdevs;
-    JOYINFOEX joyinfo;
-    JOYCAPS joycaps;
-    MMRESULT result;
-
-    /* Reset the joystick ID & name mapping tables */
-    for (i = 0; i < MAX_JOYSTICKS; ++i) {
-        SYS_JoystickID[i] = 0;
-        SYS_JoystickName[i] = NULL;
-    }
-
-    /* Loop over all potential joystick devices */
-    numdevs = 0;
-    maxdevs = joyGetNumDevs();
-    for (i = JOYSTICKID1; i < maxdevs && numdevs < MAX_JOYSTICKS; ++i) {
-
-        joyinfo.dwSize = sizeof(joyinfo);
-        joyinfo.dwFlags = JOY_RETURNALL;
-        result = joyGetPosEx(i, &joyinfo);
-        if (result == JOYERR_NOERROR) {
-            result = joyGetDevCaps(i, &joycaps, sizeof(joycaps));
-            if (result == JOYERR_NOERROR) {
-                SYS_JoystickID[numdevs] = i;
-                SYS_Joystick[numdevs] = joycaps;
-                SYS_JoystickName[numdevs] =
-                    GetJoystickName(i, joycaps.szRegKey);
-                numdevs++;
-            }
-        }
-    }
-    return (numdevs);
-}
-
-/* Function to get the device-dependent name of a joystick */
-const char *
-SDL_SYS_JoystickName(int index)
-{
-    if (SYS_JoystickName[index] != NULL) {
-        return (SYS_JoystickName[index]);
-    } else {
-        return (SYS_Joystick[index].szPname);
-    }
-}
-
-/* Function to open a joystick for use.
-   The joystick to open is specified by the index field of the joystick.
-   This should fill the nbuttons and naxes fields of the joystick structure.
-   It returns 0, or -1 if there is an error.
- */
-int
-SDL_SYS_JoystickOpen(SDL_Joystick * joystick)
-{
-    int index, i;
-    int caps_flags[MAX_AXES - 2] =
-        { JOYCAPS_HASZ, JOYCAPS_HASR, JOYCAPS_HASU, JOYCAPS_HASV };
-    int axis_min[MAX_AXES], axis_max[MAX_AXES];
-
-
-    /* shortcut */
-    index = joystick->index;
-    axis_min[0] = SYS_Joystick[index].wXmin;
-    axis_max[0] = SYS_Joystick[index].wXmax;
-    axis_min[1] = SYS_Joystick[index].wYmin;
-    axis_max[1] = SYS_Joystick[index].wYmax;
-    axis_min[2] = SYS_Joystick[index].wZmin;
-    axis_max[2] = SYS_Joystick[index].wZmax;
-    axis_min[3] = SYS_Joystick[index].wRmin;
-    axis_max[3] = SYS_Joystick[index].wRmax;
-    axis_min[4] = SYS_Joystick[index].wUmin;
-    axis_max[4] = SYS_Joystick[index].wUmax;
-    axis_min[5] = SYS_Joystick[index].wVmin;
-    axis_max[5] = SYS_Joystick[index].wVmax;
-
-    /* allocate memory for system specific hardware data */
-    joystick->hwdata =
-        (struct joystick_hwdata *) SDL_malloc(sizeof(*joystick->hwdata));
-    if (joystick->hwdata == NULL) {
-        SDL_OutOfMemory();
-        return (-1);
-    }
-    SDL_memset(joystick->hwdata, 0, sizeof(*joystick->hwdata));
-
-    /* set hardware data */
-    joystick->hwdata->id = SYS_JoystickID[index];
-    for (i = 0; i < MAX_AXES; ++i) {
-        if ((i < 2) || (SYS_Joystick[index].wCaps & caps_flags[i - 2])) {
-            joystick->hwdata->transaxis[i].offset = AXIS_MIN - axis_min[i];
-            joystick->hwdata->transaxis[i].scale =
-                (float) (AXIS_MAX - AXIS_MIN) / (axis_max[i] - axis_min[i]);
-        } else {
-            joystick->hwdata->transaxis[i].offset = 0;
-            joystick->hwdata->transaxis[i].scale = 1.0; /* Just in case */
-        }
-    }
-
-    /* fill nbuttons, naxes, and nhats fields */
-    joystick->nbuttons = SYS_Joystick[index].wNumButtons;
-    joystick->naxes = SYS_Joystick[index].wNumAxes;
-    if (SYS_Joystick[index].wCaps & JOYCAPS_HASPOV) {
-        joystick->nhats = 1;
-    } else {
-        joystick->nhats = 0;
-    }
-    return (0);
-}
-
-static Uint8
-TranslatePOV(DWORD value)
-{
-    Uint8 pos;
-
-    pos = SDL_HAT_CENTERED;
-    if (value != JOY_POVCENTERED) {
-        if ((value > JOY_POVLEFT) || (value < JOY_POVRIGHT)) {
-            pos |= SDL_HAT_UP;
-        }
-        if ((value > JOY_POVFORWARD) && (value < JOY_POVBACKWARD)) {
-            pos |= SDL_HAT_RIGHT;
-        }
-        if ((value > JOY_POVRIGHT) && (value < JOY_POVLEFT)) {
-            pos |= SDL_HAT_DOWN;
-        }
-        if (value > JOY_POVBACKWARD) {
-            pos |= SDL_HAT_LEFT;
-        }
-    }
-    return (pos);
-}
-
-/* Function to update the state of a joystick - called as a device poll.
- * This function shouldn't update the joystick structure directly,
- * but instead should call SDL_PrivateJoystick*() to deliver events
- * and update joystick device state.
- */
-void
-SDL_SYS_JoystickUpdate(SDL_Joystick * joystick)
-{
-    MMRESULT result;
-    int i;
-    DWORD flags[MAX_AXES] = { JOY_RETURNX, JOY_RETURNY, JOY_RETURNZ,
-        JOY_RETURNR, JOY_RETURNU, JOY_RETURNV
-    };
-    DWORD pos[MAX_AXES];
-    struct _transaxis *transaxis;
-    int value, change;
-    JOYINFOEX joyinfo;
-
-    joyinfo.dwSize = sizeof(joyinfo);
-    joyinfo.dwFlags = JOY_RETURNALL | JOY_RETURNPOVCTS;
-    if (!joystick->hats) {
-        joyinfo.dwFlags &= ~(JOY_RETURNPOV | JOY_RETURNPOVCTS);
-    }
-    result = joyGetPosEx(joystick->hwdata->id, &joyinfo);
-    if (result != JOYERR_NOERROR) {
-        SetMMerror("joyGetPosEx", result);
-        return;
-    }
-
-    /* joystick motion events */
-    pos[0] = joyinfo.dwXpos;
-    pos[1] = joyinfo.dwYpos;
-    pos[2] = joyinfo.dwZpos;
-    pos[3] = joyinfo.dwRpos;
-    pos[4] = joyinfo.dwUpos;
-    pos[5] = joyinfo.dwVpos;
-
-    transaxis = joystick->hwdata->transaxis;
-    for (i = 0; i < joystick->naxes; i++) {
-        if (joyinfo.dwFlags & flags[i]) {
-            value =
-                (int) (((float) pos[i] +
-                        transaxis[i].offset) * transaxis[i].scale);
-            change = (value - joystick->axes[i]);
-            if ((change < -JOY_AXIS_THRESHOLD)
-                || (change > JOY_AXIS_THRESHOLD)) {
-                SDL_PrivateJoystickAxis(joystick, (Uint8) i, (Sint16) value);
-            }
-        }
-    }
-
-    /* joystick button events */
-    if (joyinfo.dwFlags & JOY_RETURNBUTTONS) {
-        for (i = 0; i < joystick->nbuttons; ++i) {
-            if (joyinfo.dwButtons & JOY_BUTTON_FLAG(i)) {
-                if (!joystick->buttons[i]) {
-                    SDL_PrivateJoystickButton(joystick, (Uint8) i,
-                                              SDL_PRESSED);
-                }
-            } else {
-                if (joystick->buttons[i]) {
-                    SDL_PrivateJoystickButton(joystick, (Uint8) i,
-                                              SDL_RELEASED);
-                }
-            }
-        }
-    }
-
-    /* joystick hat events */
-    if (joyinfo.dwFlags & JOY_RETURNPOV) {
-        Uint8 pos;
-
-        pos = TranslatePOV(joyinfo.dwPOV);
-        if (pos != joystick->hats[0]) {
-            SDL_PrivateJoystickHat(joystick, 0, pos);
-        }
-    }
-}
-
-/* Function to close a joystick after use */
-void
-SDL_SYS_JoystickClose(SDL_Joystick * joystick)
-{
-    if (joystick->hwdata != NULL) {
-        /* free system specific hardware data */
-        SDL_free(joystick->hwdata);
-        joystick->hwdata = NULL;
-    }
-}
-
-/* Function to perform any system-specific joystick related cleanup */
-void
-SDL_SYS_JoystickQuit(void)
-{
-    int i;
-    for (i = 0; i < MAX_JOYSTICKS; i++) {
-        if (SYS_JoystickName[i] != NULL) {
-            SDL_free(SYS_JoystickName[i]);
-            SYS_JoystickName[i] = NULL;
-        }
-    }
-}
-
-
-/* implementation functions */
-void
-SetMMerror(char *function, int code)
-{
-    static char *error;
-    static char errbuf[1024];
-
-    errbuf[0] = 0;
-    switch (code) {
-    case MMSYSERR_NODRIVER:
-        error = "Joystick driver not present";
-        break;
-
-    case MMSYSERR_INVALPARAM:
-    case JOYERR_PARMS:
-        error = "Invalid parameter(s)";
-        break;
-
-    case MMSYSERR_BADDEVICEID:
-        error = "Bad device ID";
-        break;
-
-    case JOYERR_UNPLUGGED:
-        error = "Joystick not attached";
-        break;
-
-    case JOYERR_NOCANDO:
-        error = "Can't capture joystick input";
-        break;
-
-    default:
-        SDL_snprintf(errbuf, SDL_arraysize(errbuf),
-                     "%s: Unknown Multimedia system error: 0x%x",
-                     function, code);
-        break;
-    }
-
-    if (!errbuf[0]) {
-        SDL_snprintf(errbuf, SDL_arraysize(errbuf), "%s: %s", function,
-                     error);
-    }
-    SDL_SetError("%s", errbuf);
-}
-
-#endif /* SDL_JOYSTICK_WINMM */
-/* vi: set ts=4 sw=4 expandtab: */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/joystick/windows/SDL_dxjoystick.c	Thu Jan 20 18:04:05 2011 -0800
@@ -0,0 +1,802 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997-2010 Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+
+    Sam Lantinga
+    slouken@libsdl.org
+*/
+#include "SDL_config.h"
+
+#ifdef SDL_JOYSTICK_DINPUT
+
+/* DirectInput joystick driver; written by Glenn Maynard, based on Andrei de
+ * A. Formiga's WINMM driver. 
+ *
+ * Hats and sliders are completely untested; the app I'm writing this for mostly
+ * doesn't use them and I don't own any joysticks with them. 
+ *
+ * We don't bother to use event notification here.  It doesn't seem to work
+ * with polled devices, and it's fine to call IDirectInputDevice2_GetDeviceData and
+ * let it return 0 events. */
+
+#include "SDL_error.h"
+#include "SDL_events.h"
+#include "SDL_joystick.h"
+#include "../SDL_sysjoystick.h"
+#include "../SDL_joystick_c.h"
+#define INITGUID /* Only set here, if set twice will cause mingw32 to break. */
+#include "SDL_dxjoystick_c.h"
+
+
+#ifndef DIDFT_OPTIONAL
+#define DIDFT_OPTIONAL		0x80000000
+#endif
+
+
+#define INPUT_QSIZE	32      /* Buffer up to 32 input messages */
+#define MAX_JOYSTICKS	8
+#define AXIS_MIN	-32768  /* minimum value for axis coordinate */
+#define AXIS_MAX	32767   /* maximum value for axis coordinate */
+#define JOY_AXIS_THRESHOLD	(((AXIS_MAX)-(AXIS_MIN))/100)   /* 1% motion */
+
+/* external variables referenced. */
+extern HWND SDL_HelperWindow;
+
+
+/* local variables */
+static LPDIRECTINPUT dinput = NULL;
+extern HRESULT(WINAPI * DInputCreate) (HINSTANCE hinst, DWORD dwVersion,
+                                       LPDIRECTINPUT * ppDI,
+                                       LPUNKNOWN punkOuter);
+static DIDEVICEINSTANCE SYS_Joystick[MAX_JOYSTICKS];    /* array to hold joystick ID values */
+static int SYS_NumJoysticks;
+static HINSTANCE DInputDLL = NULL;
+
+
+/* local prototypes */
+static void SetDIerror(const char *function, HRESULT code);
+static BOOL CALLBACK EnumJoysticksCallback(const DIDEVICEINSTANCE *
+                                           pdidInstance, VOID * pContext);
+static BOOL CALLBACK EnumDevObjectsCallback(LPCDIDEVICEOBJECTINSTANCE dev,
+                                            LPVOID pvRef);
+static Uint8 TranslatePOV(DWORD value);
+static int SDL_PrivateJoystickAxis_Int(SDL_Joystick * joystick, Uint8 axis,
+                                       Sint16 value);
+static int SDL_PrivateJoystickHat_Int(SDL_Joystick * joystick, Uint8 hat,
+                                      Uint8 value);
+static int SDL_PrivateJoystickButton_Int(SDL_Joystick * joystick,
+                                         Uint8 button, Uint8 state);
+
+/* Taken from Wine - Thanks! */
+DIOBJECTDATAFORMAT dfDIJoystick2[] = {
+  { &GUID_XAxis,DIJOFS_X,DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
+  { &GUID_YAxis,DIJOFS_Y,DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
+  { &GUID_ZAxis,DIJOFS_Z,DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
+  { &GUID_RxAxis,DIJOFS_RX,DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
+  { &GUID_RyAxis,DIJOFS_RY,DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
+  { &GUID_RzAxis,DIJOFS_RZ,DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
+  { &GUID_Slider,DIJOFS_SLIDER(0),DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
+  { &GUID_Slider,DIJOFS_SLIDER(1),DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
+  { &GUID_POV,DIJOFS_POV(0),DIDFT_OPTIONAL|DIDFT_POV|DIDFT_ANYINSTANCE,0},
+  { &GUID_POV,DIJOFS_POV(1),DIDFT_OPTIONAL|DIDFT_POV|DIDFT_ANYINSTANCE,0},
+  { &GUID_POV,DIJOFS_POV(2),DIDFT_OPTIONAL|DIDFT_POV|DIDFT_ANYINSTANCE,0},
+  { &GUID_POV,DIJOFS_POV(3),DIDFT_OPTIONAL|DIDFT_POV|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(0),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(1),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(2),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(3),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(4),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(5),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(6),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(7),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(8),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(9),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(10),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(11),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(12),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(13),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(14),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(15),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(16),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(17),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(18),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(19),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(20),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(21),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(22),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(23),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(24),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(25),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(26),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(27),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(28),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(29),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(30),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(31),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(32),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(33),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(34),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(35),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(36),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(37),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(38),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(39),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(40),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(41),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(42),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(43),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(44),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(45),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(46),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(47),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(48),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(49),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(50),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(51),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(52),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(53),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(54),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(55),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(56),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(57),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(58),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(59),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(60),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(61),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(62),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(63),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(64),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(65),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(66),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(67),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(68),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(69),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(70),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(71),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(72),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(73),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(74),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(75),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(76),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(77),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(78),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(79),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(80),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(81),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(82),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(83),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(84),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(85),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(86),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(87),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(88),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(89),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(90),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(91),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(92),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(93),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(94),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(95),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(96),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(97),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(98),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(99),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(100),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(101),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(102),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(103),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(104),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(105),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(106),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(107),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(108),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(109),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(110),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(111),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(112),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(113),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(114),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(115),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(116),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(117),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(118),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(119),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(120),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(121),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(122),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(123),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(124),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(125),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(126),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(127),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { &GUID_XAxis,FIELD_OFFSET(DIJOYSTATE2,lVX),DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
+  { &GUID_YAxis,FIELD_OFFSET(DIJOYSTATE2,lVY),DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
+  { &GUID_ZAxis,FIELD_OFFSET(DIJOYSTATE2,lVZ),DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
+  { &GUID_RxAxis,FIELD_OFFSET(DIJOYSTATE2,lVRx),DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
+  { &GUID_RyAxis,FIELD_OFFSET(DIJOYSTATE2,lVRy),DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
+  { &GUID_RzAxis,FIELD_OFFSET(DIJOYSTATE2,lVRz),DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
+  { &GUID_Slider,FIELD_OFFSET(DIJOYSTATE2,rglVSlider[0]),DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
+  { &GUID_Slider,FIELD_OFFSET(DIJOYSTATE2,rglVSlider[1]),DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
+  { &GUID_XAxis,FIELD_OFFSET(DIJOYSTATE2,lAX),DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
+  { &GUID_YAxis,FIELD_OFFSET(DIJOYSTATE2,lAY),DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
+  { &GUID_ZAxis,FIELD_OFFSET(DIJOYSTATE2,lAZ),DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
+  { &GUID_RxAxis,FIELD_OFFSET(DIJOYSTATE2,lARx),DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
+  { &GUID_RyAxis,FIELD_OFFSET(DIJOYSTATE2,lARy),DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
+  { &GUID_RzAxis,FIELD_OFFSET(DIJOYSTATE2,lARz),DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
+  { &GUID_Slider,FIELD_OFFSET(DIJOYSTATE2,rglASlider[0]),DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
+  { &GUID_Slider,FIELD_OFFSET(DIJOYSTATE2,rglASlider[1]),DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
+  { &GUID_XAxis,FIELD_OFFSET(DIJOYSTATE2,lFX),DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
+  { &GUID_YAxis,FIELD_OFFSET(DIJOYSTATE2,lFY),DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
+  { &GUID_ZAxis,FIELD_OFFSET(DIJOYSTATE2,lFZ),DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
+  { &GUID_RxAxis,FIELD_OFFSET(DIJOYSTATE2,lFRx),DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
+  { &GUID_RyAxis,FIELD_OFFSET(DIJOYSTATE2,lFRy),DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
+  { &GUID_RzAxis,FIELD_OFFSET(DIJOYSTATE2,lFRz),DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
+  { &GUID_Slider,FIELD_OFFSET(DIJOYSTATE2,rglFSlider[0]),DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
+  { &GUID_Slider,FIELD_OFFSET(DIJOYSTATE2,rglFSlider[1]),DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
+};
+
+const DIDATAFORMAT c_dfDIJoystick2 = {
+    sizeof(DIDATAFORMAT),
+    sizeof(DIOBJECTDATAFORMAT),
+    DIDF_ABSAXIS,
+    sizeof(DIJOYSTATE2),
+    SDL_arraysize(dfDIJoystick2),
+    dfDIJoystick2
+};
+
+
+/* Convert a DirectInput return code to a text message */
+static void
+SetDIerror(const char *function, HRESULT code)
+{
+    /*
+    SDL_SetError("%s() [%s]: %s", function,
+                 DXGetErrorString9A(code), DXGetErrorDescription9A(code));
+     */
+    SDL_SetError("%s() DirectX error %d", function, code);
+}
+
+
+/* Function to scan the system for joysticks.
+ * This function should set SDL_numjoysticks to the number of available
+ * joysticks.  Joystick 0 should be the system default joystick.
+ * It should return 0, or -1 on an unrecoverable fatal error.
+ */
+int
+SDL_SYS_JoystickInit(void)
+{
+    HRESULT result;
+    HINSTANCE instance;
+
+    SYS_NumJoysticks = 0;
+
+    result = CoInitialize(NULL);
+    if (FAILED(result)) {
+        SetDIerror("CoInitialize", result);
+        return (-1);
+    }
+
+    result = CoCreateInstance(&CLSID_DirectInput, NULL, CLSCTX_INPROC_SERVER,
+                              &IID_IDirectInput, (LPVOID)&dinput);
+
+    if (FAILED(result)) {
+        SetDIerror("CoCreateInstance", result);
+        return (-1);
+    }
+
+    /* Because we used CoCreateInstance, we need to Initialize it, first. */
+    instance = GetModuleHandle(NULL);
+    if (instance == NULL) {
+        SDL_SetError("GetModuleHandle() failed with error code %d.",
+                     GetLastError());
+        return (-1);
+    }
+    result = IDirectInput_Initialize(dinput, instance, DIRECTINPUT_VERSION);
+
+    if (FAILED(result)) {
+        SetDIerror("IDirectInput::Initialize", result);
+        return (-1);
+    }
+
+    /* Look for joysticks, wheels, head trackers, gamepads, etc.. */
+    result = IDirectInput_EnumDevices(dinput,
+                                      DIDEVTYPE_JOYSTICK,
+                                      EnumJoysticksCallback,
+                                      NULL, DIEDFL_ATTACHEDONLY);
+
+    return SYS_NumJoysticks;
+}
+
+static BOOL CALLBACK
+EnumJoysticksCallback(const DIDEVICEINSTANCE * pdidInstance, VOID * pContext)
+{
+    SDL_memcpy(&SYS_Joystick[SYS_NumJoysticks], pdidInstance,
+               sizeof(DIDEVICEINSTANCE));
+    SYS_NumJoysticks++;
+
+    if (SYS_NumJoysticks >= MAX_JOYSTICKS)
+        return DIENUM_STOP;
+
+    return DIENUM_CONTINUE;
+}
+
+/* Function to get the device-dependent name of a joystick */
+const char *
+SDL_SYS_JoystickName(int index)
+{
+        /***-> test for invalid index ? */
+    return (SYS_Joystick[index].tszProductName);
+}
+
+/* Function to open a joystick for use.
+   The joystick to open is specified by the index field of the joystick.
+   This should fill the nbuttons and naxes fields of the joystick structure.
+   It returns 0, or -1 if there is an error.
+ */
+int
+SDL_SYS_JoystickOpen(SDL_Joystick * joystick)
+{
+    HRESULT result;
+    LPDIRECTINPUTDEVICE device;
+    DIPROPDWORD dipdw;
+
+    SDL_memset(&dipdw, 0, sizeof(DIPROPDWORD));
+    dipdw.diph.dwSize = sizeof(DIPROPDWORD);
+    dipdw.diph.dwHeaderSize = sizeof(DIPROPHEADER);
+
+
+    /* allocate memory for system specific hardware data */
+    joystick->hwdata =
+        (struct joystick_hwdata *) SDL_malloc(sizeof(struct joystick_hwdata));
+    if (joystick->hwdata == NULL) {
+        SDL_OutOfMemory();
+        return (-1);
+    }
+    SDL_memset(joystick->hwdata, 0, sizeof(struct joystick_hwdata));
+    joystick->hwdata->buffered = 1;
+    joystick->hwdata->Capabilities.dwSize = sizeof(DIDEVCAPS);
+
+    result =
+        IDirectInput_CreateDevice(dinput,
+                                  &SYS_Joystick[joystick->index].
+                                  guidInstance, &device, NULL);
+    if (FAILED(result)) {
+        SetDIerror("IDirectInput::CreateDevice", result);
+        return (-1);
+    }
+
+    /* Now get the IDirectInputDevice2 interface, instead. */
+    result = IDirectInputDevice_QueryInterface(device,
+                                               &IID_IDirectInputDevice2,
+                                               (LPVOID *) & joystick->
+                                               hwdata->InputDevice);
+    /* We are done with this object.  Use the stored one from now on. */
+    IDirectInputDevice_Release(device);
+
+    if (FAILED(result)) {
+        SetDIerror("IDirectInputDevice::QueryInterface", result);
+        return (-1);
+    }
+
+    /* Aquire shared access. Exclusive access is required for forces,
+     * though. */
+    result =
+        IDirectInputDevice2_SetCooperativeLevel(joystick->hwdata->
+                                                InputDevice, SDL_HelperWindow,
+                                                DISCL_EXCLUSIVE |
+                                                DISCL_BACKGROUND);
+    if (FAILED(result)) {
+        SetDIerror("IDirectInputDevice2::SetCooperativeLevel", result);
+        return (-1);
+    }
+
+    /* Use the extended data structure: DIJOYSTATE2. */
+    result =
+        IDirectInputDevice2_SetDataFormat(joystick->hwdata->InputDevice,
+                                          &c_dfDIJoystick2);
+    if (FAILED(result)) {
+        SetDIerror("IDirectInputDevice2::SetDataFormat", result);
+        return (-1);
+    }
+
+    /* Get device capabilities */
+    result =
+        IDirectInputDevice2_GetCapabilities(joystick->hwdata->InputDevice,
+                                            &joystick->hwdata->Capabilities);
+
+    if (FAILED(result)) {
+        SetDIerror("IDirectInputDevice2::GetCapabilities", result);
+        return (-1);
+    }
+
+    /* Force capable? */
+    if (joystick->hwdata->Capabilities.dwFlags & DIDC_FORCEFEEDBACK) {
+
+        result = IDirectInputDevice2_Acquire(joystick->hwdata->InputDevice);
+
+        if (FAILED(result)) {
+            SetDIerror("IDirectInputDevice2::Acquire", result);
+            return (-1);
+        }
+
+        /* reset all accuators. */
+        result =
+            IDirectInputDevice2_SendForceFeedbackCommand(joystick->hwdata->
+                                                         InputDevice,
+                                                         DISFFC_RESET);
+
+        /* Not necessarily supported, ignore if not supported.
+        if (FAILED(result)) {
+            SetDIerror("IDirectInputDevice2::SendForceFeedbackCommand",
+                       result);
+            return (-1);
+        }
+        */
+
+        result = IDirectInputDevice2_Unacquire(joystick->hwdata->InputDevice);
+
+        if (FAILED(result)) {
+            SetDIerror("IDirectInputDevice2::Unacquire", result);
+            return (-1);
+        }
+
+        /* Turn on auto-centering for a ForceFeedback device (until told
+         * otherwise). */
+        dipdw.diph.dwObj = 0;
+        dipdw.diph.dwHow = DIPH_DEVICE;
+        dipdw.dwData = DIPROPAUTOCENTER_ON;
+
+        result =
+            IDirectInputDevice2_SetProperty(joystick->hwdata->InputDevice,
+                                            DIPROP_AUTOCENTER, &dipdw.diph);
+
+        /* Not necessarily supported, ignore if not supported.
+        if (FAILED(result)) {
+            SetDIerror("IDirectInputDevice2::SetProperty", result);
+            return (-1);
+        }
+        */
+    }
+
+    /* What buttons and axes does it have? */
+    IDirectInputDevice2_EnumObjects(joystick->hwdata->InputDevice,
+                                    EnumDevObjectsCallback, joystick,
+                                    DIDFT_BUTTON | DIDFT_AXIS | DIDFT_POV);
+
+    dipdw.diph.dwObj = 0;
+    dipdw.diph.dwHow = DIPH_DEVICE;
+    dipdw.dwData = INPUT_QSIZE;
+
+    /* Set the buffer size */
+    result =
+        IDirectInputDevice2_SetProperty(joystick->hwdata->InputDevice,
+                                        DIPROP_BUFFERSIZE, &dipdw.diph);
+
+    if (result == DI_POLLEDDEVICE) {
+        /* This device doesn't support buffering, so we're forced
+         * to use less reliable polling. */
+        joystick->hwdata->buffered = 0;
+    } else if (FAILED(result)) {
+        SetDIerror("IDirectInputDevice2::SetProperty", result);
+        return (-1);
+    }
+
+    return (0);
+}
+
+static BOOL CALLBACK
+EnumDevObjectsCallback(LPCDIDEVICEOBJECTINSTANCE dev, LPVOID pvRef)
+{
+    SDL_Joystick *joystick = (SDL_Joystick *) pvRef;
+    HRESULT result;
+    input_t *in = &joystick->hwdata->Inputs[joystick->hwdata->NumInputs];
+
+    in->ofs = dev->dwOfs;
+
+    if (dev->dwType & DIDFT_BUTTON) {
+        in->type = BUTTON;
+        in->num = joystick->nbuttons;
+        joystick->nbuttons++;
+    } else if (dev->dwType & DIDFT_POV) {
+        in->type = HAT;
+        in->num = joystick->nhats;
+        joystick->nhats++;
+    } else if (dev->dwType & DIDFT_AXIS) {
+        DIPROPRANGE diprg;
+        DIPROPDWORD dilong;
+
+        in->type = AXIS;
+        in->num = joystick->naxes;
+
+        diprg.diph.dwSize = sizeof(diprg);
+        diprg.diph.dwHeaderSize = sizeof(diprg.diph);
+        diprg.diph.dwObj = dev->dwOfs;
+        diprg.diph.dwHow = DIPH_BYOFFSET;
+        diprg.lMin = AXIS_MIN;
+        diprg.lMax = AXIS_MAX;
+
+        result =
+            IDirectInputDevice2_SetProperty(joystick->hwdata->InputDevice,
+                                            DIPROP_RANGE, &diprg.diph);
+        if (FAILED(result)) {
+            return DIENUM_CONTINUE;     /* don't use this axis */
+        }
+
+        /* Set dead zone to 0. */
+        dilong.diph.dwSize = sizeof(dilong);
+        dilong.diph.dwHeaderSize = sizeof(dilong.diph);
+        dilong.diph.dwObj = dev->dwOfs;
+        dilong.diph.dwHow = DIPH_BYOFFSET;
+        dilong.dwData = 0;
+        result =
+            IDirectInputDevice2_SetProperty(joystick->hwdata->InputDevice,
+                                            DIPROP_DEADZONE, &dilong.diph);
+        if (FAILED(result)) {
+            return DIENUM_CONTINUE;     /* don't use this axis */
+        }
+
+        joystick->naxes++;
+    } else {
+        /* not supported at this time */
+        return DIENUM_CONTINUE;
+    }
+
+    joystick->hwdata->NumInputs++;
+
+    if (joystick->hwdata->NumInputs == MAX_INPUTS) {
+        return DIENUM_STOP;     /* too many */
+    }
+
+    return DIENUM_CONTINUE;
+}
+
+/* Function to update the state of a joystick - called as a device poll.
+ * This function shouldn't update the joystick structure directly,
+ * but instead should call SDL_PrivateJoystick*() to deliver events
+ * and update joystick device state.
+ */
+void
+SDL_SYS_JoystickUpdate_Polled(SDL_Joystick * joystick)
+{
+    DIJOYSTATE2 state;
+    HRESULT result;
+    int i;
+
+    result =
+        IDirectInputDevice2_GetDeviceState(joystick->hwdata->InputDevice,
+                                           sizeof(DIJOYSTATE2), &state);
+    if (result == DIERR_INPUTLOST || result == DIERR_NOTACQUIRED) {
+        IDirectInputDevice2_Acquire(joystick->hwdata->InputDevice);
+        result =
+            IDirectInputDevice2_GetDeviceState(joystick->hwdata->InputDevice,
+                                               sizeof(DIJOYSTATE2), &state);
+    }
+
+    /* Set each known axis, button and POV. */
+    for (i = 0; i < joystick->hwdata->NumInputs; ++i) {
+        const input_t *in = &joystick->hwdata->Inputs[i];
+
+        switch (in->type) {
+        case AXIS:
+            switch (in->ofs) {
+            case DIJOFS_X:
+                SDL_PrivateJoystickAxis_Int(joystick, in->num,
+                                            (Sint16) state.lX);
+                break;
+            case DIJOFS_Y:
+                SDL_PrivateJoystickAxis_Int(joystick, in->num,
+                                            (Sint16) state.lY);
+                break;
+            case DIJOFS_Z:
+                SDL_PrivateJoystickAxis_Int(joystick, in->num,
+                                            (Sint16) state.lZ);
+                break;
+            case DIJOFS_RX:
+                SDL_PrivateJoystickAxis_Int(joystick, in->num,
+                                            (Sint16) state.lRx);
+                break;
+            case DIJOFS_RY:
+                SDL_PrivateJoystickAxis_Int(joystick, in->num,
+                                            (Sint16) state.lRy);
+                break;
+            case DIJOFS_RZ:
+                SDL_PrivateJoystickAxis_Int(joystick, in->num,
+                                            (Sint16) state.lRz);
+                break;
+            case DIJOFS_SLIDER(0):
+                SDL_PrivateJoystickAxis_Int(joystick, in->num,
+                                            (Sint16) state.rglSlider[0]);
+                break;
+            case DIJOFS_SLIDER(1):
+                SDL_PrivateJoystickAxis_Int(joystick, in->num,
+                                            (Sint16) state.rglSlider[1]);
+                break;
+            }
+
+            break;
+
+        case BUTTON:
+            SDL_PrivateJoystickButton_Int(joystick, in->num,
+                                          (Uint8) (state.
+                                                   rgbButtons[in->ofs -
+                                                              DIJOFS_BUTTON0]
+                                                   ? SDL_PRESSED :
+                                                   SDL_RELEASED));
+            break;
+        case HAT:
+            {
+                Uint8 pos = TranslatePOV(state.rgdwPOV[in->ofs -
+                                                       DIJOFS_POV(0)]);
+                SDL_PrivateJoystickHat_Int(joystick, in->num, pos);
+                break;
+            }
+        }
+    }
+}
+
+void
+SDL_SYS_JoystickUpdate_Buffered(SDL_Joystick * joystick)
+{
+    int i;
+    HRESULT result;
+    DWORD numevents;
+    DIDEVICEOBJECTDATA evtbuf[INPUT_QSIZE];
+
+    numevents = INPUT_QSIZE;
+    result =
+        IDirectInputDevice2_GetDeviceData(joystick->hwdata->InputDevice,
+                                          sizeof(DIDEVICEOBJECTDATA), evtbuf,
+                                          &numevents, 0);
+    if (result == DIERR_INPUTLOST || result == DIERR_NOTACQUIRED) {
+        IDirectInputDevice2_Acquire(joystick->hwdata->InputDevice);
+        result =
+            IDirectInputDevice2_GetDeviceData(joystick->hwdata->InputDevice,
+                                              sizeof(DIDEVICEOBJECTDATA),
+                                              evtbuf, &numevents, 0);
+    }
+
+    /* Handle the events or punt */
+    if (FAILED(result))
+        return;
+
+    for (i = 0; i < (int) numevents; ++i) {
+        int j;
+
+        for (j = 0; j < joystick->hwdata->NumInputs; ++j) {
+            const input_t *in = &joystick->hwdata->Inputs[j];
+
+            if (evtbuf[i].dwOfs != in->ofs)
+                continue;
+
+            switch (in->type) {
+            case AXIS:
+                SDL_PrivateJoystickAxis(joystick, in->num,
+                                        (Sint16) evtbuf[i].dwData);
+                break;
+            case BUTTON:
+                SDL_PrivateJoystickButton(joystick, in->num,
+                                          (Uint8) (evtbuf[i].
+                                                   dwData ? SDL_PRESSED :
+                                                   SDL_RELEASED));
+                break;
+            case HAT:
+                {
+                    Uint8 pos = TranslatePOV(evtbuf[i].dwData);
+                    SDL_PrivateJoystickHat(joystick, in->num, pos);
+                }
+            }
+        }
+    }
+}
+
+
+static Uint8
+TranslatePOV(DWORD value)
+{
+    const int HAT_VALS[] = {
+        SDL_HAT_UP,
+        SDL_HAT_UP | SDL_HAT_RIGHT,
+        SDL_HAT_RIGHT,
+        SDL_HAT_DOWN | SDL_HAT_RIGHT,
+        SDL_HAT_DOWN,
+        SDL_HAT_DOWN | SDL_HAT_LEFT,
+        SDL_HAT_LEFT,
+        SDL_HAT_UP | SDL_HAT_LEFT
+    };
+
+    if (LOWORD(value) == 0xFFFF)
+        return SDL_HAT_CENTERED;
+
+    /* Round the value up: */
+    value += 4500 / 2;
+    value %= 36000;
+    value /= 4500;
+
+    if (value >= 8)
+        return SDL_HAT_CENTERED;        /* shouldn't happen */
+
+    return HAT_VALS[value];
+}
+
+/* SDL_PrivateJoystick* doesn't discard duplicate events, so we need to
+ * do it. */
+static int
+SDL_PrivateJoystickAxis_Int(SDL_Joystick * joystick, Uint8 axis, Sint16 value)
+{
+    if (joystick->axes[axis] != value)
+        return SDL_PrivateJoystickAxis(joystick, axis, value);
+    return 0;
+}
+
+static int
+SDL_PrivateJoystickHat_Int(SDL_Joystick * joystick, Uint8 hat, Uint8 value)
+{
+    if (joystick->hats[hat] != value)
+        return SDL_PrivateJoystickHat(joystick, hat, value);
+    return 0;
+}
+
+static int
+SDL_PrivateJoystickButton_Int(SDL_Joystick * joystick, Uint8 button,
+                              Uint8 state)
+{
+    if (joystick->buttons[button] != state)
+        return SDL_PrivateJoystickButton(joystick, button, state);
+    return 0;
+}
+
+void
+SDL_SYS_JoystickUpdate(SDL_Joystick * joystick)
+{
+    HRESULT result;
+
+    result = IDirectInputDevice2_Poll(joystick->hwdata->InputDevice);
+    if (result == DIERR_INPUTLOST || result == DIERR_NOTACQUIRED) {
+        IDirectInputDevice2_Acquire(joystick->hwdata->InputDevice);
+        IDirectInputDevice2_Poll(joystick->hwdata->InputDevice);
+    }
+
+    if (joystick->hwdata->buffered)
+        SDL_SYS_JoystickUpdate_Buffered(joystick);
+    else
+        SDL_SYS_JoystickUpdate_Polled(joystick);
+}
+
+/* Function to close a joystick after use */
+void
+SDL_SYS_JoystickClose(SDL_Joystick * joystick)
+{
+    IDirectInputDevice2_Unacquire(joystick->hwdata->InputDevice);
+    IDirectInputDevice2_Release(joystick->hwdata->InputDevice);
+
+    if (joystick->hwdata != NULL) {
+        /* free system specific hardware data */
+        SDL_free(joystick->hwdata);
+    }
+}
+
+/* Function to perform any system-specific joystick related cleanup */
+void
+SDL_SYS_JoystickQuit(void)
+{
+    IDirectInput_Release(dinput);
+    dinput = NULL;
+}
+
+#endif /* SDL_JOYSTICK_DINPUT */
+
+/* vi: set ts=4 sw=4 expandtab: */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/joystick/windows/SDL_dxjoystick_c.h	Thu Jan 20 18:04:05 2011 -0800
@@ -0,0 +1,73 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997-2010 Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+
+    Sam Lantinga
+    slouken@libsdl.org
+*/
+#include "SDL_config.h"
+
+#ifndef SDL_JOYSTICK_DINPUT_H
+
+/* DirectInput joystick driver; written by Glenn Maynard, based on Andrei de
+ * A. Formiga's WINMM driver. 
+ *
+ * Hats and sliders are completely untested; the app I'm writing this for mostly
+ * doesn't use them and I don't own any joysticks with them. 
+ *
+ * We don't bother to use event notification here.  It doesn't seem to work
+ * with polled devices, and it's fine to call IDirectInputDevice2_GetDeviceData and
+ * let it return 0 events. */
+
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+
+#define DIRECTINPUT_VERSION 0x0700      /* Need version 7 for force feedback. */
+#include <dinput.h>
+
+
+#define MAX_INPUTS	256     /* each joystick can have up to 256 inputs */
+
+
+/* local types */
+typedef enum Type
+{ BUTTON, AXIS, HAT } Type;
+
+typedef struct input_t
+{
+    /* DirectInput offset for this input type: */
+    DWORD ofs;
+
+    /* Button, axis or hat: */
+    Type type;
+
+    /* SDL input offset: */
+    Uint8 num;
+} input_t;
+
+/* The private structure used to keep track of a joystick */
+struct joystick_hwdata
+{
+    LPDIRECTINPUTDEVICE2 InputDevice;
+    DIDEVCAPS Capabilities;
+    int buffered;
+
+    input_t Inputs[MAX_INPUTS];
+    int NumInputs;
+};
+
+#endif /* SDL_JOYSTICK_DINPUT_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/joystick/windows/SDL_mmjoystick.c	Thu Jan 20 18:04:05 2011 -0800
@@ -0,0 +1,428 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997-2010 Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+
+    Sam Lantinga
+    slouken@libsdl.org
+*/
+#include "SDL_config.h"
+
+#ifdef SDL_JOYSTICK_WINMM
+
+/* Win32 MultiMedia Joystick driver, contributed by Andrei de A. Formiga */
+
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+#include <mmsystem.h>
+#include <regstr.h>
+
+#include "SDL_events.h"
+#include "SDL_joystick.h"
+#include "../SDL_sysjoystick.h"
+#include "../SDL_joystick_c.h"
+
+#define MAX_JOYSTICKS	16
+#define MAX_AXES	6       /* each joystick can have up to 6 axes */
+#define MAX_BUTTONS	32      /* and 32 buttons                      */
+#define AXIS_MIN	-32768  /* minimum value for axis coordinate */
+#define AXIS_MAX	32767   /* maximum value for axis coordinate */
+/* limit axis to 256 possible positions to filter out noise */
+#define JOY_AXIS_THRESHOLD      (((AXIS_MAX)-(AXIS_MIN))/256)
+#define JOY_BUTTON_FLAG(n)	(1<<n)
+
+
+/* array to hold joystick ID values */
+static UINT SYS_JoystickID[MAX_JOYSTICKS];
+static JOYCAPS SYS_Joystick[MAX_JOYSTICKS];
+static char *SYS_JoystickName[MAX_JOYSTICKS];
+
+/* The private structure used to keep track of a joystick */
+struct joystick_hwdata
+{
+    /* joystick ID */
+    UINT id;
+
+    /* values used to translate device-specific coordinates into
+       SDL-standard ranges */
+    struct _transaxis
+    {
+        int offset;
+        float scale;
+    } transaxis[6];
+};
+
+/* Convert a Windows Multimedia API return code to a text message */
+static void SetMMerror(char *function, int code);
+
+
+static char *
+GetJoystickName(int index, const char *szRegKey)
+{
+    /* added 7/24/2004 by Eckhard Stolberg */
+    /*
+       see if there is a joystick for the current
+       index (1-16) listed in the registry
+     */
+    char *name = NULL;
+    HKEY hTopKey;
+    HKEY hKey;
+    DWORD regsize;
+    LONG regresult;
+    char regkey[256];
+    char regvalue[256];
+    char regname[256];
+
+    SDL_snprintf(regkey, SDL_arraysize(regkey), "%s\\%s\\%s",
+                 REGSTR_PATH_JOYCONFIG, szRegKey, REGSTR_KEY_JOYCURR);
+    hTopKey = HKEY_LOCAL_MACHINE;
+    regresult = RegOpenKeyExA(hTopKey, regkey, 0, KEY_READ, &hKey);
+    if (regresult != ERROR_SUCCESS) {
+        hTopKey = HKEY_CURRENT_USER;
+        regresult = RegOpenKeyExA(hTopKey, regkey, 0, KEY_READ, &hKey);
+    }
+    if (regresult != ERROR_SUCCESS) {
+        return NULL;
+    }
+
+    /* find the registry key name for the joystick's properties */
+    regsize = sizeof(regname);
+    SDL_snprintf(regvalue, SDL_arraysize(regvalue), "Joystick%d%s", index + 1,
+                 REGSTR_VAL_JOYOEMNAME);
+    regresult =
+        RegQueryValueExA(hKey, regvalue, 0, 0, (LPBYTE) regname, &regsize);
+    RegCloseKey(hKey);
+
+    if (regresult != ERROR_SUCCESS) {
+        return NULL;
+    }
+
+    /* open that registry key */
+    SDL_snprintf(regkey, SDL_arraysize(regkey), "%s\\%s", REGSTR_PATH_JOYOEM,
+                 regname);
+    regresult = RegOpenKeyExA(hTopKey, regkey, 0, KEY_READ, &hKey);
+    if (regresult != ERROR_SUCCESS) {
+        return NULL;
+    }
+
+    /* find the size for the OEM name text */
+    regsize = sizeof(regvalue);
+    regresult =
+        RegQueryValueExA(hKey, REGSTR_VAL_JOYOEMNAME, 0, 0, NULL, &regsize);
+    if (regresult == ERROR_SUCCESS) {
+        /* allocate enough memory for the OEM name text ... */
+        name = (char *) SDL_malloc(regsize);
+        if (name) {
+            /* ... and read it from the registry */
+            regresult = RegQueryValueExA(hKey,
+                                         REGSTR_VAL_JOYOEMNAME, 0, 0,
+                                         (LPBYTE) name, &regsize);
+        }
+    }
+    RegCloseKey(hKey);
+
+    return (name);
+}
+
+/* Function to scan the system for joysticks.
+ * This function should set SDL_numjoysticks to the number of available
+ * joysticks.  Joystick 0 should be the system default joystick.
+ * It should return 0, or -1 on an unrecoverable fatal error.
+ */
+int
+SDL_SYS_JoystickInit(void)
+{
+    int i;
+    int maxdevs;
+    int numdevs;
+    JOYINFOEX joyinfo;
+    JOYCAPS joycaps;
+    MMRESULT result;
+
+    /* Reset the joystick ID & name mapping tables */
+    for (i = 0; i < MAX_JOYSTICKS; ++i) {
+        SYS_JoystickID[i] = 0;
+        SYS_JoystickName[i] = NULL;
+    }
+
+    /* Loop over all potential joystick devices */
+    numdevs = 0;
+    maxdevs = joyGetNumDevs();
+    for (i = JOYSTICKID1; i < maxdevs && numdevs < MAX_JOYSTICKS; ++i) {
+
+        joyinfo.dwSize = sizeof(joyinfo);
+        joyinfo.dwFlags = JOY_RETURNALL;
+        result = joyGetPosEx(i, &joyinfo);
+        if (result == JOYERR_NOERROR) {
+            result = joyGetDevCaps(i, &joycaps, sizeof(joycaps));
+            if (result == JOYERR_NOERROR) {
+                SYS_JoystickID[numdevs] = i;
+                SYS_Joystick[numdevs] = joycaps;
+                SYS_JoystickName[numdevs] =
+                    GetJoystickName(i, joycaps.szRegKey);
+                numdevs++;
+            }
+        }
+    }
+    return (numdevs);
+}
+
+/* Function to get the device-dependent name of a joystick */
+const char *
+SDL_SYS_JoystickName(int index)
+{
+    if (SYS_JoystickName[index] != NULL) {
+        return (SYS_JoystickName[index]);
+    } else {
+        return (SYS_Joystick[index].szPname);
+    }
+}
+
+/* Function to open a joystick for use.
+   The joystick to open is specified by the index field of the joystick.
+   This should fill the nbuttons and naxes fields of the joystick structure.
+   It returns 0, or -1 if there is an error.
+ */
+int
+SDL_SYS_JoystickOpen(SDL_Joystick * joystick)
+{
+    int index, i;
+    int caps_flags[MAX_AXES - 2] =
+        { JOYCAPS_HASZ, JOYCAPS_HASR, JOYCAPS_HASU, JOYCAPS_HASV };
+    int axis_min[MAX_AXES], axis_max[MAX_AXES];
+
+
+    /* shortcut */
+    index = joystick->index;
+    axis_min[0] = SYS_Joystick[index].wXmin;
+    axis_max[0] = SYS_Joystick[index].wXmax;
+    axis_min[1] = SYS_Joystick[index].wYmin;
+    axis_max[1] = SYS_Joystick[index].wYmax;
+    axis_min[2] = SYS_Joystick[index].wZmin;
+    axis_max[2] = SYS_Joystick[index].wZmax;
+    axis_min[3] = SYS_Joystick[index].wRmin;
+    axis_max[3] = SYS_Joystick[index].wRmax;
+    axis_min[4] = SYS_Joystick[index].wUmin;
+    axis_max[4] = SYS_Joystick[index].wUmax;
+    axis_min[5] = SYS_Joystick[index].wVmin;
+    axis_max[5] = SYS_Joystick[index].wVmax;
+
+    /* allocate memory for system specific hardware data */
+    joystick->hwdata =
+        (struct joystick_hwdata *) SDL_malloc(sizeof(*joystick->hwdata));
+    if (joystick->hwdata == NULL) {
+        SDL_OutOfMemory();
+        return (-1);
+    }
+    SDL_memset(joystick->hwdata, 0, sizeof(*joystick->hwdata));
+
+    /* set hardware data */
+    joystick->hwdata->id = SYS_JoystickID[index];
+    for (i = 0; i < MAX_AXES; ++i) {
+        if ((i < 2) || (SYS_Joystick[index].wCaps & caps_flags[i - 2])) {
+            joystick->hwdata->transaxis[i].offset = AXIS_MIN - axis_min[i];
+            joystick->hwdata->transaxis[i].scale =
+                (float) (AXIS_MAX - AXIS_MIN) / (axis_max[i] - axis_min[i]);
+        } else {
+            joystick->hwdata->transaxis[i].offset = 0;
+            joystick->hwdata->transaxis[i].scale = 1.0; /* Just in case */
+        }
+    }
+
+    /* fill nbuttons, naxes, and nhats fields */
+    joystick->nbuttons = SYS_Joystick[index].wNumButtons;
+    joystick->naxes = SYS_Joystick[index].wNumAxes;
+    if (SYS_Joystick[index].wCaps & JOYCAPS_HASPOV) {
+        joystick->nhats = 1;
+    } else {
+        joystick->nhats = 0;
+    }
+    return (0);
+}
+
+static Uint8
+TranslatePOV(DWORD value)
+{
+    Uint8 pos;
+
+    pos = SDL_HAT_CENTERED;
+    if (value != JOY_POVCENTERED) {
+        if ((value > JOY_POVLEFT) || (value < JOY_POVRIGHT)) {
+            pos |= SDL_HAT_UP;
+        }
+        if ((value > JOY_POVFORWARD) && (value < JOY_POVBACKWARD)) {
+            pos |= SDL_HAT_RIGHT;
+        }
+        if ((value > JOY_POVRIGHT) && (value < JOY_POVLEFT)) {
+            pos |= SDL_HAT_DOWN;
+        }
+        if (value > JOY_POVBACKWARD) {
+            pos |= SDL_HAT_LEFT;
+        }
+    }
+    return (pos);
+}
+
+/* Function to update the state of a joystick - called as a device poll.
+ * This function shouldn't update the joystick structure directly,
+ * but instead should call SDL_PrivateJoystick*() to deliver events
+ * and update joystick device state.
+ */
+void
+SDL_SYS_JoystickUpdate(SDL_Joystick * joystick)
+{
+    MMRESULT result;
+    int i;
+    DWORD flags[MAX_AXES] = { JOY_RETURNX, JOY_RETURNY, JOY_RETURNZ,
+        JOY_RETURNR, JOY_RETURNU, JOY_RETURNV
+    };
+    DWORD pos[MAX_AXES];
+    struct _transaxis *transaxis;
+    int value, change;
+    JOYINFOEX joyinfo;
+
+    joyinfo.dwSize = sizeof(joyinfo);
+    joyinfo.dwFlags = JOY_RETURNALL | JOY_RETURNPOVCTS;
+    if (!joystick->hats) {
+        joyinfo.dwFlags &= ~(JOY_RETURNPOV | JOY_RETURNPOVCTS);
+    }
+    result = joyGetPosEx(joystick->hwdata->id, &joyinfo);
+    if (result != JOYERR_NOERROR) {
+        SetMMerror("joyGetPosEx", result);
+        return;
+    }
+
+    /* joystick motion events */
+    pos[0] = joyinfo.dwXpos;
+    pos[1] = joyinfo.dwYpos;
+    pos[2] = joyinfo.dwZpos;
+    pos[3] = joyinfo.dwRpos;
+    pos[4] = joyinfo.dwUpos;
+    pos[5] = joyinfo.dwVpos;
+
+    transaxis = joystick->hwdata->transaxis;
+    for (i = 0; i < joystick->naxes; i++) {
+        if (joyinfo.dwFlags & flags[i]) {
+            value =
+                (int) (((float) pos[i] +
+                        transaxis[i].offset) * transaxis[i].scale);
+            change = (value - joystick->axes[i]);
+            if ((change < -JOY_AXIS_THRESHOLD)
+                || (change > JOY_AXIS_THRESHOLD)) {
+                SDL_PrivateJoystickAxis(joystick, (Uint8) i, (Sint16) value);
+            }
+        }
+    }
+
+    /* joystick button events */
+    if (joyinfo.dwFlags & JOY_RETURNBUTTONS) {
+        for (i = 0; i < joystick->nbuttons; ++i) {
+            if (joyinfo.dwButtons & JOY_BUTTON_FLAG(i)) {
+                if (!joystick->buttons[i]) {
+                    SDL_PrivateJoystickButton(joystick, (Uint8) i,
+                                              SDL_PRESSED);
+                }
+            } else {
+                if (joystick->buttons[i]) {
+                    SDL_PrivateJoystickButton(joystick, (Uint8) i,
+                                              SDL_RELEASED);
+                }
+            }
+        }
+    }
+
+    /* joystick hat events */
+    if (joyinfo.dwFlags & JOY_RETURNPOV) {
+        Uint8 pos;
+
+        pos = TranslatePOV(joyinfo.dwPOV);
+        if (pos != joystick->hats[0]) {
+            SDL_PrivateJoystickHat(joystick, 0, pos);
+        }
+    }
+}
+
+/* Function to close a joystick after use */
+void
+SDL_SYS_JoystickClose(SDL_Joystick * joystick)
+{
+    if (joystick->hwdata != NULL) {
+        /* free system specific hardware data */
+        SDL_free(joystick->hwdata);
+        joystick->hwdata = NULL;
+    }
+}
+
+/* Function to perform any system-specific joystick related cleanup */
+void
+SDL_SYS_JoystickQuit(void)
+{
+    int i;
+    for (i = 0; i < MAX_JOYSTICKS; i++) {
+        if (SYS_JoystickName[i] != NULL) {
+            SDL_free(SYS_JoystickName[i]);
+            SYS_JoystickName[i] = NULL;
+        }
+    }
+}
+
+
+/* implementation functions */
+void
+SetMMerror(char *function, int code)
+{
+    static char *error;
+    static char errbuf[1024];
+
+    errbuf[0] = 0;
+    switch (code) {
+    case MMSYSERR_NODRIVER:
+        error = "Joystick driver not present";
+        break;
+
+    case MMSYSERR_INVALPARAM:
+    case JOYERR_PARMS:
+        error = "Invalid parameter(s)";
+        break;
+
+    case MMSYSERR_BADDEVICEID:
+        error = "Bad device ID";
+        break;
+
+    case JOYERR_UNPLUGGED:
+        error = "Joystick not attached";
+        break;
+
+    case JOYERR_NOCANDO:
+        error = "Can't capture joystick input";
+        break;
+
+    default:
+        SDL_snprintf(errbuf, SDL_arraysize(errbuf),
+                     "%s: Unknown Multimedia system error: 0x%x",
+                     function, code);
+        break;
+    }
+
+    if (!errbuf[0]) {
+        SDL_snprintf(errbuf, SDL_arraysize(errbuf), "%s: %s", function,
+                     error);
+    }
+    SDL_SetError("%s", errbuf);
+}
+
+#endif /* SDL_JOYSTICK_WINMM */
+/* vi: set ts=4 sw=4 expandtab: */
--- a/src/loadso/win32/SDL_sysloadso.c	Thu Jan 20 17:33:06 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,145 +0,0 @@
-/*
-    SDL - Simple DirectMedia Layer
-    Copyright (C) 1997-2010 Sam Lantinga
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Lesser General Public
-    License as published by the Free Software Foundation; either
-    version 2.1 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Lesser General Public License for more details.
-
-    You should have received a copy of the GNU Lesser General Public
-    License along with this library; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-
-    Sam Lantinga
-    slouken@libsdl.org
-*/
-#include "SDL_config.h"
-
-#ifdef SDL_LOADSO_WIN32
-
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-/* System dependent library loading routines                           */
-
-#define WIN32_LEAN_AND_MEAN
-#include <windows.h>
-
-#include "SDL_loadso.h"
-
-void *
-SDL_LoadObject(const char *sofile)
-{
-    void *handle = NULL;
-    const char *loaderror = "Unknown error";
-
-#if defined(_WIN32_WCE)
-    char errbuf[512];
-
-    wchar_t *errbuf_t = SDL_malloc(512 * sizeof(wchar_t));
-    wchar_t *sofile_t = SDL_malloc((MAX_PATH + 1) * sizeof(wchar_t));
-
-    MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, sofile, -1, sofile_t,
-                        MAX_PATH);
-    handle = (void *) LoadLibrary(sofile_t);
-
-    /* Generate an error message if all loads failed */
-    if (handle == NULL) {
-        FormatMessage((FORMAT_MESSAGE_IGNORE_INSERTS |
-                       FORMAT_MESSAGE_FROM_SYSTEM),
-                      NULL, GetLastError(),
-                      MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
-                      errbuf_t, SDL_arraysize(errbuf), NULL);
-        WideCharToMultiByte(CP_ACP, 0, errbuf_t, -1, errbuf, 511, NULL, NULL);
-        loaderror = errbuf;
-    }
-
-    SDL_free(sofile_t);
-    SDL_free(errbuf_t);
-
-#else /*if defined(__WIN32__) */
-    char errbuf[512];
-
-    handle = (void *) LoadLibrary(sofile);
-
-    /* Generate an error message if all loads failed */
-    if (handle == NULL) {
-        FormatMessage((FORMAT_MESSAGE_IGNORE_INSERTS |
-                       FORMAT_MESSAGE_FROM_SYSTEM),
-                      NULL, GetLastError(),
-                      MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
-                      errbuf, SDL_arraysize(errbuf), NULL);
-        loaderror = errbuf;
-    }
-#endif
-
-    if (handle == NULL) {
-        SDL_SetError("Failed loading %s: %s", sofile, loaderror);
-    }
-    return (handle);
-}
-
-void *
-SDL_LoadFunction(void *handle, const char *name)
-{
-    void *symbol = NULL;
-    const char *loaderror = "Unknown error";
-
-#if defined(_WIN32_WCE)
-    char errbuf[512];
-    int length = SDL_strlen(name);
-
-    wchar_t *name_t = SDL_malloc((length + 1) * sizeof(wchar_t));
-    wchar_t *errbuf_t = SDL_malloc(512 * sizeof(wchar_t));
-
-    MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, name, -1, name_t, length + 1);
-
-    symbol = (void *) GetProcAddress((HMODULE) handle, name_t);
-    if (symbol == NULL) {
-        FormatMessage((FORMAT_MESSAGE_IGNORE_INSERTS |
-                       FORMAT_MESSAGE_FROM_SYSTEM),
-                      NULL, GetLastError(),
-                      MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
-                      errbuf_t, SDL_arraysize(errbuf), NULL);
-        WideCharToMultiByte(CP_ACP, 0, errbuf_t, -1, errbuf, 511, NULL, NULL);
-        loaderror = errbuf;
-    }
-
-    SDL_free(name_t);
-    SDL_free(errbuf_t);
-
-#else /*if defined(WIN32) */
-    char errbuf[512];
-
-    symbol = (void *) GetProcAddress((HMODULE) handle, name);
-    if (symbol == NULL) {
-        FormatMessage((FORMAT_MESSAGE_IGNORE_INSERTS |
-                       FORMAT_MESSAGE_FROM_SYSTEM),
-                      NULL, GetLastError(),
-                      MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
-                      errbuf, SDL_arraysize(errbuf), NULL);
-        loaderror = errbuf;
-    }
-#endif
-
-    if (symbol == NULL) {
-        SDL_SetError("Failed loading %s: %s", name, loaderror);
-    }
-    return (symbol);
-}
-
-void
-SDL_UnloadObject(void *handle)
-{
-    if (handle != NULL) {
-        FreeLibrary((HMODULE) handle);
-    }
-}
-
-#endif /* SDL_LOADSO_WIN32 */
-
-/* vi: set ts=4 sw=4 expandtab: */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/loadso/windows/SDL_sysloadso.c	Thu Jan 20 18:04:05 2011 -0800
@@ -0,0 +1,145 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997-2010 Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+
+    Sam Lantinga
+    slouken@libsdl.org
+*/
+#include "SDL_config.h"
+
+#ifdef SDL_LOADSO_WINDOWS
+
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+/* System dependent library loading routines                           */
+
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+
+#include "SDL_loadso.h"
+
+void *
+SDL_LoadObject(const char *sofile)
+{
+    void *handle = NULL;
+    const char *loaderror = "Unknown error";
+
+#if defined(_WIN32_WCE)
+    char errbuf[512];
+
+    wchar_t *errbuf_t = SDL_malloc(512 * sizeof(wchar_t));
+    wchar_t *sofile_t = SDL_malloc((MAX_PATH + 1) * sizeof(wchar_t));
+
+    MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, sofile, -1, sofile_t,
+                        MAX_PATH);
+    handle = (void *) LoadLibrary(sofile_t);
+
+    /* Generate an error message if all loads failed */
+    if (handle == NULL) {
+        FormatMessage((FORMAT_MESSAGE_IGNORE_INSERTS |
+                       FORMAT_MESSAGE_FROM_SYSTEM),
+                      NULL, GetLastError(),
+                      MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
+                      errbuf_t, SDL_arraysize(errbuf), NULL);
+        WideCharToMultiByte(CP_ACP, 0, errbuf_t, -1, errbuf, 511, NULL, NULL);
+        loaderror = errbuf;
+    }
+
+    SDL_free(sofile_t);
+    SDL_free(errbuf_t);
+
+#else /*if defined(__WINDOWS__) */
+    char errbuf[512];
+
+    handle = (void *) LoadLibrary(sofile);
+
+    /* Generate an error message if all loads failed */
+    if (handle == NULL) {
+        FormatMessage((FORMAT_MESSAGE_IGNORE_INSERTS |
+                       FORMAT_MESSAGE_FROM_SYSTEM),
+                      NULL, GetLastError(),
+                      MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
+                      errbuf, SDL_arraysize(errbuf), NULL);
+        loaderror = errbuf;
+    }
+#endif
+
+    if (handle == NULL) {
+        SDL_SetError("Failed loading %s: %s", sofile, loaderror);
+    }
+    return (handle);
+}
+
+void *
+SDL_LoadFunction(void *handle, const char *name)
+{
+    void *symbol = NULL;
+    const char *loaderror = "Unknown error";
+
+#if defined(_WIN32_WCE)
+    char errbuf[512];
+    int length = SDL_strlen(name);
+
+    wchar_t *name_t = SDL_malloc((length + 1) * sizeof(wchar_t));
+    wchar_t *errbuf_t = SDL_malloc(512 * sizeof(wchar_t));
+
+    MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, name, -1, name_t, length + 1);
+
+    symbol = (void *) GetProcAddress((HMODULE) handle, name_t);
+    if (symbol == NULL) {
+        FormatMessage((FORMAT_MESSAGE_IGNORE_INSERTS |
+                       FORMAT_MESSAGE_FROM_SYSTEM),
+                      NULL, GetLastError(),
+                      MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
+                      errbuf_t, SDL_arraysize(errbuf), NULL);
+        WideCharToMultiByte(CP_ACP, 0, errbuf_t, -1, errbuf, 511, NULL, NULL);
+        loaderror = errbuf;
+    }
+
+    SDL_free(name_t);
+    SDL_free(errbuf_t);
+
+#else /*if defined(WIN32) */
+    char errbuf[512];
+
+    symbol = (void *) GetProcAddress((HMODULE) handle, name);
+    if (symbol == NULL) {
+        FormatMessage((FORMAT_MESSAGE_IGNORE_INSERTS |
+                       FORMAT_MESSAGE_FROM_SYSTEM),
+                      NULL, GetLastError(),
+                      MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
+                      errbuf, SDL_arraysize(errbuf), NULL);
+        loaderror = errbuf;
+    }
+#endif
+
+    if (symbol == NULL) {
+        SDL_SetError("Failed loading %s: %s", name, loaderror);
+    }
+    return (symbol);
+}
+
+void
+SDL_UnloadObject(void *handle)
+{
+    if (handle != NULL) {
+        FreeLibrary((HMODULE) handle);
+    }
+}
+
+#endif /* SDL_LOADSO_WINDOWS */
+
+/* vi: set ts=4 sw=4 expandtab: */
--- a/src/main/win32/SDL_win32_main.c	Thu Jan 20 17:33:06 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,205 +0,0 @@
-/*
-    SDL_main.c, placed in the public domain by Sam Lantinga  4/13/98
-
-    The WinMain function -- calls your program's main() function
-*/
-
-#include <stdio.h>
-#include <stdlib.h>
-
-#define WIN32_LEAN_AND_MEAN
-#include <windows.h>
-
-/* Include the SDL main definition header */
-#include "SDL.h"
-#include "SDL_main.h"
-
-#ifdef main
-# ifndef _WIN32_WCE_EMULATION
-#  undef main
-# endif /* _WIN32_WCE_EMULATION */
-#endif /* main */
-
-#if defined(_WIN32_WCE) && _WIN32_WCE < 300
-/* seems to be undefined in Win CE although in online help */
-#define isspace(a) (((CHAR)a == ' ') || ((CHAR)a == '\t'))
-#endif /* _WIN32_WCE < 300 */
-
-static void
-UnEscapeQuotes(char *arg)
-{
-    char *last = NULL;
-
-    while (*arg) {
-        if (*arg == '"' && *last == '\\') {
-            char *c_curr = arg;
-            char *c_last = last;
-
-            while (*c_curr) {
-                *c_last = *c_curr;
-                c_last = c_curr;
-                c_curr++;
-            }
-            *c_last = '\0';
-        }
-        last = arg;
-        arg++;
-    }
-}
-
-/* Parse a command line buffer into arguments */
-static int
-ParseCommandLine(char *cmdline, char **argv)
-{
-    char *bufp;
-    char *lastp = NULL;
-    int argc, last_argc;
-
-    argc = last_argc = 0;
-    for (bufp = cmdline; *bufp;) {
-        /* Skip leading whitespace */
-        while (isspace(*bufp)) {
-            ++bufp;
-        }
-        /* Skip over argument */
-        if (*bufp == '"') {
-            ++bufp;
-            if (*bufp) {
-                if (argv) {
-                    argv[argc] = bufp;
-                }
-                ++argc;
-            }
-            /* Skip over word */
-            lastp = bufp;
-            while (*bufp && (*bufp != '"' || *lastp == '\\')) {
-                lastp = bufp;
-                ++bufp;
-            }
-        } else {
-            if (*bufp) {
-                if (argv) {
-                    argv[argc] = bufp;
-                }
-                ++argc;
-            }
-            /* Skip over word */
-            while (*bufp && !isspace(*bufp)) {
-                ++bufp;
-            }
-        }
-        if (*bufp) {
-            if (argv) {
-                *bufp = '\0';
-            }
-            ++bufp;
-        }
-
-        /* Strip out \ from \" sequences */
-        if (argv && last_argc != argc) {
-            UnEscapeQuotes(argv[last_argc]);
-        }
-        last_argc = argc;
-    }
-    if (argv) {
-        argv[argc] = NULL;
-    }
-    return (argc);
-}
-
-/* Show an error message */
-static void
-ShowError(const char *title, const char *message)
-{
-/* If USE_MESSAGEBOX is defined, you need to link with user32.lib */
-#ifdef USE_MESSAGEBOX
-    MessageBox(NULL, message, title, MB_ICONEXCLAMATION | MB_OK);
-#else
-    fprintf(stderr, "%s: %s\n", title, message);
-#endif
-}
-
-/* Pop up an out of memory message, returns to Windows */
-static BOOL
-OutOfMemory(void)
-{
-    ShowError("Fatal Error", "Out of memory - aborting");
-    return FALSE;
-}
-
-#if defined(_MSC_VER) && !defined(_WIN32_WCE)
-/* The VC++ compiler needs main defined */
-#define console_main main
-#endif
-
-/* This is where execution begins [console apps] */
-int
-console_main(int argc, char *argv[])
-{
-    int status;
-
-    /* Run the application main() code */
-    status = SDL_main(argc, argv);
-
-    /* Exit cleanly, calling atexit() functions */
-    exit(status);
-
-    /* Hush little compiler, don't you cry... */
-    return 0;
-}
-
-/* This is where execution begins [windowed apps] */
-int WINAPI
-WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPTSTR szCmdLine, int sw)
-{
-    char **argv;
-    int argc;
-    char *cmdline;
-#ifdef _WIN32_WCE
-    wchar_t *bufp;
-    int nLen;
-#else
-    char *bufp;
-    size_t nLen;
-#endif
-
-#ifdef _WIN32_WCE
-    nLen = wcslen(szCmdLine) + 128 + 1;
-    bufp = SDL_stack_alloc(wchar_t, nLen * 2);
-    wcscpy(bufp, TEXT("\""));
-    GetModuleFileName(NULL, bufp + 1, 128 - 3);
-    wcscpy(bufp + wcslen(bufp), TEXT("\" "));
-    wcsncpy(bufp + wcslen(bufp), szCmdLine, nLen - wcslen(bufp));
-    nLen = wcslen(bufp) + 1;
-    cmdline = SDL_stack_alloc(char, nLen);
-    if (cmdline == NULL) {
-        return OutOfMemory();
-    }
-    WideCharToMultiByte(CP_ACP, 0, bufp, -1, cmdline, nLen, NULL, NULL);
-#else
-    /* Grab the command line */
-    bufp = GetCommandLine();
-    nLen = SDL_strlen(bufp) + 1;
-    cmdline = SDL_stack_alloc(char, nLen);
-    if (cmdline == NULL) {
-        return OutOfMemory();
-    }
-    SDL_strlcpy(cmdline, bufp, nLen);
-#endif
-
-    /* Parse it into argv and argc */
-    argc = ParseCommandLine(cmdline, NULL);
-    argv = SDL_stack_alloc(char *, argc + 1);
-    if (argv == NULL) {
-        return OutOfMemory();
-    }
-    ParseCommandLine(cmdline, argv);
-
-    /* Run the main program */
-    console_main(argc, argv);
-
-    /* Hush little compiler, don't you cry... */
-    return 0;
-}
-
-/* vi: set ts=4 sw=4 expandtab: */
--- a/src/main/win32/version.rc	Thu Jan 20 17:33:06 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,38 +0,0 @@
-
-#include "winresrc.h"
-
-LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Version
-//
-
-VS_VERSION_INFO VERSIONINFO
- FILEVERSION 1,3,0,0
- PRODUCTVERSION 1,3,0,0
- FILEFLAGSMASK 0x3fL
- FILEFLAGS 0x0L
- FILEOS 0x40004L
- FILETYPE 0x2L
- FILESUBTYPE 0x0L
-BEGIN
-    BLOCK "StringFileInfo"
-    BEGIN
-        BLOCK "040904b0"
-        BEGIN
-            VALUE "CompanyName", "\0"
-            VALUE "FileDescription", "SDL\0"
-            VALUE "FileVersion", "1, 3, 0, 0\0"
-            VALUE "InternalName", "SDL\0"
-            VALUE "LegalCopyright", "Copyright  2009 Sam Lantinga\0"
-            VALUE "OriginalFilename", "SDL.dll\0"
-            VALUE "ProductName", "Simple DirectMedia Layer\0"
-            VALUE "ProductVersion", "1, 3, 0, 0\0"
-        END
-    END
-    BLOCK "VarFileInfo"
-    BEGIN
-        VALUE "Translation", 0x409, 1200
-    END
-END
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/windows/SDL_windows_main.c	Thu Jan 20 18:04:05 2011 -0800
@@ -0,0 +1,205 @@
+/*
+    SDL_main.c, placed in the public domain by Sam Lantinga  4/13/98
+
+    The WinMain function -- calls your program's main() function
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+
+/* Include the SDL main definition header */
+#include "SDL.h"
+#include "SDL_main.h"
+
+#ifdef main
+# ifndef _WIN32_WCE_EMULATION
+#  undef main
+# endif /* _WIN32_WCE_EMULATION */
+#endif /* main */
+
+#if defined(_WIN32_WCE) && _WIN32_WCE < 300
+/* seems to be undefined in Win CE although in online help */
+#define isspace(a) (((CHAR)a == ' ') || ((CHAR)a == '\t'))
+#endif /* _WIN32_WCE < 300 */
+
+static void
+UnEscapeQuotes(char *arg)
+{
+    char *last = NULL;
+
+    while (*arg) {
+        if (*arg == '"' && *last == '\\') {
+            char *c_curr = arg;
+            char *c_last = last;
+
+            while (*c_curr) {
+                *c_last = *c_curr;
+                c_last = c_curr;
+                c_curr++;
+            }
+            *c_last = '\0';
+        }
+        last = arg;
+        arg++;
+    }
+}
+
+/* Parse a command line buffer into arguments */
+static int
+ParseCommandLine(char *cmdline, char **argv)
+{
+    char *bufp;
+    char *lastp = NULL;
+    int argc, last_argc;
+
+    argc = last_argc = 0;
+    for (bufp = cmdline; *bufp;) {
+        /* Skip leading whitespace */
+        while (isspace(*bufp)) {
+            ++bufp;
+        }
+        /* Skip over argument */
+        if (*bufp == '"') {
+            ++bufp;
+            if (*bufp) {
+                if (argv) {
+                    argv[argc] = bufp;
+                }
+                ++argc;
+            }
+            /* Skip over word */
+            lastp = bufp;
+            while (*bufp && (*bufp != '"' || *lastp == '\\')) {
+                lastp = bufp;
+                ++bufp;
+            }
+        } else {
+            if (*bufp) {
+                if (argv) {
+                    argv[argc] = bufp;
+                }
+                ++argc;
+            }
+            /* Skip over word */
+            while (*bufp && !isspace(*bufp)) {
+                ++bufp;
+            }
+        }
+        if (*bufp) {
+            if (argv) {
+                *bufp = '\0';
+            }
+            ++bufp;
+        }
+
+        /* Strip out \ from \" sequences */
+        if (argv && last_argc != argc) {
+            UnEscapeQuotes(argv[last_argc]);
+        }
+        last_argc = argc;
+    }
+    if (argv) {
+        argv[argc] = NULL;
+    }
+    return (argc);
+}
+
+/* Show an error message */
+static void
+ShowError(const char *title, const char *message)
+{
+/* If USE_MESSAGEBOX is defined, you need to link with user32.lib */
+#ifdef USE_MESSAGEBOX
+    MessageBox(NULL, message, title, MB_ICONEXCLAMATION | MB_OK);
+#else
+    fprintf(stderr, "%s: %s\n", title, message);
+#endif
+}
+
+/* Pop up an out of memory message, returns to Windows */
+static BOOL
+OutOfMemory(void)
+{
+    ShowError("Fatal Error", "Out of memory - aborting");
+    return FALSE;
+}
+
+#if defined(_MSC_VER) && !defined(_WIN32_WCE)
+/* The VC++ compiler needs main defined */
+#define console_main main
+#endif
+
+/* This is where execution begins [console apps] */
+int
+console_main(int argc, char *argv[])
+{
+    int status;
+
+    /* Run the application main() code */
+    status = SDL_main(argc, argv);
+
+    /* Exit cleanly, calling atexit() functions */
+    exit(status);
+
+    /* Hush little compiler, don't you cry... */
+    return 0;
+}
+
+/* This is where execution begins [windowed apps] */
+int WINAPI
+WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPTSTR szCmdLine, int sw)
+{
+    char **argv;
+    int argc;
+    char *cmdline;
+#ifdef _WIN32_WCE
+    wchar_t *bufp;
+    int nLen;
+#else
+    char *bufp;
+    size_t nLen;
+#endif
+
+#ifdef _WIN32_WCE
+    nLen = wcslen(szCmdLine) + 128 + 1;
+    bufp = SDL_stack_alloc(wchar_t, nLen * 2);
+    wcscpy(bufp, TEXT("\""));
+    GetModuleFileName(NULL, bufp + 1, 128 - 3);
+    wcscpy(bufp + wcslen(bufp), TEXT("\" "));
+    wcsncpy(bufp + wcslen(bufp), szCmdLine, nLen - wcslen(bufp));
+    nLen = wcslen(bufp) + 1;
+    cmdline = SDL_stack_alloc(char, nLen);
+    if (cmdline == NULL) {
+        return OutOfMemory();
+    }
+    WideCharToMultiByte(CP_ACP, 0, bufp, -1, cmdline, nLen, NULL, NULL);
+#else
+    /* Grab the command line */
+    bufp = GetCommandLine();
+    nLen = SDL_strlen(bufp) + 1;
+    cmdline = SDL_stack_alloc(char, nLen);
+    if (cmdline == NULL) {
+        return OutOfMemory();
+    }
+    SDL_strlcpy(cmdline, bufp, nLen);
+#endif
+
+    /* Parse it into argv and argc */
+    argc = ParseCommandLine(cmdline, NULL);
+    argv = SDL_stack_alloc(char *, argc + 1);
+    if (argv == NULL) {
+        return OutOfMemory();
+    }
+    ParseCommandLine(cmdline, argv);
+
+    /* Run the main program */
+    console_main(argc, argv);
+
+    /* Hush little compiler, don't you cry... */
+    return 0;
+}
+
+/* vi: set ts=4 sw=4 expandtab: */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/windows/version.rc	Thu Jan 20 18:04:05 2011 -0800
@@ -0,0 +1,38 @@
+
+#include "winresrc.h"
+
+LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Version
+//
+
+VS_VERSION_INFO VERSIONINFO
+ FILEVERSION 1,3,0,0
+ PRODUCTVERSION 1,3,0,0
+ FILEFLAGSMASK 0x3fL
+ FILEFLAGS 0x0L
+ FILEOS 0x40004L
+ FILETYPE 0x2L
+ FILESUBTYPE 0x0L
+BEGIN
+    BLOCK "StringFileInfo"
+    BEGIN
+        BLOCK "040904b0"
+        BEGIN
+            VALUE "CompanyName", "\0"
+            VALUE "FileDescription", "SDL\0"
+            VALUE "FileVersion", "1, 3, 0, 0\0"
+            VALUE "InternalName", "SDL\0"
+            VALUE "LegalCopyright", "Copyright  2009 Sam Lantinga\0"
+            VALUE "OriginalFilename", "SDL.dll\0"
+            VALUE "ProductName", "Simple DirectMedia Layer\0"
+            VALUE "ProductVersion", "1, 3, 0, 0\0"
+        END
+    END
+    BLOCK "VarFileInfo"
+    BEGIN
+        VALUE "Translation", 0x409, 1200
+    END
+END
--- a/src/stdlib/SDL_getenv.c	Thu Jan 20 17:33:06 2011 -0800
+++ b/src/stdlib/SDL_getenv.c	Thu Jan 20 18:04:05 2011 -0800
@@ -25,7 +25,7 @@
 
 #ifndef HAVE_GETENV
 
-#if defined(__WIN32__) && !defined(_WIN32_WCE)
+#if defined(__WINDOWS__) && !defined(_WIN32_WCE)
 
 #define WIN32_LEAN_AND_MEAN
 #include <windows.h>
@@ -163,7 +163,7 @@
     return value;
 }
 
-#endif /* __WIN32__ */
+#endif /* __WINDOWS__ */
 
 #endif /* !HAVE_GETENV */
 
--- a/src/thread/SDL_thread_c.h	Thu Jan 20 17:33:06 2011 -0800
+++ b/src/thread/SDL_thread_c.h	Thu Jan 20 18:04:05 2011 -0800
@@ -35,8 +35,8 @@
 #include "pthread/SDL_systhread_c.h"
 #elif SDL_THREAD_SPROC
 #include "irix/SDL_systhread_c.h"
-#elif SDL_THREAD_WIN32
-#include "win32/SDL_systhread_c.h"
+#elif SDL_THREAD_WINDOWS
+#include "windows/SDL_systhread_c.h"
 #elif SDL_THREAD_NDS
 #include "nds/SDL_systhread_c.h"
 #else
--- a/src/thread/win32/SDL_sysmutex.c	Thu Jan 20 17:33:06 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,102 +0,0 @@
-/*
-    SDL - Simple DirectMedia Layer
-    Copyright (C) 1997-2010 Sam Lantinga
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Lesser General Public
-    License as published by the Free Software Foundation; either
-    version 2.1 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Lesser General Public License for more details.
-
-    You should have received a copy of the GNU Lesser General Public
-    License along with this library; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-
-    Sam Lantinga
-    slouken@libsdl.org
-*/
-#include "SDL_config.h"
-
-/* Mutex functions using the Win32 API */
-
-#define WIN32_LEAN_AND_MEAN
-#include <windows.h>
-
-#include "SDL_mutex.h"
-
-
-struct SDL_mutex
-{
-    HANDLE id;
-};
-
-/* Create a mutex */
-SDL_mutex *
-SDL_CreateMutex(void)
-{
-    SDL_mutex *mutex;
-
-    /* Allocate mutex memory */
-    mutex = (SDL_mutex *) SDL_malloc(sizeof(*mutex));
-    if (mutex) {
-        /* Create the mutex, with initial value signaled */
-        mutex->id = CreateMutex(NULL, FALSE, NULL);
-        if (!mutex->id) {
-            SDL_SetError("Couldn't create mutex");
-            SDL_free(mutex);
-            mutex = NULL;
-        }
-    } else {
-        SDL_OutOfMemory();
-    }
-    return (mutex);
-}
-
-/* Free the mutex */
-void
-SDL_DestroyMutex(SDL_mutex * mutex)
-{
-    if (mutex) {
-        if (mutex->id) {
-            CloseHandle(mutex->id);
-            mutex->id = 0;
-        }
-        SDL_free(mutex);
-    }
-}
-
-/* Lock the mutex */
-int
-SDL_mutexP(SDL_mutex * mutex)
-{
-    if (mutex == NULL) {
-        SDL_SetError("Passed a NULL mutex");
-        return -1;
-    }
-    if (WaitForSingleObject(mutex->id, INFINITE) == WAIT_FAILED) {
-        SDL_SetError("Couldn't wait on mutex");
-        return -1;
-    }
-    return (0);
-}
-
-/* Unlock the mutex */
-int
-SDL_mutexV(SDL_mutex * mutex)
-{
-    if (mutex == NULL) {
-        SDL_SetError("Passed a NULL mutex");
-        return -1;
-    }
-    if (ReleaseMutex(mutex->id) == FALSE) {
-        SDL_SetError("Couldn't release mutex");
-        return -1;
-    }
-    return (0);
-}
-
-/* vi: set ts=4 sw=4 expandtab: */
--- a/src/thread/win32/SDL_syssem.c	Thu Jan 20 17:33:06 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,174 +0,0 @@
-/*
-    SDL - Simple DirectMedia Layer
-    Copyright (C) 1997-2010 Sam Lantinga
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Lesser General Public
-    License as published by the Free Software Foundation; either
-    version 2.1 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Lesser General Public License for more details.
-
-    You should have received a copy of the GNU Lesser General Public
-    License along with this library; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-
-    Sam Lantinga
-    slouken@libsdl.org
-*/
-#include "SDL_config.h"
-
-/* Semaphore functions using the Win32 API */
-
-#define WIN32_LEAN_AND_MEAN
-#include <windows.h>
-
-#include "SDL_thread.h"
-#if defined(_WIN32_WCE) && (_WIN32_WCE < 300)
-#include "win_ce_semaphore.h"
-#endif
-
-
-struct SDL_semaphore
-{
-#if defined(_WIN32_WCE) && (_WIN32_WCE < 300)
-    SYNCHHANDLE id;
-#else
-    HANDLE id;
-#endif
-    LONG volatile count;
-};
-
-
-/* Create a semaphore */
-SDL_sem *
-SDL_CreateSemaphore(Uint32 initial_value)
-{
-    SDL_sem *sem;
-
-    /* Allocate sem memory */
-    sem = (SDL_sem *) SDL_malloc(sizeof(*sem));
-    if (sem) {
-        /* Create the semaphore, with max value 32K */
-#if defined(_WIN32_WCE) && (_WIN32_WCE < 300)
-        sem->id = CreateSemaphoreCE(NULL, initial_value, 32 * 1024, NULL);
-#else
-        sem->id = CreateSemaphore(NULL, initial_value, 32 * 1024, NULL);
-#endif
-        sem->count = initial_value;
-        if (!sem->id) {
-            SDL_SetError("Couldn't create semaphore");
-            SDL_free(sem);
-            sem = NULL;
-        }
-    } else {
-        SDL_OutOfMemory();
-    }
-    return (sem);
-}
-
-/* Free the semaphore */
-void
-SDL_DestroySemaphore(SDL_sem * sem)
-{
-    if (sem) {
-        if (sem->id) {
-#if defined(_WIN32_WCE) && (_WIN32_WCE < 300)
-            CloseSynchHandle(sem->id);
-#else
-            CloseHandle(sem->id);
-#endif
-            sem->id = 0;
-        }
-        SDL_free(sem);
-    }
-}
-
-int
-SDL_SemWaitTimeout(SDL_sem * sem, Uint32 timeout)
-{
-    int retval;
-    DWORD dwMilliseconds;
-
-    if (!sem) {
-        SDL_SetError("Passed a NULL sem");
-        return -1;
-    }
-
-    if (timeout == SDL_MUTEX_MAXWAIT) {
-        dwMilliseconds = INFINITE;
-    } else {
-        dwMilliseconds = (DWORD) timeout;
-    }
-#if defined(_WIN32_WCE) && (_WIN32_WCE < 300)
-    switch (WaitForSemaphoreCE(sem->id, dwMilliseconds)) {
-#else
-    switch (WaitForSingleObject(sem->id, dwMilliseconds)) {
-#endif
-    case WAIT_OBJECT_0:
-        InterlockedDecrement(&sem->count);
-        retval = 0;
-        break;
-    case WAIT_TIMEOUT:
-        retval = SDL_MUTEX_TIMEDOUT;
-        break;
-    default:
-        SDL_SetError("WaitForSingleObject() failed");
-        retval = -1;
-        break;
-    }
-    return retval;
-}
-
-int
-SDL_SemTryWait(SDL_sem * sem)
-{
-    return SDL_SemWaitTimeout(sem, 0);
-}
-
-int
-SDL_SemWait(SDL_sem * sem)
-{
-    return SDL_SemWaitTimeout(sem, SDL_MUTEX_MAXWAIT);
-}
-
-/* Returns the current count of the semaphore */
-Uint32
-SDL_SemValue(SDL_sem * sem)
-{
-    if (!sem) {
-        SDL_SetError("Passed a NULL sem");
-        return 0;
-    }
-    return (Uint32)sem->count;
-}
-
-int
-SDL_SemPost(SDL_sem * sem)
-{
-    if (!sem) {
-        SDL_SetError("Passed a NULL sem");
-        return -1;
-    }
-    /* Increase the counter in the first place, because
-     * after a successful release the semaphore may
-     * immediately get destroyed by another thread which
-     * is waiting for this semaphore.
-     */
-    InterlockedIncrement(&sem->count);
-#if defined(_WIN32_WCE) && (_WIN32_WCE < 300)
-    if (ReleaseSemaphoreCE(sem->id, 1, NULL) == FALSE) {
-#else
-    if (ReleaseSemaphore(sem->id, 1, NULL) == FALSE) {
-#endif
-        InterlockedDecrement(&sem->count);      /* restore */
-        SDL_SetError("ReleaseSemaphore() failed");
-        return -1;
-    }
-    return 0;
-}
-
-/* vi: set ts=4 sw=4 expandtab: */
--- a/src/thread/win32/SDL_systhread.c	Thu Jan 20 17:33:06 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,167 +0,0 @@
-/*
-    SDL - Simple DirectMedia Layer
-    Copyright (C) 1997-2010 Sam Lantinga
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Lesser General Public
-    License as published by the Free Software Foundation; either
-    version 2.1 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Lesser General Public License for more details.
-
-    You should have received a copy of the GNU Lesser General Public
-    License along with this library; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-
-    Sam Lantinga
-    slouken@libsdl.org
-*/
-#include "SDL_config.h"
-
-/* Win32 thread management routines for SDL */
-
-#define WIN32_LEAN_AND_MEAN
-#include <windows.h>
-
-#include "SDL_thread.h"
-#include "../SDL_thread_c.h"
-#include "../SDL_systhread.h"
-
-#ifndef SDL_PASSED_BEGINTHREAD_ENDTHREAD
-#ifndef _WIN32_WCE
-/* We'll use the C library from this DLL */
-#include <process.h>
-#endif
-
-#if __GNUC__
-typedef uintptr_t (__cdecl * pfnSDL_CurrentBeginThread) (void *, unsigned,
-                                                             unsigned
-                                                             (__stdcall *
-                                                              func) (void *),
-                                                             void *arg,
-                                                             unsigned,
-                                                             unsigned
-                                                             *threadID);
-typedef void (__cdecl * pfnSDL_CurrentEndThread) (unsigned code);
-#elif defined(__WATCOMC__)
-/* This is for Watcom targets except OS2 */
-#if __WATCOMC__ < 1240
-#define __watcall
-#endif
-typedef unsigned long (__watcall * pfnSDL_CurrentBeginThread) (void *,
-                                                               unsigned,
-                                                               unsigned
-                                                               (__stdcall *
-                                                                func) (void
-                                                                       *),
-                                                               void *arg,
-                                                               unsigned,
-                                                               unsigned
-                                                               *threadID);
-typedef void (__watcall * pfnSDL_CurrentEndThread) (unsigned code);
-#else
-typedef uintptr_t(__cdecl * pfnSDL_CurrentBeginThread) (void *, unsigned,
-                                                        unsigned (__stdcall *
-                                                                  func) (void
-                                                                         *),
-                                                        void *arg, unsigned,
-                                                        unsigned *threadID);
-typedef void (__cdecl * pfnSDL_CurrentEndThread) (unsigned code);
-#endif
-#endif /* !SDL_PASSED_BEGINTHREAD_ENDTHREAD */
-
-
-typedef struct ThreadStartParms
-{
-    void *args;
-    pfnSDL_CurrentEndThread pfnCurrentEndThread;
-} tThreadStartParms, *pThreadStartParms;
-
-static DWORD __stdcall
-RunThread(void *data)
-{
-    pThreadStartParms pThreadParms = (pThreadStartParms) data;
-    pfnSDL_CurrentEndThread pfnCurrentEndThread = NULL;
-
-    // Call the thread function!
-    SDL_RunThread(pThreadParms->args);
-
-    // Get the current endthread we have to use!
-    if (pThreadParms) {
-        pfnCurrentEndThread = pThreadParms->pfnCurrentEndThread;
-        SDL_free(pThreadParms);
-    }
-    // Call endthread!
-    if (pfnCurrentEndThread)
-        (*pfnCurrentEndThread) (0);
-    return (0);
-}
-
-#ifdef SDL_PASSED_BEGINTHREAD_ENDTHREAD
-int
-SDL_SYS_CreateThread(SDL_Thread * thread, void *args,
-                     pfnSDL_CurrentBeginThread pfnBeginThread,
-                     pfnSDL_CurrentEndThread pfnEndThread)
-{
-#else
-int
-SDL_SYS_CreateThread(SDL_Thread * thread, void *args)
-{
-#ifdef _WIN32_WCE
-    pfnSDL_CurrentBeginThread pfnBeginThread = NULL;