XTestFakeKeyEvent GDK-equivalent

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

XTestFakeKeyEvent GDK-equivalent

Gtk+ - General mailing list
Hi,

I'm working into implementing a virtual remote keyboard/touch pad daemon for Linux, currently I'm dumping events into an uinput device, but that is giving me some trouble with my keyboard layout (which is brazillian, br-abnt2). I was looking for a way to this in X, found XTestFakeKeyEvent and was wondering if I could make it simpler and cross-platform using
GDK3. I tried this attached code, but it doesn't do anything. I was wondering if someone has done this before and know what I'm doing wrong or if I should just give up doing with GDK.

Also, this is an extra, if I can't just fake key events, what should I use to map unicode chars into linux/input.h event key codes based on my keyboard layout on X? What about Wayland?

Thank you!


Sent with ProtonMail Secure Email.


_______________________________________________
gtk-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-list

main.c (1K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: XTestFakeKeyEvent GDK-equivalent

Allin Cottrell
On Thu, 5 Jul 2018, Anarchean via gtk-list wrote:

> I'm working into implementing a virtual remote keyboard/touch pad
> daemon for Linux, currently I'm dumping events into an uinput
> device, but that is giving me some trouble with my keyboard layout
> (which is brazillian, br-abnt2). I was looking for a way to this
> in X, found XTestFakeKeyEvent and was wondering if I could make it
> simpler and cross-platform using GDK3. I tried this attached code,
> but it doesn't do anything. I was wondering if someone has done
> this before and know what I'm doing wrong or if I should just give
> up doing with GDK.

The context is a little different, but the attached function works,
given a pointers to an existing GtkWidget and GdkEvent.

> Also, this is an extra, if I can't just fake key events, what
> should I use to map unicode chars into linux/input.h event key
> codes based on my keyboard layout on X? What about Wayland?

man xmodmap ?

--
Allin Cottrell
Department of Economics
Wake Forest University
_______________________________________________
gtk-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-list

manufacture.c (1K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: XTestFakeKeyEvent GDK-equivalent

Gtk+ - General mailing list
In reply to this post by Gtk+ - General mailing list
Hello,

On 07/05/2018 02:40 PM, Anarchean via gtk-list wrote:

> Hi,
>
> I'm working into implementing a virtual remote keyboard/touch pad daemon
> for Linux, currently I'm dumping events into an uinput device, but that
> is giving me some trouble with my keyboard layout (which is brazillian,
> br-abnt2). I was looking for a way to this in X, found XTestFakeKeyEvent
> and was wondering if I could make it simpler and cross-platform using
> GDK3. I tried this attached code, but it doesn't do anything. I was
> wondering if someone has done this before and know what I'm doing wrong
> or if I should just give up doing with GDK.

Perhaps something like this?
https://developer.gnome.org/gdk3/stable/gdk3-Testing.html#gdk-test-simulate-key


--
Eric Williams
Software Engineer - Eclipse/SWT Team
Red Hat
_______________________________________________
gtk-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-list
Reply | Threaded
Open this post in threaded view
|

Re: XTestFakeKeyEvent GDK-equivalent

Gtk+ - General mailing list
In reply to this post by Allin Cottrell
‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐

On 5 July 2018 10:32 PM, Allin Cottrell <[hidden email]> wrote:

> On Thu, 5 Jul 2018, Anarchean via gtk-list wrote:
>
> > I'm working into implementing a virtual remote keyboard/touch pad
> >
> > daemon for Linux, currently I'm dumping events into an uinput
> >
> > device, but that is giving me some trouble with my keyboard layout
> >
> > (which is brazillian, br-abnt2). I was looking for a way to this
> >
> > in X, found XTestFakeKeyEvent and was wondering if I could make it
> >
> > simpler and cross-platform using GDK3. I tried this attached code,
> >
> > but it doesn't do anything. I was wondering if someone has done
> >
> > this before and know what I'm doing wrong or if I should just give
> >
> > up doing with GDK.
>
> The context is a little different, but the attached function works,
>
> given a pointers to an existing GtkWidget and GdkEvent.
>

I tried your code out. It works OK, but its limited to emitting events to a GTK managed window and what I really wanted was to insert events into the X11/Wayland Display server, so that any application which has the focus could receive the events.

Maybe that is not possible within GTK and I need to access lower-level libraries like X/Wayland?

> > Also, this is an extra, if I can't just fake key events, what
> >
> > should I use to map unicode chars into linux/input.h event key
> >
> > codes based on my keyboard layout on X? What about Wayland?
>
> man xmodmap ?
>

I didn't know about xmodmap. I don't want to capture the standard out, tho. But I'll look into their source code to say what they code to capture the mapping.

Thank you for your help, Allin! That gave me some direction.

>
> -----------------
>
> Allin Cottrell
>
> Department of Economics
>
> Wake Forest University


_______________________________________________
gtk-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-list
Reply | Threaded
Open this post in threaded view
|

Re: XTestFakeKeyEvent GDK-equivalent

Gtk+ - General mailing list
In reply to this post by Gtk+ - General mailing list



​Sent with ProtonMail Secure Email.​

‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐

On 6 July 2018 9:57 AM, Eric Williams <[hidden email]> wrote:

> Hello,
>
> On 07/05/2018 02:40 PM, Anarchean via gtk-list wrote:
>
> > Hi,
> >
> > I'm working into implementing a virtual remote keyboard/touch pad daemon
> >
> > for Linux, currently I'm dumping events into an uinput device, but that
> >
> > is giving me some trouble with my keyboard layout (which is brazillian,
> >
> > br-abnt2). I was looking for a way to this in X, found XTestFakeKeyEvent
> >
> > and was wondering if I could make it simpler and cross-platform using
> >
> > GDK3. I tried this attached code, but it doesn't do anything. I was
> >
> > wondering if someone has done this before and know what I'm doing wrong
> >
> > or if I should just give up doing with GDK.
>
> Perhaps something like this?
>
> https://developer.gnome.org/gdk3/stable/gdk3-Testing.html#gdk-test-simulate-key
>
>
> -----------------------------------------------------------------------------------------------------------------
>
> Eric Williams
>
> Software Engineer - Eclipse/SWT Team
>
> Red Hat
Hey, Eric. I've just tried that function, it didn't do anything, I'm attaching my code so you can see if I'm doing this wrong.

_______________________________________________
gtk-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-list

eric.c (1K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: XTestFakeKeyEvent GDK-equivalent

Allin Cottrell
In reply to this post by Gtk+ - General mailing list
On Fri, 6 Jul 2018, Anarchean wrote:

> On 5 July 2018 10:32 PM, Allin Cottrell <[hidden email]> wrote:
[...]

>> The context is a little different, but the attached function works,
>> given pointers to an existing GtkWidget and GdkEvent.
>
> I tried your code out. It works OK, but its limited to emitting
> events to a GTK managed window and what I really wanted was to
> insert events into the X11/Wayland Display server, so that any
> application which has the focus could receive the events.
>
> Maybe that is not possible within GTK and I need to access
> lower-level libraries like X/Wayland?

Yes, I expect so. It occurred to me after posting my variant code
that it would not do what you wanted, if you're looking to send
keystrokes to some arbitrary target outside of your GTK application.
It seems pretty clear that if you want to send to an arbitrary X11
(or Wayland) window you'd need an API that gives you an ID for that
window, at least.

--
Allin Cottrell
Department of Economics
Wake Forest University
_______________________________________________
gtk-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-list
Reply | Threaded
Open this post in threaded view
|

Re: XTestFakeKeyEvent GDK-equivalent

James Cameron-2
In reply to this post by Gtk+ - General mailing list
For quick hacks or testing apps, I use xdotool.  I've no idea if it
works with Wayland though.

--
James Cameron
http://quozl.netrek.org/
_______________________________________________
gtk-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-list
Reply | Threaded
Open this post in threaded view
|

Re: XTestFakeKeyEvent GDK-equivalent

Gtk+ - General mailing list
In reply to this post by Gtk+ - General mailing list
Hi;

virtual keyboards running outside of the windowing system platform as clients do not use the XTest API — mostly because it's meant only for testing X, and because it's only for X. Injecting synthetic events into the windowing system is just not going to give you what you want, if what you want is to write a input driver. Additionally, GDK won't let you do this because GDK is a client toolkit, and it can only consume events coming from the windowing system, not inject them for random clients to process.

You will need to write a device driver — either for X11, or for the Linux kernel — that does this for you.

Ciao,
 Emmanuele.

On Fri, 6 Jul 2018 at 01:49, Anarchean via gtk-list <[hidden email]> wrote:
Hi,

I'm working into implementing a virtual remote keyboard/touch pad daemon for Linux, currently I'm dumping events into an uinput device, but that is giving me some trouble with my keyboard layout (which is brazillian, br-abnt2). I was looking for a way to this in X, found XTestFakeKeyEvent and was wondering if I could make it simpler and cross-platform using
GDK3. I tried this attached code, but it doesn't do anything. I was wondering if someone has done this before and know what I'm doing wrong or if I should just give up doing with GDK.

Also, this is an extra, if I can't just fake key events, what should I use to map unicode chars into linux/input.h event key codes based on my keyboard layout on X? What about Wayland?

Thank you!


Sent with ProtonMail Secure Email.

_______________________________________________
gtk-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-list


--

_______________________________________________
gtk-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-list
Reply | Threaded
Open this post in threaded view
|

Re: XTestFakeKeyEvent GDK-equivalent

Gtk+ - General mailing list
In reply to this post by James Cameron-2
Hi James,

xdotool is a good option, but I would prefer to use a library instead, and a cross-platform one. I looked xdotool source code, and they use XTest internally. I was just curious to see if there were any way of doing that directly from GTK.

Anyway, thank you for answering.

‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐

On 6 July 2018 6:30 PM, James Cameron <[hidden email]> wrote:

> For quick hacks or testing apps, I use xdotool. I've no idea if it
>
> works with Wayland though.
>
>
> --------------------------------------------------------------------------------------------------
>
> James Cameron
>
> http://quozl.netrek.org/
>
> gtk-list mailing list
>
> [hidden email]
>
> https://mail.gnome.org/mailman/listinfo/gtk-list


_______________________________________________
gtk-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-list
Reply | Threaded
Open this post in threaded view
|

Re: XTestFakeKeyEvent GDK-equivalent

Gtk+ - General mailing list
In reply to this post by Gtk+ - General mailing list
Hello Emmanuele,

Well, my requirements allow an only-X or -Wayland solution, but I totally understand what you mean, I feel it is weird using a testing API do implement functionality.
My current solution is using uniput to create a virtual device in user space, I'm just having trouble with the keyboard layout, GDK was my hope to convert char -> keysym and send it directly to the X server. I guess I'll just have to get the mapping right in both server and client, either manually or trying to read XKB mappings.
I'm looking at Onboard (https://code.launchpad.net/~onboard/onboard/trunk) code and I think they do what I want.

Anyway, thank you for the help.

Sent with ProtonMail Secure Email.

‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
On 7 July 2018 9:51 AM, Emmanuele Bassi <[hidden email]> wrote:

Hi;

virtual keyboards running outside of the windowing system platform as clients do not use the XTest API — mostly because it's meant only for testing X, and because it's only for X. Injecting synthetic events into the windowing system is just not going to give you what you want, if what you want is to write a input driver. Additionally, GDK won't let you do this because GDK is a client toolkit, and it can only consume events coming from the windowing system, not inject them for random clients to process.

You will need to write a device driver — either for X11, or for the Linux kernel — that does this for you.

Ciao,
 Emmanuele.

On Fri, 6 Jul 2018 at 01:49, Anarchean via gtk-list <[hidden email]> wrote:
Hi,

I'm working into implementing a virtual remote keyboard/touch pad daemon for Linux, currently I'm dumping events into an uinput device, but that is giving me some trouble with my keyboard layout (which is brazillian, br-abnt2). I was looking for a way to this in X, found XTestFakeKeyEvent and was wondering if I could make it simpler and cross-platform using
GDK3. I tried this attached code, but it doesn't do anything. I was wondering if someone has done this before and know what I'm doing wrong or if I should just give up doing with GDK.

Also, this is an extra, if I can't just fake key events, what should I use to map unicode chars into linux/input.h event key codes based on my keyboard layout on X? What about Wayland?

Thank you!


Sent with ProtonMail Secure Email.

_______________________________________________
gtk-list mailing list


--


_______________________________________________
gtk-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-list