From b8fdf85f32a8d383b67671173ec7017da4954c08 Mon Sep 17 00:00:00 2001 From: Nederg Date: Mon, 26 Aug 2024 18:31:23 +0200 Subject: [PATCH] mappings fixed, buttons working --- src/ble_keyboard.rs | 143 +----------------- src/enums.rs | 354 ++++++++++++++++++++------------------------ src/lib.rs | 216 +++++++++++++-------------- src/main.rs | 5 +- 4 files changed, 282 insertions(+), 436 deletions(-) diff --git a/src/ble_keyboard.rs b/src/ble_keyboard.rs index ca71628..af23223 100644 --- a/src/ble_keyboard.rs +++ b/src/ble_keyboard.rs @@ -76,136 +76,7 @@ const HID_REPORT_DISCRIPTOR: &[u8] = hid!( ); pub const SHIFT: u8 = 0x80; -pub const ASCII_MAP: &[u8] = &[ - 0x00, // NUL - 0x00, // SOH - 0x00, // STX - 0x00, // ETX - 0x00, // EOT - 0x00, // ENQ - 0x00, // ACK - 0x00, // BEL - 0x2a, // BS Backspace - 0x2b, // TAB Tab - 0x28, // LF Enter - 0x00, // VT - 0x00, // FF - 0x00, // CR - 0x00, // SO - 0x00, // SI - 0x00, // DEL - 0x00, // DC1 - 0x00, // DC2 - 0x00, // DC3 - 0x00, // DC4 - 0x00, // NAK - 0x00, // SYN - 0x00, // ETB - 0x00, // CAN - 0x00, // EM - 0x00, // SUB - 0x00, // ESC - 0x00, // FS - 0x00, // GS - 0x00, // RS - 0x00, // US - 0x2c, // ' ' - 0x1e | SHIFT, // ! - 0x34 | SHIFT, // " - 0x20 | SHIFT, // # - 0x21 | SHIFT, // $ - 0x22 | SHIFT, // % - 0x24 | SHIFT, // & - 0x34, // ' - 0x26 | SHIFT, // ( - 0x27 | SHIFT, // ) - 0x25 | SHIFT, // * - 0x2e | SHIFT, // + - 0x36, // , - 0x2d, // - - 0x37, // . - 0x38, // / - 0x27, // 0 - 0x1e, // 1 - 0x1f, // 2 - 0x20, // 3 - 0x21, // 4 - 0x22, // 5 - 0x23, // 6 - 0x24, // 7 - 0x25, // 8 - 0x26, // 9 - 0x33 | SHIFT, // : - 0x33, // ; - 0x36 | SHIFT, // < - 0x2e, // = - 0x37 | SHIFT, // > - 0x38 | SHIFT, // ? - 0x1f | SHIFT, // @ - 0x04 | SHIFT, // A - 0x05 | SHIFT, // B - 0x06 | SHIFT, // C - 0x07 | SHIFT, // D - 0x08 | SHIFT, // E - 0x09 | SHIFT, // F - 0x0a | SHIFT, // G - 0x0b | SHIFT, // H - 0x0c | SHIFT, // I - 0x0d | SHIFT, // J - 0x0e | SHIFT, // K - 0x0f | SHIFT, // L - 0x10 | SHIFT, // M - 0x11 | SHIFT, // N - 0x12 | SHIFT, // O - 0x13 | SHIFT, // P - 0x14 | SHIFT, // Q - 0x15 | SHIFT, // R - 0x16 | SHIFT, // S - 0x17 | SHIFT, // T - 0x18 | SHIFT, // U - 0x19 | SHIFT, // V - 0x1a | SHIFT, // W - 0x1b | SHIFT, // X - 0x1c | SHIFT, // Y - 0x1d | SHIFT, // Z - 0x2f, // [ - 0x31, // bslash - 0x30, // ] - 0x23 | SHIFT, // ^ - 0x2d | SHIFT, // _ - 0x35, // ` - 0x04, // a - 0x05, // b - 0x06, // c - 0x07, // d - 0x08, // e - 0x09, // f - 0x0a, // g - 0x0b, // h - 0x0c, // i - 0x0d, // j - 0x0e, // k - 0x0f, // l - 0x10, // m - 0x11, // n - 0x12, // o - 0x13, // p - 0x14, // q - 0x15, // r - 0x16, // s - 0x17, // t - 0x18, // u - 0x19, // v - 0x1a, // w - 0x1b, // x - 0x1c, // y - 0x1d, // z - 0x2f | SHIFT, // { - 0x31 | SHIFT, // | - 0x30 | SHIFT, // } - 0x35 | SHIFT, // ~ - 0, // DEL -]; +pub const ASCII_MAP: &[u8] = &[]; #[repr(packed)] struct KeyReport { @@ -280,12 +151,12 @@ impl Keyboard { } pub fn press(&mut self, char: u8) { - let mut key = ASCII_MAP[char as usize]; - if (key & SHIFT) > 0 { - self.key_report.modifiers |= 0x02; - key &= !SHIFT; - } - self.key_report.keys[0] = key; + // let mut key = ASCII_MAP[char as usize]; + // if (key & SHIFT) > 0 { + // self.key_report.modifiers |= 0x02; + // key &= !SHIFT; + // } + self.key_report.keys[0] = char; self.send_report(&self.key_report); } diff --git a/src/enums.rs b/src/enums.rs index 0c22dc3..17730b7 100644 --- a/src/enums.rs +++ b/src/enums.rs @@ -9,194 +9,168 @@ pub enum Layer { #[derive(Clone, Copy, Debug)] pub enum HidMapings { No = 0x00, - RollOver, /* 0x01 */ - PostFail, /* 0x02 */ - Undefined, /* 0x03 */ - LowerA, /* 0x04 */ - LowerB, /* 0x05 */ - LowerC, /* 0x06 */ - LowerD, /* 0x07 */ - LowerE, /* 0x08 */ - LowerF, /* 0x09 */ - LowerG, /* 0x0A */ - LowerH, /* 0x0B */ - LowerI, /* 0x0C */ - LowerJ, /* 0x0D */ - LowerK, /* 0x0E */ - LowerL, /* 0x0F */ - LowerM, /* 0x10 */ - LowerN, /* 0x11 */ - LowerO, /* 0x12 */ - LowerP, /* 0x13 */ - LowerQ, /* 0x14 */ - LowerR, /* 0x15 */ - LowerS, /* 0x16 */ - LowerT, /* 0x17 */ - LowerU, /* 0x18 */ - LowerV, /* 0x19 */ - LowerW, /* 0x1A */ - LowerX, /* 0x1B */ - LowerY, /* 0x1C */ - LowerZ, /* 0x1D */ - UpperA = 0x04 | SHIFT, /* 0x04 */ - UpperB = 0x05 | SHIFT, /* 0x05 */ - UpperC = 0x06 | SHIFT, /* 0x06 */ - UpperD = 0x07 | SHIFT, /* 0x07 */ - UpperE = 0x08 | SHIFT, /* 0x08 */ - UpperF = 0x09 | SHIFT, /* 0x09 */ - UpperG = 0x0A | SHIFT, /* 0x0A */ - UpperH = 0x0B | SHIFT, /* 0x0B */ - UpperI = 0x0C | SHIFT, /* 0x0C */ - UpperJ = 0x0D | SHIFT, /* 0x0D */ - UpperK = 0x0E | SHIFT, /* 0x0E */ - UpperL = 0x0F | SHIFT, /* 0x0F */ - UpperM = 0x10 | SHIFT, /* 0x10 */ - UpperN = 0x11 | SHIFT, /* 0x11 */ - UpperO = 0x12 | SHIFT, /* 0x12 */ - UpperP = 0x13 | SHIFT, /* 0x13 */ - UpperQ = 0x14 | SHIFT, /* 0x14 */ - UpperR = 0x15 | SHIFT, /* 0x15 */ - UpperS = 0x16 | SHIFT, /* 0x16 */ - UpperT = 0x17 | SHIFT, /* 0x17 */ - UpperU = 0x18 | SHIFT, /* 0x18 */ - UpperV = 0x19 | SHIFT, /* 0x19 */ - UpperW = 0x1A | SHIFT, /* 0x1A */ - UpperX = 0x1B | SHIFT, /* 0x1B */ - UpperY = 0x1C | SHIFT, /* 0x1C */ - UpperZ = 0x1D | SHIFT, /* 0x1D */ - Num1, /* 0x1E */ - Num2, /* 0x1F */ - Num3, /* 0x20 */ - Num4, /* 0x21 */ - Num5, /* 0x22 */ - Num6, /* 0x23 */ - Num7, /* 0x24 */ - Num8, /* 0x25 */ - Num9, /* 0x26 */ - Num0, /* 0x27 */ - Enter, /* 0x28 */ - Escape, /* 0x29 */ - Bspace, /* 0x2A */ - Tab, /* 0x2B */ - Space, /* 0x2C */ - Minus, /* 0x2D */ - Equal, /* 0x2E */ - Lbracket, /* 0x2F */ - Rbracket, /* 0x30 */ - Bslash, /* 0x31 *//* \ (and |) */ - NonusHash, /* 0x32 *//* Non-US # and ~ (Typically near the Enter key) */ - Scolon, /* 0x33 *//* ; (and :) */ - Quote, /* 0x34 *//* ' and " */ - Grave, /* 0x35 *//* Grave accent and tilde */ - Comma, /* 0x36 *//* , and < */ - Dot, /* 0x37 *//* . and > */ - Slash, /* 0x38 *//* / and ? */ - Capslock, /* 0x39 */ - F1, /* 0x3A */ - F2, /* 0x3B */ - F3, /* 0x3C */ - F4, /* 0x3D */ - F5, /* 0x3E */ - F6, /* 0x3F */ - F7, /* 0x40 */ - F8, /* 0x41 */ - F9, /* 0x42 */ - F10, /* 0x43 */ - F11, /* 0x44 */ - F12, /* 0x45 */ - Pscreen, /* 0x46 */ - Scrolllock, /* 0x47 */ - Pause, /* 0x48 */ - Insert, /* 0x49 */ - Home, /* 0x4A */ - Pgup, /* 0x4B */ - Delete, /* 0x4C */ - End, /* 0x4D */ - Pgdown, /* 0x4E */ - Right, /* 0x4F */ - Left, /* 0x50 */ - Down, /* 0x51 */ - Up, /* 0x52 */ - Numlock, /* 0x53 */ - KpSlash, /* 0x54 */ - KpAsterisk, /* 0x55 */ - KpMinus, /* 0x56 */ - KpPlus, /* 0x57 */ - KpEnter, /* 0x58 */ - Kp1, /* 0x59 */ - Kp2, /* 0x5A */ - Kp3, /* 0x5B */ - Kp4, /* 0x5C */ - Kp5, /* 0x5D */ - Kp6, /* 0x5E */ - Kp7, /* 0x5F */ - Kp8, /* 0x60 */ - Kp9, /* 0x61 */ - Kp0, /* 0x62 */ - KpDot, /* 0x63 */ - NonusBslash, /* 0x64 *//* Non-US \ and | (Typically near the Left-Shift key) */ - Application, /* 0x65 */ - Power, /* 0x66 */ - KpEqual, /* 0x67 */ - F13, /* 0x68 */ - F14, /* 0x69 */ - F15, /* 0x6A */ - F16, /* 0x6B */ - F17, /* 0x6C */ - F18, /* 0x6D */ - F19, /* 0x6E */ - F20, /* 0x6F */ - F21, /* 0x70 */ - F22, /* 0x71 */ - F23, /* 0x72 */ - F24, /* 0x73 */ - Execute, /* 0x74 */ - Help, /* 0x75 */ - Menu, /* 0x76 */ - Select, /* 0x77 */ - Stop, /* 0x78 */ - Again, /* 0x79 */ - Undo, /* 0x7A */ - Cut, /* 0x7B */ - Copy, /* 0x7C */ - Paste, /* 0x7D */ - Find, /* 0x7E */ - Mute, /* 0x7F */ - Volup, /* 0x80 */ - Voldown, /* 0x81 */ - LockingCaps, /* 0x82 *//* locking Caps Lock */ - LockingNum, /* 0x83 *//* locking Num Lock */ - LockingScroll, /* 0x84 *//* locking Scroll Lock */ - KpComma, /* 0x85 */ - KpEqualAs400, /* 0x86 *//* equal sign on AS/400 */ - Int1, /* 0x87 */ - Int2, /* 0x88 */ - Int3, /* 0x89 */ - Int4, /* 0x8A */ - Int5, /* 0x8B */ - Int6, /* 0x8C */ - Int7, /* 0x8D */ - Int8, /* 0x8E */ - Int9, /* 0x8F */ - Lang1, /* 0x90 */ - Lang2, /* 0x91 */ - Lang3, /* 0x92 */ - Lang4, /* 0x93 */ - Lang5, /* 0x94 */ - Lang6, /* 0x95 */ - Lang7, /* 0x96 */ - Lang8, /* 0x97 */ - Lang9, /* 0x98 */ - AltErase, /* 0x99 */ - Sysreq, /* 0x9A */ - Cancel, /* 0x9B */ - Clear, /* 0x9C */ - Prior, /* 0x9D */ - Return, /* 0x9E */ - Separator, /* 0x9F */ - Out, /* 0xA0 */ - Oper, /* 0xA1 */ - ClearAgain, /* 0xA2 */ - Crsel, /* 0xA3 */ - Exsel, /* 0xA4 */ + RollOver = 0x01, + PostFail = 0x02, + Undefined = 0x03, + LowerA = 0x04, + LowerB = 0x05, + LowerC = 0x06, + LowerD = 0x07, + LowerE = 0x08, + LowerF = 0x09, + LowerG = 0x0A, + LowerH = 0x0B, + LowerI = 0x0C, + LowerJ = 0x0D, + LowerK = 0x0E, + LowerL = 0x0F, + LowerM = 0x10, + LowerN = 0x11, + LowerO = 0x12, + LowerP = 0x13, + LowerQ = 0x14, + LowerR = 0x15, + LowerS = 0x16, + LowerT = 0x17, + LowerU = 0x18, + LowerV = 0x19, + LowerW = 0x1A, + LowerX = 0x1B, + LowerY = 0x1C, + LowerZ = 0x1D, + Num1 = 0x1E, + Num2 = 0x1F, + Num3 = 0x20, + Num4 = 0x21, + Num5 = 0x22, + Num6 = 0x23, + Num7 = 0x24, + Num8 = 0x25, + Num9 = 0x26, + Num0 = 0x27, + Enter = 0x28, + Escape = 0x29, + Bspace = 0x2A, + Tab = 0x2B, + Space = 0x2C, + Minus = 0x2D, + Equal = 0x2E, + Lbracket = 0x2F, + Rbracket = 0x30, + Bslash = 0x31, /* \ (and |) */ + NonusHash = 0x32, /* Non-US # and ~ (Typically near the Enter key) */ + Scolon = 0x33, /* ; (and :) */ + Quote = 0x34, /* ' and " */ + Grave = 0x35, /* Grave accent and tilde */ + Comma = 0x36, /* = and < */ + Dot = 0x37, /* . and > */ + Slash = 0x38, /* / and ? */ + Capslock = 0x39, + F1 = 0x3A, + F2 = 0x3B, + F3 = 0x3C, + F4 = 0x3D, + F5 = 0x3E, + F6 = 0x3F, + F7 = 0x40, + F8 = 0x41, + F9 = 0x42, + F10 = 0x43, + F11 = 0x44, + F12 = 0x45, + Pscreen = 0x46, + Scrolllock = 0x47, + Pause = 0x48, + Insert = 0x49, + Home = 0x4A, + Pgup = 0x4B, + Delete = 0x4C, + End = 0x4D, + Pgdown = 0x4E, + Right = 0x4F, + Left = 0x50, + Down = 0x51, + Up = 0x52, + Numlock = 0x53, + KpSlash = 0x54, + KpAsterisk = 0x55, + KpMinus = 0x56, + KpPlus = 0x57, + KpEnter = 0x58, + Kp1 = 0x59, + Kp2 = 0x5A, + Kp3 = 0x5B, + Kp4 = 0x5C, + Kp5 = 0x5D, + Kp6 = 0x5E, + Kp7 = 0x5F, + Kp8 = 0x60, + Kp9 = 0x61, + Kp0 = 0x62, + KpDot = 0x63, + NonusBslash = 0x64, /* Non-US \ and | (Typically near the Left-Shift key) */ + Application = 0x65, + Power = 0x66, + KpEqual = 0x67, + F13 = 0x68, + F14 = 0x69, + F15 = 0x6A, + F16 = 0x6B, + F17 = 0x6C, + F18 = 0x6D, + F19 = 0x6E, + F20 = 0x6F, + F21 = 0x70, + F22 = 0x71, + F23 = 0x72, + F24 = 0x73, + Execute = 0x74, + Help = 0x75, + Menu = 0x76, + Select = 0x77, + Stop = 0x78, + Again = 0x79, + Undo = 0x7A, + Cut = 0x7B, + Copy = 0x7C, + Paste = 0x7D, + Find = 0x7E, + Mute = 0x7F, + Volup = 0x80, + Voldown = 0x81, + LockingCaps = 0x82, /* locking Caps Lock */ + LockingNum = 0x83, /* locking Num Lock */ + LockingScroll = 0x84, /* locking Scroll Lock */ + KpComma = 0x85, + KpEqualAs400 = 0x86, /* equal sign on AS/400 */ + Int1 = 0x87, + Int2 = 0x88, + Int3 = 0x89, + Int4 = 0x8A, + Int5 = 0x8B, + Int6 = 0x8C, + Int7 = 0x8D, + Int8 = 0x8E, + Int9 = 0x8F, + Lang1 = 0x90, + Lang2 = 0x91, + Lang3 = 0x92, + Lang4 = 0x93, + Lang5 = 0x94, + Lang6 = 0x95, + Lang7 = 0x96, + Lang8 = 0x97, + Lang9 = 0x98, + AltErase = 0x99, + Sysreq = 0x9A, + Cancel = 0x9B, + Clear = 0x9C, + Prior = 0x9D, + Return = 0x9E, + Separator = 0x9F, + Out = 0xA0, + Oper = 0xA1, + ClearAgain = 0xA2, + Crsel = 0xA3, + Exsel = 0xA4, } diff --git a/src/lib.rs b/src/lib.rs index 7b45087..862a093 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -45,9 +45,9 @@ pub mod enums; #[derive(Clone, Default, Debug)] pub struct KeyboardLeftSide { - pub base_layer: HashMap<(i32, i32), HidMapings>, - pub shift_layer: HashMap<(i32, i32), HidMapings>, - pub upper_layer: HashMap<(i32, i32), HidMapings>, + pub base_layer: HashMap<(i32, i32), u8>, + pub shift_layer: HashMap<(i32, i32), u8>, + pub upper_layer: HashMap<(i32, i32), u8>, } impl KeyboardLeftSide { @@ -61,119 +61,119 @@ impl KeyboardLeftSide { pub fn initialize_layers(&mut self) { self.initialie_base_layer(); - self.initialie_shift_layer(); + // self.initialie_shift_layer(); self.initialie_upper_layer(); } fn initialie_base_layer(&mut self) { - self.base_layer.insert((0, 2), HidMapings::Escape); // ESC - self.base_layer.insert((0, 3), HidMapings::Num1); // 1 - self.base_layer.insert((0, 10), HidMapings::Num2); // 2 - self.base_layer.insert((0, 6), HidMapings::Num3); // 3 - self.base_layer.insert((0, 7), HidMapings::Num4); // 4 - self.base_layer.insert((0, 4), HidMapings::Num5); // 5 - - self.base_layer.insert((1, 2), HidMapings::Tab); // TAB - self.base_layer.insert((1, 3), HidMapings::LowerQ); // q - self.base_layer.insert((1, 10), HidMapings::LowerW); // w - self.base_layer.insert((1, 6), HidMapings::LowerE); // e - self.base_layer.insert((1, 7), HidMapings::LowerR); // r - self.base_layer.insert((1, 4), HidMapings::LowerT); // t - - self.base_layer.insert((12, 2), HidMapings::Capslock); // CAP - self.base_layer.insert((12, 3), HidMapings::LowerA); // a - self.base_layer.insert((12, 10), HidMapings::LowerS); // s - self.base_layer.insert((12, 6), HidMapings::LowerD); // d - self.base_layer.insert((12, 7), HidMapings::LowerF); // f - self.base_layer.insert((12, 4), HidMapings::LowerG); // g - - self.base_layer.insert((18, 2), HidMapings::No); // - self.base_layer.insert((18, 3), HidMapings::LowerZ); // z - self.base_layer.insert((18, 10), HidMapings::LowerX); // x - self.base_layer.insert((18, 6), HidMapings::LowerC); // c - self.base_layer.insert((18, 7), HidMapings::LowerV); // v - self.base_layer.insert((18, 4), HidMapings::LowerB); // b - - self.base_layer.insert((19, 2), HidMapings::No); // - self.base_layer.insert((19, 3), HidMapings::No); // - self.base_layer.insert((19, 10), HidMapings::No); // LAYER - self.base_layer.insert((19, 6), HidMapings::No); // CONTROL - self.base_layer.insert((19, 7), HidMapings::No); // SHIFT - self.base_layer.insert((19, 4), HidMapings::Enter); // ENTER + self.base_layer.insert((0, 2), HidMapings::Escape as u8); // ESC + self.base_layer.insert((0, 3), HidMapings::Num1 as u8); // 1 + self.base_layer.insert((0, 10), HidMapings::Num2 as u8); // 2 + self.base_layer.insert((0, 6), HidMapings::Num3 as u8); // 3 + self.base_layer.insert((0, 7), HidMapings::Num4 as u8); // 4 + self.base_layer.insert((0, 4), HidMapings::Num5 as u8); // 5 + + self.base_layer.insert((1, 2), HidMapings::Tab as u8); // TAB + self.base_layer.insert((1, 3), HidMapings::LowerQ as u8); // q + self.base_layer.insert((1, 10), HidMapings::LowerW as u8); // w + self.base_layer.insert((1, 6), HidMapings::LowerE as u8); // e + self.base_layer.insert((1, 7), HidMapings::LowerR as u8); // r + self.base_layer.insert((1, 4), HidMapings::LowerT as u8); // t + + self.base_layer.insert((12, 2), HidMapings::Capslock as u8); // CAP + self.base_layer.insert((12, 3), HidMapings::LowerA as u8); // a + self.base_layer.insert((12, 10), HidMapings::LowerS as u8); // s + self.base_layer.insert((12, 6), HidMapings::LowerD as u8); // d + self.base_layer.insert((12, 7), HidMapings::LowerF as u8); // f + self.base_layer.insert((12, 4), HidMapings::LowerG as u8); // g + + self.base_layer.insert((18, 2), HidMapings::No as u8); // + self.base_layer.insert((18, 3), HidMapings::LowerZ as u8); // z + self.base_layer.insert((18, 10), HidMapings::LowerX as u8); // x + self.base_layer.insert((18, 6), HidMapings::LowerC as u8); // c + self.base_layer.insert((18, 7), HidMapings::LowerV as u8); // v + self.base_layer.insert((18, 4), HidMapings::LowerB as u8); // b + + self.base_layer.insert((19, 2), HidMapings::No as u8); // + self.base_layer.insert((19, 3), HidMapings::No as u8); // + self.base_layer.insert((19, 10), HidMapings::No as u8); // LAYER + self.base_layer.insert((19, 6), HidMapings::No as u8); // CONTROL + self.base_layer.insert((19, 7), HidMapings::No as u8); // SHIFT + self.base_layer.insert((19, 4), HidMapings::Enter as u8); // ENTER } - fn initialie_shift_layer(&mut self) { - self.shift_layer.insert((0, 2), HidMapings::Escape); // ESC - self.shift_layer.insert((0, 3), HidMapings::No); // ! - self.shift_layer.insert((0, 10), HidMapings::No); // @ - self.shift_layer.insert((0, 6), HidMapings::No); // # - self.shift_layer.insert((0, 7), HidMapings::No); // $ - self.shift_layer.insert((0, 4), HidMapings::No); // % - - self.shift_layer.insert((1, 2), HidMapings::Tab); // TAB - self.shift_layer.insert((1, 3), HidMapings::UpperQ); // Q - self.shift_layer.insert((1, 10), HidMapings::UpperW); // W - self.shift_layer.insert((1, 6), HidMapings::UpperE); // E - self.shift_layer.insert((1, 7), HidMapings::UpperR); // R - self.shift_layer.insert((1, 4), HidMapings::UpperT); // T - - self.shift_layer.insert((12, 2), HidMapings::Capslock); // CAPSLOCK - self.shift_layer.insert((12, 3), HidMapings::UpperA); // A - self.shift_layer.insert((12, 10), HidMapings::UpperS); // S - self.shift_layer.insert((12, 6), HidMapings::UpperD); // D - self.shift_layer.insert((12, 7), HidMapings::UpperF); // F - self.shift_layer.insert((12, 4), HidMapings::UpperG); // G - - self.shift_layer.insert((18, 2), HidMapings::No); // - self.shift_layer.insert((18, 3), HidMapings::UpperZ); // Z - self.shift_layer.insert((18, 10), HidMapings::UpperX); // X - self.shift_layer.insert((18, 6), HidMapings::UpperC); // C - self.shift_layer.insert((18, 7), HidMapings::UpperV); // V - self.shift_layer.insert((18, 4), HidMapings::UpperB); // B - - self.shift_layer.insert((19, 2), HidMapings::No); // - self.shift_layer.insert((19, 3), HidMapings::No); // - self.shift_layer.insert((19, 10), HidMapings::No); // LAYER - self.shift_layer.insert((19, 6), HidMapings::No); // CONTROL - self.shift_layer.insert((19, 7), HidMapings::No); // SHIFT - self.shift_layer.insert((19, 4), HidMapings::Enter); // ENTER - } + // fn initialie_shift_layer(&mut self) { + // self.shift_layer.insert((0, 2), HidMapings::Escape as u8); // ESC + // self.shift_layer.insert((0, 3), HidMapings::No as u8); // ! + // self.shift_layer.insert((0, 10), HidMapings::No as u8); // @ + // self.shift_layer.insert((0, 6), HidMapings::No as u8); // # + // self.shift_layer.insert((0, 7), HidMapings::No as u8); // $ + // self.shift_layer.insert((0, 4), HidMapings::No as u8); // % + + // self.shift_layer.insert((1, 2), HidMapings::Tab as u8); // TAB + // self.shift_layer.insert((1, 3), HidMapings::UpperQ as u8); // Q + // self.shift_layer.insert((1, 10), HidMapings::UpperW as u8); // W + // self.shift_layer.insert((1, 6), HidMapings::UpperE as u8); // E + // self.shift_layer.insert((1, 7), HidMapings::UpperR as u8); // R + // self.shift_layer.insert((1, 4), HidMapings::UpperT as u8); // T + + // self.shift_layer.insert((12, 2), HidMapings::Capslock as u8); // CAPSLOCK + // self.shift_layer.insert((12, 3), HidMapings::UpperA as u8); // A + // self.shift_layer.insert((12, 10), HidMapings::UpperS as u8); // S + // self.shift_layer.insert((12, 6), HidMapings::UpperD as u8); // D + // self.shift_layer.insert((12, 7), HidMapings::UpperF as u8); // F + // self.shift_layer.insert((12, 4), HidMapings::UpperG as u8); // G + + // self.shift_layer.insert((18, 2), HidMapings::No as u8); // + // self.shift_layer.insert((18, 3), HidMapings::UpperZ as u8); // Z + // self.shift_layer.insert((18, 10), HidMapings::UpperX as u8); // X + // self.shift_layer.insert((18, 6), HidMapings::UpperC as u8); // C + // self.shift_layer.insert((18, 7), HidMapings::UpperV as u8); // V + // self.shift_layer.insert((18, 4), HidMapings::UpperB as u8); // B + + // self.shift_layer.insert((19, 2), HidMapings::No as u8); // + // self.shift_layer.insert((19, 3), HidMapings::No as u8); // + // self.shift_layer.insert((19, 10), HidMapings::No as u8); // LAYER + // self.shift_layer.insert((19, 6), HidMapings::No as u8); // CONTROL + // self.shift_layer.insert((19, 7), HidMapings::No as u8); // SHIFT + // self.shift_layer.insert((19, 4), HidMapings::Enter as u8); // ENTER + // } fn initialie_upper_layer(&mut self) { - self.upper_layer.insert((0, 2), HidMapings::Escape); // ESC - self.upper_layer.insert((0, 3), HidMapings::No); // - self.upper_layer.insert((0, 10), HidMapings::No); // - self.upper_layer.insert((0, 6), HidMapings::No); // - self.upper_layer.insert((0, 7), HidMapings::No); // - self.upper_layer.insert((0, 4), HidMapings::No); // - - self.upper_layer.insert((1, 2), HidMapings::Tab); // TAB - self.upper_layer.insert((1, 3), HidMapings::No); // - self.upper_layer.insert((1, 10), HidMapings::Up); // UP - self.upper_layer.insert((1, 6), HidMapings::No); // - self.upper_layer.insert((1, 7), HidMapings::No); // - self.upper_layer.insert((1, 4), HidMapings::No); // - - self.upper_layer.insert((12, 2), HidMapings::Capslock); // CAPSLOCK - self.upper_layer.insert((12, 3), HidMapings::Left); // LEFT - self.upper_layer.insert((12, 10), HidMapings::Down); // DOWN - self.upper_layer.insert((12, 6), HidMapings::Right); // RIGHT - self.upper_layer.insert((12, 7), HidMapings::No); // - self.upper_layer.insert((12, 4), HidMapings::No); // - - self.upper_layer.insert((18, 2), HidMapings::No); // - self.upper_layer.insert((18, 3), HidMapings::No); // - self.upper_layer.insert((18, 10), HidMapings::No); // - self.upper_layer.insert((18, 6), HidMapings::No); // - self.upper_layer.insert((18, 7), HidMapings::No); // - self.upper_layer.insert((18, 4), HidMapings::No); // - - self.upper_layer.insert((19, 2), HidMapings::No); // - self.upper_layer.insert((19, 3), HidMapings::No); // - self.upper_layer.insert((19, 10), HidMapings::No); // LAYER - self.upper_layer.insert((19, 6), HidMapings::No); // CONTROL - self.upper_layer.insert((19, 7), HidMapings::No); // SHIFT - self.upper_layer.insert((19, 4), HidMapings::Enter); // ENTER + self.upper_layer.insert((0, 2), HidMapings::Escape as u8); // ESC + self.upper_layer.insert((0, 3), HidMapings::No as u8); // + self.upper_layer.insert((0, 10), HidMapings::No as u8); // + self.upper_layer.insert((0, 6), HidMapings::No as u8); // + self.upper_layer.insert((0, 7), HidMapings::No as u8); // + self.upper_layer.insert((0, 4), HidMapings::No as u8); // + + self.upper_layer.insert((1, 2), HidMapings::Tab as u8); // TAB + self.upper_layer.insert((1, 3), HidMapings::No as u8); // + self.upper_layer.insert((1, 10), HidMapings::Up as u8); // UP + self.upper_layer.insert((1, 6), HidMapings::No as u8); // + self.upper_layer.insert((1, 7), HidMapings::No as u8); // + self.upper_layer.insert((1, 4), HidMapings::No as u8); // + + self.upper_layer.insert((12, 2), HidMapings::Capslock as u8); // CAPSLOCK + self.upper_layer.insert((12, 3), HidMapings::Left as u8); // LEFT + self.upper_layer.insert((12, 10), HidMapings::Down as u8); // DOWN + self.upper_layer.insert((12, 6), HidMapings::Right as u8); // RIGHT + self.upper_layer.insert((12, 7), HidMapings::No as u8); // + self.upper_layer.insert((12, 4), HidMapings::No as u8); // + + self.upper_layer.insert((18, 2), HidMapings::No as u8); // + self.upper_layer.insert((18, 3), HidMapings::No as u8); // + self.upper_layer.insert((18, 10), HidMapings::No as u8); // + self.upper_layer.insert((18, 6), HidMapings::No as u8); // + self.upper_layer.insert((18, 7), HidMapings::No as u8); // + self.upper_layer.insert((18, 4), HidMapings::No as u8); // + + self.upper_layer.insert((19, 2), HidMapings::No as u8); // + self.upper_layer.insert((19, 3), HidMapings::No as u8); // + self.upper_layer.insert((19, 10), HidMapings::No as u8); // LAYER + self.upper_layer.insert((19, 6), HidMapings::No as u8); // CONTROL + self.upper_layer.insert((19, 7), HidMapings::No as u8); // SHIFT + self.upper_layer.insert((19, 4), HidMapings::Enter as u8); // ENTER } } diff --git a/src/main.rs b/src/main.rs index 4852179..131f01b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -95,8 +95,9 @@ fn main() -> anyhow::Result<()> { if let Some(valid_key) = keyboard_left.base_layer.get(&pins_active) { /* If the previos key is same as the active key */ - log::info!("{:?}", *valid_key); - keyboard.press(*valid_key as u8); + log::info!("Valid Key {:?}", *valid_key); + + keyboard.press(*valid_key); keyboard.release(); } }