[gnome-games/wip/exalm/sharp-x68000: 203/203] Revert "retro-input-manager: Don't set CoreView joypad controller"
- From: Alexander Mikhaylenko <alexm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games/wip/exalm/sharp-x68000: 203/203] Revert "retro-input-manager: Don't set CoreView joypad controller"
- Date: Thu, 29 Nov 2018 13:12:10 +0000 (UTC)
commit ec6806f255ea66ea8168b0a2a9ec188d731d5b21
Author: Alexander Mikhaylenko <exalm7659 gmail com>
Date: Wed Nov 28 19:56:04 2018 +0500
Revert "retro-input-manager: Don't set CoreView joypad controller"
This reverts commit 099eb11c4060bacddb1e66383bb22eeec5b9fa3c.
src/retro/retro-input-manager.vala | 53 +++++++++++++++++++++-----------------
1 file changed, 29 insertions(+), 24 deletions(-)
---
diff --git a/src/retro/retro-input-manager.vala b/src/retro/retro-input-manager.vala
index 5acd1257..c2059e0d 100644
--- a/src/retro/retro-input-manager.vala
+++ b/src/retro/retro-input-manager.vala
@@ -3,6 +3,7 @@
private class Games.RetroInputManager : Object {
private Retro.Core core;
private Retro.CoreView view;
+ private Retro.Controller core_view_joypad;
private KeyboardMappingManager keyboard_mapping_manager;
private Manette.Monitor monitor;
private InputMode _input_mode;
@@ -12,26 +13,19 @@ private class Games.RetroInputManager : Object {
if (value == _input_mode)
return;
- var core_view_joypad = view.as_controller (Retro.ControllerType.JOYPAD);
-
_input_mode = value;
- switch (value) {
- case InputMode.GAMEPAD:
- core.set_keyboard (null);
- core.set_default_controller (Retro.ControllerType.JOYPAD, core_view_joypad);
- break;
- case InputMode.KEYBOARD:
- core.set_keyboard (view);
- core.set_default_controller (Retro.ControllerType.JOYPAD, null);
+ if (value == InputMode.KEYBOARD) {
+ var core_view_keyboard = view.as_controller (Retro.ControllerType.KEYBOARD);
- break;
- case InputMode.NONE:
+ core.set_keyboard (view);
+ core.set_default_controller (Retro.ControllerType.KEYBOARD,
core_view_keyboard);
+ } else {
core.set_keyboard (null);
- core.set_default_controller (Retro.ControllerType.JOYPAD, null);
-
- break;
+ core.set_default_controller (Retro.ControllerType.KEYBOARD, null);
}
+
+ update_core_view_gamepad ();
}
}
@@ -52,8 +46,10 @@ private class Games.RetroInputManager : Object {
keyboard_mapping_manager = new KeyboardMappingManager ();
view.set_key_joypad_mapping (keyboard_mapping_manager.mapping);
keyboard_mapping_manager.changed.connect (on_keyboard_mapping_manager_changed);
+
view.set_as_default_controller (core);
- input_mode = InputMode.GAMEPAD;
+ core.set_default_controller (Retro.ControllerType.JOYPAD, null);
+ core_view_joypad = view.as_controller (Retro.ControllerType.JOYPAD);
monitor = new Manette.Monitor ();
var iterator = monitor.iterate ();
@@ -70,8 +66,9 @@ private class Games.RetroInputManager : Object {
core_view_joypad_port = controllers.length;
devices += null;
controllers += null;
- core.set_controller (core_view_joypad_port, null);
monitor.device_connected.connect (on_device_connected);
+
+ input_mode = InputMode.GAMEPAD;
}
~RetroInputManager () {
@@ -83,6 +80,18 @@ private class Games.RetroInputManager : Object {
core.set_controller (port, null);
}
+ private void update_core_view_gamepad () {
+ devices[core_view_joypad_port] = null;
+
+ if (input_mode == InputMode.GAMEPAD) {
+ controllers[core_view_joypad_port] = core_view_joypad;
+ core.set_controller (core_view_joypad_port, core_view_joypad);
+ } else {
+ controllers[core_view_joypad_port] = null;
+ core.set_controller (core_view_joypad_port, null);
+ }
+ }
+
private void on_keyboard_mapping_manager_changed () {
view.set_key_joypad_mapping (keyboard_mapping_manager.mapping);
}
@@ -103,9 +112,7 @@ private class Games.RetroInputManager : Object {
if (controllers[i] == null) {
// Found an disconnected port and so assigning core_view_joypad to it
core_view_joypad_port = i;
- devices[core_view_joypad_port] = null;
- controllers[core_view_joypad_port] = null;
- core.set_controller (core_view_joypad_port, null);
+ update_core_view_gamepad ();
return;
}
@@ -116,7 +123,7 @@ private class Games.RetroInputManager : Object {
core_view_joypad_port = controllers.length;
devices += null;
controllers += null;
- core.set_controller (core_view_joypad_port, null);
+ update_core_view_gamepad ();
}
private void on_device_disconnected (Manette.Device device) {
@@ -132,9 +139,7 @@ private class Games.RetroInputManager : Object {
devices[core_view_joypad_port] = null;
controllers[core_view_joypad_port] = null;
core_view_joypad_port = port;
- devices[core_view_joypad_port] = null;
- controllers[core_view_joypad_port] = null;
- core.set_controller (core_view_joypad_port, null);
+ update_core_view_gamepad ();
}
else {
// Just remove the controller as no need to shift the
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]