Skip to content

Commit 844205a

Browse files
committed
Add Hotkey for Cleaning Memory
1 parent 9c97775 commit 844205a

File tree

4 files changed

+16
-5
lines changed

4 files changed

+16
-5
lines changed

gameutil-rs/Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
[package]
22
name = "gameutil-rs"
3-
version = "0.1.0"
3+
version = "0.2.0"
44
edition = "2021"
55

66
[dependencies]
77
windows-dll = "0.3.0"
88
winapi = { version = "0.3.9", features = ["processthreadsapi"] }
99
sysinfo = "0.22.4"
1010
nwg = {version = "^1.0.12", package = "native-windows-gui"}
11+
livesplit-hotkey = "0.6.0"
1112

1213
[target.'cfg(target_os="windows")'.build-dependencies]
1314
winres = "^0.1"
@@ -16,5 +17,4 @@ winres = "^0.1"
1617
opt-level = 3
1718
lto = true
1819
codegen-units = 1
19-
panic = "abort"
20-
debug = 0
20+
panic = "abort"

gameutil-rs/src/gui.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use nwg::NativeUi;
22

3-
mod sys;
3+
pub mod sys;
44

55
#[derive(Default)]
66
pub struct GameUtil {

gameutil-rs/src/gui/sys.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,3 +146,12 @@ pub fn cleanworkingset() {
146146
}
147147
}
148148
}
149+
150+
// TODO: args for more hotkeys and callbacks
151+
pub fn hotkey() -> livesplit_hotkey::Hook {
152+
let hotkey = livesplit_hotkey::Hook::new().expect("failed to make new hotkey!");
153+
hotkey.register(livesplit_hotkey::KeyCode::F4, move || {
154+
cleanworkingset();
155+
}).expect("failed to register hotkey!");
156+
hotkey
157+
}

gameutil-rs/src/main.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,7 @@
33
mod gui;
44

55
fn main() {
6+
let hotkey = gui::sys::hotkey();
67
gui::gui_init();
7-
}
8+
hotkey.unregister(livesplit_hotkey::KeyCode::F4).expect("failed to unregister hotkey!");
9+
}

0 commit comments

Comments
 (0)