Dynamically load wintab32.dll
--HG-- extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%403177
This commit is contained in:
parent
d9f99f5203
commit
a13b4b8736
9 changed files with 60 additions and 11 deletions
|
@ -136,7 +136,9 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
|||
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;
|
||||
}
|
||||
|
|
|
@ -55,7 +55,8 @@ WIN_InitKeyboard(_THIS)
|
|||
/* 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 <sdl@libsdl.org>, 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 <sdl@libsdl.org>, 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 @@ WIN_InitKeyboard(_THIS)
|
|||
}
|
||||
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 <sdl@libsdl.org>, 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 <sdl@libsdl.org>, including a description of your keyboard hardware.\n");
|
||||
#endif
|
||||
for (i = 0; i < SDL_arraysize(keypad_scancodes); ++i) {
|
||||
keypad_scancodes[i] =
|
||||
|
|
|
@ -154,7 +154,7 @@ WIN_InitMouse(_THIS)
|
|||
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 @@ WIN_InitMouse(_THIS)
|
|||
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);
|
||||
|
|
|
@ -60,6 +60,9 @@ WIN_DeleteDevice(SDL_VideoDevice * device)
|
|||
FreeLibrary(data->d3dDLL);
|
||||
}
|
||||
#endif
|
||||
if (data->wintabDLL) {
|
||||
FreeLibrary(data->wintabDLL);
|
||||
}
|
||||
SDL_free(device->driverdata);
|
||||
SDL_free(device);
|
||||
}
|
||||
|
@ -104,6 +107,32 @@ WIN_CreateDevice(int devindex)
|
|||
}
|
||||
#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;
|
||||
|
|
|
@ -66,6 +66,15 @@ typedef struct SDL_VideoData
|
|||
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;
|
||||
|
|
|
@ -148,6 +148,7 @@ SetupWindowData(_THIS, SDL_Window * window, HWND hwnd, SDL_bool created)
|
|||
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 @@ WIN_CreateWindow(_THIS, SDL_Window * window)
|
|||
}
|
||||
|
||||
/* 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 @@ WIN_CreateWindow(_THIS, SDL_Window * window)
|
|||
}
|
||||
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 @@ WIN_SetWindowGrab(_THIS, SDL_Window * window)
|
|||
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 @@ WIN_DestroyWindow(_THIS, SDL_Window * window)
|
|||
#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);
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
/* *INDENT-OFF* */
|
||||
/* -------------------------------- pktdef.h -------------------------------- */
|
||||
/* Combined 16 & 32-bit version. */
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
/* *INDENT-OFF* */
|
||||
/* -------------------------------- wintab.h -------------------------------- */
|
||||
/* Combined 16 & 32-bit version. */
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
/* *INDENT-OFF* */
|
||||
/* ------------------------------- wintabx.h -------------------------------- */
|
||||
/* Combined 16 & 32-bit version. */
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue