aboutsummaryrefslogtreecommitdiff
path: root/docs/keymap.md
diff options
context:
space:
mode:
authorDrashna Jaelre <drashna@live.com>2019-03-18 14:22:02 -0700
committerMechMerlin <30334081+mechmerlin@users.noreply.github.com>2019-03-18 14:22:02 -0700
commitc534a4c775098f2b6cc8e7f36d35cf642f4323a5 (patch)
treef025c6ade37e4fc6bc930e05fe9a734dd273c974 /docs/keymap.md
parent28e182bc8a2976562e0d76a1332527e0a4be81ea (diff)
downloadqmk_firmware-c534a4c775098f2b6cc8e7f36d35cf642f4323a5.tar.gz
qmk_firmware-c534a4c775098f2b6cc8e7f36d35cf642f4323a5.zip
[Docs] Smallish overhaul of the docs (#5281)
* Fix up Common functions doc * Add to extra commands to flashing doc * Rearrange and touch up Macros * Expand Newbs Flashing guide * Update process_record documentation * Add git to best practices name in sidebar * Expand FAQ for build/flashing * Add deprecated info to functions * Update docs/feature_macros.md Co-Authored-By: drashna <drashna@live.com> * Update docs/feature_macros.md Co-Authored-By: drashna <drashna@live.com> * Update docs/flashing.md Co-Authored-By: drashna <drashna@live.com> * Update docs/flashing.md Co-Authored-By: drashna <drashna@live.com> * Update docs/keymap.md Co-Authored-By: drashna <drashna@live.com> * Update docs/newbs_flashing.md Co-Authored-By: drashna <drashna@live.com> * Update docs/newbs_flashing.md Co-Authored-By: drashna <drashna@live.com> * Update docs/custom_quantum_functions.md Co-Authored-By: drashna <drashna@live.com> * Update docs/faq_build.md Co-Authored-By: drashna <drashna@live.com> * Update docs/feature_macros.md Co-Authored-By: drashna <drashna@live.com> * Update docs/keymap.md Co-Authored-By: drashna <drashna@live.com> * Fix up Common functions doc * Make pre-init example accurate * Update docs/custom_quantum_functions.md Co-Authored-By: drashna <drashna@live.com> * Zadig Driver catchall * Spelling Depriciated * Completely remove fn_actions section
Diffstat (limited to 'docs/keymap.md')
-rw-r--r--docs/keymap.md56
1 files changed, 0 insertions, 56 deletions
diff --git a/docs/keymap.md b/docs/keymap.md
index 49e6654a2..457dbf67e 100644
--- a/docs/keymap.md
+++ b/docs/keymap.md
@@ -161,62 +161,6 @@ Some interesting things to note:
161* We have used our `_______` definition to turn `KC_TRNS` into `_______`. This makes it easier to spot the keys that have changed on this layer. 161* We have used our `_______` definition to turn `KC_TRNS` into `_______`. This makes it easier to spot the keys that have changed on this layer.
162* While in this layer if you press one of the `_______` keys it will activate the key in the next lowest active layer. 162* While in this layer if you press one of the `_______` keys it will activate the key in the next lowest active layer.
163 163
164### Custom Functions
165
166At the bottom of the file we've defined a single custom function. This function defines a key that sends `KC_ESC` when pressed without modifiers and `KC_GRAVE` when modifiers are held. There are a couple pieces that need to be in place for this to work, and we will go over both of them.
167
168#### `fn_actions[]`
169
170We define the `fn_actions[]` array to point to custom functions. `F(N)` in a keymap will call element N of that array. For the Clueboard's that looks like this:
171
172 const uint16_t PROGMEM fn_actions[] = {
173 [0] = ACTION_FUNCTION(0), // Calls action_function()
174 };
175
176In this case we've instructed QMK to call the `ACTION_FUNCTION` callback, which we will define in the next section.
177
178> This `fn_actions[]` interface is mostly for backward compatibility. In QMK, you don't need to use `fn_actions[]`. You can directly use `ACTION_FUNCTION(N)` or any other action code value itself normally generated by the macro in `keymaps[][MATRIX_ROWS][MATRIX_COLS]`. N in `F(N)` can only be 0 to 31. Use of the action code directly in `keymaps` unlocks this limitation.
179
180You can get a full list of Action Functions in [action_code.h](https://github.com/qmk/qmk_firmware/blob/master/tmk_core/common/action_code.h).
181
182#### `action_function()`
183
184To actually handle the keypress event we define an `action_function()`. This function will be called when the key is pressed, and then again when the key is released. We have to handle both situations within our code, as well as determining whether to send/release `KC_ESC` or `KC_GRAVE`.
185
186 void action_function(keyrecord_t *record, uint8_t id, uint8_t opt) {
187 static uint8_t mods_pressed;
188
189 switch (id) {
190 case 0:
191 /* Handle the combined Grave/Esc key
192 */
193 mods_pressed = get_mods()&GRAVE_MODS; // Check to see what mods are pressed
194
195 if (record->event.pressed) {
196 /* The key is being pressed.
197 */
198 if (mods_pressed) {
199 add_key(KC_GRV);
200 send_keyboard_report();
201 } else {
202 add_key(KC_ESC);
203 send_keyboard_report();
204 }
205 } else {
206 /* The key is being released.
207 */
208 if (mods_pressed) {
209 del_key(KC_GRV);
210 send_keyboard_report();
211 } else {
212 del_key(KC_ESC);
213 send_keyboard_report();
214 }
215 }
216 break;
217 }
218 }
219
220# Nitty Gritty Details 164# Nitty Gritty Details
221 165
222This should have given you a basic overview for creating your own keymap. For more details see the following resources: 166This should have given you a basic overview for creating your own keymap. For more details see the following resources: