[gnome-games] retro: Adapt to API changes in retro-gtk
- From: Adrien Plazas <aplazas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games] retro: Adapt to API changes in retro-gtk
- Date: Tue, 10 Oct 2017 17:48:30 +0000 (UTC)
commit e1d5c22fccc8c3511a321734b7a30f7646cf7f29
Author: Adrien Plazas <kekun plazas laposte net>
Date: Tue Oct 10 14:04:23 2017 +0200
retro: Adapt to API changes in retro-gtk
src/retro/retro-core-source.vala | 7 ++++++-
src/retro/retro-input-manager.vala | 36 +++++++++++++-----------------------
src/retro/retro-runner.vala | 16 ++++++----------
3 files changed, 25 insertions(+), 34 deletions(-)
---
diff --git a/src/retro/retro-core-source.vala b/src/retro/retro-core-source.vala
index 30ddaa5..b50ddc2 100644
--- a/src/retro/retro-core-source.vala
+++ b/src/retro/retro-core-source.vala
@@ -37,7 +37,7 @@ public class Games.RetroCoreSource : Object {
throw new RetroError.MODULE_NOT_FOUND (_("No module found for platform “%s” and MIME
types [ “%s” ]."), platform, string.joinv (_("”, “"), mime_types));
if (core_descriptor.has_firmwares (platform))
- foreach (var firmware in core_descriptor.get_firmwares (platform))
+ foreach (var firmware in core_descriptor_get_firmwares (core_descriptor, platform))
check_firmware_is_valid (firmware);
}
@@ -99,4 +99,9 @@ public class Games.RetroCoreSource : Object {
throw new RetroError.FIRMWARE_NOT_FOUND (_("This game requires the %s
firmware file with a SHA-512 fingerprint of %s to run."), firmware_file.get_path (), sha512);
}
}
+
+ // FIXME Workaround a bug in valac or vapigen preventing from using the
+ // version from the retro-gtk VAPI.
+ [CCode (cname="retro_core_descriptor_get_firmwares", array_length=true, array_length_cname="length",
array_length_type="gsize")]
+ private static extern string[] core_descriptor_get_firmwares (Retro.CoreDescriptor core_descriptor,
string platform) throws Error;
}
diff --git a/src/retro/retro-input-manager.vala b/src/retro/retro-input-manager.vala
index 8595b9f..bdf24a1 100644
--- a/src/retro/retro-input-manager.vala
+++ b/src/retro/retro-input-manager.vala
@@ -1,30 +1,32 @@
// This file is part of GNOME Games. License: GPL-3.0+.
-private class Games.RetroInputManager : Retro.InputDeviceManager, Retro.Rumble {
+private class Games.RetroInputManager : Object {
+ private Retro.Core core;
private Retro.InputDevice core_view_joypad;
private GamepadMonitor gamepad_monitor;
private Retro.InputDevice?[] input_devices;
private int core_view_joypad_port;
private bool present_analog_sticks;
- public RetroInputManager (Retro.CoreView view, bool present_analog_sticks) {
+ public RetroInputManager (Retro.Core core, Retro.CoreView view, bool present_analog_sticks) {
+ this.core = core;
this.present_analog_sticks = present_analog_sticks;
core_view_joypad = view.as_input_device (Retro.DeviceType.JOYPAD);
- set_keyboard (view);
+ core.set_keyboard (view);
gamepad_monitor = GamepadMonitor.get_instance ();
gamepad_monitor.foreach_gamepad ((gamepad) => {
var port = input_devices.length;
var retro_gamepad = new RetroGamepad (gamepad, present_analog_sticks);
input_devices += retro_gamepad;
- set_controller_device (port, retro_gamepad);
+ core.set_controller (port, retro_gamepad);
gamepad.unplugged.connect (() => handle_gamepad_unplugged (port));
});
core_view_joypad_port = input_devices.length;
input_devices += core_view_joypad;
- set_controller_device (core_view_joypad_port, core_view_joypad);
+ core.set_controller (core_view_joypad_port, core_view_joypad);
gamepad_monitor.gamepad_plugged.connect (handle_gamepad_plugged);
}
@@ -34,7 +36,7 @@ private class Games.RetroInputManager : Retro.InputDeviceManager, Retro.Rumble {
var port = core_view_joypad_port;
var retro_gamepad = new RetroGamepad (gamepad, present_analog_sticks);
input_devices[port] = retro_gamepad;
- set_controller_device (port, retro_gamepad);
+ core.set_controller (port, retro_gamepad);
gamepad.unplugged.connect (() => handle_gamepad_unplugged (port));
// Assign the CoreView's joypad to another unplugged port if it
@@ -44,7 +46,7 @@ private class Games.RetroInputManager : Retro.InputDeviceManager, Retro.Rumble {
// Found an unplugged port and so assigning core_view_joypad to it
core_view_joypad_port = i;
input_devices[core_view_joypad_port] = core_view_joypad;
- set_controller_device (core_view_joypad_port, core_view_joypad);
+ core.set_controller (core_view_joypad_port, core_view_joypad);
return;
}
@@ -54,7 +56,7 @@ private class Games.RetroInputManager : Retro.InputDeviceManager, Retro.Rumble {
// CoreView's joypad to ports.
core_view_joypad_port = input_devices.length;
input_devices += core_view_joypad;
- set_controller_device (core_view_joypad_port, core_view_joypad);
+ core.set_controller (core_view_joypad_port, core_view_joypad);
}
private void handle_gamepad_unplugged (int port) {
@@ -62,28 +64,16 @@ private class Games.RetroInputManager : Retro.InputDeviceManager, Retro.Rumble {
// Remove the controller and shift the CoreView's joypad to
// "lesser" port.
input_devices[core_view_joypad_port] = null;
- remove_controller_device (core_view_joypad_port);
+ core.remove_controller (core_view_joypad_port);
core_view_joypad_port = port;
input_devices[core_view_joypad_port] = core_view_joypad;
- set_controller_device (core_view_joypad_port, core_view_joypad);
+ core.set_controller (core_view_joypad_port, core_view_joypad);
}
else {
// Just remove the controller as no need to shift the
// CoreView's joypad.
input_devices[port] = null;
- remove_controller_device (port);
+ core.remove_controller (port);
}
}
-
- private bool set_rumble_state (uint port, Retro.RumbleEffect effect, uint16 strength) {
- if (port > input_devices.length)
- return false;
-
- if (input_devices[port] == null || input_devices[port] == core_view_joypad)
- return false;
-
- // TODO Transmit the rumble signal to the gamepad.
-
- return false;
- }
}
diff --git a/src/retro/retro-runner.vala b/src/retro/retro-runner.vala
index 1448490..f7261ec 100644
--- a/src/retro/retro-runner.vala
+++ b/src/retro/retro-runner.vala
@@ -190,11 +190,11 @@ public class Games.RetroRunner : Object, Runner {
settings.changed["video-filter"].connect (on_video_filter_changed);
on_video_filter_changed ();
- var present_analog_sticks = input_capabilities == null ||
input_capabilities.get_allow_analog_gamepads ();
- input_manager = new RetroInputManager (view, present_analog_sticks);
-
prepare_core ();
+ var present_analog_sticks = input_capabilities == null ||
input_capabilities.get_allow_analog_gamepads ();
+ input_manager = new RetroInputManager (core, view, present_analog_sticks);
+
core.shutdown.connect (on_shutdown);
core.run (); // Needed to finish preparing some cores.
@@ -256,8 +256,6 @@ public class Games.RetroRunner : Object, Runner {
core.log.connect (Retro.g_log);
view.set_core (core);
- core.input_interface = input_manager;
- core.rumble_interface = input_manager;
string[] medias_uris = {};
media_set.foreach_media ((media) => {
@@ -266,9 +264,7 @@ public class Games.RetroRunner : Object, Runner {
});
core.set_medias (medias_uris);
-
- core.init ();
-
+ core.boot ();
core.set_current_media (media_set.selected_media_number);
}
@@ -428,7 +424,7 @@ public class Games.RetroRunner : Object, Runner {
if (!core.supports_serialization ())
return;
- var buffer = core.serialize_state ();
+ var buffer = core.get_state ();
var dir = Application.get_snapshots_dir ();
try_make_dir (dir);
@@ -450,7 +446,7 @@ public class Games.RetroRunner : Object, Runner {
uint8[] data = null;
FileUtils.get_data (snapshot_path, out data);
- core.deserialize_state (data);
+ core.set_state (data);
}
private void save_media_data () throws Error {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]