diff options
| author | Teddy Wing | 2018-10-29 21:03:16 +0100 | 
|---|---|---|
| committer | Teddy Wing | 2018-10-29 21:03:16 +0100 | 
| commit | 9c3ca6c3ed6703881993a05051d997c686a24b0b (patch) | |
| tree | 9f76d31ad27c419fe2d3a72b42620c3d94be9a87 /src/map.rs | |
| parent | 44f6a2d5544e3ad49e5e3c52167c045aed1d56b2 (diff) | |
| download | dome-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.rs | 10 | 
1 files changed, 9 insertions, 1 deletions
| @@ -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 => (), | 
