Skip to content

Commit

Permalink
Add Hotkey for Cleaning Memory
Browse files Browse the repository at this point in the history
  • Loading branch information
Zusier committed Mar 1, 2022
1 parent 9c97775 commit 844205a
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 5 deletions.
6 changes: 3 additions & 3 deletions gameutil-rs/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
[package]
name = "gameutil-rs"
version = "0.1.0"
version = "0.2.0"
edition = "2021"

[dependencies]
windows-dll = "0.3.0"
winapi = { version = "0.3.9", features = ["processthreadsapi"] }
sysinfo = "0.22.4"
nwg = {version = "^1.0.12", package = "native-windows-gui"}
livesplit-hotkey = "0.6.0"

[target.'cfg(target_os="windows")'.build-dependencies]
winres = "^0.1"
Expand All @@ -16,5 +17,4 @@ winres = "^0.1"
opt-level = 3
lto = true
codegen-units = 1
panic = "abort"
debug = 0
panic = "abort"
2 changes: 1 addition & 1 deletion gameutil-rs/src/gui.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use nwg::NativeUi;

mod sys;
pub mod sys;

#[derive(Default)]
pub struct GameUtil {
Expand Down
9 changes: 9 additions & 0 deletions gameutil-rs/src/gui/sys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,3 +146,12 @@ pub fn cleanworkingset() {
}
}
}

// TODO: args for more hotkeys and callbacks
pub fn hotkey() -> livesplit_hotkey::Hook {
let hotkey = livesplit_hotkey::Hook::new().expect("failed to make new hotkey!");
hotkey.register(livesplit_hotkey::KeyCode::F4, move || {
cleanworkingset();
}).expect("failed to register hotkey!");
hotkey
}
4 changes: 3 additions & 1 deletion gameutil-rs/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,7 @@
mod gui;

fn main() {
let hotkey = gui::sys::hotkey();
gui::gui_init();
}
hotkey.unregister(livesplit_hotkey::KeyCode::F4).expect("failed to unregister hotkey!");
}

0 comments on commit 844205a

Please sign in to comment.