Search
lxdream.org :: lxdream :: r449:21440948c684
lxdream 0.9.1
released Jun 29
Download Now
changeset449:21440948c684
parent448:3e5f0c52f0ec
child450:207461e79f21
authornkeynes
dateTue Oct 16 12:38:01 2007 +0000 (12 years ago)
Modify keyboard input to use unmodified key values only
lxdreamrc
src/drivers/video_gtk.c
1.1 --- a/lxdreamrc Tue Oct 16 12:36:59 2007 +0000
1.2 +++ b/lxdreamrc Tue Oct 16 12:38:01 2007 +0000
1.3 @@ -16,10 +16,9 @@
1.4 analog right = KP_Right
1.5 analog up = KP_Up
1.6 analog down = KP_Down
1.7 - button X = A, a
1.8 - button Y = S, s
1.9 - button A = Z, z
1.10 - button B = X, x
1.11 - trigger left = D, d
1.12 - trigger right = C, c
1.13 -
1.14 + button X = a
1.15 + button Y = s
1.16 + button A = z
1.17 + button B = x
1.18 + trigger left = d
1.19 + trigger right = c
2.1 --- a/src/drivers/video_gtk.c Tue Oct 16 12:36:59 2007 +0000
2.2 +++ b/src/drivers/video_gtk.c Tue Oct 16 12:38:01 2007 +0000
2.3 @@ -1,5 +1,5 @@
2.4 /**
2.5 - * $Id: video_gtk.c,v 1.15 2007-10-13 04:01:02 nkeynes Exp $
2.6 + * $Id: video_gtk.c,v 1.16 2007-10-16 12:38:01 nkeynes Exp $
2.7 *
2.8 * The PC side of the video support (responsible for actually displaying /
2.9 * rendering frames)
2.10 @@ -36,13 +36,36 @@
2.11 struct display_driver display_gtk_driver = { "gtk", video_gtk_init, video_gtk_shutdown,
2.12 video_gtk_resolve_keysym,
2.13 NULL, NULL, NULL, NULL, NULL, NULL, NULL };
2.14 -
2.15 +
2.16 +/**
2.17 + * Extract the keyval of the key event if no modifier keys were pressed -
2.18 + * in other words get the keyval of the key by itself. The other way around
2.19 + * would be to use the hardware keysyms directly rather than the keyvals,
2.20 + * but the mapping looks to be messier.
2.21 + */
2.22 +uint16_t video_gtk_unmodified_keyval( GdkEventKey *event )
2.23 +{
2.24 + GdkKeymap *keymap = gdk_keymap_get_default();
2.25 + guint keyval;
2.26 +
2.27 + gdk_keymap_translate_keyboard_state( keymap, event->hardware_keycode, 0, 0, &keyval,
2.28 + NULL, NULL, NULL );
2.29 + return keyval;
2.30 +}
2.31
2.32 gboolean video_gtk_keydown_callback(GtkWidget *widget,
2.33 GdkEventKey *event,
2.34 gpointer user_data)
2.35 {
2.36 - input_event_keydown( event->keyval );
2.37 + input_event_keydown( video_gtk_unmodified_keyval(event) );
2.38 + return TRUE;
2.39 +}
2.40 +
2.41 +gboolean video_gtk_keyup_callback(GtkWidget *widget,
2.42 + GdkEventKey *event,
2.43 + gpointer user_data)
2.44 +{
2.45 + input_event_keyup( video_gtk_unmodified_keyval(event) );
2.46 return TRUE;
2.47 }
2.48
2.49 @@ -54,14 +77,6 @@
2.50 return (uint16_t)val;
2.51 }
2.52
2.53 -gboolean video_gtk_keyup_callback(GtkWidget *widget,
2.54 - GdkEventKey *event,
2.55 - gpointer user_data)
2.56 -{
2.57 - input_event_keyup( event->keyval );
2.58 - return TRUE;
2.59 -}
2.60 -
2.61 gboolean video_gtk_expose_callback(GtkWidget *widget, GdkEventExpose *event, gpointer data )
2.62 {
2.63 gl_redisplay_last();
.