[gtk+] win32: Fix tilt from Wintab devices
- From: Ignacio Casal Quinteiro <icq src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] win32: Fix tilt from Wintab devices
- Date: Tue, 22 Nov 2016 10:21:22 +0000 (UTC)
commit 9e3bd03d3ec1de295d2fb2e2eb7499b4d4851859
Author: Andrew Chadwick <a t chadwick gmail com>
Date: Sat Nov 19 18:34:29 2016 +0000
win32: Fix tilt from Wintab devices
Move the orientation sanity-checks into the packet decode func.
Rationale: the packet handling func may otherwise read beyond the end of
device->last_axis_data.
Also expand them to cope with my test Huion's weird reporting.
Also correct the azimuth angle to align with GDK's presentation.
Most importantly, fix annoying comment typo.
https://bugzilla.gnome.org/show_bug.cgi?id=774265
gdk/win32/gdkdevicemanager-win32.c | 34 +++++++++++++++++++++++++---------
1 files changed, 25 insertions(+), 9 deletions(-)
---
diff --git a/gdk/win32/gdkdevicemanager-win32.c b/gdk/win32/gdkdevicemanager-win32.c
index 9f1f391..f88dab7 100644
--- a/gdk/win32/gdkdevicemanager-win32.c
+++ b/gdk/win32/gdkdevicemanager-win32.c
@@ -613,17 +613,12 @@ wintab_init_check (GdkDeviceManagerWin32 *device_manager)
num_axes++;
}
- /* The wintab driver for the Wacom ArtPad II reports
- * PK_ORIENTATION in CSR_PKTDATA, but the tablet doesn't
- * actually sense tilt. Catch this by noticing that the
- * orientation axis's azimuth resolution is zero.
- */
- if ((device->pktdata & PK_ORIENTATION) && axis_or[0].axResolution == 0)
+ if (device->pktdata & PK_ORIENTATION)
{
device->orientation_axes[0] = axis_or[0];
device->orientation_axes[1] = axis_or[1];
- /* Wintab gives us aximuth and altitude, which
+ /* Wintab gives us azimuth and altitude, which
* we convert to x and y tilt in the -1000..1000 range
*/
_gdk_device_add_axis (GDK_DEVICE (device),
@@ -805,11 +800,32 @@ decode_tilt (gint *axis_data,
{
double az, el;
- /* As I don't have a tilt-sensing tablet,
- * I cannot test this code.
+ /* The wintab driver for the Wacom ArtPad II reports
+ * PK_ORIENTATION in CSR_PKTDATA, but the tablet doesn't
+ * actually sense tilt. Catch this by noticing that the
+ * orientation axis's azimuth resolution is zero.
+ *
+ * The same is true of the Huion H610PRO, but in this case
+ * it's the altitude resolution that's zero. GdkEvents with
+ * sensible tilts will need both, so only add the GDK tilt axes
+ * if both wintab axes are going to be well-behaved in use.
+ */
+ if ((axes == NULL) || (axis_data == NULL) ||
+ (axes[0].axResolution == 0) ||
+ (axes[1].axResolution == 0))
+ {
+ axis_data[0] = 0;
+ axis_data[1] = 0;
+ return;
+ }
+
+ /*
+ * Tested with a Wacom Intuos 5 touch M (PTH-650) + Wacom drivers 6.3.18-5.
+ * Wintab's reference angle leads gdk's by 90 degrees.
*/
az = TWOPI * packet->pkOrientation.orAzimuth /
(axes[0].axResolution / 65536.);
+ az -= G_PI / 2;
el = TWOPI * packet->pkOrientation.orAltitude /
(axes[1].axResolution / 65536.);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]