From 8fff0de618845d6914e3869f061f3dbdeaa5ed05 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Sun, 14 Oct 2018 19:14:39 +0200 Subject: Test media key simulator static library Added a build of `libdome_key_event_source_simulator.a` to the root of the project to test running the function from Rust. Works. Needs to be built with custom `RUSTFLAGS` in order to build: $ RUSTFLAGS="-L ." cargo test dktest We'll need to figure out how to add this to the Rust build script. Now that we know it works, we can integrate the static library more permanently into the project. --- dome_key_map.h | 2 ++ src/key_code.rs | 17 +++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/dome_key_map.h b/dome_key_map.h index 63de9fe..2e77bc9 100644 --- a/dome_key_map.h +++ b/dome_key_map.h @@ -39,6 +39,8 @@ void c_run_key_action(State *state, Trigger trigger, const Trigger *mode); void config_free(Config *ptr); +extern void dkess_press_key(int16_t key, int16_t modifier_flags); + void logger_init(void); void state_free(State *ptr); diff --git a/src/key_code.rs b/src/key_code.rs index c2a2d2a..e0cb4e9 100644 --- a/src/key_code.rs +++ b/src/key_code.rs @@ -32,6 +32,23 @@ use core_graphics::event::{ // } // } +#[link(name = "dome_key_event_source_simulator", kind="static")] +extern "C" { + fn dkess_press_key(key: i16, modifier_flags: i16); +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn dktest() { + unsafe { + dkess_press_key(0, 0); + } + } +} + // kVK_F13 = 0x69, // kVK_F14 = 0x6B, // kVK_F15 = 0x71, -- cgit v1.2.3