-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This only works on Windows right now. It compiles on other platforms too, but is stubbed out with a dummy implementation, that just never causes any hotkey events.
- Loading branch information
Showing
21 changed files
with
589 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "livesplit-core" | ||
version = "0.1.4" | ||
version = "0.2.0" | ||
authors = ["Christopher Serr <[email protected]>"] | ||
documentation = "https://docs.rs/livesplit-core/" | ||
repository = "https://github.com/CryZe/livesplit-core" | ||
|
@@ -27,3 +27,4 @@ image = "0.12.3" | |
derive_more = "0.6.0" | ||
derive-new = "0.4.0" | ||
pdqsort = "0.1.2" | ||
hotkey = { path = "hotkey" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "livesplit-core-capi" | ||
version = "0.1.4" | ||
version = "0.2.0" | ||
authors = ["Christopher Serr <[email protected]>"] | ||
|
||
[dependencies] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
use livesplit_core::HotkeyTimer; | ||
use timer::OwnedTimer; | ||
use timer_read_lock::OwnedTimerReadLock; | ||
use timer_write_lock::OwnedTimerWriteLock; | ||
use super::{alloc, own, acc, drop}; | ||
use std::ptr; | ||
|
||
pub type OwnedHotkeyTimer = *mut HotkeyTimer; | ||
|
||
#[no_mangle] | ||
pub unsafe extern "C" fn HotkeyTimer_new(timer: OwnedTimer) -> OwnedHotkeyTimer { | ||
if let Ok(timer) = HotkeyTimer::new(own(timer)) { | ||
alloc(timer) | ||
} else { | ||
ptr::null_mut() | ||
} | ||
} | ||
|
||
#[no_mangle] | ||
pub unsafe extern "C" fn HotkeyTimer_drop(this: OwnedHotkeyTimer) { | ||
drop(this); | ||
} | ||
|
||
#[no_mangle] | ||
pub unsafe extern "C" fn HotkeyTimer_read(this: *const HotkeyTimer) -> OwnedTimerReadLock { | ||
alloc(acc(this).read()) | ||
} | ||
|
||
#[no_mangle] | ||
pub unsafe extern "C" fn HotkeyTimer_write(this: *const HotkeyTimer) -> OwnedTimerWriteLock { | ||
alloc(acc(this).write()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
use livesplit_core::Timer; | ||
use super::{drop, acc}; | ||
use std::sync::RwLockReadGuard; | ||
use std::ops::Deref; | ||
|
||
pub type TimerReadLock = RwLockReadGuard<'static, Timer>; | ||
pub type OwnedTimerReadLock = *mut TimerReadLock; | ||
|
||
#[no_mangle] | ||
pub unsafe extern "C" fn TimerReadLock_drop(this: OwnedTimerReadLock) { | ||
drop(this); | ||
} | ||
|
||
#[no_mangle] | ||
pub unsafe extern "C" fn TimerReadLock_timer(this: *const TimerReadLock) -> *const Timer { | ||
acc(this).deref() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
use livesplit_core::Timer; | ||
use super::{drop, acc_mut}; | ||
use std::sync::RwLockWriteGuard; | ||
use std::ops::DerefMut; | ||
|
||
pub type TimerWriteLock = RwLockWriteGuard<'static, Timer>; | ||
pub type OwnedTimerWriteLock = *mut TimerWriteLock; | ||
|
||
#[no_mangle] | ||
pub unsafe extern "C" fn TimerWriteLock_drop(this: OwnedTimerWriteLock) { | ||
drop(this); | ||
} | ||
|
||
#[no_mangle] | ||
pub unsafe extern "C" fn TimerWriteLock_timer(this: *mut TimerWriteLock) -> *mut Timer { | ||
acc_mut(this).deref_mut() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
target/ | ||
**/*.rs.bk | ||
Cargo.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
[package] | ||
name = "hotkey" | ||
version = "0.1.0" | ||
authors = ["Christopher Serr <[email protected]>"] | ||
|
||
[target.'cfg(windows)'.dependencies] | ||
winapi = "0.2.8" | ||
user32-sys = "0.2.0" | ||
kernel32-sys = "0.2.2" | ||
|
||
[dependencies] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#[cfg(windows)] | ||
pub mod windows; | ||
#[cfg(windows)] | ||
pub use windows::*; | ||
|
||
#[cfg(not(any(windows)))] | ||
pub mod other; | ||
#[cfg(not(any(windows)))] | ||
pub use other::*; | ||
|
||
#[derive(Debug, Clone, Copy, Eq, PartialEq, Hash)] | ||
pub enum KeyEvent { | ||
KeyUp(KeyCode), | ||
KeyDown(KeyCode), | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
use KeyEvent; | ||
|
||
#[derive(Debug, Eq, PartialEq, Hash, Copy, Clone)] | ||
pub struct KeyCode; | ||
|
||
pub struct Hook; | ||
|
||
pub fn register_hook<F>(callback: F) -> Result<Hook, ()> | ||
where F: FnMut(KeyEvent) + Send + 'static | ||
{ | ||
drop(callback); | ||
Ok(Hook) | ||
} |
Oops, something went wrong.