Fix T58776, T58030: pressure sensitivity on Linux not working for some tablets.
authorBrecht Van Lommel <brechtvanlommel@gmail.com>
Wed, 5 Dec 2018 12:58:38 +0000 (13:58 +0100)
committerBrecht Van Lommel <brechtvanlommel@gmail.com>
Wed, 5 Dec 2018 13:02:37 +0000 (14:02 +0100)
intern/ghost/intern/GHOST_SystemX11.cpp

index 0c0abc9535644016f5d78fcc3c8d18ea65e59d56..3befb700c55d9a752438ef1de781cb3c6695e19c 100644 (file)
@@ -2269,6 +2269,8 @@ void GHOST_SystemX11::refreshXInputDevices()
                                        if (m_xtablet.StylusDevice != NULL) {
                                                /* Find how many pressure levels tablet has */
                                                XAnyClassPtr ici = device_info[i].inputclassinfo;
+                                               bool found_valuator_class = false;
+
                                                for (int j = 0; j < m_xtablet.StylusDevice->num_classes; ++j) {
                                                        if (ici->c_class == ValuatorClass) {
 //                                                             printf("\t\tfound ValuatorClass\n");
@@ -2286,11 +2288,23 @@ void GHOST_SystemX11::refreshXInputDevices()
                                                                        m_xtablet.YtiltLevels = 0;
                                                                }
 
+                                                               found_valuator_class = true;
+
                                                                break;
                                                        }
 
                                                        ici = (XAnyClassPtr)(((char *)ici) + ici->length);
                                                }
+
+                                               if (!found_valuator_class) {
+                                                       /* In case our name matching detects a device that
+                                                        * isn't actually a stylus. For example there can
+                                                        * be "XPPEN Tablet" and "XPPEN Tablet Pen", but
+                                                        * only the latter is a stylus. */
+                                                       XCloseDevice(m_display, m_xtablet.StylusDevice);
+                                                       m_xtablet.StylusDevice = NULL;
+                                                       m_xtablet.StylusID = 0;
+                                               }
                                        }
                                        else {
                                                m_xtablet.StylusID = 0;