[gnome-games] konami-code: Translate keyval
- From: Alexander Mikhaylenko <alexm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games] konami-code: Translate keyval
- Date: Fri, 14 Aug 2020 12:43:48 +0000 (UTC)
commit 546b26ee80cdd1cbd50c0ebcdf65a2db2530e9dd
Author: Alexander Mikhaylenko <alexm gnome org>
Date: Fri Aug 14 17:43:21 2020 +0500
konami-code: Translate keyval
Make a and b locale-independent.
src/ui/konami-code.vala | 19 ++++++++++++-------
1 file changed, 12 insertions(+), 7 deletions(-)
---
diff --git a/src/ui/konami-code.vala b/src/ui/konami-code.vala
index ecc0eafd0..306530c55 100644
--- a/src/ui/konami-code.vala
+++ b/src/ui/konami-code.vala
@@ -41,23 +41,28 @@ private class Games.KonamiCode : Object {
private uint current_index;
- public Gtk.Widget widget {
- construct {
- value.key_press_event.connect (on_key_pressed);
- }
- }
+ public Gtk.Widget widget { get; construct; }
public KonamiCode (Gtk.Widget widget) {
Object (widget: widget);
}
+ construct {
+ widget.key_press_event.connect (on_key_pressed);
+ }
+
public void reset () {
current_index = 0;
}
private bool on_key_pressed (Gdk.EventKey event) {
- if (event.keyval != CODE_LOWER_KEYS[current_index] &&
- event.keyval != CODE_UPPER_KEYS[current_index]) {
+ uint keyval;
+ var keymap = Gdk.Keymap.get_for_display (widget.get_display ());
+ keymap.translate_keyboard_state (event.hardware_keycode, event.state,
+ event.group, out keyval, null, null, null);
+
+ if (keyval != CODE_LOWER_KEYS[current_index] &&
+ keyval != CODE_UPPER_KEYS[current_index]) {
current_index = 0;
return false;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]