@@ -17,6 +17,7 @@ use godot::classes::{Engine, Resource};
1717use zbus:: fdo:: ObjectManagerProxy ;
1818use zbus:: names:: BusName ;
1919
20+ use crate :: dbus:: inputplumber:: input_manager:: InputManagerProxyBlocking ;
2021use crate :: dbus:: RunError ;
2122use 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