aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--dome_key_map.h1
-rw-r--r--src/cocoa_bridge.rs28
2 files changed, 16 insertions, 13 deletions
diff --git a/dome_key_map.h b/dome_key_map.h
index 4ee30c3..76b5f1c 100644
--- a/dome_key_map.h
+++ b/dome_key_map.h
@@ -26,6 +26,7 @@ typedef enum {
typedef struct {
const char *action;
const ActionKind *kind;
+ const HeadphoneButton *in_mode;
} CKeyActionResult;
typedef struct {
diff --git a/src/cocoa_bridge.rs b/src/cocoa_bridge.rs
index 1717b57..920ea02 100644
--- a/src/cocoa_bridge.rs
+++ b/src/cocoa_bridge.rs
@@ -86,6 +86,7 @@ impl<'a> KeyActionResult<'a> {
pub struct CKeyActionResult {
pub action: *const c_char,
pub kind: *const ActionKind,
+ pub in_mode: *const HeadphoneButton,
}
#[no_mangle]
@@ -113,25 +114,26 @@ pub extern "C" fn c_run_key_action(
let result = match run_key_action_for_mode(trigger, mode) {
Some(k) => {
- match k.action {
- Some(a) => {
- CKeyActionResult {
- action: a.into_raw(), // memory leak, must be freed from Rust
- kind: &k.kind,
- }
- },
- None => {
- CKeyActionResult {
- action: ptr::null(),
- kind: &k.kind,
- }
- },
+ let action = k.action.map_or_else(
+ || ptr::null(),
+ |a| a.into_raw(),
+ );
+ let in_mode = k.in_mode.map_or_else(
+ || ptr::null(),
+ |m| m.as_ptr(),
+ );
+
+ CKeyActionResult {
+ action: action, // memory leak, must be freed from Rust
+ kind: &k.kind,
+ in_mode: in_mode,
}
},
None => {
CKeyActionResult {
action: ptr::null(),
kind: ptr::null(),
+ in_mode: ptr::null(),
}
}
};