at master 14 kB view raw
1"""Information that should be available to the python library. 2""" 3from os import environ 4from datetime import date 5from pathlib import Path 6 7from qmk.userspace import detect_qmk_userspace 8 9# The root of the qmk_firmware tree. 10QMK_FIRMWARE = Path.cwd() 11 12# The detected userspace tree 13QMK_USERSPACE = detect_qmk_userspace() 14 15# Whether or not we have a separate userspace directory 16HAS_QMK_USERSPACE = True if QMK_USERSPACE is not None else False 17 18# Upstream repo url 19QMK_FIRMWARE_UPSTREAM = 'qmk/qmk_firmware' 20 21# This is the number of directories under `qmk_firmware/keyboards` that will be traversed. This is currently a limitation of our make system. 22MAX_KEYBOARD_SUBFOLDERS = 5 23 24# Supported processor types 25CHIBIOS_PROCESSORS = 'cortex-m0', 'cortex-m0plus', 'cortex-m3', 'cortex-m4', 'MKL26Z64', 'MK20DX128', 'MK20DX256', 'MK64FX512', 'MK66FX1M0', 'RP2040', 'STM32F042', 'STM32F072', 'STM32F103', 'STM32F303', 'STM32F401', 'STM32F405', 'STM32F407', 'STM32F411', 'STM32F446', 'STM32G0B1', 'STM32G431', 'STM32G474', 'STM32H723', 'STM32H733', 'STM32L412', 'STM32L422', 'STM32L432', 'STM32L433', 'STM32L442', 'STM32L443', 'GD32VF103', 'WB32F3G71', 'WB32FQ95', 'AT32F415' 26LUFA_PROCESSORS = 'at90usb162', 'atmega16u2', 'atmega32u2', 'atmega16u4', 'atmega32u4', 'at90usb646', 'at90usb647', 'at90usb1286', 'at90usb1287', None 27VUSB_PROCESSORS = 'atmega32a', 'atmega328p', 'atmega328', 'attiny85' 28 29# Bootloaders of the supported processors 30MCU2BOOTLOADER = { 31 "RP2040": "rp2040", 32 "MKL26Z64": "halfkay", 33 "MK20DX128": "halfkay", 34 "MK20DX256": "halfkay", 35 "MK66FX1M0": "halfkay", 36 "STM32F042": "stm32-dfu", 37 "STM32F072": "stm32-dfu", 38 "STM32F103": "stm32duino", 39 "STM32F303": "stm32-dfu", 40 "STM32F401": "stm32-dfu", 41 "STM32F405": "stm32-dfu", 42 "STM32F407": "stm32-dfu", 43 "STM32F411": "stm32-dfu", 44 "STM32F446": "stm32-dfu", 45 "STM32G0B1": "stm32-dfu", 46 "STM32G431": "stm32-dfu", 47 "STM32G474": "stm32-dfu", 48 "STM32H723": "stm32-dfu", 49 "STM32H733": "stm32-dfu", 50 "STM32L412": "stm32-dfu", 51 "STM32L422": "stm32-dfu", 52 "STM32L432": "stm32-dfu", 53 "STM32L433": "stm32-dfu", 54 "STM32L442": "stm32-dfu", 55 "STM32L443": "stm32-dfu", 56 "GD32VF103": "gd32v-dfu", 57 "WB32F3G71": "wb32-dfu", 58 "WB32FQ95": "wb32-dfu", 59 "AT32F415": "at32-dfu", 60 "atmega16u2": "atmel-dfu", 61 "atmega32u2": "atmel-dfu", 62 "atmega16u4": "atmel-dfu", 63 "atmega32u4": "atmel-dfu", 64 "at90usb162": "atmel-dfu", 65 "at90usb646": "atmel-dfu", 66 "at90usb647": "atmel-dfu", 67 "at90usb1286": "atmel-dfu", 68 "at90usb1287": "atmel-dfu", 69 "atmega32a": "bootloadhid", 70 "atmega328p": "usbasploader", 71 "atmega328": "usbasploader", 72} 73 74# Map of legacy keycodes that can be automatically updated 75LEGACY_KEYCODES = { # Comment here is to force multiline formatting 76 'RESET': 'QK_BOOT' 77} 78 79# Map VID:PID values to bootloaders 80BOOTLOADER_VIDS_PIDS = { 81 'atmel-dfu': { 82 ("03eb", "2fef"), # ATmega16U2 83 ("03eb", "2ff0"), # ATmega32U2 84 ("03eb", "2ff3"), # ATmega16U4 85 ("03eb", "2ff4"), # ATmega32U4 86 ("03eb", "2ff9"), # AT90USB64 87 ("03eb", "2ffa"), # AT90USB162 88 ("03eb", "2ffb") # AT90USB128 89 }, 90 'kiibohd': {("1c11", "b007")}, 91 'stm32-dfu': { 92 ("1eaf", "0003"), # STM32duino 93 ("0483", "df11") # STM32 DFU 94 }, 95 'apm32-dfu': {("314b", "0106")}, 96 'gd32v-dfu': {("28e9", "0189")}, 97 'wb32-dfu': {("342d", "dfa0")}, 98 'at32-dfu': {("2e3c", "df11")}, 99 'bootloadhid': {("16c0", "05df")}, 100 'usbasploader': {("16c0", "05dc")}, 101 'usbtinyisp': {("1782", "0c9f")}, 102 'md-boot': {("03eb", "6124")}, 103 'caterina': { 104 # pid.codes shared PID 105 ("1209", "2302"), # Keyboardio Atreus 2 Bootloader 106 # Spark Fun Electronics 107 ("1b4f", "9203"), # Pro Micro 3V3/8MHz 108 ("1b4f", "9205"), # Pro Micro 5V/16MHz 109 ("1b4f", "9207"), # LilyPad 3V3/8MHz (and some Pro Micro clones) 110 # Pololu Electronics 111 ("1ffb", "0101"), # A-Star 32U4 112 # Arduino SA 113 ("2341", "0036"), # Leonardo 114 ("2341", "0037"), # Micro 115 # Adafruit Industries LLC 116 ("239a", "000c"), # Feather 32U4 117 ("239a", "000d"), # ItsyBitsy 32U4 3V3/8MHz 118 ("239a", "000e"), # ItsyBitsy 32U4 5V/16MHz 119 # dog hunter AG 120 ("2a03", "0036"), # Leonardo 121 ("2a03", "0037") # Micro 122 }, 123 'hid-bootloader': { 124 ("03eb", "2067"), # QMK HID 125 ("16c0", "0478") # PJRC halfkay 126 } 127} 128 129# Common format strings 130DATE_FORMAT = '%Y-%m-%d' 131DATETIME_FORMAT = '%Y-%m-%d %H:%M:%S %Z' 132TIME_FORMAT = '%H:%M:%S' 133 134# Used when generating matrix locations 135COL_LETTERS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijilmnopqrstuvwxyz' 136ROW_LETTERS = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnop' 137 138# Constants that should match their counterparts in make 139BUILD_DIR = environ.get('BUILD_DIR', '.build') 140INTERMEDIATE_OUTPUT_PREFIX = f'{BUILD_DIR}/obj_' 141 142# Headers for generated files 143GPL2_HEADER_C_LIKE = f'''\ 144// Copyright {date.today().year} QMK 145// SPDX-License-Identifier: GPL-2.0-or-later 146''' 147 148GPL2_HEADER_SH_LIKE = f'''\ 149# Copyright {date.today().year} QMK 150# SPDX-License-Identifier: GPL-2.0-or-later 151''' 152 153GENERATED_HEADER_C_LIKE = '''\ 154/******************************************************************************* 155 88888888888 888 d8b .d888 d8b 888 d8b 156 888 888 Y8P d88P" Y8P 888 Y8P 157 888 888 888 888 158 888 88888b. 888 .d8888b 888888 888 888 .d88b. 888 .d8888b 159 888 888 "88b 888 88K 888 888 888 d8P Y8b 888 88K 160 888 888 888 888 "Y8888b. 888 888 888 88888888 888 "Y8888b. 161 888 888 888 888 X88 888 888 888 Y8b. 888 X88 162 888 888 888 888 88888P' 888 888 888 "Y8888 888 88888P' 163 888 888 164 888 888 165 888 888 166 .d88b. .d88b. 88888b. .d88b. 888d888 8888b. 888888 .d88b. .d88888 167 d88P"88b d8P Y8b 888 "88b d8P Y8b 888P" "88b 888 d8P Y8b d88" 888 168 888 888 88888888 888 888 88888888 888 .d888888 888 88888888 888 888 169 Y88b 888 Y8b. 888 888 Y8b. 888 888 888 Y88b. Y8b. Y88b 888 170 "Y88888 "Y8888 888 888 "Y8888 888 "Y888888 "Y888 "Y8888 "Y88888 171 888 172 Y8b d88P 173 "Y88P" 174*******************************************************************************/ 175''' 176 177GENERATED_HEADER_SH_LIKE = '''\ 178################################################################################ 179# 180# 88888888888 888 d8b .d888 d8b 888 d8b 181# 888 888 Y8P d88P" Y8P 888 Y8P 182# 888 888 888 888 183# 888 88888b. 888 .d8888b 888888 888 888 .d88b. 888 .d8888b 184# 888 888 "88b 888 88K 888 888 888 d8P Y8b 888 88K 185# 888 888 888 888 "Y8888b. 888 888 888 88888888 888 "Y8888b. 186# 888 888 888 888 X88 888 888 888 Y8b. 888 X88 187# 888 888 888 888 88888P' 888 888 888 "Y8888 888 88888P' 188# 189# 888 888 190# 888 888 191# 888 888 192# .d88b. .d88b. 88888b. .d88b. 888d888 8888b. 888888 .d88b. .d88888 193# d88P"88b d8P Y8b 888 "88b d8P Y8b 888P" "88b 888 d8P Y8b d88" 888 194# 888 888 88888888 888 888 88888888 888 .d888888 888 88888888 888 888 195# Y88b 888 Y8b. 888 888 Y8b. 888 888 888 Y88b. Y8b. Y88b 888 196# "Y88888 "Y8888 888 888 "Y8888 888 "Y888888 "Y888 "Y8888 "Y88888 197# 888 198# Y8b d88P 199# "Y88P" 200# 201################################################################################ 202''' 203 204LICENSE_TEXTS = [ 205 ( 206 'GPL-2.0-or-later', [ 207 """\ 208 This program is free software; you can redistribute it and/or 209 modify it under the terms of the GNU General Public License 210 as published by the Free Software Foundation; either version 2 211 of the License, or (at your option) any later version. 212 """, """\ 213 This program is free software; you can redistribute it and/or 214 modify it under the terms of the GNU General Public License 215 as published by the Free Software Foundation; either version 2 216 of the License, or any later version. 217 """ 218 ] 219 ), 220 ('GPL-2.0-only', ["""\ 221 This program is free software; you can redistribute it and/or 222 modify it under the terms of the GNU General Public License as 223 published by the Free Software Foundation; version 2. 224 """]), 225 ( 226 'GPL-3.0-or-later', [ 227 """\ 228 This program is free software: you can redistribute it and/or 229 modify it under the terms of the GNU General Public License as 230 published by the Free Software Foundation, either version 3 of 231 the License, or (at your option) any later version. 232 """, """\ 233 This program is free software: you can redistribute it and/or 234 modify it under the terms of the GNU General Public License as 235 published by the Free Software Foundation, either version 3 of 236 the License, or any later version. 237 """ 238 ] 239 ), 240 ('GPL-3.0-only', ["""\ 241 This program is free software: you can redistribute it and/or 242 modify it under the terms of the GNU General Public License as 243 published by the Free Software Foundation, version 3. 244 """]), 245 ( 246 'LGPL-2.1-or-later', [ 247 """\ 248 This program is free software; you can redistribute it and/or 249 modify it under the terms of the GNU Lesser General Public License 250 as published by the Free Software Foundation; either version 2.1 251 of the License, or (at your option) any later version. 252 """, """\ 253 This program is free software; you can redistribute it and/or 254 modify it under the terms of the GNU Lesser General Public License 255 as published by the Free Software Foundation; either version 2.1 256 of the License, or any later version. 257 """, """\ 258 This library is free software; you can redistribute it and/or 259 modify it under the terms of the GNU Lesser General Public License 260 as published by the Free Software Foundation; either version 2.1 261 of the License, or (at your option) any later version. 262 """, """\ 263 This library is free software; you can redistribute it and/or 264 modify it under the terms of the GNU Lesser General Public License 265 as published by the Free Software Foundation; either version 2.1 266 of the License, or any later version. 267 """ 268 ] 269 ), 270 ( 271 'LGPL-2.1-only', [ 272 """\ 273 This program is free software; you can redistribute it and/or 274 modify it under the terms of the GNU Lesser General Public License as 275 published by the Free Software Foundation; version 2.1. 276 """, """\ 277 This library is free software; you can redistribute it and/or 278 modify it under the terms of the GNU Lesser General Public License as 279 published by the Free Software Foundation; version 2.1. 280 """ 281 ] 282 ), 283 ( 284 'LGPL-3.0-or-later', [ 285 """\ 286 This program is free software; you can redistribute it and/or 287 modify it under the terms of the GNU Lesser General Public License 288 as published by the Free Software Foundation; either version 3 289 of the License, or (at your option) any later version. 290 """, """\ 291 This program is free software; you can redistribute it and/or 292 modify it under the terms of the GNU Lesser General Public License 293 as published by the Free Software Foundation; either version 3 294 of the License, or any later version. 295 """, """\ 296 This library is free software; you can redistribute it and/or 297 modify it under the terms of the GNU Lesser General Public License 298 as published by the Free Software Foundation; either version 3 299 of the License, or (at your option) any later version. 300 """, """\ 301 This library is free software; you can redistribute it and/or 302 modify it under the terms of the GNU Lesser General Public License 303 as published by the Free Software Foundation; either version 3 304 of the License, or any later version. 305 """ 306 ] 307 ), 308 ( 309 'LGPL-3.0-only', [ 310 """\ 311 This program is free software; you can redistribute it and/or 312 modify it under the terms of the GNU Lesser General Public License as 313 published by the Free Software Foundation; version 3. 314 """, """\ 315 This library is free software; you can redistribute it and/or 316 modify it under the terms of the GNU Lesser General Public License as 317 published by the Free Software Foundation; version 3. 318 """ 319 ] 320 ), 321 ('Apache-2.0', ["""\ 322 Licensed under the Apache License, Version 2.0 (the "License"); 323 you may not use this file except in compliance with the License. 324 """]), 325] 326 327JOYSTICK_AXES = ['x', 'y', 'z', 'rx', 'ry', 'rz']