[Solved] Tablet driver unable to produce QTabletEvent::Eraser
-
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
-
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
-
Why not ? That will allow you to determine what plugin is being loaded
-
@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?
-
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 ?
-
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.
- ╰─➤ QT_DEBUG_PLUGINS=1 ./QTabletTester
-
IIRC, Krita is now fully ported to Qt 5. I'd recommend checking directly with the maintainers, you will get quicker to your goal
-
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?
-
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!
-
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 :)