[gnome-games/wip/exalm/ds: 60/63] ui: Process runner shortcuts



commit 28465c25ce7cdc9a8ccd0075f90d8d098144a7b7
Author: Alexander Mikhaylenko <exalm7659 gmail com>
Date:   Sat Jan 19 02:47:25 2019 +0500

    ui: Process runner shortcuts

 src/ui/application-window.vala |  6 ++++++
 src/ui/display-box.vala        | 24 ++++++++++++++++++++++++
 2 files changed, 30 insertions(+)
---
diff --git a/src/ui/application-window.vala b/src/ui/application-window.vala
index c8e9b414..d7c55728 100644
--- a/src/ui/application-window.vala
+++ b/src/ui/application-window.vala
@@ -302,6 +302,9 @@ private class Games.ApplicationWindow : Gtk.ApplicationWindow {
                        if (!event.get_button (out button))
                                return false;
 
+                       if (display_box.gamepad_button_press_event (event))
+                               return true;
+
                        switch (button) {
                        case EventCode.BTN_MODE:
                                ui_state = UiState.COLLECTION;
@@ -646,6 +649,9 @@ private class Games.ApplicationWindow : Gtk.ApplicationWindow {
                if (ui_state != UiState.DISPLAY)
                        return false;
 
+               if (display_box.on_key_press_event (event))
+                       return true;
+
                var default_modifiers = Gtk.accelerator_get_default_mod_mask ();
 
                if ((event.keyval == Gdk.Key.f || event.keyval == Gdk.Key.F) &&
diff --git a/src/ui/display-box.vala b/src/ui/display-box.vala
index 97e96039..1162066c 100644
--- a/src/ui/display-box.vala
+++ b/src/ui/display-box.vala
@@ -70,4 +70,28 @@ private class Games.DisplayBox : Gtk.Bin {
                if (child != null)
                        display_bin.remove (child);
        }
+
+       public bool on_key_press_event (Gdk.EventKey event) {
+               if (!get_mapped ())
+                       return false;
+
+               if (runner == null)
+                       return false;
+
+               return runner.key_press_event (event);
+       }
+
+       public bool gamepad_button_press_event (Manette.Event event) {
+               if (!get_mapped ())
+                       return false;
+
+               if (runner == null)
+                       return false;
+
+               uint16 button;
+               if (!event.get_button (out button))
+                       return false;
+
+               return runner.gamepad_button_press_event (button);
+       }
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]