aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md30
-rw-r--r--common/action.c6
-rw-r--r--common/action.h68
-rw-r--r--doc/keymap.md145
-rw-r--r--keyboard/gh60/keymap.c18
-rw-r--r--keyboard/gh60/keymap_poker.h12
-rw-r--r--keyboard/gh60/keymap_poker_set.h16
7 files changed, 126 insertions, 169 deletions
diff --git a/README.md b/README.md
index 14d55ea36..e349ee61d 100644
--- a/README.md
+++ b/README.md
@@ -25,23 +25,23 @@ Projects
25You can find some keyboard specific projects under `converter` and `keyboard` directory. 25You can find some keyboard specific projects under `converter` and `keyboard` directory.
26 26
27### converter 27### converter
28* [ps2_usb](converter/ps2_usb/) - [PS/2 keyboard to USB][GH_ps2] 28* [ps2_usb](converter/ps2_usb/) - [PS/2 keyboard to USB][GH_ps2]
29* adb_usb - [ADB keyboard to USB][GH_adb] 29* [adb_usb](converter/adb_usb/) - [ADB keyboard to USB][GH_adb]
30* m0110_usb - [Machintosh 128K/512K/Plus keyboard to USB][GH_m0110] 30* [m0110_usb](converter/m0110_usb) - [Machintosh 128K/512K/Plus keyboard to USB][GH_m0110]
31* terminal_usb - [IBM Model M terminal keyboard(PS/2 scancode set3) to USB][GH_terminal] 31* [terminal_usb](converter/terminal_usb/) - [IBM Model M terminal keyboard(PS/2 scancode set3) to USB][GH_terminal]
32* news_usb - [Sony NEWS keyboard to USB][GH_news] 32* [news_usb](converter/news_usb/) - [Sony NEWS keyboard to USB][GH_news]
33* x68k_usb - [Sharp X68000 keyboard to USB][GH_x68k] 33* [x68k_usb](converter/x68k_usb/) - [Sharp X68000 keyboard to USB][GH_x68k]
34* sun_usb - Sun to USB(type4, 5 and 3?) 34* [sun_usb](converter/sun_usb/) - Sun to USB(type4, 5 and 3?)
35* usb_usb - USB to USB(experimental) 35* [usb_usb](converter/usb_usb/) - USB to USB(experimental)
36 36
37### keyboard 37### keyboard
38* hhkb - [Happy Hacking Keyboard professional][GH_hhkb] 38* [hhkb](keyboard/hhkb/) - [Happy Hacking Keyboard professional][GH_hhkb]
39* macway - [Compact keyboard mod][GH_macway] 39* [macway](keyboard/macway/) - [Compact keyboard mod][GH_macway]
40* hbkb - [Happy Buckling sprint keyboard(IBM Model M mod)][GH_hbkb] 40* [hbkb](keyboard/hbkb/) - [Happy Buckling sprint keyboard(IBM Model M mod)][GH_hbkb]
41* IIgs_Standard - Apple IIGS keyboard mod(by JeffreySung) 41* [IIgs_Standard](keyboard/IIgs_Standard/) - Apple IIGS keyboard mod(by JeffreySung)
42* hid_liber - [HID liberation controller][HID_liber](by alaricljs) 42* [hid_liber](keyboard/hid_liber/) - [HID liberation controller][HID_liber](by alaricljs)
43* phantom - [Phantom keyboard][PHANTOM] (by Tranquilite) 43* [phantom](keyboard/phantom/) - [Phantom keyboard][PHANTOM] (by Tranquilite)
44* gh60 - [GH60 keyboard][GH60] 44* [gh60](keyboard/gh60/) - [GH60 keyboard][GH60]
45 45
46[GH_macway]: http://geekhack.org/showwiki.php?title=Island:11930 46[GH_macway]: http://geekhack.org/showwiki.php?title=Island:11930
47[GH_hhkb]: http://geekhack.org/showwiki.php?title=Island:12047 47[GH_hhkb]: http://geekhack.org/showwiki.php?title=Island:12047
diff --git a/common/action.c b/common/action.c
index 7ca481fba..15e125a3e 100644
--- a/common/action.c
+++ b/common/action.c
@@ -360,6 +360,7 @@ static void process_action(keyrecord_t *record)
360 case OP_RESET: 360 case OP_RESET:
361 switch (action.layer.val & 0x03) { 361 switch (action.layer.val & 0x03) {
362 case 0: 362 case 0:
363 // NOTE: reserved
363 overlay_clear(); 364 overlay_clear();
364 keymap_clear(); 365 keymap_clear();
365 break; 366 break;
@@ -379,6 +380,7 @@ static void process_action(keyrecord_t *record)
379 overlay_clear(); 380 overlay_clear();
380 keymap_clear(); 381 keymap_clear();
381 break; 382 break;
383 /* NOTE: 4-7 rserved */
382 } 384 }
383 break; 385 break;
384 /* Keymap Reset default layer */ 386 /* Keymap Reset default layer */
@@ -519,6 +521,7 @@ static void process_action(keyrecord_t *record)
519 // Overlay Invert bit4 521 // Overlay Invert bit4
520 case OP_INV4 | 0: 522 case OP_INV4 | 0:
521 if (action.layer.val == 0) { 523 if (action.layer.val == 0) {
524 // NOTE: reserved for future use
522 overlay_clear(); 525 overlay_clear();
523 } else { 526 } else {
524 overlay_set(overlay_stat ^ action.layer.val); 527 overlay_set(overlay_stat ^ action.layer.val);
@@ -526,6 +529,7 @@ static void process_action(keyrecord_t *record)
526 break; 529 break;
527 case OP_INV4 | 1: 530 case OP_INV4 | 1:
528 if (action.layer.val == 0) { 531 if (action.layer.val == 0) {
532 // on pressed
529 if (event.pressed) overlay_clear(); 533 if (event.pressed) overlay_clear();
530 } else { 534 } else {
531 overlay_set(overlay_stat ^ action.layer.val<<4); 535 overlay_set(overlay_stat ^ action.layer.val<<4);
@@ -533,6 +537,7 @@ static void process_action(keyrecord_t *record)
533 break; 537 break;
534 case OP_INV4 | 2: 538 case OP_INV4 | 2:
535 if (action.layer.val == 0) { 539 if (action.layer.val == 0) {
540 // on released
536 if (!event.pressed) overlay_clear(); 541 if (!event.pressed) overlay_clear();
537 } else { 542 } else {
538 overlay_set(overlay_stat ^ action.layer.val<<8); 543 overlay_set(overlay_stat ^ action.layer.val<<8);
@@ -540,6 +545,7 @@ static void process_action(keyrecord_t *record)
540 break; 545 break;
541 case OP_INV4 | 3: 546 case OP_INV4 | 3:
542 if (action.layer.val == 0) { 547 if (action.layer.val == 0) {
548 // on both
543 overlay_clear(); 549 overlay_clear();
544 } else { 550 } else {
545 overlay_set(overlay_stat ^ action.layer.val<<12); 551 overlay_set(overlay_stat ^ action.layer.val<<12);
diff --git a/common/action.h b/common/action.h
index a8c56a613..ead917983 100644
--- a/common/action.h
+++ b/common/action.h
@@ -298,90 +298,50 @@ enum layer_params {
298/* 298/*
299 * Default Layer 299 * Default Layer
300 */ 300 */
301#define ACTION_DEFAULT_LAYER ACTION(ACT_KEYMAP, 0<<8 | OP_RESET | 0) 301#define ACTION_DEFAULT_LAYER ACTION(ACT_KEYMAP, ON_RELEASE<<8 | OP_RESET | 0)
302#define ACTION_DEFAULT_LAYER_SET(layer) ACTION_KEYMAP_RESET(layer) 302#define ACTION_DEFAULT_LAYER_SET(layer) ACTION_DEFAULT_LAYER_TO(layer, ON_RELEASE)
303#define ACTION_DEFAULT_LAYER_SET_P(layer) ACTION_KEYMAP_RESET_P(layer) 303#define ACTION_DEFAULT_LAYER_TO(layer, on) ACTION(ACT_KEYMAP, (layer)<<8 | OP_RESET | (on))
304#define ACTION_DEFAULT_LAYER_SET_R(layer) ACTION_KEYMAP_RESET_R(layer)
305#define ACTION_DEFAULT_LAYER_SET_B(layer) ACTION_KEYMAP_RESET_B(layer)
306#define ACTION_SET_DEFAULT_LAYER(layer) ACTION_KEYMAP_RESET(layer)
307#define ACTION_SET_DEFAULT_LAYER_P(layer) ACTION_KEYMAP_RESET_P(layer)
308#define ACTION_SET_DEFAULT_LAYER_R(layer) ACTION_KEYMAP_RESET_R(layer)
309#define ACTION_SET_DEFAULT_LAYER_B(layer) ACTION_KEYMAP_RESET_B(layer)
310/* 304/*
311 * Keymap Layer 305 * Keymap Layer
312 */ 306 */
313#define ACTION_KEYMAP(layer) ACTION_KEYMAP_MOMENTARY(layer)
314#define ACTION_KEYMAP_MOMENTARY(layer) ACTION_KEYMAP_ON_OFF(layer) 307#define ACTION_KEYMAP_MOMENTARY(layer) ACTION_KEYMAP_ON_OFF(layer)
315#define ACTION_KEYMAP_TOGGLE(layer) ACTION_KEYMAP_INV_R(layer) 308#define ACTION_KEYMAP_TOGGLE(layer) ACTION_KEYMAP_INV(layer, ON_RELEASE)
316/* Keymap Set and clear overaly */
317#define ACTION_KEYMAP_RESET(layer) ACTION_KEYMAP_RESET_R(layer)
318#define ACTION_KEYMAP_RESET_P(layer) ACTION(ACT_KEYMAP, (layer)<<8 | OP_RESET | ON_PRESS)
319#define ACTION_KEYMAP_RESET_R(layer) ACTION(ACT_KEYMAP, (layer)<<8 | OP_RESET | ON_RELEASE)
320#define ACTION_KEYMAP_RESET_B(layer) ACTION(ACT_KEYMAP, (layer)<<8 | OP_RESET | ON_BOTH)
321/* Keymap Invert */ 309/* Keymap Invert */
322#define ACTION_KEYMAP_INV(layer) ACTION_KEYMAP_INV_B(layer) 310#define ACTION_KEYMAP_INV(layer, on) ACTION(ACT_KEYMAP, (layer)<<8 | OP_INV | (on))
323#define ACTION_KEYMAP_TAP_TOGGLE(layer) ACTION(ACT_KEYMAP, (layer)<<8 | OP_INV | 0) 311#define ACTION_KEYMAP_TAP_TOGGLE(layer) ACTION(ACT_KEYMAP, (layer)<<8 | OP_INV | 0)
324#define ACTION_KEYMAP_INV_P(layer) ACTION(ACT_KEYMAP, (layer)<<8 | OP_INV | ON_PRESS)
325#define ACTION_KEYMAP_INV_R(layer) ACTION(ACT_KEYMAP, (layer)<<8 | OP_INV | ON_RELEASE)
326#define ACTION_KEYMAP_INV_B(layer) ACTION(ACT_KEYMAP, (layer)<<8 | OP_INV | ON_BOTH)
327/* Keymap On */ 312/* Keymap On */
328#define ACTION_KEYMAP_ON(layer) ACTION_KEYMAP_ON_OFF(layer) 313#define ACTION_KEYMAP_ON(layer, on) ACTION(ACT_KEYMAP, (layer)<<8 | OP_ON | (on))
329#define ACTION_KEYMAP_ON_OFF(layer) ACTION(ACT_KEYMAP, (layer)<<8 | OP_ON | 0) 314#define ACTION_KEYMAP_ON_OFF(layer) ACTION(ACT_KEYMAP, (layer)<<8 | OP_ON | 0)
330#define ACTION_KEYMAP_ON_P(layer) ACTION(ACT_KEYMAP, (layer)<<8 | OP_ON | ON_PRESS)
331#define ACTION_KEYMAP_ON_R(layer) ACTION(ACT_KEYMAP, (layer)<<8 | OP_ON | ON_RELEASE)
332#define ACTION_KEYMAP_ON_B(layer) ACTION(ACT_KEYMAP, (layer)<<8 | OP_ON | ON_BOTH)
333/* Keymap Off */ 315/* Keymap Off */
334#define ACTION_KEYMAP_OFF(layer) ACTION_KEYMAP_OFF_ON(layer) 316#define ACTION_KEYMAP_OFF(layer, on) ACTION(ACT_KEYMAP, (layer)<<8 | OP_OFF | (on))
335#define ACTION_KEYMAP_OFF_ON(layer) ACTION(ACT_KEYMAP, (layer)<<8 | OP_OFF | 0) 317#define ACTION_KEYMAP_OFF_ON(layer) ACTION(ACT_KEYMAP, (layer)<<8 | OP_OFF | 0)
336#define ACTION_KEYMAP_OFF_P(layer) ACTION(ACT_KEYMAP, (layer)<<8 | OP_OFF | ON_PRESS)
337#define ACTION_KEYMAP_OFF_R(layer) ACTION(ACT_KEYMAP, (layer)<<8 | OP_OFF | ON_RELEASE)
338#define ACTION_KEYMAP_OFF_B(layer) ACTION(ACT_KEYMAP, (layer)<<8 | OP_OFF | ON_BOTH)
339/* Keymap Set */ 318/* Keymap Set */
340#define ACTION_KEYMAP_SET(layer) ACTION_KEYMAP_SET_CLEAR(layer) 319#define ACTION_KEYMAP_SET(layer, on) ACTION(ACT_KEYMAP, (layer)<<8 | OP_SET | (on))
341#define ACTION_KEYMAP_SET_CLEAR(layer) ACTION(ACT_KEYMAP, (layer)<<8 | OP_SET | 0) 320#define ACTION_KEYMAP_SET_CLEAR(layer) ACTION(ACT_KEYMAP, (layer)<<8 | OP_SET | 0)
342#define ACTION_KEYMAP_SET_P(layer) ACTION(ACT_KEYMAP, (layer)<<8 | OP_SET | ON_PRESS)
343#define ACTION_KEYMAP_SET_R(layer) ACTION(ACT_KEYMAP, (layer)<<8 | OP_SET | ON_RELEASE)
344#define ACTION_KEYMAP_SET_B(layer) ACTION(ACT_KEYMAP, (layer)<<8 | OP_SET | ON_BOTH)
345/* Keymap Invert with tap key */ 321/* Keymap Invert with tap key */
346#define ACTION_KEYMAP_TAP_KEY(layer, key) ACTION(ACT_KEYMAP, (layer)<<8 | (key)) 322#define ACTION_KEYMAP_TAP_KEY(layer, key) ACTION(ACT_KEYMAP, (layer)<<8 | (key))
347 323
348/* 324/*
349 * Overlay Layer 325 * Overlay Layer
350 */ 326 */
351#define ACTION_OVERLAY(layer) ACTION_OVERLAY_MOMENTARY(layer)
352#define ACTION_OVERLAY_MOMENTARY(layer) ACTION_OVERLAY_ON_OFF(layer) 327#define ACTION_OVERLAY_MOMENTARY(layer) ACTION_OVERLAY_ON_OFF(layer)
353#define ACTION_OVERLAY_TOGGLE(layer) ACTION_OVERLAY_INV_R(layer) 328#define ACTION_OVERLAY_TOGGLE(layer) ACTION_OVERLAY_INV(layer, ON_RELEASE)
354/* Overlay Clear */ 329/* Overlay Clear */
355#define ACTION_OVERLAY_CLEAR ACTION(ACT_OVERLAY, 0<<8 | OP_INV4 | 0) 330#define ACTION_OVERLAY_CLEAR(on) ACTION(ACT_OVERLAY, 0<<8 | OP_INV4 | (on))
356#define ACTION_OVERLAY_CLEAR_P ACTION(ACT_OVERLAY, 0<<8 | OP_INV4 | ON_PRESS)
357#define ACTION_OVERLAY_CLEAR_R ACTION(ACT_OVERLAY, 0<<8 | OP_INV4 | ON_RELEASE)
358#define ACTION_OVERLAY_CLEAR_B ACTION(ACT_OVERLAY, 0<<8 | OP_INV4 | ON_BOTH)
359/* Overlay Invert 4-bit chunk */ 331/* Overlay Invert 4-bit chunk */
360#define ACTION_OVERLAY_INV4(bits, shift) ACTION(ACT_OVERLAY, (bits)<<8 | OP_INV4 | shift) 332#define ACTION_OVERLAY_INV4(bits, shift) ACTION(ACT_OVERLAY, (bits)<<8 | OP_INV4 | shift)
361/* Overlay Invert */ 333/* Overlay Invert */
362#define ACTION_OVERLAY_INV(layer) ACTION_OVERLAY_INV_B(layer) 334#define ACTION_OVERLAY_INV(layer, on) ACTION(ACT_OVERLAY, (layer)<<8 | OP_INV | (on))
363#define ACTION_OVERLAY_TAP_TOGGLE(layer) ACTION(ACT_OVERLAY, (layer)<<8 | OP_INV | 0) 335#define ACTION_OVERLAY_TAP_TOGGLE(layer) ACTION(ACT_OVERLAY, (layer)<<8 | OP_INV | 0)
364#define ACTION_OVERLAY_INV_P(layer) ACTION(ACT_OVERLAY, (layer)<<8 | OP_INV | ON_PRESS)
365#define ACTION_OVERLAY_INV_R(layer) ACTION(ACT_OVERLAY, (layer)<<8 | OP_INV | ON_RELEASE)
366#define ACTION_OVERLAY_INV_B(layer) ACTION(ACT_OVERLAY, (layer)<<8 | OP_INV | ON_BOTH)
367/* Overlay On */ 336/* Overlay On */
368#define ACTION_OVERLAY_ON(layer) ACTION_OVERLAY_ON_OFF(layer) 337#define ACTION_OVERLAY_ON(layer, on) ACTION(ACT_OVERLAY, (layer)<<8 | OP_ON | (on))
369#define ACTION_OVERLAY_ON_OFF(layer) ACTION(ACT_OVERLAY, (layer)<<8 | OP_ON | 0) 338#define ACTION_OVERLAY_ON_OFF(layer) ACTION(ACT_OVERLAY, (layer)<<8 | OP_ON | 0)
370#define ACTION_OVERLAY_ON_P(layer) ACTION(ACT_OVERLAY, (layer)<<8 | OP_ON | ON_PRESS)
371#define ACTION_OVERLAY_ON_R(layer) ACTION(ACT_OVERLAY, (layer)<<8 | OP_ON | ON_RELEASE)
372#define ACTION_OVERLAY_ON_B(layer) ACTION(ACT_OVERLAY, (layer)<<8 | OP_ON | ON_BOTH)
373/* Overlay Off */ 339/* Overlay Off */
374#define ACTION_OVERLAY_OFF(layer) ACTION_OVERLAY_OFF_ON(layer) 340#define ACTION_OVERLAY_OFF(layer, on) ACTION(ACT_OVERLAY, (layer)<<8 | OP_OFF | (on))
375#define ACTION_OVERLAY_OFF_ON(layer) ACTION(ACT_OVERLAY, (layer)<<8 | OP_OFF | 0) 341#define ACTION_OVERLAY_OFF_ON(layer) ACTION(ACT_OVERLAY, (layer)<<8 | OP_OFF | 0)
376#define ACTION_OVERLAY_OFF_P(layer) ACTION(ACT_OVERLAY, (layer)<<8 | OP_OFF | ON_PRESS)
377#define ACTION_OVERLAY_OFF_R(layer) ACTION(ACT_OVERLAY, (layer)<<8 | OP_OFF | ON_RELEASE)
378#define ACTION_OVERLAY_OFF_B(layer) ACTION(ACT_OVERLAY, (layer)<<8 | OP_OFF | ON_BOTH)
379/* Overlay Set */ 342/* Overlay Set */
380#define ACTION_OVERLAY_SET(layer) ACTION_OVERLAY_SET_CLEAR(layer) 343#define ACTION_OVERLAY_SET(layer, on) ACTION(ACT_OVERLAY, (layer)<<8 | OP_SET | (on))
381#define ACTION_OVERLAY_SET_CLEAR(layer) ACTION(ACT_OVERLAY, (layer)<<8 | OP_SET | 0) 344#define ACTION_OVERLAY_SET_CLEAR(layer) ACTION(ACT_OVERLAY, (layer)<<8 | OP_SET | 0)
382#define ACTION_OVERLAY_SET_P(layer) ACTION(ACT_OVERLAY, (layer)<<8 | OP_SET | ON_PRESS)
383#define ACTION_OVERLAY_SET_R(layer) ACTION(ACT_OVERLAY, (layer)<<8 | OP_SET | ON_RELEASE)
384#define ACTION_OVERLAY_SET_B(layer) ACTION(ACT_OVERLAY, (layer)<<8 | OP_SET | ON_BOTH)
385/* Overlay Invert with tap key */ 345/* Overlay Invert with tap key */
386#define ACTION_OVERLAY_TAP_KEY(layer, key) ACTION(ACT_OVERLAY, (layer)<<8 | (key)) 346#define ACTION_OVERLAY_TAP_KEY(layer, key) ACTION(ACT_OVERLAY, (layer)<<8 | (key))
387 347
diff --git a/doc/keymap.md b/doc/keymap.md
index 132975e17..a20ac18a2 100644
--- a/doc/keymap.md
+++ b/doc/keymap.md
@@ -2,7 +2,7 @@ Keymap framework - how to define your keymap
2============================================ 2============================================
3***NOTE: This is not final version, may be inconsistent with source code and changed occasionally for a while.*** 3***NOTE: This is not final version, may be inconsistent with source code and changed occasionally for a while.***
4 4
5## Keymap 5## 0. Keymap and layers
6**Keymap** is comprised of multiple layers of key layout, you can define **16** layers at most. 6**Keymap** is comprised of multiple layers of key layout, you can define **16** layers at most.
7**Layer** is an array of **keycodes** to define **actions** on each physical keys. 7**Layer** is an array of **keycodes** to define **actions** on each physical keys.
8respective layers can be validated simultaneously. Layers are indexed with 0 to 15 and higher layer has precedence. 8respective layers can be validated simultaneously. Layers are indexed with 0 to 15 and higher layer has precedence.
@@ -22,7 +22,7 @@ respective layers can be validated simultaneously. Layers are indexed with 0 to
22 0 /___________/ V low 0 `-------------------------- 22 0 /___________/ V low 0 `--------------------------
23 23
24 24
25### Keymap status 25### 0.1 Keymap status
26Keymap has its state in two parameters: 26Keymap has its state in two parameters:
27**`default_layer`** indicates a base keymap layer(0-15) which is always valid and to be referred, **`keymap_stat`** is 16bit variable which has current on/off status of layers on its each bit. 27**`default_layer`** indicates a base keymap layer(0-15) which is always valid and to be referred, **`keymap_stat`** is 16bit variable which has current on/off status of layers on its each bit.
28 28
@@ -63,15 +63,15 @@ On the other hand, you shall change `keymap_state` to overlay base layer with so
63 keymap_stat = 0x6002 <-----' 63 keymap_stat = 0x6002 <-----'
64 64
65 65
66### Layer Precedence and Transparency 66### 0.2 Layer Precedence and Transparency
67Note 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. 67Note 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.
68 68
69You can place `KC_TRNS` on overlay layer changes just part of layout to fall back on lower or base layer. 69You can place `KC_TRNS` on overlay layer changes just part of layout to fall back on lower or base layer.
70Key with `KC_TRANS` doen't has its own keycode and refers to its lower layers for keycode, instead. 70Key with `KC_TRANS` doen't has its own keycode and refers to lower valid layers for keycode, instead.
71See layer 1 or 2 below for example. 71See example below.
72 72
73 73
74### Keymap Example 74### 0.3 Keymap Example
75Keymap is **`keymaps[]`** C array in fact and you can define layers in it with **`KEYMAP()`** C macro and keycodes. To use complex actions you need to define `Fn` keycode in **`fn_actions[]`** array. 75Keymap is **`keymaps[]`** C array in fact and you can define layers in it with **`KEYMAP()`** C macro and keycodes. To use complex actions you need to define `Fn` keycode in **`fn_actions[]`** array.
76 76
77This is a keymap example for [HHKB](http://en.wikipedia.org/wiki/Happy_Hacking_Keyboard) keyboard. 77This is a keymap example for [HHKB](http://en.wikipedia.org/wiki/Happy_Hacking_Keyboard) keyboard.
@@ -145,7 +145,7 @@ You can find other keymap definitions in file `keymap.c` located on project dire
145 }; 145 };
146 146
147 static const uint16_t PROGMEM fn_actions[] = { 147 static const uint16_t PROGMEM fn_actions[] = {
148 ACTION_KEYMAP(1), // FN0 148 ACTION_KEYMAP_MOMENTARY(1), // FN0
149 ACTION_KEYMAP_TAP_KEY(2, KC_SCLN), // FN1 149 ACTION_KEYMAP_TAP_KEY(2, KC_SCLN), // FN1
150 ACTION_KEYMAP_TOGGLE(2), // FN2 150 ACTION_KEYMAP_TOGGLE(2), // FN2
151 }; 151 };
@@ -154,7 +154,7 @@ You can find other keymap definitions in file `keymap.c` located on project dire
154 154
155 155
156## 1. Keycode 156## 1. Keycode
157See [`common/keycode.h`](common/keycode.h) or keycode table below. 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. 157See [`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.
158 158
159 ***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()`. 159 ***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 160
@@ -194,7 +194,7 @@ There are 8 modifiers which has discrimination between left and right.
194`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.*** 194`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 195
196### 1.6 Keycode Table 196### 1.6 Keycode Table
197 See keycode table in [`doc/keycode.txt`](doc/keycode.txt) for description of keycodes. 197 See keycode table in [`doc/keycode.txt`](./keycode.txt) for description of keycodes.
198 198
199 In regard to implementation side most of keycodes are identical with [HID usage][HID_usage](pdf) sent to host for real and some virtual keycodes are defined to support special actions. 199 In regard to implementation side most of keycodes are identical with [HID usage][HID_usage](pdf) sent to host for real and some virtual keycodes are defined to support special actions.
200[HID_usage]: http://www.usb.org/developers/devclass_docs/Hut1_11.pdf 200[HID_usage]: http://www.usb.org/developers/devclass_docs/Hut1_11.pdf
@@ -202,7 +202,7 @@ There are 8 modifiers which has discrimination between left and right.
202 202
203 203
204## 2. Action 204## 2. Action
205See [`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. 205See [`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.
206 206
207Most 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 against using jsut keycodes. To avoid this waste 8bit keycodes are used in `KEYMAP` instead of action codes. 207Most 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 against using jsut keycodes. To avoid this waste 8bit keycodes are used in `KEYMAP` instead of action codes.
208 208
@@ -233,48 +233,51 @@ Or `Alt,Shift + Tab` can be defined. `ACTION_LMODS_KEY()` requires **4-bit modif
233 233
234 234
235 235
236### 2.2 Layer Actions 236### 2.2 Layer Action
237These actions operate layers of keymap.
238
239Parameters:
240- layer: 0-15
241- on: { press | release | both }
242
237 243
238#### 2.2.0 Default Layer 244#### 2.2.0 Default Layer
239`default_layer` is layer which always is on and refered to when actions is not defined on other layers. 245`default_layer` is layer which always is valid and referred to when actions is not defined on other layers.
240 246
241##### Return to Default Layer 247##### Return to Default Layer
242Turns on `default layer` only with clearing other all layers. 248Turns on only `default layer` with clearing other all layers.
243 249
244 ACTION_DEFAULT_LAYER 250 ACTION_DEFAULT_LAYER
245 251
246##### Set Default Layer 252##### Set Default Layer
247Sets 'default layer' to layer and turn it on without clear any other layers. 253Sets 'default layer' to layer and turn it on.
248
249 ACTION_DEFAULT_LAYER_SET(layer)
250
251This does it on { press | release | both }.
252 254
255 ACTION_DEFAULT_LAYER_SET_TO(layer)
253 ACTION_DEFAULT_LAYER_SET(layer, on) 256 ACTION_DEFAULT_LAYER_SET(layer, on)
254 257
255 258
256#### 2.2.1 Keymap 259#### 2.2.1 Keymap
257These actions operate given layer argument which ranges from 0 to 15. 260These actions operate layer status of keymap.
258 261
259##### Switch to layer 262##### Momentary Switch
260Turns on layer momentary while holding, in other words turn on when key is pressed and off when released. 263Turns on layer momentary while holding, in other words turn on when key is pressed and off when released.
261 264
262 ACTION_KEYMAP_MOMENTARY(layer) 265 ACTION_KEYMAP_MOMENTARY(layer)
263 266
264 267
265##### Toggle layer 268##### Toggle Switch
266Turns on layer on first type and turns off on next. 269Turns on layer on first type and turns off on next.
267 270
268 ACTION_KEYMAP_TOGGLE(layer) 271 ACTION_KEYMAP_TOGGLE(layer)
269 272
270 273
271##### Switch to layer with tap key 274##### Momentary Switch with tap key
272Turns on layer momentary while holding but registers key on tap. 275Turns on layer momentary while holding but registers key on tap.
273 276
274 ACTION_KEYMAP_TAP_KEY(layer, key) 277 ACTION_KEYMAP_TAP_KEY(layer, key)
275 278
276 279
277##### Switch to layer with tap toggle 280##### Momentary Switch with tap toggle
278Turns on layer momentary while holding but toggles it with serial taps. 281Turns on layer momentary while holding but toggles it with serial taps.
279 282
280 ACTION_KEYMAP_TAP_TOGGLE(layer) 283 ACTION_KEYMAP_TAP_TOGGLE(layer)
@@ -325,6 +328,7 @@ Invert 4bits out of 16bits of overlay status on both press and release.
325 ACTION_OVERLAY_INV4(bits, shift) 328 ACTION_OVERLAY_INV4(bits, shift)
326 329
327 330
331
328### 2.3 Macro action 332### 2.3 Macro action
329***TBD*** 333***TBD***
330 334
@@ -398,93 +402,80 @@ See `keyboard/hhkb/keymap.c` for sample.
398 402
399 403
400 404
401## 3. Layer 405## 4. Layer switching Example
402 Layer is key-action map to assign action to every physical key. You can define multiple layers in keymap and make layers active out of keymap during operation at will. 406There are some ways to switch layer with 'Layer' actions.
403 407
404 First layer is indexed by `0` which usually become `default layer` and active in initial state. 408### 4.1 Momentary switching
409Momentary switching changes layer only while holding Fn key.
405 410
406You can define **16 layers** at most in each keymaps and overlays. 411This 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.
407 412
408 ____________ 413 ACTION_KEYMAP_MOMENTARY(1)
409 / /
410 / //
411 15 /___________///
412 14 /___________//_
413 13 /___________/ /
414 /: : : : : //
415 3 /___________///
416 2 /___________///
417 1 /___________//
418 .->0 /___________/
419 `--- default_layer = 0
420 414
421 you can define a layer with placing keycode symbols separated with `comma` in `KEYMAP`, which is formed with resemblance to physical keyboard layout so as you can easily put keycode on place you want to map. ***You can define most of keys with just using keycodes*** except for `Fn` key serving special actions.
422 415
423### 3.0 Transparency 416After switch actions of destination layer are perfomed.
424With KC_TRNS you can define transparent key which itself doesn't have action but refer to lower valid layer. Transparent key is useful when you want to change part of layout not over all. 417***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.
425 418
426 419
420### 4.2 Toggle switching
421Toggle switching changes layer after press then release. With this you can keep staying on the layer until you press the key again to return.
427 422
428## 4. Layer switching 423This is toggle action of 'Layer 2'.
429You can have some ways to switch layer with these actions.
430There are two kind of layer switch action `Layer Set` and `Layer Bit` and two type of switching behaviour **Momentary** and **Toggle**.
431 424
432### 4.1 Momentary switching 425 ACTION_KEYMAP_TOGGLE(2)
433Momentary switching changes layer only while holding Fn key.
434 426
435#### 4.1.1 Momentary Set
436This action makes `Layer 1` active on key press event and inactive on release event..
437 427
438 ACTION_KEYMAP_MOMENTARY(1)
439 428
429### 4.3 Momentary switching with Tap key
430These actions switch layer only while holding `Fn` key and register key on tap. **Tap** means to press and release key quickly.
440 431
441It switches to destination layer immediately when key is pressed, after that actions on keymap of destination layer is perfomed. ***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. To get back to `default layer` you can use this action. 432 ACTION_KEYMAP_TAP_KEY(2, KC_SCLN)
442 433
443 ACTION_LAYER_DEFAULT 434With this you can place layer switching function on normal key like ';' without losing its original key register function.
444 435
445#### 4.1.2 Momentary Bit
446This `Layer Bit` action performs XOR `1` with `current layer` on both press and release event. If you are on `Layer 0` now next layer to switch will be `Layer 1`. To come back to previous layer you need to place same action on destination layer.
447 436
448 ACTION_LAYER_BIT(1)
449 437
450### 4.2 Toggle switching 438### 4.4 Momentary switching with Tap Toggle
451Toggle switching changes layer after press then release. You keep being on the layer until you press key to return. 439This switches layer only while holding `Fn` key and toggle layer after several taps. **Tap** means to press and release key quickly.
452 440
453#### 4.2.1 Toggle Set 441 ACTION_KEYMAP_TAP_TOGGLE(1)
454This `Layer Set Toggle` action is to set `Layer 1` to `current layer` on release and do none on press.
455 442
456 ACTION_LAYER_SET_TOGGLE(1) 443Number of taps can be defined with `TAPPING_TOGGLE` in `config.h`, `5` by default.
457 444
458To get back to `default layer` you can use this action.
459 445
460 ACTION_LAYER_DEFAULT
461 446
462#### 4.2.2 Toggle Bit 447## Tapping
463This `Layer Bit Toggle` action is to XOR `1` with `current layer` on release and do none on press. If you are on `Layer 2` you'll switch to `Layer 3` on press. To come back to previous layer you need to place same action on destination layer. 448Tapping 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.
464 449
465 ACTION_LAYER_BIT_TOGGLE(1) 450### Tap Key
451This 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.
466 452
453Action for modifier with tap key.
467 454
468### 4.3 Momentary switching with Tap key 455 ACTION_LMODS_TAP_KEY(mods, key)
469These actions switch to layer only while holding `Fn` key and register key on tap. **Tap** means to press and release key quickly.
470 456
471 ACTION_LAYER_SET_TAP_KEY(2, KC_SCLN) 457Action for `Fn` with tap key.
472 ACTION_LAYER_SET_BIT_KEY(2, KC_SCLN)
473 458
474With these you can place layer switching function on normal alphabet key like `;` without losing its original register function. 459 ACTION_KEYMAP_TAP_KEY(layer, key)
475 460
476### 4.4 Momentary switching with Tap Toggle 461[dual_role]: http://en.wikipedia.org/wiki/Modifier_key#Dual-role_modifier_keys
477This changes layer only while holding `Fn` key and toggle layer after several taps. **Tap** means to press and release key quickly.
478 462
479 ACTION_LAYER_SET_TAP_TOGGLE(layer)
480 ACTION_LAYER_BIT_TAP_TOGGLE(layer)
481 463
482Number of taps can be defined with `TAPPING_TOGGLE` in `config.h`, `5` by default. 464### Tap Toggle
465This 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.
466
467 ACTION_KEYMAP_TAP_TOGGLE(layer)
483 468
484 469
485## Tapping
486### Tap Key
487### One Shot Modifier 470### One Shot Modifier
471This adds oneshot feature to modifier key. 'One Shot Modifier' is one time modifier which has effect only on following one alpha key.
472It works as normal modifier key when holding but oneshot modifier when tapping.
473
474 ACTION_LMODS_ONESHOT(mods)
475
476Say 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.
477
478
488 479
489 480
490## Legacy Keymap 481## Legacy Keymap
diff --git a/keyboard/gh60/keymap.c b/keyboard/gh60/keymap.c
index af7af64d1..1f5344d4c 100644
--- a/keyboard/gh60/keymap.c
+++ b/keyboard/gh60/keymap.c
@@ -204,15 +204,15 @@ static const uint8_t PROGMEM overlays[][MATRIX_ROWS][MATRIX_COLS] = {};
204 * Fn action definition 204 * Fn action definition
205 */ 205 */
206static const uint16_t PROGMEM fn_actions[] = { 206static const uint16_t PROGMEM fn_actions[] = {
207 [0] = ACTION_KEYMAP(4), // FN0 207 [0] = ACTION_KEYMAP_MOMENTARY(4),
208 [1] = ACTION_KEYMAP_TAP_KEY(5, KC_SLASH), // FN1 208 [1] = ACTION_KEYMAP_TAP_KEY(5, KC_SLASH),
209 [2] = ACTION_KEYMAP_TAP_KEY(6, KC_SCLN), // FN2 209 [2] = ACTION_KEYMAP_TAP_KEY(6, KC_SCLN),
210 [3] = ACTION_KEYMAP(6), // FN3 210 [3] = ACTION_KEYMAP_MOMENTARY(6),
211 [4] = ACTION_KEYMAP(7), // to Layout selector 211 [4] = ACTION_KEYMAP_MOMENTARY(7), // to Layout selector
212 [5] = ACTION_SET_DEFAULT_LAYER(0), // set qwerty layout 212 [5] = ACTION_DEFAULT_LAYER_SET(0), // set qwerty layout
213 [6] = ACTION_SET_DEFAULT_LAYER(1), // set colemak layout 213 [6] = ACTION_DEFAULT_LAYER_SET(1), // set colemak layout
214 [7] = ACTION_SET_DEFAULT_LAYER(2), // set dvorak layout 214 [7] = ACTION_DEFAULT_LAYER_SET(2), // set dvorak layout
215 [8] = ACTION_SET_DEFAULT_LAYER(3), // set workman layout 215 [8] = ACTION_DEFAULT_LAYER_SET(3), // set workman layout
216}; 216};
217#endif 217#endif
218 218
diff --git a/keyboard/gh60/keymap_poker.h b/keyboard/gh60/keymap_poker.h
index 2bbda6106..3e0921ad9 100644
--- a/keyboard/gh60/keymap_poker.h
+++ b/keyboard/gh60/keymap_poker.h
@@ -92,13 +92,13 @@ static const uint8_t PROGMEM overlays[][MATRIX_ROWS][MATRIX_COLS] = {
92}; 92};
93static const uint16_t PROGMEM fn_actions[] = { 93static const uint16_t PROGMEM fn_actions[] = {
94 /* Poker Layout */ 94 /* Poker Layout */
95 [0] = ACTION_OVERLAY(2), // to Fn overlay 95 [0] = ACTION_OVERLAY_MOMENTARY(2), // to Fn overlay
96 [1] = ACTION_OVERLAY_TOGGLE(0), // toggle arrow overlay 96 [1] = ACTION_OVERLAY_TOGGLE(0), // toggle arrow overlay
97 [2] = ACTION_OVERLAY_TOGGLE(1), // toggle Esc overlay 97 [2] = ACTION_OVERLAY_TOGGLE(1), // toggle Esc overlay
98 [3] = ACTION_RMODS_KEY(MOD_BIT(KC_RCTL)|MOD_BIT(KC_RSFT), KC_ESC), // Task(RControl,RShift+Esc) 98 [3] = ACTION_RMODS_KEY(MOD_BIT(KC_RCTL)|MOD_BIT(KC_RSFT), KC_ESC), // Task(RControl,RShift+Esc)
99 [4] = ACTION_OVERLAY(3), // to Layout selector 99 [4] = ACTION_OVERLAY_MOMENTARY(3), // to Layout selector
100 [5] = ACTION_SET_DEFAULT_LAYER(0), // set qwerty layout 100 [5] = ACTION_DEFAULT_LAYER_SET(0), // set qwerty layout
101 [6] = ACTION_SET_DEFAULT_LAYER(1), // set colemak layout 101 [6] = ACTION_DEFAULT_LAYER_SET(1), // set colemak layout
102 [7] = ACTION_SET_DEFAULT_LAYER(2), // set dvorak layout 102 [7] = ACTION_DEFAULT_LAYER_SET(2), // set dvorak layout
103 [8] = ACTION_SET_DEFAULT_LAYER(3), // set workman layout 103 [8] = ACTION_DEFAULT_LAYER_SET(3), // set workman layout
104}; 104};
diff --git a/keyboard/gh60/keymap_poker_set.h b/keyboard/gh60/keymap_poker_set.h
index bf4d8959f..eaaf3159d 100644
--- a/keyboard/gh60/keymap_poker_set.h
+++ b/keyboard/gh60/keymap_poker_set.h
@@ -67,15 +67,15 @@ static const uint8_t PROGMEM overlays[][MATRIX_ROWS][MATRIX_COLS] = {
67 */ 67 */
68static const uint16_t PROGMEM fn_actions[] = { 68static const uint16_t PROGMEM fn_actions[] = {
69 /* Poker Layout */ 69 /* Poker Layout */
70 [0] = ACTION_OVERLAY_SET_P(3), // FN0 move to Fn'd when press 70 [0] = ACTION_OVERLAY_SET(3, ON_PRESS), // FN0 move to Fn'd when press
71 [1] = ACTION_OVERLAY_SET_P(4), // FN1 move to Fn'd arrow when press 71 [1] = ACTION_OVERLAY_SET(4, ON_PRESS), // FN1 move to Fn'd arrow when press
72 [2] = ACTION_OVERLAY_SET_P(5), // FN2 move to Fn'd Esc when press 72 [2] = ACTION_OVERLAY_SET(5, ON_PRESS), // FN2 move to Fn'd Esc when press
73 [3] = ACTION_OVERLAY_SET_P(6), // FN3 move to Fn'd arrow + Esc when press 73 [3] = ACTION_OVERLAY_SET(6, ON_PRESS), // FN3 move to Fn'd arrow + Esc when press
74 74
75 [4] = ACTION_OVERLAY_CLEAR, // FN4 clear overlay when release 75 [4] = ACTION_OVERLAY_CLEAR(ON_RELEASE), // FN4 clear overlay when release
76 [5] = ACTION_OVERLAY_SET_R(0), // FN5 move to arrow when release 76 [5] = ACTION_OVERLAY_SET(0, ON_RELEASE), // FN5 move to arrow when release
77 [6] = ACTION_OVERLAY_SET_R(1), // FN6 move to Esc when release 77 [6] = ACTION_OVERLAY_SET(1, ON_RELEASE), // FN6 move to Esc when release
78 [7] = ACTION_OVERLAY_SET_R(2), // FN7 move to arrow + Esc when release 78 [7] = ACTION_OVERLAY_SET(2, ON_RELEASE), // FN7 move to arrow + Esc when release
79 79
80 [8] = ACTION_RMODS_KEY(MOD_BIT(KC_RCTL)|MOD_BIT(KC_RSFT), KC_ESC), // FN8 Task(RControl,RShift+Esc) 80 [8] = ACTION_RMODS_KEY(MOD_BIT(KC_RCTL)|MOD_BIT(KC_RSFT), KC_ESC), // FN8 Task(RControl,RShift+Esc)
81}; 81};