240 lines
10 KiB
Rust
240 lines
10 KiB
Rust
//! Project: CMtec CMDR Keyboard 51
|
||
//! Date: 2023-07-01
|
||
//! Author: Christoffer Martinsson
|
||
//! Email: cm@cmtec.se
|
||
//! License: Please refer to LICENSE in root directory
|
||
|
||
// Button index map:
|
||
// ------------------------------------- -------------------------------------
|
||
// | 0 | 1 | 2 | 3 | 4 | 5 | 48 51 | 6 | 7 | 8 | 9 | 10 | 11 |
|
||
// | 12 | 13 | 14 | 15 | 16 | 17 | 49 52 | 18 | 19 | 20 | 21 | 22 | 23 |
|
||
// | 24 | 25 | 26 | 27 | 28 | 29 | 50 53 | 30 | 31 | 32 | 33 | 34 | 35 |
|
||
// ------------------| 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 |------------------
|
||
// ------------------------------------------------------ 45 46 47
|
||
// 54 55 56 57 58 59
|
||
// Swedish keymap conversion table:
|
||
// US Swedish
|
||
// --------------------------
|
||
// Grave §
|
||
// Semicolon ö
|
||
// Apostrophe ä
|
||
// LeftBrace å
|
||
// ForwardSlash -
|
||
// NonUSBackslash <
|
||
// Equal ´
|
||
// Backslash '
|
||
// RightBrace ^
|
||
// Minus +
|
||
// LeftAlt Alt
|
||
// RightAlt AltGr
|
||
|
||
use crate::NUMBER_OF_KEYS;
|
||
use usbd_human_interface_device::page::Keyboard;
|
||
|
||
/// Function (Fn) buttons index (need two buttons)
|
||
/// Button 41 are used both as Fn and RightAlt (AltGr) for better ergonomics.
|
||
/// This means that RightAlt is only available on layer 1 keys.
|
||
pub const FN_BUTTONS: [u8; 3] = [37, 43, 44];
|
||
|
||
/// Sticky button [index, layer]
|
||
pub const STICKY_BUTTON: [u8; 2] = [48, 0];
|
||
|
||
/// Button map to HID key (three Function layers)
|
||
pub const MAP: [[Keyboard; NUMBER_OF_KEYS]; 3] = [
|
||
[
|
||
// Function layer 0
|
||
// HID Key // Button Index
|
||
// -----------------------------------------
|
||
Keyboard::Tab, // 0
|
||
Keyboard::Q, // 1
|
||
Keyboard::W, // 2
|
||
Keyboard::E, // 3
|
||
Keyboard::R, // 4
|
||
Keyboard::T, // 5
|
||
Keyboard::Y, // 6
|
||
Keyboard::U, // 7
|
||
Keyboard::I, // 8
|
||
Keyboard::O, // 9
|
||
Keyboard::P, // 10
|
||
Keyboard::LeftBrace, // 11 å
|
||
Keyboard::LeftControl, // 12
|
||
Keyboard::A, // 13
|
||
Keyboard::S, // 14
|
||
Keyboard::D, // 15
|
||
Keyboard::F, // 16
|
||
Keyboard::G, // 17
|
||
Keyboard::H, // 18
|
||
Keyboard::J, // 19
|
||
Keyboard::K, // 20
|
||
Keyboard::L, // 21
|
||
Keyboard::Semicolon, // 22 ö
|
||
Keyboard::Apostrophe, // 23 ä
|
||
Keyboard::LeftShift, // 24
|
||
Keyboard::Z, // 25
|
||
Keyboard::X, // 26
|
||
Keyboard::C, // 27
|
||
Keyboard::V, // 28
|
||
Keyboard::B, // 29
|
||
Keyboard::N, // 30
|
||
Keyboard::M, // 31
|
||
Keyboard::Comma, // 32
|
||
Keyboard::Dot, // 33
|
||
Keyboard::ForwardSlash, // 34 -
|
||
Keyboard::RightShift, // 35
|
||
Keyboard::LeftAlt, // 36
|
||
Keyboard::NoEventIndicated, // 37 Fn (= will never trigg this layer)
|
||
Keyboard::Space, // 38
|
||
Keyboard::DeleteBackspace, // 39
|
||
Keyboard::LeftGUI, // 40
|
||
Keyboard::ReturnEnter, // 41
|
||
Keyboard::Space, // 42
|
||
Keyboard::NoEventIndicated, // 43 Fn (= will never trigg this layer)
|
||
Keyboard::NoEventIndicated, // 44 Fn (= will never trigg this layer)
|
||
Keyboard::NoEventIndicated, // 45 no button connected
|
||
Keyboard::NoEventIndicated, // 46 no button connected
|
||
Keyboard::NoEventIndicated, // 47 no button connected
|
||
Keyboard::NoEventIndicated, // 48
|
||
Keyboard::VolumeUp, // 49
|
||
Keyboard::VolumeDown, // 50
|
||
Keyboard::PrintScreen, // 51
|
||
Keyboard::F5, // 52
|
||
Keyboard::F6, // 53
|
||
Keyboard::NoEventIndicated, // 54 no button connected
|
||
Keyboard::NoEventIndicated, // 55 no button connected
|
||
Keyboard::NoEventIndicated, // 56 no button connected
|
||
Keyboard::NoEventIndicated, // 57 no button connected
|
||
Keyboard::NoEventIndicated, // 58 no button connected
|
||
Keyboard::NoEventIndicated, // 59 no button connected
|
||
],
|
||
[
|
||
// Function layer 1
|
||
// HID Key // Button Index
|
||
// -----------------------------------------
|
||
Keyboard::Escape, // 0
|
||
Keyboard::F1, // 1
|
||
Keyboard::F2, // 2
|
||
Keyboard::F3, // 3
|
||
Keyboard::F4, // 4
|
||
Keyboard::F5, // 5
|
||
Keyboard::F6, // 6
|
||
Keyboard::F7, // 7
|
||
Keyboard::F8, // 8
|
||
Keyboard::F9, // 9
|
||
Keyboard::F10, // 10
|
||
Keyboard::DeleteForward, // 11
|
||
Keyboard::LeftControl, // 12
|
||
Keyboard::Keyboard1, // 13
|
||
Keyboard::Keyboard2, // 14
|
||
Keyboard::Keyboard3, // 15
|
||
Keyboard::Keyboard4, // 16
|
||
Keyboard::Keyboard5, // 17
|
||
Keyboard::Keyboard6, // 18
|
||
Keyboard::Keyboard7, // 19
|
||
Keyboard::Keyboard8, // 20
|
||
Keyboard::Keyboard9, // 21
|
||
Keyboard::Keyboard0, // 22
|
||
Keyboard::ReturnEnter, // 23
|
||
Keyboard::LeftShift, // 24
|
||
Keyboard::Keyboard6, // 25
|
||
Keyboard::Keyboard7, // 26
|
||
Keyboard::Keyboard8, // 27
|
||
Keyboard::Keyboard9, // 28
|
||
Keyboard::Keyboard0, // 29
|
||
Keyboard::NonUSBackslash, // 30 <
|
||
Keyboard::Equal, // 31 ´
|
||
Keyboard::Backslash, // 32 '
|
||
Keyboard::RightBrace, // 33 ^
|
||
Keyboard::Minus, // 34 +
|
||
Keyboard::RightShift, // 35
|
||
Keyboard::LeftAlt, // 36
|
||
Keyboard::NoEventIndicated, // 37 Fn (= will never trigg this layer)
|
||
Keyboard::Space, // 38
|
||
Keyboard::DeleteBackspace, // 39
|
||
Keyboard::LeftGUI, // 40
|
||
Keyboard::ReturnEnter, // 41
|
||
Keyboard::Space, // 42
|
||
Keyboard::NoEventIndicated, // 43 Fn (= will never trigg this layer)
|
||
Keyboard::NoEventIndicated, // 44 Fn (= will never trigg this layer)
|
||
Keyboard::NoEventIndicated, // 45 no button connected
|
||
Keyboard::NoEventIndicated, // 46 no button connected
|
||
Keyboard::NoEventIndicated, // 47 no button connected
|
||
Keyboard::NoEventIndicated, // 48
|
||
Keyboard::VolumeUp, // 49
|
||
Keyboard::VolumeDown, // 50
|
||
Keyboard::PrintScreen, // 51
|
||
Keyboard::F5, // 52
|
||
Keyboard::F6, // 53
|
||
Keyboard::NoEventIndicated, // 54 no button connected
|
||
Keyboard::NoEventIndicated, // 55 no button connected
|
||
Keyboard::NoEventIndicated, // 56 no button connected
|
||
Keyboard::NoEventIndicated, // 57 no button connected
|
||
Keyboard::NoEventIndicated, // 58 no button connected
|
||
Keyboard::NoEventIndicated, // 59 no button connected
|
||
],
|
||
[
|
||
// Function layer 2
|
||
// HID Key // Button Index
|
||
// -----------------------------------------
|
||
Keyboard::Escape, // 0
|
||
Keyboard::F11, // 1
|
||
Keyboard::F12, // 2
|
||
Keyboard::F13, // 3
|
||
Keyboard::F14, // 4
|
||
Keyboard::NoEventIndicated, // 5
|
||
Keyboard::Grave, // 6 §
|
||
Keyboard::NoEventIndicated, // 7 STICKY lock
|
||
Keyboard::LeftGUI, // 8
|
||
Keyboard::NoEventIndicated, // 9
|
||
Keyboard::CapsLock, // 10
|
||
Keyboard::DeleteForward, // 11
|
||
Keyboard::LeftControl, // 12
|
||
Keyboard::F15, // 13
|
||
Keyboard::F16, // 14
|
||
Keyboard::F17, // 15
|
||
Keyboard::F18, // 16
|
||
Keyboard::F19, // 17
|
||
Keyboard::LeftArrow, // 18
|
||
Keyboard::DownArrow, // 19
|
||
Keyboard::UpArrow, // 20
|
||
Keyboard::RightArrow, // 21
|
||
Keyboard::DeleteForward, // 22
|
||
Keyboard::ReturnEnter, // 23
|
||
Keyboard::LeftShift, // 24
|
||
Keyboard::F20, // 25
|
||
Keyboard::F21, // 26
|
||
Keyboard::F22, // 27
|
||
Keyboard::F23, // 28
|
||
Keyboard::F24, // 29
|
||
Keyboard::Home, // 30
|
||
Keyboard::PageDown, // 31
|
||
Keyboard::PageUp, // 32
|
||
Keyboard::End, // 33
|
||
Keyboard::Insert, // 34
|
||
Keyboard::RightShift, // 35
|
||
Keyboard::LeftAlt, // 36
|
||
Keyboard::NoEventIndicated, // 37 Fn (= will never trigg this layer)
|
||
Keyboard::Space, // 38
|
||
Keyboard::DeleteBackspace, // 39
|
||
Keyboard::LeftGUI, // 40
|
||
Keyboard::ReturnEnter, // 41
|
||
Keyboard::Space, // 42
|
||
Keyboard::NoEventIndicated, // 43 Fn (= will never trigg this layer)
|
||
Keyboard::NoEventIndicated, // 44 Fn (= will never trigg this layer)
|
||
Keyboard::NoEventIndicated, // 45 no button connected
|
||
Keyboard::NoEventIndicated, // 46 no button connected
|
||
Keyboard::NoEventIndicated, // 47 no button connected
|
||
Keyboard::NoEventIndicated, // 48
|
||
Keyboard::VolumeUp, // 49
|
||
Keyboard::VolumeDown, // 50
|
||
Keyboard::PrintScreen, // 51
|
||
Keyboard::F5, // 52
|
||
Keyboard::F6, // 53
|
||
Keyboard::NoEventIndicated, // 54 no button connected
|
||
Keyboard::NoEventIndicated, // 55 no button connected
|
||
Keyboard::NoEventIndicated, // 56 no button connected
|
||
Keyboard::NoEventIndicated, // 57 no button connected
|
||
Keyboard::NoEventIndicated, // 58 no button connected
|
||
Keyboard::NoEventIndicated, // 59 no button connected
|
||
],
|
||
];
|