From 52578e7a3f3a74966c16545e6a28311f0b22bae7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gianguido=20Sor=C3=A0?= Date: Wed, 2 Nov 2022 17:56:41 +0100 Subject: [PATCH] feat: implement Display trait for keyboard::KeyMap --- services/keyboard/src/api.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/services/keyboard/src/api.rs b/services/keyboard/src/api.rs index dc771cbbf..5657c12bc 100644 --- a/services/keyboard/src/api.rs +++ b/services/keyboard/src/api.rs @@ -1,3 +1,5 @@ +use std::fmt::Display; + pub const SERVER_NAME_KBD: &str = "_Matrix keyboard driver_"; #[derive(Debug, Default, Copy, Clone)] @@ -49,6 +51,19 @@ impl From for usize { } } +impl Display for KeyMap { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + match self { + Self::Azerty => write!(f, "AZERTY"), + Self::Qwerty => write!(f, "QWERTY"), + Self::Qwertz => write!(f, "QWERTZ"), + Self::Dvorak => write!(f, "Dvorak"), + Self::Braille => write!(f, "Braille"), + Self::Undefined => write!(f, "Undefined"), + } + } +} + // 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 {