[gnome-games/wip/aplazas/gamepad-shoulders-view: 11/12] collection-box: Select the view with gamepad shoulders
- From: Adrien Plazas <aplazas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games/wip/aplazas/gamepad-shoulders-view: 11/12] collection-box: Select the view with gamepad shoulders
- Date: Fri, 3 Aug 2018 22:13:58 +0000 (UTC)
commit 24f2c79a47b416a76556c32b2607e93a49578083
Author: Adrien Plazas <kekun plazas laposte net>
Date: Fri Aug 3 19:53:04 2018 +0200
collection-box: Select the view with gamepad shoulders
src/ui/collection-box.vala | 32 +++++++++++++++++++++++++++++++-
1 file changed, 31 insertions(+), 1 deletion(-)
---
diff --git a/src/ui/collection-box.vala b/src/ui/collection-box.vala
index 78f6acfc..cc28c476 100644
--- a/src/ui/collection-box.vala
+++ b/src/ui/collection-box.vala
@@ -51,7 +51,37 @@ private class Games.CollectionBox : Gtk.Box {
}
public bool gamepad_button_press_event (Manette.Event event) {
- return collection_view.gamepad_button_press_event (event);
+ if (!visible)
+ return false;
+
+ uint16 button;
+ if (!event.get_button (out button))
+ return false;
+
+ switch (button) {
+ case EventCode.BTN_TL:
+ var views = viewstack.get_children ();
+ unowned List<Gtk.Widget> current_view = views.find (viewstack.visible_child);
+
+ assert (current_view != null);
+
+ if (current_view.prev != null)
+ viewstack.visible_child = current_view.prev.data;
+
+ return true;
+ case EventCode.BTN_TR:
+ var views = viewstack.get_children ();
+ unowned List<Gtk.Widget> current_view = views.find (viewstack.visible_child);
+
+ assert (current_view != null);
+
+ if (current_view.next != null)
+ viewstack.visible_child = current_view.next.data;
+
+ return true;
+ default:
+ return collection_view.gamepad_button_press_event (event);
+ }
}
public bool gamepad_button_release_event (Manette.Event event) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]