[gnome-games/wip/exalm/subprocess] Adapt for subprocess libretro



commit 5829ee3aa63e8a74eb45c2211b493f9f0e8dc61c
Author: Alexander Mikhaylenko <alexm gnome org>
Date:   Sun Jan 5 20:54:01 2020 +0500

    Adapt for subprocess libretro

 flatpak/org.gnome.Games.json                    |  3 ++-
 plugins/nintendo-ds/src/nintendo-ds-runner.vala | 10 --------
 src/core/runner.vala                            |  1 +
 src/retro/retro-gamepad.vala                    | 11 ++++-----
 src/retro/retro-options.vala                    |  3 +--
 src/retro/retro-runner.vala                     | 32 +++++++++++--------------
 src/ui/display-view.vala                        |  3 +++
 7 files changed, 26 insertions(+), 37 deletions(-)
---
diff --git a/flatpak/org.gnome.Games.json b/flatpak/org.gnome.Games.json
index 83ebd0cf..a9a8b074 100644
--- a/flatpak/org.gnome.Games.json
+++ b/flatpak/org.gnome.Games.json
@@ -218,7 +218,8 @@
             "sources" : [
                 {
                     "type" : "git",
-                    "url" : "https://gitlab.gnome.org/GNOME/retro-gtk.git";
+                    "url" : "https://gitlab.gnome.org/exalm/retro-gtk.git";,
+                    "branch" : "wip/exalm/subprocess"
                 }
             ]
         },
diff --git a/plugins/nintendo-ds/src/nintendo-ds-runner.vala b/plugins/nintendo-ds/src/nintendo-ds-runner.vala
index bfebab0f..a554fe3b 100644
--- a/plugins/nintendo-ds/src/nintendo-ds-runner.vala
+++ b/plugins/nintendo-ds/src/nintendo-ds-runner.vala
@@ -34,7 +34,6 @@ private class Games.NintendoDsRunner : RetroRunner {
        }
 
        construct {
-               game_init.connect (on_init);
        }
 
        private bool core_supports_layouts () {
@@ -43,12 +42,6 @@ private class Games.NintendoDsRunner : RetroRunner {
                return core != null && core.has_option (SCREENS_LAYOUT_OPTION);
        }
 
-       private void on_init () {
-               var core = get_core ();
-
-               core.options_set.connect (update_screen_layout);
-       }
-
        private void update_screen_layout () {
                if (!core_supports_layouts ())
                        return;
@@ -70,9 +63,6 @@ private class Games.NintendoDsRunner : RetroRunner {
        }
 
        public override Gtk.Widget? get_extra_widget () {
-               if (!core_supports_layouts ())
-                       return null;
-
                return new NintendoDsLayoutSwitcher (this);
        }
 
diff --git a/src/core/runner.vala b/src/core/runner.vala
index 7a10160b..98d23542 100644
--- a/src/core/runner.vala
+++ b/src/core/runner.vala
@@ -3,6 +3,7 @@
 public interface Games.Runner : Object {
        public signal void new_savestate_created ();
        public signal void stopped ();
+       public signal void crash (string message);
 
        public abstract bool can_fullscreen { get; }
        public abstract bool can_resume { get; }
diff --git a/src/retro/retro-gamepad.vala b/src/retro/retro-gamepad.vala
index 637f8438..127b6897 100644
--- a/src/retro/retro-gamepad.vala
+++ b/src/retro/retro-gamepad.vala
@@ -54,17 +54,16 @@ private class Games.RetroGamepad : Object, Retro.Controller {
                return (1 << Retro.ControllerType.JOYPAD) | (1 << Retro.ControllerType.ANALOG);
        }
 
-       public bool set_rumble_state (Retro.RumbleEffect effect, uint16 strength) {
-               rumble_effect[effect] = strength;
+       public bool get_supports_rumble () {
+               return device.has_rumble ();
+       }
 
-               if (!device.has_rumble ())
-                       return false;
+       public void set_rumble_state (Retro.RumbleEffect effect, uint16 strength) {
+               rumble_effect[effect] = strength;
 
                device.rumble (rumble_effect[Retro.RumbleEffect.STRONG],
                               rumble_effect[Retro.RumbleEffect.WEAK],
                               uint16.MAX);
-
-               return true;
        }
 
        private bool get_button_pressed (Retro.JoypadId button) {
diff --git a/src/retro/retro-options.vala b/src/retro/retro-options.vala
index 22c4e869..ea79f822 100644
--- a/src/retro/retro-options.vala
+++ b/src/retro/retro-options.vala
@@ -15,9 +15,8 @@ private class Games.RetroOptions : Object {
 
                foreach (var key in options_keys) {
                        var val = keyfile.get_string (OPTIONS_GROUP, key);
-                       var option = core.get_option (key);
 
-                       option.set_value (val);
+                       core.override_option_default (key, val);
                }
        }
 }
diff --git a/src/retro/retro-runner.vala b/src/retro/retro-runner.vala
index f80a8db1..b40f1630 100644
--- a/src/retro/retro-runner.vala
+++ b/src/retro/retro-runner.vala
@@ -251,6 +251,9 @@ public class Games.RetroRunner : Object, Runner {
        }
 
        public void resume () {
+               if (!is_initialized)
+                       return;
+
                if (!is_ready) {
                        critical ("RetroRunner.resume() cannot be called if the game isn't playing");
                        return;
@@ -271,9 +274,11 @@ public class Games.RetroRunner : Object, Runner {
                // Keep the internal values of input_mode in sync between RetroRunner and RetroInputManager
                _input_mode = input_manager.input_mode;
 
-               core.shutdown.connect (on_shutdown);
-
-               core.run (); // Needed to finish preparing some cores.
+               core.shutdown.connect (stop);
+               core.crashed.connect ((core, error) => {
+                       stop ();
+                       crash (error);
+               });
 
                loop = new Retro.MainLoop (core);
                running = false;
@@ -322,14 +327,12 @@ public class Games.RetroRunner : Object, Runner {
 
                var options_path = get_options_path ();
                if (FileUtils.test (options_path, FileTest.EXISTS))
-                       core.options_set.connect (() => {
-                               try {
-                                       var options = new RetroOptions (options_path);
-                                       options.apply (core);
-                               } catch (Error e) {
-                                       critical (e.message);
-                               }
-                       });
+                       try {
+                               var options = new RetroOptions (options_path);
+                               options.apply (core);
+                       } catch (Error e) {
+                               critical (e.message);
+                       }
 
                game_init ();
 
@@ -339,7 +342,6 @@ public class Games.RetroRunner : Object, Runner {
 
                core.save_directory = save_directory_path;
 
-               core.log.connect (Retro.g_log);
                view.set_core (core);
 
                string[] medias_uris = {};
@@ -595,12 +597,6 @@ public class Games.RetroRunner : Object, Runner {
                             null);
        }
 
-       private bool on_shutdown () {
-               stop ();
-
-               return true;
-       }
-
        private string get_unsupported_system_message () {
                var platform_name = platform.get_name ();
                if (platform_name != null)
diff --git a/src/ui/display-view.vala b/src/ui/display-view.vala
index b718e707..5e74ed04 100644
--- a/src/ui/display-view.vala
+++ b/src/ui/display-view.vala
@@ -286,6 +286,9 @@ private class Games.DisplayView : Object, UiView {
                header_bar.media_set = runner.media_set;
                box.header_bar.media_set = runner.media_set;
 
+               runner.crash.connect (message => {
+               });
+
                is_fullscreen = settings.get_boolean ("fullscreen") && runner.can_fullscreen;
 
                if (!runner.can_resume) {


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