diff src/video/win32/SDL_win32video.c @ 2726:f23ebf1ddac4

Dynamically load wintab32.dll
author Sam Lantinga <slouken@libsdl.org>
date Tue, 26 Aug 2008 06:03:48 +0000
parents 0e2b65f32298
children 2768bd7281e0
line wrap: on
line diff
--- a/src/video/win32/SDL_win32video.c	Tue Aug 26 05:57:41 2008 +0000
+++ b/src/video/win32/SDL_win32video.c	Tue Aug 26 06:03:48 2008 +0000
@@ -60,6 +60,9 @@
         FreeLibrary(data->d3dDLL);
     }
 #endif
+    if (data->wintabDLL) {
+        FreeLibrary(data->wintabDLL);
+    }
     SDL_free(device->driverdata);
     SDL_free(device);
 }
@@ -104,6 +107,32 @@
     }
 #endif /* SDL_VIDEO_RENDER_D3D */
 
+    data->wintabDLL = LoadLibrary(TEXT("WINTAB32.DLL"));
+    if (data->wintabDLL) {
+#define PROCNAME(X) #X
+        data->WTInfo =
+            (UINT(*)(UINT, UINT, LPVOID)) GetProcAddress(data->wintabDLL,
+                                                         PROCNAME(WTInfo));
+        data->WTOpen =
+            (HCTX(*)(HWND, LPLOGCONTEXT, BOOL)) GetProcAddress(data->
+                                                               wintabDLL,
+                                                               PROCNAME
+                                                               (WTOpen));
+        data->WTPacket =
+            (int (*)(HCTX, UINT, LPVOID)) GetProcAddress(data->wintabDLL,
+                                                         PROCNAME(WTPacket));
+        data->WTClose =
+            (BOOL(*)(HCTX)) GetProcAddress(data->wintabDLL,
+                                           PROCNAME(WTClose));
+#undef PROCNAME
+
+        if (!data->WTInfo || !data->WTOpen || !data->WTPacket
+            || !data->WTClose) {
+            FreeLibrary(data->wintabDLL);
+            data->wintabDLL = NULL;
+        }
+    }
+
     /* Set the function pointers */
     device->VideoInit = WIN_VideoInit;
     device->VideoQuit = WIN_VideoQuit;