diff options
| author | Jack Humbert <jack.humb@gmail.com> | 2016-02-07 11:13:22 -0500 |
|---|---|---|
| committer | Jack Humbert <jack.humb@gmail.com> | 2016-02-07 11:13:22 -0500 |
| commit | 3a6e88d6f8982fae578b5a0094657c798aafbd38 (patch) | |
| tree | 9435fd8b3b3f6351751121091225fd4703c0f857 /README.md | |
| parent | e6a2c77fdeba1fa2cebc895e22858b61ea7174ac (diff) | |
| download | qmk_firmware-3a6e88d6f8982fae578b5a0094657c798aafbd38.tar.gz qmk_firmware-3a6e88d6f8982fae578b5a0094657c798aafbd38.zip | |
advanced macro stuff for README
Diffstat (limited to 'README.md')
| -rw-r--r-- | README.md | 68 |
1 files changed, 66 insertions, 2 deletions
| @@ -132,9 +132,73 @@ A macro can include the following commands: | |||
| 132 | 132 | ||
| 133 | So above you can see the stroke interval changed to 255ms between each keystroke, then a bunch of keys being typed, waits a while, then the macro ends. | 133 | So above you can see the stroke interval changed to 255ms between each keystroke, then a bunch of keys being typed, waits a while, then the macro ends. |
| 134 | 134 | ||
| 135 | Note: Using macros to have your keyboard send passwords for you is a bad idea. | 135 | Note: Using macros to have your keyboard send passwords for you is possible, but a bad idea. |
| 136 | 136 | ||
| 137 | ### Additional keycode aliases for software-implemented layouts (Colemak, Dvorak, etc) | 137 | ### Advanced macro functions |
| 138 | |||
| 139 | To get more control over the keys/actions your keyboard takes, the following functions are available to you in the `action_get_macro` function block: | ||
| 140 | |||
| 141 | #### `record->event.pressed` | ||
| 142 | |||
| 143 | This is a boolean value that can be tested to see if the switch is being pressed or released. An example of this is | ||
| 144 | |||
| 145 | ```c | ||
| 146 | if (record->event.pressed) { | ||
| 147 | // on keydown | ||
| 148 | } else { | ||
| 149 | // on keyup | ||
| 150 | } | ||
| 151 | ``` | ||
| 152 | |||
| 153 | #### `record->tap.count` | ||
| 154 | |||
| 155 | The number taps that a certain key gets without interruption. This value can also be reset by assigning it `0`. | ||
| 156 | |||
| 157 | #### `register_code(<kc>);` | ||
| 158 | |||
| 159 | This sends the `<kc>` keydown event to the computer. Some examples would be `KC_ESC`, `KC_C`, `KC_4`, and even modifiers such as `KC_LSFT` and `KC_LGUI`. | ||
| 160 | |||
| 161 | #### `unregister_code(<kc>);` | ||
| 162 | |||
| 163 | Parallel to `register_code` function, this sends the `<kc>` keyup event to the computer. If you don't use this, the key will be held down until it's sent. | ||
| 164 | |||
| 165 | #### `layer_on(<n>);` | ||
| 166 | |||
| 167 | This will turn on the layer `<n>` - the higher layer number will always take priority. Make sure you have `KC_TRNS` for the key you're pressing on the layer you're switching to, or you'll get stick there unless you have another plan. | ||
| 168 | |||
| 169 | #### `layer_off(<n>);` | ||
| 170 | |||
| 171 | This will turn off the layer `<n>`. | ||
| 172 | |||
| 173 | #### `clear_keyboard();` | ||
| 174 | |||
| 175 | This will clear all mods and keys currently pressed. | ||
| 176 | |||
| 177 | #### `clear_mods();` | ||
| 178 | |||
| 179 | This will clear all mods currently pressed. | ||
| 180 | |||
| 181 | #### `clear_keyboard_but_mods();` | ||
| 182 | |||
| 183 | This will clear all keys besides the mods currently pressed. | ||
| 184 | |||
| 185 | #### Timer functionality | ||
| 186 | |||
| 187 | It's possible to start timers and read values for time-specific events - here's an example: | ||
| 188 | |||
| 189 | ```c | ||
| 190 | static uint16_t key_timer; | ||
| 191 | key_timer = timer_read(); | ||
| 192 | if (timer_elapsed(key_timer) < 100) { | ||
| 193 | // do something if less than 100ms have passed | ||
| 194 | } else { | ||
| 195 | // do something if 100ms or more have passed | ||
| 196 | } | ||
| 197 | ``` | ||
| 198 | |||
| 199 | It's best to declare the `static uint16_t start;` outside of the macro block (top of file, etc). | ||
| 200 | |||
| 201 | ## Additional keycode aliases for software-implemented layouts (Colemak, Dvorak, etc) | ||
| 138 | 202 | ||
| 139 | Everything is assuming you're in Qwerty (in software) by default, but there is built-in support for using a Colemak or Dvorak layout by including this at the top of your keymap: | 203 | Everything is assuming you're in Qwerty (in software) by default, but there is built-in support for using a Colemak or Dvorak layout by including this at the top of your keymap: |
| 140 | 204 | ||
