[gnome-games/wip/exalm/ds-popover: 28/30] w
- From: Alexander Mikhaylenko <alexm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games/wip/exalm/ds-popover: 28/30] w
- Date: Fri, 18 Jan 2019 20:19:28 +0000 (UTC)
commit 2f822fe1e311f63d41507d34d9d9f734a3002c18
Author: Alexander Mikhaylenko <exalm7659 gmail com>
Date: Fri Jan 18 22:52:08 2019 +0500
w
plugins/nintendo-ds/src/nintendo-ds-runner.vala | 23 +++++++++++++++++++
src/command/command-runner.vala | 12 ++++++++++
src/core/runner.vala | 4 ++++
src/dummy/dummy-runner.vala | 12 ++++++++++
src/meson.build | 6 ++++-
src/retro/retro-runner.vala | 12 ++++++++++
src/ui/application-window.vala | 17 ++++++++++++--
src/ui/display-box.vala | 30 +++++++++++++++++++++++++
8 files changed, 113 insertions(+), 3 deletions(-)
---
diff --git a/plugins/nintendo-ds/src/nintendo-ds-runner.vala b/plugins/nintendo-ds/src/nintendo-ds-runner.vala
index dd433883..0623de11 100644
--- a/plugins/nintendo-ds/src/nintendo-ds-runner.vala
+++ b/plugins/nintendo-ds/src/nintendo-ds-runner.vala
@@ -124,4 +124,27 @@ private class Games.NintendoDsRunner : Object, Runner {
public InputMode[] get_available_input_modes () {
return runner.get_available_input_modes ();
}
+
+ public bool gamepad_button_press_event (Manette.Event event) {
+ uint16 button;
+
+ if (!event.get_button (out button))
+ return false;
+
+ if (button != EventCode.BTN_THUMBR)
+ return false;
+
+ var view_bottom = settings.get_boolean ("view-bottom-screen");
+ settings.set_boolean ("view-bottom-screen", !view_bottom);
+
+ return true;
+ }
+
+ public bool gamepad_button_release_event (Manette.Event event) {
+ return false;
+ }
+
+ public bool gamepad_absolute_axis_event (Manette.Event event) {
+ return false;
+ }
}
diff --git a/src/command/command-runner.vala b/src/command/command-runner.vala
index c70191d6..ca83c080 100644
--- a/src/command/command-runner.vala
+++ b/src/command/command-runner.vala
@@ -85,4 +85,16 @@ public class Games.CommandRunner : Object, Runner {
public InputMode[] get_available_input_modes () {
return { };
}
+
+ public bool gamepad_button_press_event (Manette.Event event) {
+ return false;
+ }
+
+ public bool gamepad_button_release_event (Manette.Event event) {
+ return false;
+ }
+
+ public bool gamepad_absolute_axis_event (Manette.Event event) {
+ return false;
+ }
}
diff --git a/src/core/runner.vala b/src/core/runner.vala
index c140405a..84799644 100644
--- a/src/core/runner.vala
+++ b/src/core/runner.vala
@@ -17,4 +17,8 @@ public interface Games.Runner : Object {
public abstract void pause ();
public abstract void stop ();
public abstract InputMode[] get_available_input_modes ();
+
+ public abstract bool gamepad_button_press_event (Manette.Event event);
+ public abstract bool gamepad_button_release_event (Manette.Event event);
+ public abstract bool gamepad_absolute_axis_event (Manette.Event event);
}
diff --git a/src/dummy/dummy-runner.vala b/src/dummy/dummy-runner.vala
index af443a54..d5abe7da 100644
--- a/src/dummy/dummy-runner.vala
+++ b/src/dummy/dummy-runner.vala
@@ -51,4 +51,16 @@ private class Games.DummyRunner : Object, Runner {
public InputMode[] get_available_input_modes () {
return { };
}
+
+ public bool gamepad_button_press_event (Manette.Event event) {
+ return false;
+ }
+
+ public bool gamepad_button_release_event (Manette.Event event) {
+ return false;
+ }
+
+ public bool gamepad_absolute_axis_event (Manette.Event event) {
+ return false;
+ }
}
diff --git a/src/meson.build b/src/meson.build
index 94bb1055..cfacbe6c 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -201,6 +201,8 @@ vala_sources = [
'main.vala',
]
+event_codes_dep = valac.find_library ('event-codes', dirs: gamepad_dir)
+
dependencies = [
config_dep,
handy_dep,
@@ -217,7 +219,7 @@ dependencies = [
xml_dep,
valac.find_library ('linux'),
valac.find_library ('posix'),
- valac.find_library ('event-codes', dirs: gamepad_dir),
+ event_codes_dep,
]
gnome_games_exec = executable (
@@ -235,9 +237,11 @@ plugin_dependencies = [
gio_dep,
glib_dep,
gtk_dep,
+ manette_dep,
retro_gtk_dep,
soup_dep,
tracker_sparql_dep,
+ event_codes_dep,
]
gnome_games_dep = declare_dependency (
diff --git a/src/retro/retro-runner.vala b/src/retro/retro-runner.vala
index 8b1e2a8d..b14d2ae0 100644
--- a/src/retro/retro-runner.vala
+++ b/src/retro/retro-runner.vala
@@ -309,6 +309,18 @@ public class Games.RetroRunner : Object, Runner {
return { InputMode.GAMEPAD };
}
+ public bool gamepad_button_press_event (Manette.Event event) {
+ return false;
+ }
+
+ public bool gamepad_button_release_event (Manette.Event event) {
+ return false;
+ }
+
+ public bool gamepad_absolute_axis_event (Manette.Event event) {
+ return false;
+ }
+
private void on_media_number_changed () {
if (!is_initialized)
return;
diff --git a/src/ui/application-window.vala b/src/ui/application-window.vala
index 443036a7..a59f21c4 100644
--- a/src/ui/application-window.vala
+++ b/src/ui/application-window.vala
@@ -291,6 +291,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;
@@ -305,18 +308,28 @@ private class Games.ApplicationWindow : Gtk.ApplicationWindow {
}
public bool gamepad_button_release_event (Manette.Event event) {
+ if (!is_active)
+ return false;
+
switch (ui_state) {
case UiState.COLLECTION:
- return is_active && collection_box.gamepad_button_release_event (event);
+ return collection_box.gamepad_button_release_event (event);
+ case UiState.DISPLAY:
+ return display_box.gamepad_button_release_event (event);
default:
return false;
}
}
public bool gamepad_absolute_axis_event (Manette.Event event) {
+ if (!is_active)
+ return false;
+
switch (ui_state) {
case UiState.COLLECTION:
- return is_active && collection_box.gamepad_absolute_axis_event (event);
+ return collection_box.gamepad_absolute_axis_event (event);
+ case UiState.DISPLAY:
+ return display_box.gamepad_absolute_axis_event (event);
default:
return false;
}
diff --git a/src/ui/display-box.vala b/src/ui/display-box.vala
index 97e96039..1ea8c63f 100644
--- a/src/ui/display-box.vala
+++ b/src/ui/display-box.vala
@@ -70,4 +70,34 @@ private class Games.DisplayBox : Gtk.Bin {
if (child != null)
display_bin.remove (child);
}
+
+ public bool gamepad_button_press_event (Manette.Event event) {
+ if (!get_mapped ())
+ return false;
+
+ if (runner == null)
+ return false;
+
+ return runner.gamepad_button_press_event (event);
+ }
+
+ public bool gamepad_button_release_event (Manette.Event event) {
+ if (!get_mapped ())
+ return false;
+
+ if (runner == null)
+ return false;
+
+ return runner.gamepad_button_release_event (event);
+ }
+
+ public bool gamepad_absolute_axis_event (Manette.Event event) {
+ if (!get_mapped ())
+ return false;
+
+ if (runner == null)
+ return false;
+
+ return runner.gamepad_absolute_axis_event (event);
+ }
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]