diff --git a/.gitmodules b/.gitmodules index 1c6b0aa..d531538 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,6 @@ [submodule "submodules/Catch2"] path = submodules/Catch2 url = git@github.com:catchorg/Catch2.git +[submodule "submodules/scripts"] + path = submodules/scripts + url = git@github.com:ZeKeyboard/scripts.git diff --git a/Makefile b/Makefile index ae233d3..b25ff44 100644 --- a/Makefile +++ b/Makefile @@ -25,9 +25,9 @@ PRECOMPILE_HELPER = $(TEENSY_TOOLS)/teensy-tools/1.58.0/precompile_helper OBJCOPY = $(TEENSY_COMPILE)/arm-none-eabi-objcopy POST_COMPILE = $(TEENSY_TOOLS)/teensy-tools/1.58.0/teensy_post_compile PYTHON = python3 -GENERATE_LAYOUT = scripts/generate_layout.py +GENERATE_LAYOUT = submodules/scripts/generate_layout.py -KEYBOARD_LAYOUT_JSON = resources/keyboard-layout.json +KEYBOARD_LAYOUT_JSON = submodules/scripts/resources/keyboard-layout.json PRECOMPILE_FLAGS = -x c++-header -O2 -g -Wall -ffunction-sections -fdata-sections -nostdlib -MMD -std=gnu++17 -fno-exceptions -fpermissive -fno-rtti -fno-threadsafe-statics -felide-constructors -Wno-error=narrowing -mthumb -mcpu=cortex-m7 -mfloat-abi=hard -mfpu=fpv5-d16 -D__IMXRT1062__ -DTEENSYDUINO=158 -DARDUINO=10607 -DARDUINO_TEENSY41 -DF_CPU=600000000 -DUSB_SERIAL_HID -DLAYOUT_US_ENGLISH -I$(TEENSY4_CORE) diff --git a/resources/arial.ttf b/resources/arial.ttf deleted file mode 100644 index ad7d8ea..0000000 Binary files a/resources/arial.ttf and /dev/null differ diff --git a/resources/keyboard-layout.json b/resources/keyboard-layout.json deleted file mode 100644 index e94cc0b..0000000 --- a/resources/keyboard-layout.json +++ /dev/null @@ -1,228 +0,0 @@ -[ - [ - { - "y": 0.25 - }, - "Esc\n\n\n\n\n\ncol0", - { - "x": 1 - }, - "F1\n\n\n\n\n\ncol2", - "F2\n\n\n\n\n\ncol3", - "F3\n\n\n\n\n\ncol4", - "F4\n\n\n\n\n\ncol5", - { - "x": 0.5 - }, - "F5\n\n\n\n\n\ncol6", - "F6\n\n\n\n\n\ncol7", - "F7\n\n\n\n\n\ncol8", - "F8\n\n\n\n\n\ncol9", - { - "x": 0.5 - }, - "F9\n\n\n\n\n\ncol11", - "F10\n\n\n\n\n\ncol12", - "F11\n\n\n\n\n\ncol13", - "F12\n\n\n\n\n\ncol14" - ], - [ - { - "y": 0.25 - }, - "~\n`\n\n\n\n\ncol0", - "!\n1\n\n\n\n\ncol1", - "@\n2\n\n\n\n\ncol2", - "#\n3\n\n\n\n\ncol3", - "$\n4\n\n\n\n\ncol4", - "%\n5\n\n\n\n\ncol5", - "^\n6\n\n\n\n\ncol6", - "&\n7\n\n\n\n\ncol7", - "*\n8\n\n\n\n\ncol8", - "(\n9\n\n\n\n\ncol9", - ")\n0\n\n\n\n\ncol10", - "_\n-\n\n\n\n\ncol11", - "+\n=\n\n\n\n\ncol12", - { - "w": 2 - }, - "Backspace\n\n\n\n\n\ncol13", - { - "x": 0.25, - "a": 6 - }, - "col14", - { - "x": 0.25 - }, - "col15", - { - "a": 4 - }, - "/\n\n\n\n\n\ncol16", - "*\n\n\n\n\n\ncol17", - "-\n\n\n\n\n\ncol18" - ], - [ - { - "w": 1.5 - }, - "Tab\n\n\n\n\n\ncol0", - "Q\n\n\n\n\n\ncol1", - "W\n\n\n\n\n\ncol2", - "E\n\n\n\n\n\ncol3", - "R\n\n\n\n\n\ncol4", - "T\n\n\n\n\n\ncol5", - "Y\n\n\n\n\n\ncol6", - "U\n\n\n\n\n\ncol7", - "I\n\n\n\n\n\ncol8", - "O\n\n\n\n\n\ncol9", - "P\n\n\n\n\n\ncol10", - "{\n[\n\n\n\n\ncol11", - "}\n]\n\n\n\n\ncol12", - { - "w": 1.5 - }, - "|\n\\\n\n\n\n\ncol13", - { - "x": 0.25, - "a": 6 - }, - "col14", - { - "x": 0.25, - "a": 4 - }, - "7\nHome\n\n\n\n\ncol15", - "8\n↑\n\n\n\n\ncol16", - "9\nPgUp\n\n\n\n\ncol17", - { - "h": 2 - }, - "+\n\n\n\n\n\ncol18" - ], - [ - { - "w": 1.75 - }, - "Fn\n\n\n\n\n\ncol0", - "A\n\n\n\n\n\ncol1", - "S\n\n\n\n\n\ncol2", - "D\n\n\n\n\n\ncol3", - "F\n\n\n\n\n\ncol4", - "G\n\n\n\n\n\ncol5", - "H\n\n\n\n\n\ncol6", - "J\n\n\n\n\n\ncol7", - "K\n\n\n\n\n\ncol8", - "L\n\n\n\n\n\ncol9", - ":\n;\n\n\n\n\ncol10", - "\"\n'\n\n\n\n\ncol11", - { - "w": 2.25 - }, - "Enter\n\n\n\n\n\ncol13", - { - "x": 0.25, - "a": 6 - }, - "col14", - { - "x": 0.25, - "a": 4 - }, - "4\n←\n\n\n\n\ncol15", - "5\n\n\n\n\n\ncol16", - "6\n→\n\n\n\n\ncol17" - ], - [ - { - "w": 1.25 - }, - "Shift\n\n\n\n\n\ncol0", - "<>\n\n\n\n\n\ncol1", - "Z\n\n\n\n\n\ncol2", - "X\n\n\n\n\n\ncol3", - "C\n\n\n\n\n\ncol4", - "V\n\n\n\n\n\ncol5", - "B\n\n\n\n\n\ncol6", - "N\n\n\n\n\n\ncol7", - "M\n\n\n\n\n\ncol8", - "<\n,\n\n\n\n\ncol9", - ">\n.\n\n\n\n\ncol10", - "?\n/\n\n\n\n\ncol11", - { - "x": 0.375 - }, - "Up\n\n\n\n\n\ncol12", - { - "x": 0.375 - }, - "Down\n\n\n\n\n\ncol13", - { - "x": 0.25, - "a": 6 - }, - "col14", - { - "x": 0.25, - "a": 4 - }, - "1\nEnd\n\n\n\n\ncol15", - "2\n↓\n\n\n\n\ncol16", - "3\nPgDn\n\n\n\n\ncol17", - { - "h": 2 - }, - "Enter\n\n\n\n\n\ncol18" - ], - [ - { - "w": 1.25 - }, - "Ctrl\n\n\n\n\n\ncol0", - { - "w": 1.25 - }, - "Win\n\n\n\n\n\ncol1", - { - "w": 1.25 - }, - "Alt\n\n\n\n\n\ncol2", - { - "w": 2.25 - }, - "Space\n\n\n\n\n\ncol4", - { - "w": 1.75 - }, - "Fn\n\n\n\n\n\ncol6", - { - "a": 6, - "w": 2.25 - }, - "col8", - { - "a": 4, - "w": 1.25 - }, - "Alt\n\n\n\n\n\ncol10", - { - "x": 0.375 - }, - "Win\n\n\n\n\n\ncol11", - "Menu\n\n\n\n\n\ncol12", - "Ctrl\n\n\n\n\n\ncol13", - { - "x": 0.625, - "a": 6 - }, - "col14", - { - "x": 0.25, - "a": 4, - "w": 2 - }, - "0\nIns\n\n\n\n\ncol15", - ".\nDel\n\n\n\n\ncol17" - ] -] \ No newline at end of file diff --git a/scripts/generate_layout.py b/scripts/generate_layout.py deleted file mode 100644 index add7ec8..0000000 --- a/scripts/generate_layout.py +++ /dev/null @@ -1,195 +0,0 @@ -import json -import argparse -import os -import sys -from pathlib import Path -from typing import List, Tuple, Optional - -import keycodes - -SKELETON = """#pragma once -#include "../common/key_properties.h" - -// This file is generated by generate_layout.py. Do not edit manually. - -namespace common::constants -{{ - -const int TOTAL_NUM_KEYS = {total_num_keys}; -const int NUM_ROWS = {num_rows}; -const int NUM_COLS = {num_cols}; - -constexpr KeyDescription KEY_PROPERTIES[constants::TOTAL_NUM_KEYS] = -{{ - {rows} -}}; - -constexpr KeyDescription const* KEY_PROPERTIES_BY_ROW_COL[constants::NUM_ROWS][constants::NUM_COLS] = -{{ - {rows_and_cols} -}}; - -}} -""" - - -class KeyDescription: - def __init__(self, row: int, col: int, x: float, y: float, height: float, width: float, default_key: int, default_key_str: Optional[str]): - self.row: int = row - self.col: int = col - self.x: float = x - self.y: float = y - self.height: float = height - self.width: float = width - self.default_key: int = default_key - self.default_key_str: Optional[str] = default_key_str; - - def __str__(self) -> str: - return f"KeyDescription(row={self.row}, col={self.col}, x={self.x}, y={self.y}, height={self.height}, width={self.width}, default_key={self.default_key}, default_key_str={self.default_key_str})" - - def __repr__(self) -> str: - return self.__str__() - - def to_cpp(self) -> str: - return f"KeyDescription {{ {self.row}, {self.col}, {self.x}, {self.y}, {self.height}, {self.width}, {hex(self.default_key)} {'/* ' + self.default_key_str + ' */' if self.default_key_str is not None else ''}}}" - - -def parse_args(): - parser = argparse.ArgumentParser(description="Generate C++ layout description from keyboard-layout-editor.com") - parser.add_argument("-i", "--input", - help="Path to the input file, generated by keyboard-layout-editor.com", - type=Path, required=True) - parser.add_argument("-o", "--output", help="Path to the generated C++ file.", - type=str, default="output.cpp") - return parser.parse_args() - - -def extract_col(text: str) -> int: - """Extracts the column number from the text, e.g. "col1" -> 1, "col10" -> 10""" - col_half = text.lower().split("col")[1] - if len(col_half) == 1 or not col_half[1].isdigit(): - return int(col_half[0]) - else: - return int(col_half[0]) * 10 + int(col_half[1]) - - -def extract_default_key(text: str) -> Optional[str]: - col_num = extract_col(text) - text_col_split = text.upper().split(f"COL{col_num}") - key_first_half = keycodes.KEY_CODE_NAMES.get(text_col_split[0].strip(), None) - if key_first_half is not None: - return key_first_half - return keycodes.KEY_CODE_NAMES.get(text_col_split[1].strip(), None) - - -def parse_json_layout(json_layout) -> Tuple[List[List[KeyDescription]], int]: - max_col = 0 - curr_y = 0 - rows = [] - for row_num, row in enumerate(json_layout): - curr_y += 1 - cols = [] - curr_x = 0 - width = 1 - set_width = False - height = 1 - set_height = False - for item in row: - if isinstance(item, dict): - if "y" in item: - curr_y += item["y"] - if "x" in item: - curr_x += item["x"] - if "w" in item: - width = item["w"] - set_width = True - if "h" in item: - height = item["h"] - set_height = True - else: - if not set_width: - width = 1 - if not set_height: - height = 1 - - col_num = extract_col(item) - default_key_str = extract_default_key(item) - default_key = keycodes.KEY_CODES.get(default_key_str, 0) - key = KeyDescription( - row=row_num, - col=col_num, - x=curr_x, - y=curr_y, - height=height, - width=width, - default_key=default_key, - default_key_str=default_key_str) - cols.append(key) - - curr_x += width - set_width = False - set_height = False - - max_col = max(max_col, col_num) - - rows.append(cols) - return rows, max_col - - -def get_row_col_grid(rows: List[List[KeyDescription]], max_col: int) -> List[List[Optional[int]]]: - grid = [[None] * (max_col + 1) for _ in range(len(rows))] - index = 0 - for row in rows: - for key in row: - grid[key.row][key.col] = index - index += 1 - return grid - - -def write_cpp(rows: List[List[KeyDescription]], max_col: int, output_path: str): - num_rows = len(rows) - num_cols = max_col + 1 - total_num_keys = sum([len(row) for row in rows]) - - rows_str = ",\n ".join([",\n ".join( - [key.to_cpp() for key in row]) for row in rows]) - - grid = get_row_col_grid(rows, max_col) - grid_rows = [] - for row_index, row in enumerate(grid): - grid_cols = [] - for index in row: - if index is None: - grid_cols.append("nullptr") - else: - grid_cols.append(f"&KEY_PROPERTIES[{index}]") - row = ",\n ".join(grid_cols) - grid_rows.append(f"{{\n // Row {row_index}\n {row}\n }}") - rows_and_cols = ",\n ".join(grid_rows) - - cpp = SKELETON.format( - total_num_keys=total_num_keys, - rows=rows_str, - num_rows=num_rows, - rows_and_cols=rows_and_cols, - num_cols=num_cols) - with open(output_path, "w") as f: - f.write(cpp) - - -def main(): - args = parse_args() - if not os.path.isfile(args.input): - print(f"Input file {args.input} does not exist.") - sys.exit(1) - - json_layout = None - with open(args.input) as f: - json_layout = json.load(f) - - rows, max_col = parse_json_layout(json_layout) - write_cpp(rows, max_col, args.output) - - -if __name__ == "__main__": - main() diff --git a/scripts/keycodes.py b/scripts/keycodes.py deleted file mode 100644 index d251b73..0000000 --- a/scripts/keycodes.py +++ /dev/null @@ -1,285 +0,0 @@ -KEY_CODE_NAMES = { - "CTRL": "MODIFIERKEY_CTRL", - "SHIFT": "MODIFIERKEY_SHIFT", - "ALT": "MODIFIERKEY_ALT", - "GUI": "MODIFIERKEY_GUI", - "CTRL": "MODIFIERKEY_LEFT_CTRL", - "SHIFT": "MODIFIERKEY_LEFT_SHIFT", - "ALTGR": "MODIFIERKEY_LEFT_ALT", - "GUI": "MODIFIERKEY_LEFT_GUI", - "CTRL": "MODIFIERKEY_RIGHT_CTRL", - "SHIFT": "MODIFIERKEY_RIGHT_SHIFT", - "ALT": "MODIFIERKEY_RIGHT_ALT", - "GUI": "MODIFIERKEY_RIGHT_GUI", - "POWERDOWN": "KEY_SYSTEM_POWER_DOWN", - "SLEEP": "KEY_SYSTEM_SLEEP", - "WAKEUP": "KEY_SYSTEM_WAKE_UP", - "PLAY": "KEY_MEDIA_PLAY", - "PAUSE": "KEY_MEDIA_PAUSE", - "RECORD": "KEY_MEDIA_RECORD", - "FASTFORWARD": "KEY_MEDIA_FAST_FORWARD", - "REWIND": "KEY_MEDIA_REWIND", - "NEXT": "KEY_MEDIA_NEXT_TRACK", - "PREV": "KEY_MEDIA_PREV_TRACK", - "STOP": "KEY_MEDIA_STOP", - "EJECT": "KEY_MEDIA_EJECT", - "RANDOMPLAY": "KEY_MEDIA_RANDOM_PLAY", - "PLAYPAUSE": "KEY_MEDIA_PLAY_PAUSE", - "PLAYSKIP": "KEY_MEDIA_PLAY_SKIP", - "MUTE": "KEY_MEDIA_MUTE", - "VOLUMEINC": "KEY_MEDIA_VOLUME_INC", - "VOLUMEDEC": "KEY_MEDIA_VOLUME_DEC", - "A": "KEY_A", - "B": "KEY_B", - "C": "KEY_C", - "D": "KEY_D", - "E": "KEY_E", - "F": "KEY_F", - "G": "KEY_G", - "H": "KEY_H", - "I": "KEY_I", - "J": "KEY_J", - "K": "KEY_K", - "L": "KEY_L", - "M": "KEY_M", - "N": "KEY_N", - "O": "KEY_O", - "P": "KEY_P", - "Q": "KEY_Q", - "R": "KEY_R", - "S": "KEY_S", - "T": "KEY_T", - "U": "KEY_U", - "V": "KEY_V", - "W": "KEY_W", - "X": "KEY_X", - "Y": "KEY_Y", - "Z": "KEY_Z", - "1": "KEY_1", - "2": "KEY_2", - "3": "KEY_3", - "4": "KEY_4", - "5": "KEY_5", - "6": "KEY_6", - "7": "KEY_7", - "8": "KEY_8", - "9": "KEY_9", - "0": "KEY_0", - "ENTER": "KEY_ENTER", - "ESC": "KEY_ESC", - "BACKSPACE": "KEY_BACKSPACE", - "TAB": "KEY_TAB", - "SPACE": "KEY_SPACE", - "-": "KEY_MINUS", - "=": "KEY_EQUAL", - "{": "KEY_LEFT_BRACE", - "}": "KEY_RIGHT_BRACE", - "\\": "KEY_BACKSLASH", - "C": "KEY_NON_US_NUM", - ";": "KEY_SEMICOLON", - "\"": "KEY_QUOTE", - "~": "KEY_TILDE", - ",": "KEY_COMMA", - ".": "KEY_PERIOD", - "/": "KEY_SLASH", - "CAPSLOCK": "KEY_CAPS_LOCK", - "F1": "KEY_F1", - "F2": "KEY_F2", - "F3": "KEY_F3", - "F4": "KEY_F4", - "F5": "KEY_F5", - "F6": "KEY_F6", - "F7": "KEY_F7", - "F8": "KEY_F8", - "F9": "KEY_F9", - "F10": "KEY_F10", - "F11": "KEY_F11", - "F12": "KEY_F12", - "PRINTSCREEN": "KEY_PRINTSCREEN", - "SCROLLLOCK": "KEY_SCROLL_LOCK", - "PAUSE": "KEY_PAUSE", - "INSERT": "KEY_INSERT", - "HOME": "KEY_HOME", - "PAGEUP": "KEY_PAGE_UP", - "DELETE": "KEY_DELETE", - "END": "KEY_END", - "PAGEDOWN": "KEY_PAGE_DOWN", - "RIGHT": "KEY_RIGHT", - "LEFT": "KEY_LEFT", - "DOWN": "KEY_DOWN", - "UP": "KEY_UP", - "NUMLOCK": "KEY_NUM_LOCK", - "K/": "KEYPAD_SLASH", - "K*": "KEYPAD_ASTERIX", - "K-": "KEYPAD_MINUS", - "K+": "KEYPAD_PLUS", - "KENTER": "KEYPAD_ENTER", - "K1": "KEYPAD_1", - "K2": "KEYPAD_2", - "K3": "KEYPAD_3", - "K4": "KEYPAD_4", - "K5": "KEYPAD_5", - "K6": "KEYPAD_6", - "K7": "KEYPAD_7", - "K8": "KEYPAD_8", - "K9": "KEYPAD_9", - "K0": "KEYPAD_0", - "K.": "KEYPAD_PERIOD", - "N/": "KEY_NON_US_BS", - "MENU": "KEY_MENU", - "F13": "KEY_F13", - "F14": "KEY_F14", - "F15": "KEY_F15", - "F16": "KEY_F16", - "F17": "KEY_F17", - "F18": "KEY_F18", - "F19": "KEY_F19", - "F20": "KEY_F20", - "F21": "KEY_F21", - "F22": "KEY_F22", - "F23": "KEY_F23", - "F24": "KEY_F24", -} - -KEY_CODES = { - "MODIFIERKEY_CTRL": 0x01 | 0xE000, - "MODIFIERKEY_SHIFT": 0x02 | 0xE000, - "MODIFIERKEY_ALT": 0x04 | 0xE000, - "MODIFIERKEY_GUI": 0x08 | 0xE000, - "MODIFIERKEY_LEFT_CTRL": 0x01 | 0xE000, - "MODIFIERKEY_LEFT_SHIFT": 0x02 | 0xE000, - "MODIFIERKEY_LEFT_ALT": 0x04 | 0xE000, - "MODIFIERKEY_LEFT_GUI": 0x08 | 0xE000, - "MODIFIERKEY_RIGHT_CTRL": 0x10 | 0xE000, - "MODIFIERKEY_RIGHT_SHIFT": 0x20 | 0xE000, - "MODIFIERKEY_RIGHT_ALT": 0x40 | 0xE000, - "MODIFIERKEY_RIGHT_GUI": 0x80 | 0xE000, - "KEY_SYSTEM_POWER_DOWN": 0x81 | 0xE200, - "KEY_SYSTEM_SLEEP": 0x82 | 0xE200, - "KEY_SYSTEM_WAKE_UP": 0x83 | 0xE200, - "KEY_MEDIA_PLAY": 0xB0 | 0xE400, - "KEY_MEDIA_PAUSE": 0xB1 | 0xE400, - "KEY_MEDIA_RECORD": 0xB2 | 0xE400, - "KEY_MEDIA_FAST_FORWARD": 0xB3 | 0xE400, - "KEY_MEDIA_REWIND": 0xB4 | 0xE400, - "KEY_MEDIA_NEXT_TRACK": 0xB5 | 0xE400, - "KEY_MEDIA_PREV_TRACK": 0xB6 | 0xE400, - "KEY_MEDIA_STOP": 0xB7 | 0xE400, - "KEY_MEDIA_EJECT": 0xB8 | 0xE400, - "KEY_MEDIA_RANDOM_PLAY": 0xB9 | 0xE400, - "KEY_MEDIA_PLAY_PAUSE": 0xCD | 0xE400, - "KEY_MEDIA_PLAY_SKIP": 0xCE | 0xE400, - "KEY_MEDIA_MUTE": 0xE2 | 0xE400, - "KEY_MEDIA_VOLUME_INC": 0xE9 | 0xE400, - "KEY_MEDIA_VOLUME_DEC": 0xEA | 0xE400, - "KEY_A": 4 | 0xF000, - "KEY_B": 5 | 0xF000, - "KEY_C": 6 | 0xF000, - "KEY_D": 7 | 0xF000, - "KEY_E": 8 | 0xF000, - "KEY_F": 9 | 0xF000, - "KEY_G": 10 | 0xF000, - "KEY_H": 11 | 0xF000, - "KEY_I": 12 | 0xF000, - "KEY_J": 13 | 0xF000, - "KEY_K": 14 | 0xF000, - "KEY_L": 15 | 0xF000, - "KEY_M": 16 | 0xF000, - "KEY_N": 17 | 0xF000, - "KEY_O": 18 | 0xF000, - "KEY_P": 19 | 0xF000, - "KEY_Q": 20 | 0xF000, - "KEY_R": 21 | 0xF000, - "KEY_S": 22 | 0xF000, - "KEY_T": 23 | 0xF000, - "KEY_U": 24 | 0xF000, - "KEY_V": 25 | 0xF000, - "KEY_W": 26 | 0xF000, - "KEY_X": 27 | 0xF000, - "KEY_Y": 28 | 0xF000, - "KEY_Z": 29 | 0xF000, - "KEY_1": 30 | 0xF000, - "KEY_2": 31 | 0xF000, - "KEY_3": 32 | 0xF000, - "KEY_4": 33 | 0xF000, - "KEY_5": 34 | 0xF000, - "KEY_6": 35 | 0xF000, - "KEY_7": 36 | 0xF000, - "KEY_8": 37 | 0xF000, - "KEY_9": 38 | 0xF000, - "KEY_0": 39 | 0xF000, - "KEY_ENTER": 40 | 0xF000, - "KEY_ESC": 41 | 0xF000, - "KEY_BACKSPACE": 42 | 0xF000, - "KEY_TAB": 43 | 0xF000, - "KEY_SPACE": 44 | 0xF000, - "KEY_MINUS": 45 | 0xF000, - "KEY_EQUAL": 46 | 0xF000, - "KEY_LEFT_BRACE": 47 | 0xF000, - "KEY_RIGHT_BRACE": 48 | 0xF000, - "KEY_BACKSLASH": 49 | 0xF000, - "KEY_NON_US_NUM": 50 | 0xF000, - "KEY_SEMICOLON": 51 | 0xF000, - "KEY_QUOTE": 52 | 0xF000, - "KEY_TILDE": 53 | 0xF000, - "KEY_COMMA": 54 | 0xF000, - "KEY_PERIOD": 55 | 0xF000, - "KEY_SLASH": 56 | 0xF000, - "KEY_CAPS_LOCK": 57 | 0xF000, - "KEY_F1": 58 | 0xF000, - "KEY_F2": 59 | 0xF000, - "KEY_F3": 60 | 0xF000, - "KEY_F4": 61 | 0xF000, - "KEY_F5": 62 | 0xF000, - "KEY_F6": 63 | 0xF000, - "KEY_F7": 64 | 0xF000, - "KEY_F8": 65 | 0xF000, - "KEY_F9": 66 | 0xF000, - "KEY_F10": 67 | 0xF000, - "KEY_F11": 68 | 0xF000, - "KEY_F12": 69 | 0xF000, - "KEY_PRINTSCREEN": 70 | 0xF000, - "KEY_SCROLL_LOCK": 71 | 0xF000, - "KEY_PAUSE": 72 | 0xF000, - "KEY_INSERT": 73 | 0xF000, - "KEY_HOME": 74 | 0xF000, - "KEY_PAGE_UP": 75 | 0xF000, - "KEY_DELETE": 76 | 0xF000, - "KEY_END": 77 | 0xF000, - "KEY_PAGE_DOWN": 78 | 0xF000, - "KEY_RIGHT": 79 | 0xF000, - "KEY_LEFT": 80 | 0xF000, - "KEY_DOWN": 81 | 0xF000, - "KEY_UP": 82 | 0xF000, - "KEY_NUM_LOCK": 83 | 0xF000, - "KEYPAD_SLASH": 84 | 0xF000, - "KEYPAD_ASTERIX": 85 | 0xF000, - "KEYPAD_MINUS": 86 | 0xF000, - "KEYPAD_PLUS": 87 | 0xF000, - "KEYPAD_ENTER": 88 | 0xF000, - "KEYPAD_1": 89 | 0xF000, - "KEYPAD_2": 90 | 0xF000, - "KEYPAD_3": 91 | 0xF000, - "KEYPAD_4": 92 | 0xF000, - "KEYPAD_5": 93 | 0xF000, - "KEYPAD_6": 94 | 0xF000, - "KEYPAD_7": 95 | 0xF000, - "KEYPAD_8": 96 | 0xF000, - "KEYPAD_9": 97 | 0xF000, - "KEYPAD_0": 98 | 0xF000, - "KEYPAD_PERIOD": 99 | 0xF000, - "KEY_NON_US_BS": 100 | 0xF000, - "KEY_MENU": 101 | 0xF000, - "KEY_F13": 104 | 0xF000, - "KEY_F14": 105 | 0xF000, - "KEY_F15": 106 | 0xF000, - "KEY_F16": 107 | 0xF000, - "KEY_F17": 108 | 0xF000, - "KEY_F18": 109 | 0xF000, - "KEY_F19": 110 | 0xF000, - "KEY_F20": 111 | 0xF000, - "KEY_F21": 112 | 0xF000, - "KEY_F22": 113 | 0xF000, - "KEY_F23": 114 | 0xF000, - "KEY_F24": 115 | 0xF000, -} diff --git a/simulator/Makefile b/simulator/Makefile index e80a7d9..8393d2f 100644 --- a/simulator/Makefile +++ b/simulator/Makefile @@ -1,6 +1,6 @@ -KEYBOARD_LAYOUT_JSON = ../resources/keyboard-layout.json +KEYBOARD_LAYOUT_JSON = ../submodules/scripts/resources/keyboard-layout.json PYTHON = python3 -GENERATE_LAYOUT = ../scripts/generate_layout.py +GENERATE_LAYOUT = ../submodules/scripts/generate_layout.py CXX = g++ CXX_FLAGS = -c -g -Wall -Wextra -std=gnu++23 diff --git a/simulator/simulator_device.cpp b/simulator/simulator_device.cpp index cb49621..29e9ef8 100644 --- a/simulator/simulator_device.cpp +++ b/simulator/simulator_device.cpp @@ -36,12 +36,12 @@ SimulatorDevice::~SimulatorDevice() void SimulatorDevice::sleep_millis(const int millis) { - std::this_thread::sleep_for(std::chrono::milliseconds(millis * SLEEP_MULTIPLIER)); + std::this_thread::sleep_for(std::chrono::milliseconds(millis)); } void SimulatorDevice::sleep_micros(const int micros) { - std::this_thread::sleep_for(std::chrono::microseconds(micros * SLEEP_MULTIPLIER)); + std::this_thread::sleep_for(std::chrono::microseconds(micros)); } void SimulatorDevice::gpio_setup(const uint8_t pin, const PinMode mode) diff --git a/simulator/simulator_device.h b/simulator/simulator_device.h index affbc91..37e26a1 100644 --- a/simulator/simulator_device.h +++ b/simulator/simulator_device.h @@ -9,8 +9,6 @@ namespace simulator { -const int SLEEP_MULTIPLIER = 100; - class SimulatorDevice : public Device { public: diff --git a/simulator/simulator_window.cpp b/simulator/simulator_window.cpp index d00b167..56219a1 100644 --- a/simulator/simulator_window.cpp +++ b/simulator/simulator_window.cpp @@ -17,7 +17,7 @@ SimulatorWindow::SimulatorWindow(SimulatorDevice& device, core::Firmware& firmwa : device{device}, firmware{firmware}, keyboard_state{device, firmware.keymap, font} { window.create(sf::VideoMode(1920, 1080), "Simulator"); - font.loadFromFile("../resources/arial.ttf"); + font.loadFromFile("../submodules/scripts/resources/arial.ttf"); } void SimulatorWindow::update() diff --git a/submodules/scripts b/submodules/scripts new file mode 160000 index 0000000..d70d3e1 --- /dev/null +++ b/submodules/scripts @@ -0,0 +1 @@ +Subproject commit d70d3e16a42df169362857df2d68830e26b274f5