diff options
Diffstat (limited to 'hid/arduino/lib/drivers')
-rw-r--r-- | hid/arduino/lib/drivers/aum.h | 48 | ||||
-rw-r--r-- | hid/arduino/lib/drivers/board.h | 41 | ||||
-rw-r--r-- | hid/arduino/lib/drivers/connection.h | 54 | ||||
-rw-r--r-- | hid/arduino/lib/drivers/driver.h | 49 | ||||
-rw-r--r-- | hid/arduino/lib/drivers/factory.h | 39 | ||||
-rw-r--r-- | hid/arduino/lib/drivers/keyboard.h | 68 | ||||
-rw-r--r-- | hid/arduino/lib/drivers/mouse.h | 51 | ||||
-rw-r--r-- | hid/arduino/lib/drivers/serial.h | 68 | ||||
-rw-r--r-- | hid/arduino/lib/drivers/storage.h | 35 | ||||
-rw-r--r-- | hid/arduino/lib/drivers/tools.cpp | 32 | ||||
-rw-r--r-- | hid/arduino/lib/drivers/tools.h | 28 | ||||
-rw-r--r-- | hid/arduino/lib/drivers/usb-keymap.h | 141 | ||||
-rw-r--r-- | hid/arduino/lib/drivers/usb-keymap.h.mako | 37 |
13 files changed, 691 insertions, 0 deletions
diff --git a/hid/arduino/lib/drivers/aum.h b/hid/arduino/lib/drivers/aum.h new file mode 100644 index 00000000..3d407d12 --- /dev/null +++ b/hid/arduino/lib/drivers/aum.h @@ -0,0 +1,48 @@ +/***************************************************************************** +# # +# KVMD - The main PiKVM daemon. # +# # +# Copyright (C) 2018-2023 Maxim Devaev <[email protected]> # +# # +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation, either version 3 of the License, or # +# (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program. If not, see <https://www.gnu.org/licenses/>. # +# # +*****************************************************************************/ + + +#pragma once + +#include <digitalWriteFast.h> + + +inline void aumInit() { + pinModeFast(AUM_IS_USB_POWERED_PIN, INPUT); + pinModeFast(AUM_SET_USB_VBUS_PIN, OUTPUT); + pinModeFast(AUM_SET_USB_CONNECTED_PIN, OUTPUT); + digitalWriteFast(AUM_SET_USB_CONNECTED_PIN, HIGH); +} + +inline void aumProxyUsbVbus() { + bool vbus = digitalReadFast(AUM_IS_USB_POWERED_PIN); + if (digitalReadFast(AUM_SET_USB_VBUS_PIN) != vbus) { + digitalWriteFast(AUM_SET_USB_VBUS_PIN, vbus); + } +} + +inline void aumSetUsbConnected(bool connected) { + digitalWriteFast(AUM_SET_USB_CONNECTED_PIN, connected); +} + +inline bool aumIsUsbConnected() { + return digitalReadFast(AUM_SET_USB_CONNECTED_PIN); +} diff --git a/hid/arduino/lib/drivers/board.h b/hid/arduino/lib/drivers/board.h new file mode 100644 index 00000000..cc431d62 --- /dev/null +++ b/hid/arduino/lib/drivers/board.h @@ -0,0 +1,41 @@ +/***************************************************************************** +# # +# KVMD - The main PiKVM daemon. # +# # +# Copyright (C) 2018-2023 Maxim Devaev <[email protected]> # +# # +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation, either version 3 of the License, or # +# (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program. If not, see <https://www.gnu.org/licenses/>. # +# # +*****************************************************************************/ + + +#pragma once + +#include "driver.h" + + +namespace DRIVERS { + enum status { + RX_DATA = 0, + KEYBOARD_ONLINE, + MOUSE_ONLINE, + }; + + struct Board : public Driver { + using Driver::Driver; + virtual void reset() {} + virtual void periodic() {} + virtual void updateStatus(status status) {} + }; +} diff --git a/hid/arduino/lib/drivers/connection.h b/hid/arduino/lib/drivers/connection.h new file mode 100644 index 00000000..7a9beb7b --- /dev/null +++ b/hid/arduino/lib/drivers/connection.h @@ -0,0 +1,54 @@ +/***************************************************************************** +# # +# KVMD - The main PiKVM daemon. # +# # +# Copyright (C) 2018-2023 Maxim Devaev <[email protected]> # +# # +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation, either version 3 of the License, or # +# (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program. If not, see <https://www.gnu.org/licenses/>. # +# # +*****************************************************************************/ + + +#pragma once + +#include "driver.h" +#include "stdint.h" + + +namespace DRIVERS { + typedef void (*DataHandler)(const uint8_t *data, size_t size); + typedef void (*TimeoutHandler)(); + + struct Connection : public Driver { + using Driver::Driver; + + virtual void begin() {} + + virtual void periodic() {} + + void onTimeout(TimeoutHandler cb) { + _timeout_cb = cb; + } + + void onData(DataHandler cb) { + _data_cb = cb; + } + + virtual void write(const uint8_t *data, size_t size) = 0; + + protected: + TimeoutHandler _timeout_cb = nullptr; + DataHandler _data_cb = nullptr; + }; +} diff --git a/hid/arduino/lib/drivers/driver.h b/hid/arduino/lib/drivers/driver.h new file mode 100644 index 00000000..af60b112 --- /dev/null +++ b/hid/arduino/lib/drivers/driver.h @@ -0,0 +1,49 @@ +/***************************************************************************** +# # +# KVMD - The main PiKVM daemon. # +# # +# Copyright (C) 2018-2023 Maxim Devaev <[email protected]> # +# # +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation, either version 3 of the License, or # +# (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program. If not, see <https://www.gnu.org/licenses/>. # +# # +*****************************************************************************/ + + +#pragma once + +#include <stdint.h> + + +namespace DRIVERS { + enum type { + DUMMY = 0, + USB_MOUSE_ABSOLUTE, + USB_MOUSE_RELATIVE, + USB_MOUSE_ABSOLUTE_WIN98, + USB_KEYBOARD, + PS2_KEYBOARD, + NON_VOLATILE_STORAGE, + BOARD, + CONNECTION, + }; + + class Driver { + public: + Driver(type _type) : _type(_type) {} + uint8_t getType() { return _type; } + + private: + type _type; + }; +} diff --git a/hid/arduino/lib/drivers/factory.h b/hid/arduino/lib/drivers/factory.h new file mode 100644 index 00000000..116a6c84 --- /dev/null +++ b/hid/arduino/lib/drivers/factory.h @@ -0,0 +1,39 @@ +/***************************************************************************** +# # +# KVMD - The main PiKVM daemon. # +# # +# Copyright (C) 2018-2023 Maxim Devaev <[email protected]> # +# # +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation, either version 3 of the License, or # +# (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program. If not, see <https://www.gnu.org/licenses/>. # +# # +*****************************************************************************/ + +#pragma once + +#include "keyboard.h" +#include "mouse.h" +#include "storage.h" +#include "board.h" +#include "connection.h" + + +namespace DRIVERS { + struct Factory { + static Keyboard *makeKeyboard(type _type); + static Mouse *makeMouse(type _type); + static Storage *makeStorage(type _type); + static Board *makeBoard(type _type); + static Connection *makeConnection(type _type); + }; +} diff --git a/hid/arduino/lib/drivers/keyboard.h b/hid/arduino/lib/drivers/keyboard.h new file mode 100644 index 00000000..1128def9 --- /dev/null +++ b/hid/arduino/lib/drivers/keyboard.h @@ -0,0 +1,68 @@ +/***************************************************************************** +# # +# KVMD - The main PiKVM daemon. # +# # +# Copyright (C) 2018-2023 Maxim Devaev <[email protected]> # +# # +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation, either version 3 of the License, or # +# (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program. If not, see <https://www.gnu.org/licenses/>. # +# # +*****************************************************************************/ + + +#pragma once + +#include <stdint.h> + +#include "driver.h" + + +namespace DRIVERS { + typedef struct { + bool caps; + bool scroll; + bool num; + } KeyboardLedsState; + + struct Keyboard : public Driver { + using Driver::Driver; + + virtual void begin() {} + + /** + * Release all keys + */ + virtual void clear() {} + + /** + * Sends key + * @param code ??? + * @param state true pressed, false released + */ + virtual void sendKey(uint8_t code, bool state) {} + + virtual void periodic() {} + + /** + * False if online or unknown. Otherwise true. + */ + virtual bool isOffline() { + return false; + } + + virtual KeyboardLedsState getLeds() { + KeyboardLedsState result = {0}; + return result; + } + }; +} diff --git a/hid/arduino/lib/drivers/mouse.h b/hid/arduino/lib/drivers/mouse.h new file mode 100644 index 00000000..83216e29 --- /dev/null +++ b/hid/arduino/lib/drivers/mouse.h @@ -0,0 +1,51 @@ +/***************************************************************************** +# # +# KVMD - The main PiKVM daemon. # +# # +# Copyright (C) 2018-2023 Maxim Devaev <[email protected]> # +# # +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation, either version 3 of the License, or # +# (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program. If not, see <https://www.gnu.org/licenses/>. # +# # +*****************************************************************************/ + + +#pragma once + +#include <stdint.h> + +#include "driver.h" + + +namespace DRIVERS { + struct Mouse : public Driver { + using Driver::Driver; + virtual void begin() {} + + /** + * Release all keys + */ + virtual void clear() {} + virtual void sendButtons( + bool left_select, bool left_state, + bool right_select, bool right_state, + bool middle_select, bool middle_state, + bool up_select, bool up_state, + bool down_select, bool down_state) {} + virtual void sendMove(int x, int y) {} + virtual void sendRelative(int x, int y) {} + virtual void sendWheel(int delta_y) {} + virtual bool isOffline() { return false; } + virtual void periodic() {} + }; +} diff --git a/hid/arduino/lib/drivers/serial.h b/hid/arduino/lib/drivers/serial.h new file mode 100644 index 00000000..32ec5613 --- /dev/null +++ b/hid/arduino/lib/drivers/serial.h @@ -0,0 +1,68 @@ +/***************************************************************************** +# # +# KVMD - The main PiKVM daemon. # +# # +# Copyright (C) 2018-2023 Maxim Devaev <[email protected]> # +# # +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation, either version 3 of the License, or # +# (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program. If not, see <https://www.gnu.org/licenses/>. # +# # +*****************************************************************************/ + + +#pragma once + +#ifdef CMD_SERIAL +#include "connection.h" + + +namespace DRIVERS { +#ifdef Serial +# undef Serial +#endif + struct Serial : public Connection { + Serial() : Connection(CONNECTION) {} + + void begin() override { + CMD_SERIAL.begin(CMD_SERIAL_SPEED); + } + + void periodic() override { + if (CMD_SERIAL.available() > 0) { + _buffer[_index] = (uint8_t)CMD_SERIAL.read(); + if (_index == 7) { + _data_cb(_buffer, 8); + _index = 0; + } else { + _last = micros(); + ++_index; + } + } else if (_index > 0) { + if (is_micros_timed_out(_last, CMD_SERIAL_TIMEOUT)) { + _timeout_cb(); + _index = 0; + } + } + } + + void write(const uint8_t *data, size_t size) override { + CMD_SERIAL.write(data, size); + } + + private: + unsigned long _last = 0; + uint8_t _index = 0; + uint8_t _buffer[8]; + }; +} +#endif diff --git a/hid/arduino/lib/drivers/storage.h b/hid/arduino/lib/drivers/storage.h new file mode 100644 index 00000000..3b676905 --- /dev/null +++ b/hid/arduino/lib/drivers/storage.h @@ -0,0 +1,35 @@ +/***************************************************************************** +# # +# KVMD - The main PiKVM daemon. # +# # +# Copyright (C) 2018-2023 Maxim Devaev <[email protected]> # +# # +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation, either version 3 of the License, or # +# (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program. If not, see <https://www.gnu.org/licenses/>. # +# # +*****************************************************************************/ + + +#pragma once + +#include "driver.h" +#include "stdlib.h" + + +namespace DRIVERS { + struct Storage : public Driver { + using Driver::Driver; + virtual void readBlock(void *dest, const void *src, size_t size) {} + virtual void updateBlock(const void *src, void *dest, size_t size) {} + }; +} diff --git a/hid/arduino/lib/drivers/tools.cpp b/hid/arduino/lib/drivers/tools.cpp new file mode 100644 index 00000000..a6585245 --- /dev/null +++ b/hid/arduino/lib/drivers/tools.cpp @@ -0,0 +1,32 @@ +/***************************************************************************** +# # +# KVMD - The main PiKVM daemon. # +# # +# Copyright (C) 2018-2023 Maxim Devaev <[email protected]> # +# # +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation, either version 3 of the License, or # +# (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program. If not, see <https://www.gnu.org/licenses/>. # +# # +*****************************************************************************/ + + +#include "tools.h" + + +bool is_micros_timed_out(unsigned long start_ts, unsigned long timeout) { + unsigned long now = micros(); + return ( + (now >= start_ts && now - start_ts > timeout) + || (now < start_ts && ((unsigned long)-1) - start_ts + now > timeout) + ); +} diff --git a/hid/arduino/lib/drivers/tools.h b/hid/arduino/lib/drivers/tools.h new file mode 100644 index 00000000..34f88022 --- /dev/null +++ b/hid/arduino/lib/drivers/tools.h @@ -0,0 +1,28 @@ +/***************************************************************************** +# # +# KVMD - The main PiKVM daemon. # +# # +# Copyright (C) 2018-2023 Maxim Devaev <[email protected]> # +# # +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation, either version 3 of the License, or # +# (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program. If not, see <https://www.gnu.org/licenses/>. # +# # +*****************************************************************************/ + + +#pragma once + +#include <Arduino.h> + + +bool is_micros_timed_out(unsigned long start_ts, unsigned long timeout); diff --git a/hid/arduino/lib/drivers/usb-keymap.h b/hid/arduino/lib/drivers/usb-keymap.h new file mode 100644 index 00000000..5a86337f --- /dev/null +++ b/hid/arduino/lib/drivers/usb-keymap.h @@ -0,0 +1,141 @@ +/***************************************************************************** +# # +# KVMD - The main PiKVM daemon. # +# # +# Copyright (C) 2018-2023 Maxim Devaev <[email protected]> # +# # +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation, either version 3 of the License, or # +# (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program. If not, see <https://www.gnu.org/licenses/>. # +# # +*****************************************************************************/ + + +#pragma once + + +uint8_t keymapUsb(uint8_t code) { + switch (code) { + case 1: return 4; // KeyA + case 2: return 5; // KeyB + case 3: return 6; // KeyC + case 4: return 7; // KeyD + case 5: return 8; // KeyE + case 6: return 9; // KeyF + case 7: return 10; // KeyG + case 8: return 11; // KeyH + case 9: return 12; // KeyI + case 10: return 13; // KeyJ + case 11: return 14; // KeyK + case 12: return 15; // KeyL + case 13: return 16; // KeyM + case 14: return 17; // KeyN + case 15: return 18; // KeyO + case 16: return 19; // KeyP + case 17: return 20; // KeyQ + case 18: return 21; // KeyR + case 19: return 22; // KeyS + case 20: return 23; // KeyT + case 21: return 24; // KeyU + case 22: return 25; // KeyV + case 23: return 26; // KeyW + case 24: return 27; // KeyX + case 25: return 28; // KeyY + case 26: return 29; // KeyZ + case 27: return 30; // Digit1 + case 28: return 31; // Digit2 + case 29: return 32; // Digit3 + case 30: return 33; // Digit4 + case 31: return 34; // Digit5 + case 32: return 35; // Digit6 + case 33: return 36; // Digit7 + case 34: return 37; // Digit8 + case 35: return 38; // Digit9 + case 36: return 39; // Digit0 + case 37: return 40; // Enter + case 38: return 41; // Escape + case 39: return 42; // Backspace + case 40: return 43; // Tab + case 41: return 44; // Space + case 42: return 45; // Minus + case 43: return 46; // Equal + case 44: return 47; // BracketLeft + case 45: return 48; // BracketRight + case 46: return 49; // Backslash + case 47: return 51; // Semicolon + case 48: return 52; // Quote + case 49: return 53; // Backquote + case 50: return 54; // Comma + case 51: return 55; // Period + case 52: return 56; // Slash + case 53: return 57; // CapsLock + case 54: return 58; // F1 + case 55: return 59; // F2 + case 56: return 60; // F3 + case 57: return 61; // F4 + case 58: return 62; // F5 + case 59: return 63; // F6 + case 60: return 64; // F7 + case 61: return 65; // F8 + case 62: return 66; // F9 + case 63: return 67; // F10 + case 64: return 68; // F11 + case 65: return 69; // F12 + case 66: return 70; // PrintScreen + case 67: return 73; // Insert + case 68: return 74; // Home + case 69: return 75; // PageUp + case 70: return 76; // Delete + case 71: return 77; // End + case 72: return 78; // PageDown + case 73: return 79; // ArrowRight + case 74: return 80; // ArrowLeft + case 75: return 81; // ArrowDown + case 76: return 82; // ArrowUp + case 77: return 224; // ControlLeft + case 78: return 225; // ShiftLeft + case 79: return 226; // AltLeft + case 80: return 227; // MetaLeft + case 81: return 228; // ControlRight + case 82: return 229; // ShiftRight + case 83: return 230; // AltRight + case 84: return 231; // MetaRight + case 85: return 72; // Pause + case 86: return 71; // ScrollLock + case 87: return 83; // NumLock + case 88: return 101; // ContextMenu + case 89: return 84; // NumpadDivide + case 90: return 85; // NumpadMultiply + case 91: return 86; // NumpadSubtract + case 92: return 87; // NumpadAdd + case 93: return 88; // NumpadEnter + case 94: return 89; // Numpad1 + case 95: return 90; // Numpad2 + case 96: return 91; // Numpad3 + case 97: return 92; // Numpad4 + case 98: return 93; // Numpad5 + case 99: return 94; // Numpad6 + case 100: return 95; // Numpad7 + case 101: return 96; // Numpad8 + case 102: return 97; // Numpad9 + case 103: return 98; // Numpad0 + case 104: return 99; // NumpadDecimal + case 105: return 102; // Power + case 106: return 100; // IntlBackslash + case 107: return 137; // IntlYen + case 108: return 135; // IntlRo + case 109: return 136; // KanaMode + case 110: return 138; // Convert + case 111: return 139; // NonConvert + default: return 0; + } +} diff --git a/hid/arduino/lib/drivers/usb-keymap.h.mako b/hid/arduino/lib/drivers/usb-keymap.h.mako new file mode 100644 index 00000000..5ae01421 --- /dev/null +++ b/hid/arduino/lib/drivers/usb-keymap.h.mako @@ -0,0 +1,37 @@ +/***************************************************************************** +# # +# KVMD - The main PiKVM daemon. # +# # +# Copyright (C) 2018-2023 Maxim Devaev <[email protected]> # +# # +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation, either version 3 of the License, or # +# (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program. If not, see <https://www.gnu.org/licenses/>. # +# # +*****************************************************************************/ + + +#pragma once + +<%! import operator %> +uint8_t keymapUsb(uint8_t code) { + switch (code) { +% for km in sorted(keymap, key=operator.attrgetter("mcu_code")): + % if km.usb_key.is_modifier: + case ${km.mcu_code}: return ${km.usb_key.arduino_modifier_code}; // ${km.web_name} + % else: + case ${km.mcu_code}: return ${km.usb_key.code}; // ${km.web_name} + % endif +% endfor + default: return 0; + } +} |