# HG changeset patch # User Sam Lantinga # Date 1219730628 0 # Node ID f23ebf1ddac4b2f684b4f3adda85a667d2ac8cc3 # Parent 6ce6d56b63bf2beb7c9da0a142fa7d326b01f302 Dynamically load wintab32.dll diff -r 6ce6d56b63bf -r f23ebf1ddac4 src/video/win32/SDL_win32events.c --- a/src/video/win32/SDL_win32events.c Tue Aug 26 05:57:41 2008 +0000 +++ b/src/video/win32/SDL_win32events.c Tue Aug 26 06:03:48 2008 +0000 @@ -136,7 +136,9 @@ case WT_PACKET: { /* if we receive such data we need to update the pressure */ - if (WTPacket((HCTX) lParam, wParam, &packet)) { + SDL_VideoData *videodata = data->videodata; + if (videodata->wintabDLL + && videodata->WTPacket((HCTX) lParam, wParam, &packet)) { SDL_ChangeEnd(tablet, (int) packet.pkCursor); pressure = (int) packet.pkNormalPressure; } diff -r 6ce6d56b63bf -r f23ebf1ddac4 src/video/win32/SDL_win32keyboard.c --- a/src/video/win32/SDL_win32keyboard.c Tue Aug 26 05:57:41 2008 +0000 +++ b/src/video/win32/SDL_win32keyboard.c Tue Aug 26 06:03:48 2008 +0000 @@ -55,7 +55,8 @@ /* Make sure the alpha scancodes are correct. T isn't usually remapped */ if (MapVirtualKey('T', MAPVK_VK_TO_VSC) != alpha_scancodes['T' - 'A']) { #if 0 - printf("Fixing alpha scancode map, assuming US QWERTY layout!\nPlease send the following 26 lines of output to the SDL mailing list , including a description of your keyboard hardware.\n"); + printf + ("Fixing alpha scancode map, assuming US QWERTY layout!\nPlease send the following 26 lines of output to the SDL mailing list , including a description of your keyboard hardware.\n"); #endif for (i = 0; i < SDL_arraysize(alpha_scancodes); ++i) { alpha_scancodes[i] = MapVirtualKey('A' + i, MAPVK_VK_TO_VSC); @@ -66,7 +67,8 @@ } if (MapVirtualKey(VK_NUMPAD0, MAPVK_VK_TO_VSC) != keypad_scancodes[0]) { #if 0 - printf("Fixing keypad scancode map!\nPlease send the following 10 lines of output to the SDL mailing list , including a description of your keyboard hardware.\n"); + printf + ("Fixing keypad scancode map!\nPlease send the following 10 lines of output to the SDL mailing list , including a description of your keyboard hardware.\n"); #endif for (i = 0; i < SDL_arraysize(keypad_scancodes); ++i) { keypad_scancodes[i] = diff -r 6ce6d56b63bf -r f23ebf1ddac4 src/video/win32/SDL_win32mouse.c --- a/src/video/win32/SDL_win32mouse.c Tue Aug 26 05:57:41 2008 +0000 +++ b/src/video/win32/SDL_win32mouse.c Tue Aug 26 06:03:48 2008 +0000 @@ -154,7 +154,7 @@ l = SDL_strlen(device_name); /* we're checking if the device isn't by any chance a tablet */ - if (tablet == -1) { + if (data->wintabDLL && tablet == -1) { for (j = 0; j < l - 5; ++j) { for (k = 0; k < 5; ++k) { if (tab[k] != @@ -173,8 +173,8 @@ if (tablet == index) { AXIS pressure; int cursors; - WTInfo(WTI_DEVICES, DVC_NPRESSURE, &pressure); - WTInfo(WTI_DEVICES, DVC_NCSRTYPES, &cursors); + data->WTInfo(WTI_DEVICES, DVC_NPRESSURE, &pressure); + data->WTInfo(WTI_DEVICES, DVC_NCSRTYPES, &cursors); data->mouse = SDL_AddMouse(&mouse, index, device_name, pressure.axMax, pressure.axMin, cursors); diff -r 6ce6d56b63bf -r f23ebf1ddac4 src/video/win32/SDL_win32video.c --- 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; diff -r 6ce6d56b63bf -r f23ebf1ddac4 src/video/win32/SDL_win32video.h --- a/src/video/win32/SDL_win32video.h Tue Aug 26 05:57:41 2008 +0000 +++ b/src/video/win32/SDL_win32video.h Tue Aug 26 06:03:48 2008 +0000 @@ -66,6 +66,15 @@ HANDLE d3dDLL; IDirect3D9 *d3d; #endif +/* *INDENT-OFF* */ + /* Function pointers for the Wacom API */ + HANDLE wintabDLL; + UINT (*WTInfo) (UINT, UINT, LPVOID); + HCTX (*WTOpen) (HWND, LPLOGCONTEXT, BOOL); + int (*WTPacket) (HCTX, UINT, LPVOID); + BOOL (*WTClose) (HCTX); +/* *INDENT-ON* */ + int mouse; int keyboard; SDL_scancode *key_layout; diff -r 6ce6d56b63bf -r f23ebf1ddac4 src/video/win32/SDL_win32window.c --- a/src/video/win32/SDL_win32window.c Tue Aug 26 05:57:41 2008 +0000 +++ b/src/video/win32/SDL_win32window.c Tue Aug 26 06:03:48 2008 +0000 @@ -148,6 +148,7 @@ int WIN_CreateWindow(_THIS, SDL_Window * window) { + SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata; RAWINPUTDEVICE Rid; AXIS TabX, TabY; LOGCONTEXT lc; @@ -205,15 +206,15 @@ } /* we're configuring the tablet data. See Wintab reference for more info */ - if (WTInfo(WTI_DEFSYSCTX, 0, &lc) != 0) { + if (videodata->wintabDLL && videodata->WTInfo(WTI_DEFSYSCTX, 0, &lc) != 0) { lc.lcPktData = PACKETDATA; lc.lcPktMode = PACKETMODE; lc.lcOptions |= CXO_MESSAGES; lc.lcOptions |= CXO_SYSTEM; lc.lcMoveMask = PACKETDATA; lc.lcBtnDnMask = lc.lcBtnUpMask = PACKETDATA; - WTInfo(WTI_DEVICES, DVC_X, &TabX); - WTInfo(WTI_DEVICES, DVC_Y, &TabY); + videodata->WTInfo(WTI_DEVICES, DVC_X, &TabX); + videodata->WTInfo(WTI_DEVICES, DVC_Y, &TabY); lc.lcInOrgX = 0; lc.lcInOrgY = 0; lc.lcInExtX = TabX.axMax; @@ -234,7 +235,7 @@ } g_hCtx = tmp_hctx; } - g_hCtx[window->id] = WTOpen(hwnd, &lc, TRUE); + g_hCtx[window->id] = videodata->WTOpen(hwnd, &lc, TRUE); } /* we're telling the window, we want it to report raw input events from mice */ @@ -438,6 +439,7 @@ void WIN_DestroyWindow(_THIS, SDL_Window * window) { + SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata; SDL_WindowData *data = (SDL_WindowData *) window->driverdata; if (data) { @@ -448,7 +450,9 @@ #endif ReleaseDC(data->hwnd, data->hdc); if (data->created) { - WTClose(g_hCtx[window->id]); + if (videodata->wintabDLL) { + videodata->WTClose(g_hCtx[window->id]); + } DestroyWindow(data->hwnd); } SDL_free(data); diff -r 6ce6d56b63bf -r f23ebf1ddac4 src/video/win32/wactab/pktdef.h --- a/src/video/win32/wactab/pktdef.h Tue Aug 26 05:57:41 2008 +0000 +++ b/src/video/win32/wactab/pktdef.h Tue Aug 26 06:03:48 2008 +0000 @@ -1,3 +1,4 @@ +/* *INDENT-OFF* */ /* -------------------------------- pktdef.h -------------------------------- */ /* Combined 16 & 32-bit version. */ diff -r 6ce6d56b63bf -r f23ebf1ddac4 src/video/win32/wactab/wintab.h --- a/src/video/win32/wactab/wintab.h Tue Aug 26 05:57:41 2008 +0000 +++ b/src/video/win32/wactab/wintab.h Tue Aug 26 06:03:48 2008 +0000 @@ -1,3 +1,4 @@ +/* *INDENT-OFF* */ /* -------------------------------- wintab.h -------------------------------- */ /* Combined 16 & 32-bit version. */ diff -r 6ce6d56b63bf -r f23ebf1ddac4 src/video/win32/wactab/wintabx.h --- a/src/video/win32/wactab/wintabx.h Tue Aug 26 05:57:41 2008 +0000 +++ b/src/video/win32/wactab/wintabx.h Tue Aug 26 06:03:48 2008 +0000 @@ -1,3 +1,4 @@ +/* *INDENT-OFF* */ /* ------------------------------- wintabx.h -------------------------------- */ /* Combined 16 & 32-bit version. */