logo

qmk_firmware

custom branch of QMK firmware git clone https://anongit.hacktivis.me/git/qmk_firmware.git

porting_your_keyboard_to_qmk.md (7548B)


  1. # Adding Your Keyboard to QMK
  2. This page describes the support for [Compatible Microcontrollers](compatible_microcontrollers) in QMK.
  3. If you have not yet you should read the [Keyboard Guidelines](hardware_keyboard_guidelines) to get a sense of how keyboards fit into QMK.
  4. QMK has a number of features to simplify working with keyboards. For most, you don't have to write a single line of code. To get started, run `qmk new-keyboard`:
  5. ```
  6. $ qmk new-keyboard
  7. Ψ Generating a new QMK keyboard directory
  8. Ψ Name Your Keyboard Project
  9. Ψ For more information, see:
  10. https://docs.qmk.fm/hardware_keyboard_guidelines#naming-your-keyboard-project
  11. Keyboard Name? mycoolkeeb
  12. Ψ Attribution
  13. Ψ Used for maintainer, copyright, etc.
  14. Your GitHub Username? [jsmith]
  15. Ψ More Attribution
  16. Ψ Used for maintainer, copyright, etc.
  17. Your Real Name? [John Smith]
  18. Ψ Pick Base Layout
  19. Ψ As a starting point, one of the common layouts can be used to
  20. bootstrap the process
  21. Default Layout?
  22. 1. 60_abnt2
  23. ...
  24. 65. none of the above
  25. Please enter your choice: [65]
  26. Ψ What Powers Your Project
  27. Ψ Is your board using a separate development board, such as a Pro Micro,
  28. or is the microcontroller integrated onto the PCB?
  29. For more information, see:
  30. https://docs.qmk.fm/compatible_microcontrollers
  31. Using a Development Board? [y/n] y
  32. Ψ Select Development Board
  33. Ψ For more information, see:
  34. https://docs.qmk.fm/compatible_microcontrollers
  35. Development Board?
  36. 1. bit_c_pro
  37. ...
  38. 14. promicro
  39. ...
  40. 18. svlinky
  41. Please enter your choice: [14]
  42. Ψ Created a new keyboard called mycoolkeeb.
  43. Ψ Build Command: qmk compile -kb mycoolkeeb -km default.
  44. Ψ Project Location: /Users/jsmith/qmk_firmware/keyboards/mycoolkeeb.
  45. Ψ Now update the config files to match the hardware!
  46. ```
  47. This will create all the files needed to support your new keyboard, and populate the settings with default values. Now you just need to customize it for your keyboard.
  48. ## `readme.md`
  49. This is where you'll describe your keyboard. Please follow the [Keyboard Readme Template](documentation_templates#keyboard-readmemd-template) when writing your `readme.md`. You're encouraged to place an image at the top of your `readme.md`, please use an external service such as [Imgur](https://imgur.com) to host the images.
  50. ## `keyboard.json`
  51. The `keyboard.json` file is where you configure the hardware and feature set for your keyboard. There are a lot of options that can be placed in that file, too many to list here. For a complete overview of available options see the [Data Driven Configuration Options](reference_info_json) page.
  52. ### Hardware Configuration
  53. At the top of the `keyboard.json` you'll find USB related settings. These control how your keyboard appears to the Operating System. If you don't have a good reason to change you should leave the `usb.vid` as `0xFEED`. For the `usb.pid` you should pick a number that is not yet in use.
  54. Do change the `manufacturer` and `keyboard_name` lines to accurately reflect your keyboard.
  55. ```json
  56. "keyboard_name": "my_awesome_keyboard",
  57. "maintainer": "You",
  58. "usb": {
  59. "vid": "0xFEED",
  60. "pid": "0x0000",
  61. "device_version": "1.0.0"
  62. },
  63. ```
  64. ::: tip
  65. Windows and macOS will display the `manufacturer` and `keyboard_name` in the list of USB devices. `lsusb` on Linux instead prefers the values in the list maintained by the [USB ID Repository](http://www.linux-usb.org/usb-ids.html). By default, it will only use `manufacturer` and `keyboard_name` if the list does not contain that `usb.vid` / `usb.pid`. `sudo lsusb -v` will show the values reported by the device, and they are also present in kernel logs after plugging it in.
  66. :::
  67. ### Matrix Configuration
  68. The next section of the `keyboard.json` deals with your keyboard's matrix. The first thing you should define is which pins on your MCU are connected to rows and columns. To do so simply specify the names of those pins:
  69. #### Diode Matrix
  70. ```json
  71. "matrix_pins": {
  72. "cols": ["C1", "C2", "C3", "C4"],
  73. "rows": ["D1", "D2", "D3", "D4"]
  74. },
  75. ```
  76. The matrix dimensions are inferred from the length of the `matrix_pins.cols` and `matrix_pins.rows` arrays (previously specified explicitly in `config.h` with `MATRIX_ROWS` and `MATRIX_COLS`).
  77. Finally, you can specify the direction your diodes point. This can be `COL2ROW` or `ROW2COL`.
  78. ```json
  79. "diode_direction": "ROW2COL",
  80. ```
  81. #### Direct Pin Matrix
  82. To configure a keyboard where each switch is connected to a separate pin and ground instead of sharing row and column pins, use `matrix_pins.direct`. This overrides the behaviour of `diode_direction`, `matrix_pins.cols` and `matrix_pins.rows`, and they should not be specified together.
  83. ```json
  84. "matrix_pins": {
  85. "direct": [
  86. ["F1", "E6", "B0", "B2", "B3"],
  87. ["F5", "F0", "B1", "B7", "D2"],
  88. ["F6", "F7", "C7", "D5", "D3"],
  89. ["B5", "C6", "B6", null, null]
  90. ]
  91. },
  92. ```
  93. Here, the matrix dimensions are inferred directly from the dimensions of the `matrix_pins.direct` array. Since there are no row or column pins to prescribe the matrix dimensions, you can arrange it however you like. Each "row" must contain the same number of "column"s; use `null` to fill in blank spaces, but try to minimize them.
  94. ### Layout Macros
  95. Next is configuring layout macro(s). These define the physical arrangement of keys, and their position within the matrix that switches are connected to. This allows you to have a physical arrangement of keys that differs from the wiring matrix.
  96. ```json
  97. "layouts": {
  98. "LAYOUT_ortho_4x4": {
  99. "layout": [
  100. {"matrix": [0, 0], "x": 0, "y": 0},
  101. {"matrix": [0, 1], "x": 1, "y": 0},
  102. {"matrix": [0, 2], "x": 2, "y": 0},
  103. {"matrix": [0, 3], "x": 3, "y": 0},
  104. {"matrix": [1, 0], "x": 0, "y": 1},
  105. {"matrix": [1, 1], "x": 1, "y": 1},
  106. {"matrix": [1, 2], "x": 2, "y": 1},
  107. {"matrix": [1, 3], "x": 3, "y": 1},
  108. {"matrix": [2, 0], "x": 0, "y": 2},
  109. {"matrix": [2, 1], "x": 1, "y": 2},
  110. {"matrix": [2, 2], "x": 2, "y": 2},
  111. {"matrix": [2, 3], "x": 3, "y": 2},
  112. {"matrix": [3, 0], "x": 0, "y": 3},
  113. {"matrix": [3, 1], "x": 1, "y": 3},
  114. {"matrix": [3, 2], "x": 2, "y": 3},
  115. {"matrix": [3, 3], "x": 3, "y": 3}
  116. ]
  117. }
  118. }
  119. ```
  120. In the above example,
  121. * `LAYOUT_ortho_4x4` defines the name of the layout macro
  122. * It must conform to the [layout guidelines](hardware_keyboard_guidelines#keyboard-name-h)
  123. * `"matrix": [0, 0]` defines the matrix row and column that the key is associated with
  124. ::: tip
  125. See also: [Split Keyboard Layout Macro](features/split_keyboard#layout-macro) and [Matrix to Physical Layout](understanding_qmk#matrix-to-physical-layout-map).
  126. :::
  127. ## Additional Configuration
  128. There are a lot of features that can be turned on or off, configured or tuned. Some of these have yet to be migrated over to [Data Driven Configuration](data_driven_config). The following sections cover the process for when a data-driven option is unavailable.
  129. ### Configuration Options
  130. For available options for `config.h`, you should see the [Config Options](config_options#the-configh-file) page for more details.
  131. ### Build Options
  132. For available options for `rules.mk`, see the [Config Options](config_options#feature-options) page for a detailed list and description.