Index: in_keyboard/Makefile =================================================================== --- in_keyboard/Makefile (nonexistent) +++ in_keyboard/Makefile (revision 12290) @@ -0,0 +1,12 @@ +TRUNK=../../../trunk +CFLAGS=-g -Wall -I $(TRUNK)/src_plugins `pkg-config --cflags gtk+-2.0` +LDFLAGS=-g `pkg-config --libs gtk+-2.0` +#CFLAGS=-g -Wall -I $(TRUNK)/src_plugins -DPCB_GTK3 `pkg-config --cflags gtk+-3.0` +#LDFLAGS=-g `pkg-config --libs gtk+-3.0` + +all: in_keyboard + +in_keyboard: in_keyboard.o + +clean: + rm *.o in_keyboard Index: in_keyboard/in_keyboard.c =================================================================== --- in_keyboard/in_keyboard.c (nonexistent) +++ in_keyboard/in_keyboard.c (revision 12290) @@ -0,0 +1,70 @@ +/* From Alain : This program captures key events and prints the key modifier, + * "group=0" key label (unicode char) and "key name" according to GDK + */ + +#include +#include + +gboolean on_key_press(GtkWidget * widget, GdkEventKey * event, gpointer user_data); + +int main(int argc, char *argv[]) +{ + GtkWidget *window; + + gtk_init(&argc, &argv); + + window = gtk_window_new(GTK_WINDOW_TOPLEVEL); + + g_signal_connect(G_OBJECT(window), "destroy", G_CALLBACK(gtk_main_quit), NULL); + g_signal_connect(G_OBJECT(window), "key_press_event", G_CALLBACK(on_key_press), NULL); + + gtk_widget_show_all(window); + + gtk_main(); + + return 0; +} + +void key_press_cb(GdkEventKey * kev) +{ + + if (kev->keyval <= 0xffff) { + GdkModifierType state = (GdkModifierType) (kev->state); + //int slen, mods = 0; + //static int seq_len = 0; + unsigned short int kv = kev->keyval; + + if (state & GDK_SHIFT_MASK) { + guint *keyvals; + GdkKeymapKey *keys; + gint n_entries; + + if (gdk_keymap_get_entries_for_keycode(gdk_keymap_get_default(), kev->hardware_keycode, &keys, &keyvals, &n_entries)) { + kv = keyvals[0]; + printf(""); + g_free(keys); + g_free(keyvals); + } + } + if (state & GDK_CONTROL_MASK) { + printf(""); + } + if (state & GDK_MOD1_MASK) { + printf(""); + } + printf(" %c \t%s\n", gdk_keyval_to_unicode(kv), gdk_keyval_name(kv)); + + } +} + +gboolean on_key_press(GtkWidget * widget, GdkEventKey * event, gpointer user_data) +{ + key_press_cb(event); + + /* CTRL-q exits the application */ + if (event->keyval == GDK_KEY_q && event->state & GDK_CONTROL_MASK) { + gtk_main_quit(); + } + + return FALSE; +}