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: Tue, 24 Jan 2023 10:03:02 +0200

Thanks. I need some guidance on how feasible the following is and how
I would go about doing it.

1. How do I draw vector graphics object in an emacs buffer. I.e.
line-to, move-to, close-path, fill etc. Do I need to generate the
pixels on my own (can be done e.g. with the agg library or with
libcairo) and then place the image as on overlay (how?), or is there
higher lever interface? Is it accessible from elisp or from C?
2. How can I trace the x,y input coordinates of mouse movement. E.g.
I'd like to run a command to enter capture mode, and then catch
subsequent motion events of the mouse, until the mouse button is
raised. The resulting object should be a list of motion coordinates.
3. How would I do the same for a stylus while catching additional pressure data?
4. Given some vector graphics objects drawn on the screen, how would I
do mouse hit detection, so that doing a mouse click on the object,
returns the object id? (This I can do "offline" though, by drawing a
"label image" of the buffer contents on mouse press end then finding
the label of the object under the mouse.)

Thanks!

On Tue, Jan 24, 2023 at 1:47 AM Po Lu <Luangruo@yahoo.com> wrote:
>
> Emacs 29 already has native support for version 2 of the the X Input 
> extension and its various input devices.
>
> See the node Touchscreen Events in the Emacs Lisp reference manual.  This is 
> not yet supported on the PGTK build.
>
> On January 24, 2023 5:15:58 AM GMT+08:00, Dov Grobgeld 
> <dov.grobgeld@gmail.com> wrote:
> >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]