diff --git a/services/keyboard/src/api.rs b/services/keyboard/src/api.rs index 012e6eb64..9c1c278e1 100644 --- a/services/keyboard/src/api.rs +++ b/services/keyboard/src/api.rs @@ -47,38 +47,39 @@ impl Into for KeyMap { } } +// Opcodes are pinned down to allow for unsafe FFI extraction of key hits #[derive(Debug, num_derive::FromPrimitive, num_derive::ToPrimitive)] pub(crate) enum Opcode { /// set which keyboard mapping is present - SelectKeyMap, //(KeyMap), - GetKeyMap, + SelectKeyMap = 0, //(KeyMap), + GetKeyMap = 1, /// request for ScanCodes - RegisterListener, + RegisterListener = 2, /// request for raw keyups/downs - RegisterRawListener, + RegisterRawListener = 3, /// set repeat delay, rate; both in ms - SetRepeat, //(u32, u32), + SetRepeat = 4, //(u32, u32), /// set chording interval (how long to wait for all keydowns to happen before interpreting as a chord), in ms (for braille keyboards) - SetChordInterval, //(u32), + SetChordInterval = 5, //(u32), /// used by host mode emulation and debug UART to inject keys - InjectKey, //(char), + InjectKey = 6, //(char), /// used by the interrupt handler to transfer results to the main loop - HandlerTrigger, + HandlerTrigger = 7, /// used to turn keyboard vibrate on and off - Vibe, + Vibe = 8, /// a blocking key listener - blocks until a key is hit - BlockingKeyListener, + BlockingKeyListener = 9, /// Suspend/resume callback - SuspendResume, + SuspendResume = 10, } // this structure is used to register a keyboard listener. Currently, we only accept diff --git a/services/keyboard/src/lib.rs b/services/keyboard/src/lib.rs index 18b915a4e..5f0046bf8 100644 --- a/services/keyboard/src/lib.rs +++ b/services/keyboard/src/lib.rs @@ -92,6 +92,8 @@ impl Keyboard { Ok(_) | Err(_) => panic!("internal error: Incorrect return type") } } + /// Reveal the connection ID for use with unsafe FFI calls + pub fn conn(&self) -> xous::CID { self.conn } #[cfg(not(any(target_os = "none", target_os = "xous")))] pub fn hostmode_inject_key(&self, c: char) {