aboutsummaryrefslogtreecommitdiffstats
path: root/src/map.rs
diff options
context:
space:
mode:
authorTeddy Wing2018-10-29 21:03:16 +0100
committerTeddy Wing2018-10-29 21:03:16 +0100
commit9c3ca6c3ed6703881993a05051d997c686a24b0b (patch)
tree9f76d31ad27c419fe2d3a72b42620c3d94be9a87 /src/map.rs
parent44f6a2d5544e3ad49e5e3c52167c045aed1d56b2 (diff)
downloaddome-key-map-9c3ca6c3ed6703881993a05051d997c686a24b0b.tar.bz2
run_key_action(): Call a function pointer when mode changes
Take a function pointer argument that will be called whenever a mode is activated or deactivated. We'll be using this on the Objective-C side to play audio when the mode changes.
Diffstat (limited to 'src/map.rs')
-rw-r--r--src/map.rs10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/map.rs b/src/map.rs
index f2cd770..54da17a 100644
--- a/src/map.rs
+++ b/src/map.rs
@@ -21,10 +21,16 @@ impl PlayAudio {
}
}
+#[repr(C)]
+pub enum ModeChange {
+ Activated,
+ Deactivated,
+}
+
pub fn run_key_action<'a>(
state: &mut State,
trigger: &'a [HeadphoneButton],
- play_audio: PlayAudio,
+ on_mode_change: extern "C" fn(mode_change: ModeChange),
) {
match state.map_group {
Some(ref map_group) => {
@@ -43,6 +49,7 @@ pub fn run_key_action<'a>(
// Err(e) => error!("{}", e),
// }
// }
+ on_mode_change(ModeChange::Deactivated);
return;
}
@@ -68,6 +75,7 @@ pub fn run_key_action<'a>(
// Err(e) => error!("{}", e),
// }
// }
+ on_mode_change(ModeChange::Activated);
}
},
None => (),