From 5a7b155a8c1efff7691b0b2184b1f0feaa9a7a69 Mon Sep 17 00:00:00 2001 From: Nolan Darilek Date: Thu, 14 Mar 2024 13:04:42 -0500 Subject: [PATCH] chore: Upgrade Bevy to v0.13 and windows to v0.54. --- Cargo.toml | 4 ++-- src/lib.rs | 8 +++++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 7250c7b..2e85d42 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,11 +9,11 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -bevy = { version = "0.12", default-features = false } +bevy = { version = "0.13", default-features = false } ctrlc = "3" [target.'cfg(windows)'.dependencies] -windows = { version = "0.52", features = [ +windows = { version = "0.54", features = [ "Win32_Foundation", "Win32_System_Power", "Win32_System_Registry", diff --git a/src/lib.rs b/src/lib.rs index b5cc9a7..78aefdb 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -18,12 +18,15 @@ fn setup(mut commands: Commands) { #[cfg(windows)] unsafe { let mut active: *mut GUID = std::ptr::null_mut(); - Power::PowerGetActiveScheme(None, &mut active).expect("Failed to get active power scheme"); + Power::PowerGetActiveScheme(None, &mut active) + .ok() + .expect("Failed to get active power scheme"); if let Some(active) = active.as_ref() { let scheme = DefaultScheme(*active); commands.insert_resource(scheme); ctrlc::set_handler(move || { Power::PowerSetActiveScheme(None, Some(active)) + .ok() .expect("Failed to set power scheme"); std::process::exit(1); }) @@ -45,6 +48,7 @@ fn focus_change( #[cfg(windows)] unsafe { Power::PowerSetActiveScheme(None, Some(&GUID_MIN_POWER_SAVINGS)) + .ok() .expect("Failed to set power scheme"); } } else { @@ -52,6 +56,7 @@ fn focus_change( if config.restore_original_scheme_on_unfocus { unsafe { Power::PowerSetActiveScheme(None, Some(&**scheme)) + .ok() .expect("Failed to set power scheme"); } } @@ -65,6 +70,7 @@ fn exit(mut exit: EventReader, scheme: Res) { #[cfg(windows)] unsafe { Power::PowerSetActiveScheme(None, Some(&**scheme)) + .ok() .expect("Failed to restore original power scheme"); } }