emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Stylus drawing input?


From: Dov Grobgeld
Subject: Re: Stylus drawing input?
Date: Mon, 23 Jan 2023 23:15:58 +0200

On X11, to read stylus input, we need to use XInput extension.

Gdk, used in gtk, has a good abstraction to it that allows doing code
like the following to distinguish between mouse and stylus input in
its motion notify callback, and in this case extract the pressure.

  int on_motion_notify_event(GdkEventMotion *event)
  {
    // The pressure value is:
    //   found=false for mouse motion
    //   0 for proximity stylus motion
    //   >0 for the pen touching the pad
    double pressure=-1;
    int found = gdk_event_get_axis((GdkEvent*)event,
GDK_AXIS_PRESSURE, &pressure);
    GdkDeviceTool *tool = gdk_event_get_device_tool((GdkEvent*)event);

    // For mouse the tool isn't defined, so we set a default -1
    GdkDeviceToolType tool_type = (GdkDeviceToolType)(-1);
    if (tool)
      // true for stylus only
      tool_type = gdk_device_tool_get_tool_type (tool);

    printf("motion_notify: tool_type=%d,
x=%.3f},y=%.3f},found_stylus=%d,pressure=%.3f\n",
          (int)tool_type,
          event->x, event->y, found, pressure);
    return TRUE;
  }

To support styluses (i.e. to distinguish them from mouse events) we
need something similar in emacs.

Regards,


On Mon, Jan 16, 2023 at 10:27 AM <tomas@tuxteam.de> wrote:
>
> On Mon, Jan 16, 2023 at 08:45:55AM +0100, Dr. Arne Babenhauserheide wrote:
> > PS: Here is a website with a description that does not rely on unfree
> >     platforms: https://misohena.jp/blog/2021-09-21-emacs-easy-draw.html
> >
> > The clearest description is a gif, though:
> > https://misohena.jp/blog/wp-content/uploads/2021-09-21-edraw-example.gif
>
> Thanks for the non-github link!
>
> Cheers
> --
> t



reply via email to

[Prev in Thread] Current Thread [Next in Thread]