[gnome-games] retro-input-manager: Add 'input-mode' property
- From: Alexander Mikhaylenko <alexm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games] retro-input-manager: Add 'input-mode' property
- Date: Tue, 20 Nov 2018 01:43:05 +0000 (UTC)
commit 484aa2d2cc3f96b2d619393d6395fbea08d798e5
Author: Yetizone <andreii lisita gmail com>
Date: Sun Nov 18 18:15:03 2018 +0200
retro-input-manager: Add 'input-mode' property
Only allow gamepad input in `InputMode.GAMEPAD`, and only keyboard input in `InputMode.KEYBOARD`.
src/retro/retro-input-manager.vala | 32 +++++++++++++++++++++++++++++++-
1 file changed, 31 insertions(+), 1 deletion(-)
---
diff --git a/src/retro/retro-input-manager.vala b/src/retro/retro-input-manager.vala
index c31221cb..5acd1257 100644
--- a/src/retro/retro-input-manager.vala
+++ b/src/retro/retro-input-manager.vala
@@ -5,6 +5,36 @@ private class Games.RetroInputManager : Object {
private Retro.CoreView view;
private KeyboardMappingManager keyboard_mapping_manager;
private Manette.Monitor monitor;
+ private InputMode _input_mode;
+ public InputMode input_mode {
+ get { return _input_mode; }
+ set {
+ 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);
+
+ break;
+ case InputMode.NONE:
+ core.set_keyboard (null);
+ core.set_default_controller (Retro.ControllerType.JOYPAD, null);
+
+ break;
+ }
+ }
+ }
+
// This is used only to compute the port on which a device is connected,
// which is needed to not store it in closures which would also hold a
// reference on the current object and create a reference cycle, leading to
@@ -22,8 +52,8 @@ 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);
- core.set_keyboard (view);
view.set_as_default_controller (core);
+ input_mode = InputMode.GAMEPAD;
monitor = new Manette.Monitor ();
var iterator = monitor.iterate ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]