1

I'm trying to capture pen input using Gdk (in vala). Here's my code

    var source = anEvent.get_device().get_source();

    if (source == Gdk.InputSource.MOUSE) {
        stdout.printf("mouse\n");
    } else if (source == Gdk.InputSource.PEN) {
        stdout.printf("pen\n");
    } else if (source == Gdk.InputSource.ERASER) {
        stdout.printf("eraser\n");
    } else {
        stdout.printf("something else\n");
    }
    Gtk.main_do_event(anEvent);

However, pen input seems to be recognised as a mouse input! Touch and keyboard input seems to be recognized correctly however. This is especially strange since I tested both with the integrated wacom pen on my Thinkpad X1 Yoga as well as a separate Intuos Pro, both which are recognized by Gnome. Also, switching between Xorg / Wayland makes no difference. What am I missing? Or is it simply an issue with Gdk / Gtk / Gnome? Thanks!

JomanJi
  • 1,407
  • 1
  • 17
  • 27
  • I don't have the answer but you may learn how thing work behind the scenes by reading the [blog of Peter Hutterer about libinput](http://who-t.blogspot.fr/). – liberforce Feb 09 '18 at 09:57
  • You might want to open a bug on libinput too, or maybe the kernel. – liberforce Feb 09 '18 at 10:03

1 Answers1

1

Solved it by using Gdk.DeviceToolType instead.

var tool = anEvent.get_device_tool().get_tool_type();

if (tool == Gdk.DeviceToolType.PEN) {
    stdout.printf("pen?\n");
}

... 

works instead.

JomanJi
  • 1,407
  • 1
  • 17
  • 27