aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--dome_key_map.h6
-rw-r--r--src/cocoa_bridge.rs16
2 files changed, 22 insertions, 0 deletions
diff --git a/dome_key_map.h b/dome_key_map.h
index 7bd77ca..633e9b3 100644
--- a/dome_key_map.h
+++ b/dome_key_map.h
@@ -23,6 +23,8 @@ typedef enum {
MapKind_Command,
} MapKind;
+typedef struct State State;
+
typedef struct {
const HeadphoneButton *buttons;
size_t length;
@@ -35,3 +37,7 @@ typedef struct {
} CKeyActionResult;
const CKeyActionResult *c_run_key_action(Trigger trigger, const Trigger *mode);
+
+void state_free(State *ptr);
+
+State *state_new(void);
diff --git a/src/cocoa_bridge.rs b/src/cocoa_bridge.rs
index e860d24..a864e13 100644
--- a/src/cocoa_bridge.rs
+++ b/src/cocoa_bridge.rs
@@ -92,6 +92,22 @@ pub struct CKeyActionResult {
pub in_mode: *const Trigger,
}
+#[derive(Default)]
+pub struct State {
+ in_mode: Option<Vec<HeadphoneButton>>,
+}
+
+#[no_mangle]
+pub extern "C" fn state_new() -> *mut State {
+ Box::into_raw(Box::new(State::default()))
+}
+
+#[no_mangle]
+pub extern "C" fn state_free(ptr: *mut State) {
+ if ptr.is_null() { return }
+ unsafe { Box::from_raw(ptr); }
+}
+
#[no_mangle]
pub extern "C" fn c_run_key_action(
trigger: Trigger,