Skip to content

Commit 8ab96c0

Browse files
committed
fix(Input): enable InputPlumber management of all supported devices in full session
1 parent c89e4a3 commit 8ab96c0

File tree

3 files changed

+43
-0
lines changed

3 files changed

+43
-0
lines changed

core/ui/card_ui/card_ui.gd

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,9 @@ func _ready() -> void:
143143
get_viewport().gui_focus_changed.connect(_on_focus_changed)
144144
library_manager.reload_library()
145145

146+
# Enable InputPlumber management of all supported input devices
147+
input_plumber.manage_all_devices = true
148+
146149
# Setup inputplumber to receive guide presses.
147150
input_plumber.set_intercept_mode(InputPlumberInstance.INTERCEPT_MODE_ALL)
148151
input_plumber.set_intercept_activation(PackedStringArray(["Gamepad:Button:Guide"]), "Gamepad:Button:Guide")

extensions/core/src/dbus/inputplumber/input_manager.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,12 @@ trait InputManager {
3838
/// StopTargetDevice method
3939
fn stop_target_device(&self, path: &str) -> zbus::Result<()>;
4040

41+
/// ManageAllDevices property
42+
#[zbus(property)]
43+
fn manage_all_devices(&self) -> zbus::Result<bool>;
44+
#[zbus(property)]
45+
fn set_manage_all_devices(&self, value: bool) -> zbus::Result<()>;
46+
4147
/// InterceptMode property
4248
#[zbus(property)]
4349
fn intercept_mode(&self) -> zbus::Result<String>;

extensions/core/src/input/inputplumber.rs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ use godot::classes::{Engine, Resource};
1717
use zbus::fdo::ObjectManagerProxy;
1818
use zbus::names::BusName;
1919

20+
use crate::dbus::inputplumber::input_manager::InputManagerProxyBlocking;
2021
use crate::dbus::RunError;
2122
use crate::{get_dbus_system, get_dbus_system_blocking, RUNTIME};
2223

@@ -101,6 +102,10 @@ pub struct InputPlumberInstance {
101102
/// The current target event for intercept mode
102103
#[var(get = get_intercept_target, set = set_intercept_target)]
103104
intercept_target: GString,
105+
/// Whether or not to automatically manage all supported input devices
106+
#[allow(dead_code)]
107+
#[var(get = get_manage_all_devices, set = set_manage_all_devices)]
108+
manage_all_devices: bool,
104109
}
105110

106111
#[godot_api]
@@ -128,6 +133,15 @@ impl InputPlumberInstance {
128133
#[signal]
129134
fn composite_device_removed(dbus_path: GString);
130135

136+
/// Return a proxy instance to the input manager
137+
fn get_proxy(&self) -> Option<InputManagerProxyBlocking> {
138+
if let Some(conn) = self.conn.as_ref() {
139+
InputManagerProxyBlocking::builder(conn).build().ok()
140+
} else {
141+
None
142+
}
143+
}
144+
131145
/// Returns true if the InputPlumber service is currently running
132146
#[func]
133147
fn is_running(&self) -> bool {
@@ -259,6 +273,24 @@ impl InputPlumberInstance {
259273
}
260274
}
261275

276+
/// Gets whether or not InputPlumber should automatically manage all supported devices
277+
#[func]
278+
fn get_manage_all_devices(&self) -> bool {
279+
let Some(proxy) = self.get_proxy() else {
280+
return false;
281+
};
282+
proxy.manage_all_devices().unwrap_or_default()
283+
}
284+
285+
/// Sets whether or not InputPlumber should automatically manage all supported devices
286+
#[func]
287+
fn set_manage_all_devices(&self, value: bool) {
288+
let Some(proxy) = self.get_proxy() else {
289+
return;
290+
};
291+
proxy.set_manage_all_devices(value).unwrap_or_default()
292+
}
293+
262294
/// Gets the current intercept mode for all composite devices
263295
#[func]
264296
fn get_intercept_mode(&self) -> i64 {
@@ -408,6 +440,7 @@ impl IResource for InputPlumberInstance {
408440
intercept_mode: Default::default(),
409441
intercept_triggers: Default::default(),
410442
intercept_target: Default::default(),
443+
manage_all_devices: Default::default(),
411444
};
412445
}
413446

@@ -428,6 +461,7 @@ impl IResource for InputPlumberInstance {
428461
intercept_mode: 0,
429462
intercept_triggers: PackedStringArray::from(&["Gamepad:Button:Guide".into()]),
430463
intercept_target: "Gamepad:Button:Guide".into(),
464+
manage_all_devices: Default::default(),
431465
};
432466

433467
// Do initial device discovery

0 commit comments

Comments
 (0)