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](https://protonmail.com) Secure Email.
#include <stdio.h>
#include <string.h>
#include <gdk/gdk.h>
#include <gio/gio.h>
#include <gtk/gtk.h>
#include <unistd.h>
static void
activate (GApplication *app)
{
GdkEventKey event;
GdkDisplay *dpy;
GdkKeymap *kmap;
GdkKeymapKey *keys;
gint n_keys;
guint keyval = GDK_KEY_o;
dpy = gdk_display_get_default ();
kmap = gdk_keymap_get_for_display (dpy);
gdk_keymap_get_entries_for_keyval (kmap, keyval, &keys, &n_keys);
memset (&event, 0, sizeof (event));
event.type = GDK_KEY_PRESS;
event.window = NULL;
event.send_event = 0;
event.time = GDK_CURRENT_TIME;
event.state = 0;
event.keyval = keyval;
event.length = 1;
event.string = strdup ("o");
event.hardware_keycode = keys->keycode;
event.group = keys->group;
event.is_modifier = 0;
gdk_display_put_event (dpy, (GdkEvent *) (&event));
event.type = GDK_KEY_RELEASE;
gdk_display_put_event (dpy, (GdkEvent *) (&event));
while (gtk_events_pending ()) {
gtk_main_iteration ();
}
}
int
main (int argc, char **argv)
{
GtkApplication *app;
app = gtk_application_new ("com.anarchean.linuxrc", G_APPLICATION_FLAGS_NONE);
g_signal_connect (app, "activate", G_CALLBACK (activate), NULL);
return g_application_run (G_APPLICATION (app), argc, argv);
}
_______________________________________________
gtk-list mailing list
gtk-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-list