From 53bce285ab42641959ce11095732d34a8e893f88 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 11 Feb 2013 08:16:32 +0000 Subject: [PATCH] patch [#31636] no pressure with Genius Mousepen i608X tablet from Viktoria S. (viktorias) --- intern/ghost/intern/GHOST_SystemX11.cpp | 29 +++++++++++++++++++------ intern/ghost/intern/GHOST_SystemX11.h | 3 +++ 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/intern/ghost/intern/GHOST_SystemX11.cpp b/intern/ghost/intern/GHOST_SystemX11.cpp index 7ba8889fd1e..f8c7bf45ffc 100644 --- a/intern/ghost/intern/GHOST_SystemX11.cpp +++ b/intern/ghost/intern/GHOST_SystemX11.cpp @@ -133,6 +133,10 @@ GHOST_SystemX11( m_xclip_out = XInternAtom(m_display, "XCLIP_OUT", False); m_incr = XInternAtom(m_display, "INCR", False); m_utf8_string = XInternAtom(m_display, "UTF8_STRING", False); +#ifdef WITH_X11_XINPUT + m_xi_tablet = XInternAtom(m_display, XI_TABLET, False); +#endif + m_last_warp = 0; @@ -1939,7 +1943,9 @@ void GHOST_SystemX11::initXInputDevices() // printf("Tablet type:'%s', name:'%s', index:%d\n", device_type, device_info[i].name, i); - if (m_xtablet.StylusDevice == NULL && is_stylus(device_info[i].name, device_type)) { + if ((m_xtablet.StylusDevice == NULL) && + (is_stylus(device_info[i].name, device_type) || (device_info[i].type == m_xi_tablet))) + { // printf("\tfound stylus\n"); m_xtablet.StylusID = device_info[i].id; m_xtablet.StylusDevice = XOpenDevice(m_display, m_xtablet.StylusID); @@ -1952,11 +1958,18 @@ void GHOST_SystemX11::initXInputDevices() // printf("\t\tfound ValuatorClass\n"); XValuatorInfo *xvi = (XValuatorInfo *)ici; m_xtablet.PressureLevels = xvi->axes[2].max_value; - - /* this is assuming that the tablet has the same tilt resolution in both - * positive and negative directions. It would be rather weird if it didn't.. */ - m_xtablet.XtiltLevels = xvi->axes[3].max_value; - m_xtablet.YtiltLevels = xvi->axes[4].max_value; + + if (xvi->num_axes > 3) { + /* this is assuming that the tablet has the same tilt resolution in both + * positive and negative directions. It would be rather weird if it didn't.. */ + m_xtablet.XtiltLevels = xvi->axes[3].max_value; + m_xtablet.YtiltLevels = xvi->axes[4].max_value; + } + else { + m_xtablet.XtiltLevels = 0; + m_xtablet.YtiltLevels = 0; + } + break; } @@ -1967,7 +1980,9 @@ void GHOST_SystemX11::initXInputDevices() m_xtablet.StylusID = 0; } } - else if (m_xtablet.EraserDevice == NULL && is_eraser(device_info[i].name, device_type)) { + else if ((m_xtablet.EraserDevice == NULL) && + (is_eraser(device_info[i].name, device_type))) + { // printf("\tfound eraser\n"); m_xtablet.EraserID = device_info[i].id; m_xtablet.EraserDevice = XOpenDevice(m_display, m_xtablet.EraserID); diff --git a/intern/ghost/intern/GHOST_SystemX11.h b/intern/ghost/intern/GHOST_SystemX11.h index 5fd494637f9..69ae634bb25 100644 --- a/intern/ghost/intern/GHOST_SystemX11.h +++ b/intern/ghost/intern/GHOST_SystemX11.h @@ -301,6 +301,9 @@ public: Atom m_xclip_out; Atom m_incr; Atom m_utf8_string; +#ifdef WITH_X11_XINPUT + Atom m_xi_tablet; +#endif #ifdef WITH_X11_XINPUT typedef struct GHOST_TabletX11 {