Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [Solved] Tablet driver unable to produce QTabletEvent::Eraser
QtWS25 Last Chance

[Solved] Tablet driver unable to produce QTabletEvent::Eraser

Scheduled Pinned Locked Moved General and Desktop
11 Posts 2 Posters 3.3k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    LeslieViljoen
    wrote on last edited by LeslieViljoen
    #1

    Hi!

    I am developing a driver for a Bosto Kingtee graphics tablet (https://github.com/lesliev/bosto_14wa) that for the most part works in Qt, though the eraser on the back of the pen looks like a stylus to Qt. Short of trying to compile and debug Qt, I'm not sure how to get it working.

    I am calling the kernel functions to report the eraser device like so:
    input_report_key(input_dev, tool, 1);

    When the eraser touches the tablet, input_dev will be set to the eraser device, tool will be set to the Linux constant BTN_TOOL_RUBBER (http://lxr.free-electrons.com/source/include/uapi/linux/input.h#L542), and the 1 means the device is close to the tablet.

    I would have thought that the BTN_TOOL_RUBBER tool would be enough for programs to realise that this is an eraser, but for Gimp I needed to have a second device, so that there was a device for stylus and another for eraser. Once I had that, Gimp started working properly. But this does not work for Qt programs.

    Poking around Qt5.6's "qtbase" code (processInputEvent in qevdevtablet.cpp), it looks like BTN_TOOL_RUBBER should be all I need to make Qt return QTabletEvent::Eraser to client programs, but all they ever get is QTabletEvent::Pen.

    Can you think of any reason why this might be happening?

    The notes here look relevant: http://doc.qt.io/qt-5.5/qtabletevent.html
    If the tablet is configured in xorg.conf to use the Wacom driver, there will be separate XInput "devices" for the stylus, eraser, and (optionally) cursor and touchpad. Qt recognizes these by their names. Otherwise, if the tablet is configured to use the evdev driver, there will be only one device and applications may not be able to distinguish the stylus from the eraser.

    Though I cannot see code to check for names in qevdevtablet.cpp, I do see some in qxcbconnection_xi2.cpp. So I've tried naming the devices various things like "stylus" and "eraser" and these names are correctly reported by "xinput" - but Qt still does not detect the eraser.

    So all I can conclude so far is that my driver must be an "evdev driver". Can you tell me how to confirm that this is the case?

    Leslie

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      You should be able to see what plugins are loaded by your application by setting the QT_DEBUG_PLUGINS environment variable to 1 in the Run part of the project panel

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      L 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi and welcome to devnet,

        You should be able to see what plugins are loaded by your application by setting the QT_DEBUG_PLUGINS environment variable to 1 in the Run part of the project panel

        L Offline
        L Offline
        LeslieViljoen
        wrote on last edited by
        #3

        @SGaist I don't think this is for me.

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Why not ? That will allow you to determine what plugin is being loaded

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          L 1 Reply Last reply
          0
          • SGaistS SGaist

            Why not ? That will allow you to determine what plugin is being loaded

            L Offline
            L Offline
            LeslieViljoen
            wrote on last edited by
            #5

            @SGaist I don't know what the "project panel" is. Also, why are plugins relevant to the graphics tablet driver? I can set environment variables though, and when I set QT_DEBUG_PLUGINS, I get a lot of plugin errors like this:

            "The file '/usr/lib/kde4/plugins/imageformats/kimg_jp2.so' is not a valid Qt plugin."

            Some are not errors, like this:

            QFactoryLoader::QFactoryLoader() looking at "/usr/lib/x86_64-linux-gnu/qt4/plugins/imageformats/libqgif.so"
            keys ("gif")

            There are many. Would you like a list?

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Sorry, I thought you were using Qt Creator.

              It is relevant because it's a way to check if you have the evdev plugin loaded for that or just using the input handling from the platform plugin.

              Since you're on linux, what flavor are you using ?

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0
              • L Offline
                L Offline
                LeslieViljoen
                wrote on last edited by LeslieViljoen
                #7

                Ah right, I should be more specific. I've been trying to get the tablet working with Krita - but since that doesn't (yet) use Qt5 directly for tablet support, I've been using this project to debug what's going on with Qt: https://github.com/callaa/QTabletTest

                This is everything I get in the console:

                • ╰─➤ QT_DEBUG_PLUGINS=1 ./QTabletTester
                  QFactoryLoader::QFactoryLoader() looking at "/usr/lib/kde4/plugins/styles/oxygen.so"
                  "The file '/usr/lib/kde4/plugins/styles/oxygen.so' is not a valid Qt plugin."
                  not a plugin
                  QFactoryLoader::QFactoryLoader() looking at "/usr/lib/x86_64-linux-gnu/qt4/plugins/inputmethods/libqimsw-multi.so"
                  keys ("imsw-multi")

                This is without the tablet plugged in right now. Later on I can try with the tablet plugged in, if that makes any difference.

                I am using Ubuntu 14.04.

                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  IIRC, Krita is now fully ported to Qt 5. I'd recommend checking directly with the maintainers, you will get quicker to your goal

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  1 Reply Last reply
                  0
                  • L Offline
                    L Offline
                    LeslieViljoen
                    wrote on last edited by
                    #9

                    I went to the Krita forum first and was told that it checks the QTabletEvent::Eraser flag to determine if the device is an eraser.

                    This code below is from QTabletTest, which displays the device type returned from event->pointerType(). This is always QTabletEvent::Pen, no matter what I do.

                    void TabletTestView::showTabletEvent(QTabletEvent *event)
                    {
                    	QString action;
                    	if(event->type() == QEvent::TabletMove)
                    		action = "moved";
                    	if(event->type() == QEvent::TabletPress)
                    		action = "pressed";
                    	else if(event->type() == QEvent::TabletRelease)
                    		action = "lifted";
                    
                    	_pointeritem->setPos(event->pos());
                    	QPointF pos = tabletEventPos(event);
                    	_pointertext->setText(
                    				QString("%1 (%2) %3 at %4, %5, pressure=%6 [id: %7]")
                    				.arg(devicename(event->device()))
                    				.arg(pointername(event->pointerType()))
                    				.arg(action)
                    				.arg(pos.x(), 0, 'f', 1)
                    				.arg(pos.y(), 0, 'f', 1)
                    				.arg(event->pressure() * 100.0, 0, 'f', 1)
                            .arg(event->uniqueId())
                    	);
                    	emit logEvent(_pointertext->text());
                    }
                    

                    At this point, all I can do is try to debug Qt to figure out how it detects the pointer type. Is there a way I can build the Qt libs without killing my system? Do I need to build them in a VM? Should I try apt-get source, hack the packages and reinstall them? Is there a way to build debug Qt libs and get QTabletTest to use my hacked libs instead of the system ones?

                    1 Reply Last reply
                    0
                    • L Offline
                      L Offline
                      LeslieViljoen
                      wrote on last edited by
                      #10

                      Woohoo, I got it to work! I realised that QTabletTester was actually building with qt4! When I built it with Qt5 qmake it did indeed detect the eraser device!

                      Thanks anyway!

                      1 Reply Last reply
                      0
                      • SGaistS Offline
                        SGaistS Offline
                        SGaist
                        Lifetime Qt Champion
                        wrote on last edited by
                        #11

                        Good !

                        That's a tricky case :)

                        Since you have it working now, please update the thread title prepending [solved] so other forum users may know a solution has been found :)

                        Interested in AI ? www.idiap.ch
                        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                        1 Reply Last reply
                        0

                        • Login

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • Users
                        • Groups
                        • Search
                        • Get Qt Extensions
                        • Unsolved