aboutsummaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authortmk <nobody@nowhere>2013-04-05 02:56:29 +0900
committertmk <nobody@nowhere>2013-04-05 03:26:36 +0900
commit25d8de6e7b9b1570e87ea48b17f180ed9326304f (patch)
tree059fd5890eeaaaf6263e19461771c0123461de98 /doc
parent489fd75fdfa279e82e92af73e3489ff012c4eef1 (diff)
downloadqmk_firmware-25d8de6e7b9b1570e87ea48b17f180ed9326304f.tar.gz
qmk_firmware-25d8de6e7b9b1570e87ea48b17f180ed9326304f.zip
Fix doc/keymap.md for new actions
Diffstat (limited to 'doc')
-rw-r--r--doc/keymap.md113
1 files changed, 74 insertions, 39 deletions
diff --git a/doc/keymap.md b/doc/keymap.md
index 77e615a3e..474a706e0 100644
--- a/doc/keymap.md
+++ b/doc/keymap.md
@@ -203,16 +203,22 @@ There are 8 modifiers which has discrimination between left and right.
203 203
204 204
205## 2. Action 205## 2. Action
206See [`common/action.h`](../common/action.h). Action is a **16bit code** and defines function to perform on events of a key like press, release, holding and tapping. 206See [`common/action_code.h`](../common/action_code.h). Action is a **16bit code** and defines function to perform on events of a key like press, release, holding and tapping.
207 207
208Most of keys just register 8bit scancode to host, but to support other complex features needs 16bit extended action codes internally. However, using 16bit action codes in keymap results in double size in memory compared to using jsut keycodes. To avoid this waste 8bit keycodes are used in `KEYMAP()` instead of action codes. 208Most of keys just register 8bit scancode to host, but to support other complex features needs 16bit extended action codes internally. However, using 16bit action codes in keymap results in double size in memory compared to using jsut keycodes. To avoid this waste 8bit keycodes are used in `KEYMAP()` instead of action codes.
209 209
210***You can just use keycodes of `Normal key`, `Modifier`, `Mousekey` and `System & Media key` in keymap*** to indicate corresponding actions instead of using action codes. While ***to use other special actions you should use keycode of `Fn` key defined in `fn_actions[]`.*** 210***You can just use keycodes of `Normal key`, `Modifier`, `Mousekey` and `System & Media key` in keymap*** to indicate corresponding actions instead of using action codes. While ***to use other special actions you should use keycode of `Fn` key defined in `fn_actions[]`.***
211 211
212 212
213### 2.1 Key action 213### 2.1 Key Action
214This is a simple action that registers scancodes(HID usage in fact) to host on press event of key and unregister on release. 214This is a simple action that registers scancodes(HID usage in fact) to host on press event of key and unregister on release.
215 215
216#### Parameters
217+ **mods**: { ` MOD_LCTL`, ` MOD_LSFT`, ` MOD_LALT`, ` MOD_LGUI`,
218 ` MOD_RCTL`, ` MOD_RSFT`, ` MOD_RALT`, ` MOD_RGUI` }
219+ **key**: keycode
220
221
216#### 2.1.1 Normal key and Modifier 222#### 2.1.1 Normal key and Modifier
217***This action usually won't be used expressly in keymap*** because you can just use keycodes in `KEYMAP()` instead. 223***This action usually won't be used expressly in keymap*** because you can just use keycodes in `KEYMAP()` instead.
218 224
@@ -226,67 +232,72 @@ This action is comprised of strokes of modifiers and a key. `Macro` action is ne
226 232
227Say you want to assign a key to `Shift + 1` to get charactor *'!'* or `Alt + Tab` to switch application windows. 233Say you want to assign a key to `Shift + 1` to get charactor *'!'* or `Alt + Tab` to switch application windows.
228 234
229 ACTION_MOD_KEY(KC_LSFT, KC_1) 235 ACTION_MODS_KEY(MOD_LSFT, KC_1)
230 ACTION_MOD_KEY(KC_LALT, KC_TAB) 236 ACTION_MODS_KEY(MOD_LALT, KC_TAB)
231 237
232Or `Alt,Shift + Tab` can be defined. `ACTION_LMODS_KEY()` requires **4-bit modifier state** and a **keycode** as arguments. See `keycode.h` for `MOD_BIT()` macro. 238Or `Alt,Shift + Tab` can be defined. `ACTION_MODS_KEY(mods, key)` requires **4-bit modifier state** and a **keycode** as arguments. See `keycode.h` for `MOD_BIT()` macro.
233 239
234 ACTION_MODS_KEY((MOD_BIT(KC_LALT) | MOD_BIT(KC_LSFT)), KC_TAB) 240 ACTION_MODS_KEY(MOD_LALT | MOD_LSFT, KC_TAB)
235 241
236#### 2.1.3 Multiple Modifiers 242#### 2.1.3 Multiple Modifiers
237Registers multiple modifiers with a key. 243Registers multiple modifiers with pressing a key. To specify multiple modifiers use `|`.
238 244
239 ACTION_MODS(MOD_BIT(KC_ALT) | MOD_BIT(KC_LSFT)) 245 ACTION_MODS(MOD_ALT | MOD_LSFT)
240 246
241#### 2.1.3 Modifier with tap key 247#### 2.1.3 Modifier with tap key
248Works as a modifier key while holding, but registers a key on tap(press and release quickly).
249
242 250
243 ACTION_MODS_TAP_KEY(KC_RSFT, KC_GRV) 251 ACTION_MODS_TAP_KEY(MOD_RCTL, KC_ENT)
244 252
245 253
246 254
247### 2.2 Layer Action 255### 2.2 Layer Action
248These actions operate layers of keymap. 256These actions operate layers of keymap.
249 257
250**Parameters:** 258#### Parameters
259You can specify a **target layer** of action and **when the action is executed**. Some actions take a **bit value** for bitwise operation.
251 260
252+ **layer**: 0-31 261
253+ **on**: { press | release | both } 262+ **layer**: `0`-`31`
263+ **on**: { `ON_PRESS` | `ON_RELEASE` | `ON_BOTH` }
264+ **bits**: 4-bit value and 1-bit mask bit
254 265
255 266
256#### 2.2.1 Default Layer 267#### 2.2.1 Default Layer
257`default_layer` is layer which always is valid and referred to when actions is not defined on other overlay layers. 268Default Layer is a layer which always is valid and referred to when actions is not defined on other overlay layers.
258 269
259Sets `default_layer` to given parameter `layer` and turn it on. 270This sets Default Layer to given parameter `layer` and activate it.
260 271
261 ACTION_DEFAULT_LAYER(layer) 272 ACTION_DEFAULT_LAYER(layer)
262 273
263 274
264#### 2.2.2 Momentary Switch 275#### 2.2.2 Momentary Switch
265Turns on `layer` momentarily while holding, in other words turn on when key is pressed and off when released. 276Turns on `layer` momentarily while holding, in other words it activates when key is pressed and deactivate when released.
266 277
267 ACTION_LAYER_MOMENTARY(layer) 278 ACTION_LAYER_MOMENTARY(layer)
268 279
269 280
270#### 2.2.3 Toggle Switch 281#### 2.2.3 Toggle Switch
271Turns on layer on first type and turns off on next. 282Turns on `layer` with first type(press and release) and turns off with next.
272 283
273 ACTION_LAYER_TOGGLE(layer) 284 ACTION_LAYER_TOGGLE(layer)
274 285
275 286
276#### 2.2.4 Momentary Switch with tap key 287#### 2.2.4 Momentary Switch with tap key
277Turns on layer momentary while holding but registers key on tap. 288Turns on `layer` momentary while holding, but registers key on tap(press and release quickly).
278 289
279 ACTION_LAYER_TAP_KEY(layer, key) 290 ACTION_LAYER_TAP_KEY(layer, key)
280 291
281 292
282#### 2.2.5 Momentary Switch with tap toggle 293#### 2.2.5 Momentary Switch with tap toggle
283Turns on layer momentary while holding but toggles it with serial taps. 294Turns on `layer` momentary while holding and toggles it with serial taps.
284 295
285 ACTION_LAYER_TAP_TOGGLE(layer) 296 ACTION_LAYER_TAP_TOGGLE(layer)
286 297
287 298
288#### 2.2.6 Invert state of layer 299#### 2.2.6 Invert state of layer
289Inverts current layer state. If the layer is on it becomes off with this action. 300Inverts current state of `layer`. If the layer is on it becomes off with this action.
290 301
291 ACTION_LAYER_INVERT(layer, on) 302 ACTION_LAYER_INVERT(layer, on)
292 303
@@ -322,6 +333,30 @@ Turns on layer only and clear all layer on release..
322 ACTION_LAYER_SET_CLEAR(layer) 333 ACTION_LAYER_SET_CLEAR(layer)
323 334
324 335
336#### 2.2.10 Bitwise operation
337
338**part** indicates which part of 32bit layer state(0-7). **bits** is 5-bit value. **on** indicates when the action is executed.
339
340 ACTION_LAYER_BIT_AND(part, bits, on)
341 ACTION_LAYER_BIT_OR(part, bits, on)
342 ACTION_LAYER_BIT_XOR(part, bits, on)
343 ACTION_LAYER_BIT_SET(part, bits, on)
344
345These actions works with prameters as following code.
346
347 uint8_t shift = part*4;
348 uint32_t mask = (bits&0x10) ? ~(0xf<<shift) : 0;
349 uint32_t layer_state = layer_state <bitop> ((bits<<shift)|mask);
350
351
352Default Layer also has bitwise operations, they are executed when key is released.
353
354 ACTION_DEFAULT_LAYER_BIT_AND(part, bits)
355 ACTION_DEFAULT_LAYER_BIT_OR(part, bits)
356 ACTION_DEFAULT_LAYER_BIT_XOR(part, bits)
357 ACTION_DEFAULT_LAYER_BIT_SET(part, bits)
358
359
325 360
326### 2.3 Macro action 361### 2.3 Macro action
327***TBD*** 362***TBD***
@@ -403,72 +438,72 @@ There are some ways to switch layer with 'Layer' actions.
403### 3.1 Momentary switching 438### 3.1 Momentary switching
404Momentary switching changes layer only while holding Fn key. 439Momentary switching changes layer only while holding Fn key.
405 440
406This action makes 'Layer 1' active(valid) on key press event and inactive on release event. Namely you can overlay a layer on base layer temporarily with this. 441This action makes 'Layer 1' active(valid) on key press event and inactive on release event. Namely you can overlay a layer on lower layers or default layer temporarily with this action.
407 442
408 ACTION_LAYER_MOMENTARY(1) 443 ACTION_LAYER_MOMENTARY(1)
409 444
410 445
411After switch actions of destination layer are perfomed. 446Note that after switching on press the actions on destinaton layer(Layer 1) are perfomed.
412***Thus you shall need to place action to come back on destination layer***, or you will be stuck in destination layer without way to get back. Usually you need to palce same action or 'KC_TRNS` on destination layer to get back. 447***Thus you shall need to place an action to go back on destination layer***, or you will be stuck in destination layer without way to get back. Usually you need to palce same action or 'KC_TRNS` on destination layer to get back.
413 448
414 449
415### 3.2 Toggle switching 450### 3.2 Toggle switching
416Toggle switching changes layer after press then release. With this you can keep staying on the layer until you press the key again to return. 451Toggle switching performed after releasing a key. With this action you can keep staying on the destination layer until you type the key again to return.
417 452
418This is toggle action of 'Layer 2'. 453This performs toggle switching action of 'Layer 2'.
419 454
420 ACTION_LAYER_TOGGLE(2) 455 ACTION_LAYER_TOGGLE(2)
421 456
422 457
423 458
424### 3.3 Momentary switching with Tap key 459### 3.3 Momentary switching with Tap key
425These actions switch layer only while holding `Fn` key and register key on tap. **Tap** means to press and release key quickly. 460These actions switch a layer only while holding a key but register the key on tap. **Tap** means to press and release a key quickly.
426 461
427 ACTION_LAYER_TAP_KEY(2, KC_SCLN) 462 ACTION_LAYER_TAP_KEY(2, KC_SCLN)
428 463
429With this you can place layer switching function on normal key like ';' without losing its original key register function. 464With this you can place a layer switching action on normal key like ';' without losing its original key register function. This action allows you to have layer switchig action without necessity of a dedicated key. It means you can have it even on home row of keyboard.
430 465
431 466
432 467
433### 3.4 Momentary switching with Tap Toggle 468### 3.4 Momentary switching with Tap Toggle
434This switches layer only while holding `Fn` key and toggle layer after several taps. **Tap** means to press and release key quickly. 469This switches layer only while holding a key but toggle layer with several taps. **Tap** means to press and release key quickly.
435 470
436 ACTION_LAYER_TAP_TOGGLE(1) 471 ACTION_LAYER_TAP_TOGGLE(1)
437 472
438Number of taps can be defined with `TAPPING_TOGGLE` in `config.h`, `5` by default. 473Number of taps can be configured with `TAPPING_TOGGLE` in `config.h`, `5` by default.
439 474
440 475
441 476
442## 4. Tapping 477## 4. Tapping
443Tapping is to press and release key quickly. Tapping speed is determined with setting of `TAPPING_TERM`, which can be defined in `config.h`, 200ms by default. 478Tapping is to press and release a key quickly. Tapping speed is determined with setting of `TAPPING_TERM`, which can be defined in `config.h`, 200ms by default.
444 479
445### 4.1 Tap Key 480### 4.1 Tap Key
446This is feature to assign normal key action and modifier including `Fn` to just one physical key. This is a kind of [Dual role modifier][dual_role]. It works as modifier or `Fn` when holding a key but registers normal key when tapping. 481This is a feature to assign normal key action and modifier including layer switching to just same one physical key. This is a kind of [Dual role modifier][dual_role]. It works as modifier when holding the key but registers normal key when tapping.
447 482
448Action for modifier with tap key. 483Modifier with tap key:
449 484
450 ACTION_LMODS_TAP_KEY(mods, key) 485 ACTION_MODS_TAP_KEY(MOD_RSFT, KC_GRV)
451 486
452Action for `Fn` with tap key. 487Layer switching with tap key:
453 488
454 ACTION_LAYER_TAP_KEY(layer, key) 489 ACTION_LAYER_TAP_KEY(2, KC_SCLN)
455 490
456[dual_role]: http://en.wikipedia.org/wiki/Modifier_key#Dual-role_modifier_keys 491[dual_role]: http://en.wikipedia.org/wiki/Modifier_key#Dual-role_modifier_keys
457 492
458 493
459### 4.2 Tap Toggle 494### 4.2 Tap Toggle
460This is feature to assign both toggle layer and momentary switch layer action to just one physical key. It works as mementary switch when holding a key but toggle switch when tapping. 495This is a feature to assign both toggle layer and momentary switch layer action to just same one physical key. It works as mementary layer switch when holding a key but toggle switch with several taps.
461 496
462 ACTION_LAYER_TAP_TOGGLE(layer) 497 ACTION_LAYER_TAP_TOGGLE(1)
463 498
464 499
465### 4.3 One Shot Modifier 500### 4.3 One Shot Modifier
466This adds oneshot feature to modifier key. 'One Shot Modifier' is one time modifier which has effect only on following one alpha key. 501This adds oneshot feature to modifier key. 'One Shot Modifier' is one time modifier which has effect only on following just one key.
467It works as normal modifier key when holding but oneshot modifier when tapping. 502It works as normal modifier key when holding but oneshot modifier when tapping.
468 503
469 ACTION_LMODS_ONESHOT(mods) 504 ACTION_MODS_ONESHOT(MOD_LSFT)
470 505
471Say you want to type 'The', you have to push and hold Shift before type 't' then release Shift before type 'h' and 'e' or you'll get 'THe'. With One Shot Modifier you can tap Shift then type 't', 'h' and 'e' normally, you don't need to holding Shift key properly here. 506Say you want to type 'The', you have to push and hold Shift before type 't' then release Shift before type 'h' and 'e' or you'll get 'THe'. With One Shot Modifier you can tap Shift then type 't', 'h' and 'e' normally, you don't need to holding Shift key properly here.
472 507
473 508
474 509