@@ -361,7 +361,7 @@ impl Manager {
361361 let is_suspended = match device. is_suspended ( ) . await {
362362 Ok ( suspended) => suspended,
363363 Err ( e) => {
364- log:: error !( "Failed to check if device is suspended: {e:?}" ) ;
364+ log:: debug !( "Failed to check if device is suspended: {e:?}" ) ;
365365 continue ;
366366 }
367367 } ;
@@ -1797,7 +1797,7 @@ impl Manager {
17971797 log:: info!( "Setting player order to: {order:?}" ) ;
17981798
17991799 // Ensure the given paths are valid composite device paths
1800- let new_order = order
1800+ let new_order: Vec < String > = order
18011801 . into_iter ( )
18021802 . filter ( |path| {
18031803 let is_valid = self . composite_devices . contains_key ( path) ;
@@ -1808,43 +1808,30 @@ impl Manager {
18081808 } )
18091809 . collect ( ) ;
18101810
1811- // Update gamepad order in dbus interface
1812- self . update_and_emit_gamepad_order ( new_order) ;
1811+ // Get each device to resume
1812+ let devices: Vec < CompositeDeviceClient > = new_order
1813+ . into_iter ( )
1814+ . map ( |path| self . composite_devices . get ( & path) . unwrap ( ) . clone ( ) )
1815+ . collect ( ) ;
18131816
1814- let manager_tx = self . tx . clone ( ) ;
18151817 tokio:: task:: spawn ( async move {
1816- // Send suspend command to manager
1817- let ( tx, mut rx) = mpsc:: channel ( 1 ) ;
1818- if let Err ( e) = manager_tx
1819- . send ( ManagerCommand :: SystemSleep { sender : tx } )
1820- . await
1821- {
1822- log:: error!( "Failed to send system sleep command to manager: {e:?}" ) ;
1823- return ;
1824- }
1825-
1826- // Wait for all devices to suspend
1827- if rx. recv ( ) . await . is_none ( ) {
1828- log:: error!( "Failed to get response from manager for system sleep command" ) ;
1829- return ;
1818+ // Suspend all composite devices
1819+ for device in devices. iter ( ) {
1820+ if let Err ( e) = device. suspend ( ) . await {
1821+ log:: warn!( "Failed to suspend device: {e}" ) ;
1822+ }
18301823 }
18311824
18321825 // Sleep a little bit before resuming target devices
18331826 tokio:: time:: sleep ( Duration :: from_millis ( 100 ) ) . await ;
18341827
1835- // Send wake command to manager
1836- let ( tx, mut rx) = mpsc:: channel ( 1 ) ;
1837- if let Err ( e) = manager_tx
1838- . send ( ManagerCommand :: SystemWake { sender : tx } )
1839- . await
1840- {
1841- log:: error!( "Failed to send system wake command to manager: {e:?}" ) ;
1842- return ;
1843- }
1844-
1845- // Wait for all devices to resume
1846- if rx. recv ( ) . await . is_none ( ) {
1847- log:: error!( "Failed to get response from manager for system wake command" ) ;
1828+ // Resume all composite devices in order
1829+ for device in devices. iter ( ) {
1830+ if let Err ( e) = device. resume ( ) . await {
1831+ log:: warn!( "Failed to resume device: {e}" ) ;
1832+ continue ;
1833+ }
1834+ tokio:: time:: sleep ( Duration :: from_millis ( 100 ) ) . await ;
18481835 }
18491836 } ) ;
18501837
0 commit comments