From 3795a5cb6150e5be7521a30b70ec9f6fc30a57a8 Mon Sep 17 00:00:00 2001 From: Tor Lillqvist Date: Tue, 30 Jan 2007 23:49:39 +0000 Subject: [PATCH] New debugging function. (_gdk_input_wintab_init_check): Call it when 2007-01-31 Tor Lillqvist * gdk/win32/gdkinput-win32.c (print_cursor): New debugging function. (_gdk_input_wintab_init_check): Call it when debugging output is requested. (_gdk_input_wintab_init_check): Skip duplicated cursors for Wacom tablets. The Wacom driver reports duplicated cursors with physid==0. Fix verified by Robert *gren. (Should be U+00D6 there, but svn won't let me.) svn path=/trunk/; revision=17241 --- ChangeLog | 10 +++ gdk/win32/gdkinput-win32.c | 148 ++++++++++++++++++++++++++++++++++++- 2 files changed, 157 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 7b26372126..e5869e6cd8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2007-01-31 Tor Lillqvist + + * gdk/win32/gdkinput-win32.c (print_cursor): New debugging + function. + (_gdk_input_wintab_init_check): Call it when debugging output is + requested. + (_gdk_input_wintab_init_check): Skip duplicated cursors for Wacom + tablets. The Wacom driver reports duplicated cursors with + physid==0. Fix verified by Robert Ă–gren. + 2007-01-30 Felix Riemann * modules/printbackends/file/gtkprintbackendfile.c: diff --git a/gdk/win32/gdkinput-win32.c b/gdk/win32/gdkinput-win32.c index ad6802949c..dbfe42fdba 100644 --- a/gdk/win32/gdkinput-win32.c +++ b/gdk/win32/gdkinput-win32.c @@ -189,6 +189,135 @@ print_lc(LOGCONTEXT *lc) lc->lcSysSensX / 65536., lc->lcSysSensY / 65536.); } +static void +print_cursor (int index) +{ + int size; + int i; + char *name; + BOOL active; + WTPKT wtpkt; + BYTE buttons; + BYTE buttonbits; + char *btnnames; + char *p; + BYTE buttonmap[32]; + BYTE sysbtnmap[32]; + BYTE npbutton; + UINT npbtnmarks[2]; + UINT *npresponse; + BYTE tpbutton; + UINT tpbtnmarks[2]; + UINT *tpresponse; + DWORD physid; + UINT mode; + UINT minpktdata; + UINT minbuttons; + UINT capabilities; + + size = (*p_WTInfoA) (WTI_CURSORS + index, CSR_NAME, NULL); + name = g_malloc (size + 1); + (*p_WTInfoA) (WTI_CURSORS + index, CSR_NAME, name); + g_print ("NAME: %s\n", name); + (*p_WTInfoA) (WTI_CURSORS + index, CSR_ACTIVE, &active); + g_print ("ACTIVE: %s\n", active ? "YES" : "NO"); + (*p_WTInfoA) (WTI_CURSORS + index, CSR_PKTDATA, &wtpkt); + g_print ("PKTDATA: %#x:", (guint) wtpkt); +#define BIT(x) if (wtpkt & PK_##x) g_print (" " #x) + BIT (CONTEXT); + BIT (STATUS); + BIT (TIME); + BIT (CHANGED); + BIT (SERIAL_NUMBER); + BIT (BUTTONS); + BIT (X); + BIT (Y); + BIT (Z); + BIT (NORMAL_PRESSURE); + BIT (TANGENT_PRESSURE); + BIT (ORIENTATION); + BIT (ROTATION); +#undef BIT + g_print ("\n"); + (*p_WTInfoA) (WTI_CURSORS + index, CSR_BUTTONS, &buttons); + g_print ("BUTTONS: %d\n", buttons); + (*p_WTInfoA) (WTI_CURSORS + index, CSR_BUTTONBITS, &buttonbits); + g_print ("BUTTONBITS: %d\n", buttonbits); + size = (*p_WTInfoA) (WTI_CURSORS + index, CSR_BTNNAMES, NULL); + g_print ("BTNNAMES:"); + if (size > 0) + { + btnnames = g_malloc (size + 1); + (*p_WTInfoA) (WTI_CURSORS + index, CSR_BTNNAMES, btnnames); + p = btnnames; + while (*p) + { + g_print (" %s", p); + p += strlen (p) + 1; + } + } + g_print ("\n"); + (*p_WTInfoA) (WTI_CURSORS + index, CSR_BUTTONMAP, buttonmap); + g_print ("BUTTONMAP:"); + for (i = 0; i < buttons; i++) + g_print (" %d", buttonmap[i]); + g_print ("\n"); + (*p_WTInfoA) (WTI_CURSORS + index, CSR_SYSBTNMAP, sysbtnmap); + g_print ("SYSBTNMAP:"); + for (i = 0; i < buttons; i++) + g_print (" %d", sysbtnmap[i]); + g_print ("\n"); + (*p_WTInfoA) (WTI_CURSORS + index, CSR_NPBUTTON, &npbutton); + g_print ("NPBUTTON: %d\n", npbutton); + (*p_WTInfoA) (WTI_CURSORS + index, CSR_NPBTNMARKS, npbtnmarks); + g_print ("NPBTNMARKS: %d %d\n", npbtnmarks[0], npbtnmarks[1]); + size = (*p_WTInfoA) (WTI_CURSORS + index, CSR_NPRESPONSE, NULL); + g_print ("NPRESPONSE:"); + if (size > 0) + { + npresponse = g_malloc (size); + (*p_WTInfoA) (WTI_CURSORS + index, CSR_NPRESPONSE, npresponse); + for (i = 0; i < size / sizeof (UINT); i++) + g_print (" %d", npresponse[i]); + } + g_print ("\n"); + (*p_WTInfoA) (WTI_CURSORS + index, CSR_TPBUTTON, &tpbutton); + g_print ("TPBUTTON: %d\n", tpbutton); + (*p_WTInfoA) (WTI_CURSORS + index, CSR_TPBTNMARKS, tpbtnmarks); + g_print ("TPBTNMARKS: %d %d\n", tpbtnmarks[0], tpbtnmarks[1]); + size = (*p_WTInfoA) (WTI_CURSORS + index, CSR_TPRESPONSE, NULL); + g_print ("TPRESPONSE:"); + if (size > 0) + { + tpresponse = g_malloc (size); + (*p_WTInfoA) (WTI_CURSORS + index, CSR_TPRESPONSE, tpresponse); + for (i = 0; i < size / sizeof (UINT); i++) + g_print (" %d", tpresponse[i]); + } + g_print ("\n"); + (*p_WTInfoA) (WTI_CURSORS + index, CSR_PHYSID, &physid); + g_print ("PHYSID: %#x\n", (guint) physid); + (*p_WTInfoA) (WTI_CURSORS + index, CSR_CAPABILITIES, &capabilities); + g_print ("CAPABILITIES: %#x:", capabilities); +#define BIT(x) if (capabilities & CRC_##x) g_print (" " #x) + BIT (MULTIMODE); + BIT (AGGREGATE); + BIT (INVERT); +#undef BIT + g_print ("\n"); + if (capabilities & CRC_MULTIMODE) + { + (*p_WTInfoA) (WTI_CURSORS + index, CSR_MODE, &mode); + g_print ("MODE: %d\n", mode); + } + if (capabilities & CRC_AGGREGATE) + { + (*p_WTInfoA) (WTI_CURSORS + index, CSR_MINPKTDATA, &minpktdata); + g_print ("MINPKTDATA: %d\n", minpktdata); + (*p_WTInfoA) (WTI_CURSORS + index, CSR_MINBUTTONS, &minbuttons); + g_print ("MINBUTTONS: %d\n", minbuttons); + } +} #endif void @@ -201,6 +330,7 @@ _gdk_input_wintab_init_check (void) HCTX *hctx; UINT ndevices, ncursors, ncsrtypes, firstcsr, hardware; BOOL active; + DWORD physid; AXIS axis_x, axis_y, axis_npressure, axis_or[3]; int i, k; int devix, cursorix; @@ -353,10 +483,26 @@ _gdk_input_wintab_init_check (void) GDK_NOTE (INPUT, g_print("Whoops, no queue size could be set\n")); for (cursorix = firstcsr; cursorix < firstcsr + ncsrtypes; cursorix++) { +#ifdef DEBUG_WINTAB + GDK_NOTE (INPUT, (g_print("Cursor %d:\n", cursorix), print_cursor (cursorix))); +#endif active = FALSE; (*p_WTInfoA) (WTI_CURSORS + cursorix, CSR_ACTIVE, &active); if (!active) continue; + + /* Wacom tablets seem to report cursors corresponding to + * nonexistent pens or pucks. At least my ArtPad II reports + * six cursors: a puck, pressure stylus and eraser stylus, + * and then the same three again. I only have a + * pressure-sensitive pen. The puck instances, and the + * second instances of the styluses report physid zero. So + * at least for Wacom, skip cursors with physid zero. + */ + (*p_WTInfoA) (WTI_CURSORS + cursorix, CSR_PHYSID, &physid); + if (strcmp (devname, "WACOM Tablet") == 0 && physid == 0) + continue; + gdkdev = g_object_new (GDK_TYPE_DEVICE, NULL); (*p_WTInfoA) (WTI_CURSORS + cursorix, CSR_NAME, csrname); gdkdev->info.name = g_strconcat (devname, " ", csrname, NULL); @@ -1087,8 +1233,8 @@ _gdk_input_grab_pointer (GdkWindow *window, else { x_grab_window = NULL; - tmp_list = _gdk_input_devices; #if 0 + tmp_list = _gdk_input_devices; while (tmp_list) { gdkdev = (GdkDevicePrivate *)tmp_list->data;