aboutsummaryrefslogtreecommitdiff
path: root/doc/keymap.md
diff options
context:
space:
mode:
Diffstat (limited to 'doc/keymap.md')
-rw-r--r--doc/keymap.md36
1 files changed, 18 insertions, 18 deletions
diff --git a/doc/keymap.md b/doc/keymap.md
index 3a549de62..7ef7430c9 100644
--- a/doc/keymap.md
+++ b/doc/keymap.md
@@ -68,7 +68,7 @@ On the other hand, you shall change `layer_state` to overlay base layer with som
68Note that ***higher layer has higher priority on stack of layers***, namely firmware falls down from top layer to bottom to look up keycode. Once it spots keycode other than **`KC_TRNS`**(transparent) on a layer it stops searching and lower layers aren't referred. 68Note that ***higher layer has higher priority on stack of layers***, namely firmware falls down from top layer to bottom to look up keycode. Once it spots keycode other than **`KC_TRNS`**(transparent) on a layer it stops searching and lower layers aren't referred.
69 69
70You can place `KC_TRNS` on overlay layer changes just part of layout to fall back on lower or base layer. 70You can place `KC_TRNS` on overlay layer changes just part of layout to fall back on lower or base layer.
71Key with `KC_TRANS` doen't has its own keycode and refers to lower valid layers for keycode, instead. 71Key with `KC_TRANS` doesn't has its own keycode and refers to lower valid layers for keycode, instead.
72See example below. 72See example below.
73 73
74 74
@@ -155,12 +155,12 @@ You can find other keymap definitions in file `keymap.c` located on project dire
155 155
156 156
157## 1. Keycode 157## 1. Keycode
158See [`common/keycode.h`](../common/keycode.h) or keycode table below for the detail. Keycode is internal **8bit code** to inidicate action performed on key in keymap. Keycode has `KC_` prefixed symbol respectively. Most of keycodes like `KC_A` have simple action registers key to host on press and unregister on release, while some of other keycodes has some special actions like `Fn` keys, Media contorl keys, System control keys and Mousekeys. 158See [`common/keycode.h`](../common/keycode.h) or keycode table below for the detail. Keycode is internal **8bit code** to indicate action performed on key in keymap. Keycode has `KC_` prefixed symbol respectively. Most of keycodes like `KC_A` have simple action registers key to host on press and unregister on release, while some of other keycodes has some special actions like `Fn` keys, Media control keys, System control keys and Mousekeys.
159 159
160 ***In `KEYMAP()` macro you should omit prefix part `KC_` of keycode to keep keymap compact.*** For example, just use `A` instead you place `KC_A` in `KEYMAP()`. Some keycodes has 4-letter **short name** in addition to descriptive name, you'll prefer short one in `KEYMAP()`. 160 ***In `KEYMAP()` macro you should omit prefix part `KC_` of keycode to keep keymap compact.*** For example, just use `A` instead you place `KC_A` in `KEYMAP()`. Some keycodes has 4-letter **short name** in addition to descriptive name, you'll prefer short one in `KEYMAP()`.
161 161
162### 1.0 Other key 162### 1.0 Other key
163- `KC_NO` for no aciton 163- `KC_NO` for no action
164- `KC_TRNS` for layer transparency (See above) 164- `KC_TRNS` for layer transparency (See above)
165 165
166### 1.1 Normal key 166### 1.1 Normal key
@@ -192,7 +192,7 @@ There are 8 modifiers which has discrimination between left and right.
192- `KC_WSCH`, `KC_WHOM`, `KC_WBAK`, `KC_WFWD`, `KC_WSTP`, `KC_WREF`, `KC_WFAV` for web browser operation 192- `KC_WSCH`, `KC_WHOM`, `KC_WBAK`, `KC_WFWD`, `KC_WSTP`, `KC_WREF`, `KC_WFAV` for web browser operation
193 193
194### 1.5 Fn key 194### 1.5 Fn key
195`KC_FNnn` are keycodes for `Fn` key which not given any actions at the beginning unlike most of keycodes has its own inborn action. To use these keycodes in `KEYMAP()` you need to assign action you want at first. Action of `Fn` key is defined in `fn_actions[]` and its index of the array is identical with number part of `KC_FNnn`. Thus `KC_FN0` keyocde indicates the action defined in first element of the array. ***32 `Fn` keys can be defined at most.*** 195`KC_FNnn` are keycodes for `Fn` key which not given any actions at the beginning unlike most of keycodes has its own inborn action. To use these keycodes in `KEYMAP()` you need to assign action you want at first. Action of `Fn` key is defined in `fn_actions[]` and its index of the array is identical with number part of `KC_FNnn`. Thus `KC_FN0` keycode indicates the action defined in first element of the array. ***32 `Fn` keys can be defined at most.***
196 196
197### 1.6 Keycode Table 197### 1.6 Keycode Table
198 See keycode table in [`doc/keycode.txt`](./keycode.txt) for description of keycodes. 198 See keycode table in [`doc/keycode.txt`](./keycode.txt) for description of keycodes.
@@ -205,7 +205,7 @@ There are 8 modifiers which has discrimination between left and right.
205## 2. Action 205## 2. Action
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. 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 just 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
@@ -230,7 +230,7 @@ You can define these actions on *'A'* key and *'left shift'* modifier with:
230#### 2.1.2 Modified key 230#### 2.1.2 Modified key
231This action is comprised of strokes of modifiers and a key. `Macro` action is needed if you want more complex key strokes. 231This action is comprised of strokes of modifiers and a key. `Macro` action is needed if you want more complex key strokes.
232 232
233Say 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 character *'!'* or `Alt + Tab` to switch application windows.
234 234
235 ACTION_MODS_KEY(MOD_LSFT, KC_1) 235 ACTION_MODS_KEY(MOD_LSFT, KC_1)
236 ACTION_MODS_KEY(MOD_LALT, KC_TAB) 236 ACTION_MODS_KEY(MOD_LALT, KC_TAB)
@@ -272,7 +272,7 @@ This sets Default Layer to given parameter `layer` and activate it.
272 ACTION_DEFAULT_LAYER(layer) 272 ACTION_DEFAULT_LAYER(layer)
273 273
274 274
275#### 2.2.2 Momentary Switch 275#### 2.2.2 Momentary
276Turns on `layer` momentarily while holding, in other words it activates when key is pressed and deactivate when released. 276Turns on `layer` momentarily while holding, in other words it activates when key is pressed and deactivate when released.
277 277
278 ACTION_LAYER_MOMENTARY(layer) 278 ACTION_LAYER_MOMENTARY(layer)
@@ -342,7 +342,7 @@ Turns on layer only and clear all layer on release..
342 ACTION_LAYER_BIT_XOR(part, bits, on) 342 ACTION_LAYER_BIT_XOR(part, bits, on)
343 ACTION_LAYER_BIT_SET(part, bits, on) 343 ACTION_LAYER_BIT_SET(part, bits, on)
344 344
345These actions works with prameters as following code. 345These actions works with parameters as following code.
346 346
347 uint8_t shift = part*4; 347 uint8_t shift = part*4;
348 uint32_t mask = (bits&0x10) ? ~(0xf<<shift) : 0; 348 uint32_t mask = (bits&0x10) ? ~(0xf<<shift) : 0;
@@ -368,7 +368,7 @@ Default Layer also has bitwise operations, they are executed when key is release
368 MACRO( I(255), T(H), T(E), T(L), T(L), W(255), T(O), END ) 368 MACRO( I(255), T(H), T(E), T(L), T(L), W(255), T(O), END )
369 369
370#### 2.3.1 Macro Commands 370#### 2.3.1 Macro Commands
371- **I()** change interavl of stroke. 371- **I()** change interval of stroke.
372- **D()** press key 372- **D()** press key
373- **U()** release key 373- **U()** release key
374- **T()** type key(press and release) 374- **T()** type key(press and release)
@@ -377,7 +377,7 @@ Default Layer also has bitwise operations, they are executed when key is release
377 377
378#### 2.3.2 Examples 378#### 2.3.2 Examples
379 379
380***TODO: sample impl*** 380***TODO: sample implementation***
381See `keyboard/hhkb/keymap.c` for sample. 381See `keyboard/hhkb/keymap.c` for sample.
382 382
383 383
@@ -403,7 +403,7 @@ To define tappable `Function` action in keymap use this.
403 403
404 void keymap_call_function(keyrecord_t *event, uint8_t id, uint8_t opt) 404 void keymap_call_function(keyrecord_t *event, uint8_t id, uint8_t opt)
405 405
406This C function is called every time key is operated, argument `id` selects action to be performed and `opt` can be used for option. Functon `id` can be 0-255 and `opt` can be 0-15. 406This C function is called every time key is operated, argument `id` selects action to be performed and `opt` can be used for option. Function `id` can be 0-255 and `opt` can be 0-15.
407 407
408 `keyrecord_t` is comprised of key event and tap count. `keyevent_t` indicates which and when key is pressed or released. From `tap_count` you can know tap state, 0 means no tap. These information will be used in user function to decide how action of key is performed. 408 `keyrecord_t` is comprised of key event and tap count. `keyevent_t` indicates which and when key is pressed or released. From `tap_count` you can know tap state, 0 means no tap. These information will be used in user function to decide how action of key is performed.
409 409
@@ -423,7 +423,7 @@ This C function is called every time key is operated, argument `id` selects acti
423 uint8_t row; 423 uint8_t row;
424 } key_t; 424 } key_t;
425 425
426***TODO: sample impl*** 426***TODO: sample implementation***
427See `keyboard/hhkb/keymap.c` for sample. 427See `keyboard/hhkb/keymap.c` for sample.
428 428
429 429
@@ -462,8 +462,8 @@ This action makes 'Layer 1' active(valid) on key press event and inactive on rel
462 ACTION_LAYER_MOMENTARY(1) 462 ACTION_LAYER_MOMENTARY(1)
463 463
464 464
465Note that after switching on press the actions on destinaton layer(Layer 1) are perfomed. 465Note that after switching on press the actions on destination layer(Layer 1) are performed.
466***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. 466***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 place same action or 'KC_TRNS` on destination layer to get back.
467 467
468 468
469### 3.2 Toggle switching 469### 3.2 Toggle switching
@@ -480,7 +480,7 @@ These actions switch a layer only while holding a key but register the key on ta
480 480
481 ACTION_LAYER_TAP_KEY(2, KC_SCLN) 481 ACTION_LAYER_TAP_KEY(2, KC_SCLN)
482 482
483With 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. 483With 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 switching action without necessity of a dedicated key. It means you can have it even on home row of keyboard.
484 484
485 485
486 486
@@ -511,17 +511,17 @@ Layer switching with tap key:
511 511
512 512
513### 4.2 Tap Toggle 513### 4.2 Tap Toggle
514This 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. 514This is a feature to assign both toggle layer and momentary switch layer action to just same one physical key. It works as momentary layer switch when holding a key but toggle switch with several taps.
515 515
516 ACTION_LAYER_TAP_TOGGLE(1) 516 ACTION_LAYER_TAP_TOGGLE(1)
517 517
518 518
519### 4.3 Oneshot Modifier 519### 4.3 Oneshot Modifier
520This runs onetime effect swhich modify only on just one following key. It works as normal modifier key when holding down while oneshot modifier when tapping. 520This runs onetime effects which modify only on just one following key. It works as normal modifier key when holding down while oneshot modifier when tapping.
521 521
522 ACTION_MODS_ONESHOT(MOD_LSFT) 522 ACTION_MODS_ONESHOT(MOD_LSFT)
523 523
524Say you want to type 'The', you have to push and hold Shift key before type 't' then release it before type 'h' and 'e', otherwise you'll get 'THe' or 'the' unintentionally. With Oneshot Modifier you can tap Shift then type 't', 'h' and 'e' normally, you don't need to holding Shift key properly here. This mean you can realease Shift before 't' is pressed down. 524Say you want to type 'The', you have to push and hold Shift key before type 't' then release it before type 'h' and 'e', otherwise you'll get 'THe' or 'the' unintentionally. With Oneshot Modifier you can tap Shift then type 't', 'h' and 'e' normally, you don't need to holding Shift key properly here. This mean you can release Shift before 't' is pressed down.
525 525
526Oneshot effect is cancel unless following key is pressed down within `ONESHOT_TIMEOUT` of `config.h`. No timeout when it is `0` or not defined. 526Oneshot effect is cancel unless following key is pressed down within `ONESHOT_TIMEOUT` of `config.h`. No timeout when it is `0` or not defined.
527 527