[gnome-games/wip/exalm/loading: 14/29] libretro: Add runner factory
- From: Alexander Mikhaylenko <alexm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games/wip/exalm/loading: 14/29] libretro: Add runner factory
- Date: Mon, 11 Nov 2019 21:45:50 +0000 (UTC)
commit 2bf51b2bf2ef6c31a2d511eba41e2b7c6620bdb9
Author: Alexander Mikhaylenko <alexm gnome org>
Date: Tue Nov 12 01:39:47 2019 +0500
libretro: Add runner factory
plugins/libretro/src/libretro-plugin.vala | 29 ++++++++++++++++++++++++++++-
1 file changed, 28 insertions(+), 1 deletion(-)
---
diff --git a/plugins/libretro/src/libretro-plugin.vala b/plugins/libretro/src/libretro-plugin.vala
index 3e93f4da..ac3b9b12 100644
--- a/plugins/libretro/src/libretro-plugin.vala
+++ b/plugins/libretro/src/libretro-plugin.vala
@@ -30,7 +30,14 @@ private class Games.LibretroPlugin : Object, Plugin {
return { factory };
}
- private static Game game_for_uri (Uri uri) throws Error {
+ public RunnerFactory[] get_runner_factories () {
+ var factory = new GenericRunnerFactory (create_runner);
+ factory.add_platform (platform);
+
+ return { factory };
+ }
+
+ private static Retro.CoreDescriptor get_core_descriptor (Uri uri) throws Error {
var file_uri = new Uri.from_uri_and_scheme (uri, "file");
var file = file_uri.to_file ();
if (!file.query_exists ())
@@ -41,6 +48,12 @@ private class Games.LibretroPlugin : Object, Plugin {
if (!core_descriptor.get_is_game ())
throw new LibretroError.NOT_A_GAME ("This Libretro core descriptor doesn't isn’t a
game: %s", uri.to_string ());
+ return core_descriptor;
+ }
+
+ private static Game game_for_uri (Uri uri) throws Error {
+ var core_descriptor = get_core_descriptor (uri);
+
var uid = new LibretroUid (core_descriptor);
var title = new LibretroTitle (core_descriptor);
var icon = new LibretroIcon (core_descriptor);
@@ -59,6 +72,20 @@ private class Games.LibretroPlugin : Object, Plugin {
return game;
}
+
+ private static Runner? create_runner (Game game) throws Error {
+ var uri = game.get_uri ();
+ var core_descriptor = get_core_descriptor (uri);
+ var input_capabilities = new LibretroInputCapabilities ();
+
+ var builder = new RetroRunnerBuilder ();
+ builder.core_descriptor = core_descriptor;
+ builder.platform = platform;
+ builder.uid = game.get_uid ();
+ builder.title = game.name;
+ builder.input_capabilities = input_capabilities;
+ return builder.to_runner ();
+ }
}
[ModuleInit]
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]