aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTeddy Wing2018-10-14 19:14:39 +0200
committerTeddy Wing2018-10-14 19:14:39 +0200
commit8fff0de618845d6914e3869f061f3dbdeaa5ed05 (patch)
tree902c470215fd57a13afcc0c5857941c796346556
parentfa0e4bbca9140a0a894d21f90a2aab7371696b39 (diff)
downloaddome-key-map-8fff0de618845d6914e3869f061f3dbdeaa5ed05.tar.bz2
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.
-rw-r--r--dome_key_map.h2
-rw-r--r--src/key_code.rs17
2 files changed, 19 insertions, 0 deletions
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,