backport Nicholas Bishop's 2.5 commit from r22581, stylus fails on ubuntu 9.10 withou...
authorCampbell Barton <ideasman42@gmail.com>
Thu, 17 Sep 2009 16:17:32 +0000 (16:17 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Thu, 17 Sep 2009 16:17:32 +0000 (16:17 +0000)
intern/ghost/intern/GHOST_WindowX11.cpp

index 5a1f3bf1e217e60fba01500269d47c0dd61c2134..0457cbcaecbeff7e8ddfa2b5193ee7fd69eb3588 100644 (file)
@@ -42,6 +42,9 @@
 #include <cstring>
 #include <cstdio>
 
+#include <algorithm>
+#include <string>
+
 // For obscure full screen mode stuuf
 // lifted verbatim from blut.
 
@@ -441,7 +444,20 @@ void GHOST_WindowX11::initXInputDevices()
                        old_handler = XSetErrorHandler(ApplicationErrorHandler) ;
 
                        for(int i=0; i<device_count; ++i) {
-                               if(!strcasecmp(device_info[i].name, "stylus")) {
+                               std::string type = "";
+                               
+                               if(device_info[i].type) {
+                                       const char *orig = XGetAtomName(m_display, device_info[i].type);
+                                       // Make a copy so we can convert to lower case
+                                       if(orig) {
+                                               type = orig;
+                                               XFree((void*)orig);
+                                               std::transform(type.begin(), type.end(), type.begin(), ::tolower);
+                                       }
+                               }
+
+
+                               if(type.find("stylus") != std::string::npos) {
                                        m_xtablet.StylusID= device_info[i].id;
                                        m_xtablet.StylusDevice = XOpenDevice(m_display, m_xtablet.StylusID);
 
@@ -466,7 +482,7 @@ void GHOST_WindowX11::initXInputDevices()
                                                m_xtablet.StylusID= 0;
                                        }
                                }
-                               if(!strcasecmp(device_info[i].name, "eraser")) {
+                               if(type.find("eraser") != std::string::npos) {
                                        m_xtablet.EraserID= device_info[i].id;
                                        m_xtablet.EraserDevice = XOpenDevice(m_display, m_xtablet.EraserID);
                                        if (m_xtablet.EraserDevice == NULL) m_xtablet.EraserID= 0;
@@ -622,7 +638,7 @@ screenToClient(
        GHOST_TInt32& outX,
        GHOST_TInt32& outY
 ) const {
-       // not sure about this one!
+       // This is correct!
 
        int ax,ay;
        Window temp;