1
0
Fork 0

Clean action.h and add keymap doc

This commit is contained in:
tmk 2013-03-05 02:42:28 +09:00
parent 083c75816f
commit 1aa067e541
7 changed files with 130 additions and 173 deletions

View File

@ -25,23 +25,23 @@ Projects
You can find some keyboard specific projects under `converter` and `keyboard` directory.
### converter
* [ps2_usb](converter/ps2_usb/) - [PS/2 keyboard to USB][GH_ps2]
* adb_usb - [ADB keyboard to USB][GH_adb]
* m0110_usb - [Machintosh 128K/512K/Plus keyboard to USB][GH_m0110]
* terminal_usb - [IBM Model M terminal keyboard(PS/2 scancode set3) to USB][GH_terminal]
* news_usb - [Sony NEWS keyboard to USB][GH_news]
* x68k_usb - [Sharp X68000 keyboard to USB][GH_x68k]
* sun_usb - Sun to USB(type4, 5 and 3?)
* usb_usb - USB to USB(experimental)
* [ps2_usb](converter/ps2_usb/) - [PS/2 keyboard to USB][GH_ps2]
* [adb_usb](converter/adb_usb/) - [ADB keyboard to USB][GH_adb]
* [m0110_usb](converter/m0110_usb) - [Machintosh 128K/512K/Plus keyboard to USB][GH_m0110]
* [terminal_usb](converter/terminal_usb/) - [IBM Model M terminal keyboard(PS/2 scancode set3) to USB][GH_terminal]
* [news_usb](converter/news_usb/) - [Sony NEWS keyboard to USB][GH_news]
* [x68k_usb](converter/x68k_usb/) - [Sharp X68000 keyboard to USB][GH_x68k]
* [sun_usb](converter/sun_usb/) - Sun to USB(type4, 5 and 3?)
* [usb_usb](converter/usb_usb/) - USB to USB(experimental)
### keyboard
* hhkb - [Happy Hacking Keyboard professional][GH_hhkb]
* macway - [Compact keyboard mod][GH_macway]
* hbkb - [Happy Buckling sprint keyboard(IBM Model M mod)][GH_hbkb]
* IIgs_Standard - Apple IIGS keyboard mod(by JeffreySung)
* hid_liber - [HID liberation controller][HID_liber](by alaricljs)
* phantom - [Phantom keyboard][PHANTOM] (by Tranquilite)
* gh60 - [GH60 keyboard][GH60]
* [hhkb](keyboard/hhkb/) - [Happy Hacking Keyboard professional][GH_hhkb]
* [macway](keyboard/macway/) - [Compact keyboard mod][GH_macway]
* [hbkb](keyboard/hbkb/) - [Happy Buckling sprint keyboard(IBM Model M mod)][GH_hbkb]
* [IIgs_Standard](keyboard/IIgs_Standard/) - Apple IIGS keyboard mod(by JeffreySung)
* [hid_liber](keyboard/hid_liber/) - [HID liberation controller][HID_liber](by alaricljs)
* [phantom](keyboard/phantom/) - [Phantom keyboard][PHANTOM] (by Tranquilite)
* [gh60](keyboard/gh60/) - [GH60 keyboard][GH60]
[GH_macway]: http://geekhack.org/showwiki.php?title=Island:11930
[GH_hhkb]: http://geekhack.org/showwiki.php?title=Island:12047

View File

@ -360,6 +360,7 @@ static void process_action(keyrecord_t *record)
case OP_RESET:
switch (action.layer.val & 0x03) {
case 0:
// NOTE: reserved
overlay_clear();
keymap_clear();
break;
@ -379,6 +380,7 @@ static void process_action(keyrecord_t *record)
overlay_clear();
keymap_clear();
break;
/* NOTE: 4-7 rserved */
}
break;
/* Keymap Reset default layer */
@ -519,6 +521,7 @@ static void process_action(keyrecord_t *record)
// Overlay Invert bit4
case OP_INV4 | 0:
if (action.layer.val == 0) {
// NOTE: reserved for future use
overlay_clear();
} else {
overlay_set(overlay_stat ^ action.layer.val);
@ -526,6 +529,7 @@ static void process_action(keyrecord_t *record)
break;
case OP_INV4 | 1:
if (action.layer.val == 0) {
// on pressed
if (event.pressed) overlay_clear();
} else {
overlay_set(overlay_stat ^ action.layer.val<<4);
@ -533,6 +537,7 @@ static void process_action(keyrecord_t *record)
break;
case OP_INV4 | 2:
if (action.layer.val == 0) {
// on released
if (!event.pressed) overlay_clear();
} else {
overlay_set(overlay_stat ^ action.layer.val<<8);
@ -540,6 +545,7 @@ static void process_action(keyrecord_t *record)
break;
case OP_INV4 | 3:
if (action.layer.val == 0) {
// on both
overlay_clear();
} else {
overlay_set(overlay_stat ^ action.layer.val<<12);

View File

@ -298,90 +298,50 @@ enum layer_params {
/*
* Default Layer
*/
#define ACTION_DEFAULT_LAYER ACTION(ACT_KEYMAP, 0<<8 | OP_RESET | 0)
#define ACTION_DEFAULT_LAYER_SET(layer) ACTION_KEYMAP_RESET(layer)
#define ACTION_DEFAULT_LAYER_SET_P(layer) ACTION_KEYMAP_RESET_P(layer)
#define ACTION_DEFAULT_LAYER_SET_R(layer) ACTION_KEYMAP_RESET_R(layer)
#define ACTION_DEFAULT_LAYER_SET_B(layer) ACTION_KEYMAP_RESET_B(layer)
#define ACTION_SET_DEFAULT_LAYER(layer) ACTION_KEYMAP_RESET(layer)
#define ACTION_SET_DEFAULT_LAYER_P(layer) ACTION_KEYMAP_RESET_P(layer)
#define ACTION_SET_DEFAULT_LAYER_R(layer) ACTION_KEYMAP_RESET_R(layer)
#define ACTION_SET_DEFAULT_LAYER_B(layer) ACTION_KEYMAP_RESET_B(layer)
#define ACTION_DEFAULT_LAYER ACTION(ACT_KEYMAP, ON_RELEASE<<8 | OP_RESET | 0)
#define ACTION_DEFAULT_LAYER_SET(layer) ACTION_DEFAULT_LAYER_TO(layer, ON_RELEASE)
#define ACTION_DEFAULT_LAYER_TO(layer, on) ACTION(ACT_KEYMAP, (layer)<<8 | OP_RESET | (on))
/*
* Keymap Layer
*/
#define ACTION_KEYMAP(layer) ACTION_KEYMAP_MOMENTARY(layer)
#define ACTION_KEYMAP_MOMENTARY(layer) ACTION_KEYMAP_ON_OFF(layer)
#define ACTION_KEYMAP_TOGGLE(layer) ACTION_KEYMAP_INV_R(layer)
/* Keymap Set and clear overaly */
#define ACTION_KEYMAP_RESET(layer) ACTION_KEYMAP_RESET_R(layer)
#define ACTION_KEYMAP_RESET_P(layer) ACTION(ACT_KEYMAP, (layer)<<8 | OP_RESET | ON_PRESS)
#define ACTION_KEYMAP_RESET_R(layer) ACTION(ACT_KEYMAP, (layer)<<8 | OP_RESET | ON_RELEASE)
#define ACTION_KEYMAP_RESET_B(layer) ACTION(ACT_KEYMAP, (layer)<<8 | OP_RESET | ON_BOTH)
#define ACTION_KEYMAP_TOGGLE(layer) ACTION_KEYMAP_INV(layer, ON_RELEASE)
/* Keymap Invert */
#define ACTION_KEYMAP_INV(layer) ACTION_KEYMAP_INV_B(layer)
#define ACTION_KEYMAP_INV(layer, on) ACTION(ACT_KEYMAP, (layer)<<8 | OP_INV | (on))
#define ACTION_KEYMAP_TAP_TOGGLE(layer) ACTION(ACT_KEYMAP, (layer)<<8 | OP_INV | 0)
#define ACTION_KEYMAP_INV_P(layer) ACTION(ACT_KEYMAP, (layer)<<8 | OP_INV | ON_PRESS)
#define ACTION_KEYMAP_INV_R(layer) ACTION(ACT_KEYMAP, (layer)<<8 | OP_INV | ON_RELEASE)
#define ACTION_KEYMAP_INV_B(layer) ACTION(ACT_KEYMAP, (layer)<<8 | OP_INV | ON_BOTH)
/* Keymap On */
#define ACTION_KEYMAP_ON(layer) ACTION_KEYMAP_ON_OFF(layer)
#define ACTION_KEYMAP_ON(layer, on) ACTION(ACT_KEYMAP, (layer)<<8 | OP_ON | (on))
#define ACTION_KEYMAP_ON_OFF(layer) ACTION(ACT_KEYMAP, (layer)<<8 | OP_ON | 0)
#define ACTION_KEYMAP_ON_P(layer) ACTION(ACT_KEYMAP, (layer)<<8 | OP_ON | ON_PRESS)
#define ACTION_KEYMAP_ON_R(layer) ACTION(ACT_KEYMAP, (layer)<<8 | OP_ON | ON_RELEASE)
#define ACTION_KEYMAP_ON_B(layer) ACTION(ACT_KEYMAP, (layer)<<8 | OP_ON | ON_BOTH)
/* Keymap Off */
#define ACTION_KEYMAP_OFF(layer) ACTION_KEYMAP_OFF_ON(layer)
#define ACTION_KEYMAP_OFF(layer, on) ACTION(ACT_KEYMAP, (layer)<<8 | OP_OFF | (on))
#define ACTION_KEYMAP_OFF_ON(layer) ACTION(ACT_KEYMAP, (layer)<<8 | OP_OFF | 0)
#define ACTION_KEYMAP_OFF_P(layer) ACTION(ACT_KEYMAP, (layer)<<8 | OP_OFF | ON_PRESS)
#define ACTION_KEYMAP_OFF_R(layer) ACTION(ACT_KEYMAP, (layer)<<8 | OP_OFF | ON_RELEASE)
#define ACTION_KEYMAP_OFF_B(layer) ACTION(ACT_KEYMAP, (layer)<<8 | OP_OFF | ON_BOTH)
/* Keymap Set */
#define ACTION_KEYMAP_SET(layer) ACTION_KEYMAP_SET_CLEAR(layer)
#define ACTION_KEYMAP_SET(layer, on) ACTION(ACT_KEYMAP, (layer)<<8 | OP_SET | (on))
#define ACTION_KEYMAP_SET_CLEAR(layer) ACTION(ACT_KEYMAP, (layer)<<8 | OP_SET | 0)
#define ACTION_KEYMAP_SET_P(layer) ACTION(ACT_KEYMAP, (layer)<<8 | OP_SET | ON_PRESS)
#define ACTION_KEYMAP_SET_R(layer) ACTION(ACT_KEYMAP, (layer)<<8 | OP_SET | ON_RELEASE)
#define ACTION_KEYMAP_SET_B(layer) ACTION(ACT_KEYMAP, (layer)<<8 | OP_SET | ON_BOTH)
/* Keymap Invert with tap key */
#define ACTION_KEYMAP_TAP_KEY(layer, key) ACTION(ACT_KEYMAP, (layer)<<8 | (key))
/*
* Overlay Layer
*/
#define ACTION_OVERLAY(layer) ACTION_OVERLAY_MOMENTARY(layer)
#define ACTION_OVERLAY_MOMENTARY(layer) ACTION_OVERLAY_ON_OFF(layer)
#define ACTION_OVERLAY_TOGGLE(layer) ACTION_OVERLAY_INV_R(layer)
#define ACTION_OVERLAY_TOGGLE(layer) ACTION_OVERLAY_INV(layer, ON_RELEASE)
/* Overlay Clear */
#define ACTION_OVERLAY_CLEAR ACTION(ACT_OVERLAY, 0<<8 | OP_INV4 | 0)
#define ACTION_OVERLAY_CLEAR_P ACTION(ACT_OVERLAY, 0<<8 | OP_INV4 | ON_PRESS)
#define ACTION_OVERLAY_CLEAR_R ACTION(ACT_OVERLAY, 0<<8 | OP_INV4 | ON_RELEASE)
#define ACTION_OVERLAY_CLEAR_B ACTION(ACT_OVERLAY, 0<<8 | OP_INV4 | ON_BOTH)
#define ACTION_OVERLAY_CLEAR(on) ACTION(ACT_OVERLAY, 0<<8 | OP_INV4 | (on))
/* Overlay Invert 4-bit chunk */
#define ACTION_OVERLAY_INV4(bits, shift) ACTION(ACT_OVERLAY, (bits)<<8 | OP_INV4 | shift)
/* Overlay Invert */
#define ACTION_OVERLAY_INV(layer) ACTION_OVERLAY_INV_B(layer)
#define ACTION_OVERLAY_INV(layer, on) ACTION(ACT_OVERLAY, (layer)<<8 | OP_INV | (on))
#define ACTION_OVERLAY_TAP_TOGGLE(layer) ACTION(ACT_OVERLAY, (layer)<<8 | OP_INV | 0)
#define ACTION_OVERLAY_INV_P(layer) ACTION(ACT_OVERLAY, (layer)<<8 | OP_INV | ON_PRESS)
#define ACTION_OVERLAY_INV_R(layer) ACTION(ACT_OVERLAY, (layer)<<8 | OP_INV | ON_RELEASE)
#define ACTION_OVERLAY_INV_B(layer) ACTION(ACT_OVERLAY, (layer)<<8 | OP_INV | ON_BOTH)
/* Overlay On */
#define ACTION_OVERLAY_ON(layer) ACTION_OVERLAY_ON_OFF(layer)
#define ACTION_OVERLAY_ON(layer, on) ACTION(ACT_OVERLAY, (layer)<<8 | OP_ON | (on))
#define ACTION_OVERLAY_ON_OFF(layer) ACTION(ACT_OVERLAY, (layer)<<8 | OP_ON | 0)
#define ACTION_OVERLAY_ON_P(layer) ACTION(ACT_OVERLAY, (layer)<<8 | OP_ON | ON_PRESS)
#define ACTION_OVERLAY_ON_R(layer) ACTION(ACT_OVERLAY, (layer)<<8 | OP_ON | ON_RELEASE)
#define ACTION_OVERLAY_ON_B(layer) ACTION(ACT_OVERLAY, (layer)<<8 | OP_ON | ON_BOTH)
/* Overlay Off */
#define ACTION_OVERLAY_OFF(layer) ACTION_OVERLAY_OFF_ON(layer)
#define ACTION_OVERLAY_OFF(layer, on) ACTION(ACT_OVERLAY, (layer)<<8 | OP_OFF | (on))
#define ACTION_OVERLAY_OFF_ON(layer) ACTION(ACT_OVERLAY, (layer)<<8 | OP_OFF | 0)
#define ACTION_OVERLAY_OFF_P(layer) ACTION(ACT_OVERLAY, (layer)<<8 | OP_OFF | ON_PRESS)
#define ACTION_OVERLAY_OFF_R(layer) ACTION(ACT_OVERLAY, (layer)<<8 | OP_OFF | ON_RELEASE)
#define ACTION_OVERLAY_OFF_B(layer) ACTION(ACT_OVERLAY, (layer)<<8 | OP_OFF | ON_BOTH)
/* Overlay Set */
#define ACTION_OVERLAY_SET(layer) ACTION_OVERLAY_SET_CLEAR(layer)
#define ACTION_OVERLAY_SET(layer, on) ACTION(ACT_OVERLAY, (layer)<<8 | OP_SET | (on))
#define ACTION_OVERLAY_SET_CLEAR(layer) ACTION(ACT_OVERLAY, (layer)<<8 | OP_SET | 0)
#define ACTION_OVERLAY_SET_P(layer) ACTION(ACT_OVERLAY, (layer)<<8 | OP_SET | ON_PRESS)
#define ACTION_OVERLAY_SET_R(layer) ACTION(ACT_OVERLAY, (layer)<<8 | OP_SET | ON_RELEASE)
#define ACTION_OVERLAY_SET_B(layer) ACTION(ACT_OVERLAY, (layer)<<8 | OP_SET | ON_BOTH)
/* Overlay Invert with tap key */
#define ACTION_OVERLAY_TAP_KEY(layer, key) ACTION(ACT_OVERLAY, (layer)<<8 | (key))

View File

@ -2,7 +2,7 @@ Keymap framework - how to define your keymap
============================================
***NOTE: This is not final version, may be inconsistent with source code and changed occasionally for a while.***
## Keymap
## 0. Keymap and layers
**Keymap** is comprised of multiple layers of key layout, you can define **16** layers at most.
**Layer** is an array of **keycodes** to define **actions** on each physical keys.
respective 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
0 /___________/ V low 0 `--------------------------
### Keymap status
### 0.1 Keymap status
Keymap has its state in two parameters:
**`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.
@ -63,15 +63,15 @@ On the other hand, you shall change `keymap_state` to overlay base layer with so
keymap_stat = 0x6002 <-----'
### Layer Precedence and Transparency
### 0.2 Layer Precedence and Transparency
Note 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.
You can place `KC_TRNS` on overlay layer changes just part of layout to fall back on lower or base layer.
Key with `KC_TRANS` doen't has its own keycode and refers to its lower layers for keycode, instead.
See layer 1 or 2 below for example.
Key with `KC_TRANS` doen't has its own keycode and refers to lower valid layers for keycode, instead.
See example below.
### Keymap Example
### 0.3 Keymap Example
Keymap 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.
This 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
};
static const uint16_t PROGMEM fn_actions[] = {
ACTION_KEYMAP(1), // FN0
ACTION_KEYMAP_MOMENTARY(1), // FN0
ACTION_KEYMAP_TAP_KEY(2, KC_SCLN), // FN1
ACTION_KEYMAP_TOGGLE(2), // FN2
};
@ -154,7 +154,7 @@ You can find other keymap definitions in file `keymap.c` located on project dire
## 1. Keycode
See [`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.
See [`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.
***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()`.
@ -194,7 +194,7 @@ There are 8 modifiers which has discrimination between left and right.
`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.***
### 1.6 Keycode Table
See keycode table in [`doc/keycode.txt`](doc/keycode.txt) for description of keycodes.
See keycode table in [`doc/keycode.txt`](./keycode.txt) for description of keycodes.
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.
[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.
## 2. Action
See [`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.
See [`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.
Most 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.
@ -233,48 +233,51 @@ Or `Alt,Shift + Tab` can be defined. `ACTION_LMODS_KEY()` requires **4-bit modif
### 2.2 Layer Actions
### 2.2 Layer Action
These actions operate layers of keymap.
Parameters:
- layer: 0-15
- on: { press | release | both }
#### 2.2.0 Default Layer
`default_layer` is layer which always is on and refered to when actions is not defined on other layers.
`default_layer` is layer which always is valid and referred to when actions is not defined on other layers.
##### Return to Default Layer
Turns on `default layer` only with clearing other all layers.
Turns on only `default layer` with clearing other all layers.
ACTION_DEFAULT_LAYER
##### Set Default Layer
Sets 'default layer' to layer and turn it on without clear any other layers.
ACTION_DEFAULT_LAYER_SET(layer)
This does it on { press | release | both }.
Sets 'default layer' to layer and turn it on.
ACTION_DEFAULT_LAYER_SET_TO(layer)
ACTION_DEFAULT_LAYER_SET(layer, on)
#### 2.2.1 Keymap
These actions operate given layer argument which ranges from 0 to 15.
These actions operate layer status of keymap.
##### Switch to layer
##### Momentary Switch
Turns on layer momentary while holding, in other words turn on when key is pressed and off when released.
ACTION_KEYMAP_MOMENTARY(layer)
##### Toggle layer
##### Toggle Switch
Turns on layer on first type and turns off on next.
ACTION_KEYMAP_TOGGLE(layer)
##### Switch to layer with tap key
##### Momentary Switch with tap key
Turns on layer momentary while holding but registers key on tap.
ACTION_KEYMAP_TAP_KEY(layer, key)
##### Switch to layer with tap toggle
##### Momentary Switch with tap toggle
Turns on layer momentary while holding but toggles it with serial taps.
ACTION_KEYMAP_TAP_TOGGLE(layer)
@ -325,6 +328,7 @@ Invert 4bits out of 16bits of overlay status on both press and release.
ACTION_OVERLAY_INV4(bits, shift)
### 2.3 Macro action
***TBD***
@ -398,93 +402,80 @@ See `keyboard/hhkb/keymap.c` for sample.
## 3. Layer
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.
First layer is indexed by `0` which usually become `default layer` and active in initial state.
You can define **16 layers** at most in each keymaps and overlays.
____________
/ /
/ //
15 /___________///
14 /___________//_
13 /___________/ /
/: : : : : //
3 /___________///
2 /___________///
1 /___________//
.->0 /___________/
`--- default_layer = 0
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.
### 3.0 Transparency
With 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.
## 4. Layer switching
You can have some ways to switch layer with these actions.
There are two kind of layer switch action `Layer Set` and `Layer Bit` and two type of switching behaviour **Momentary** and **Toggle**.
## 4. Layer switching Example
There are some ways to switch layer with 'Layer' actions.
### 4.1 Momentary switching
Momentary switching changes layer only while holding Fn key.
#### 4.1.1 Momentary Set
This action makes `Layer 1` active on key press event and inactive on release event..
This 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.
ACTION_KEYMAP_MOMENTARY(1)
It 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.
After switch actions of destination layer are 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. Usually you need to palce same action or 'KC_TRNS` on destination layer to get back.
ACTION_LAYER_DEFAULT
#### 4.1.2 Momentary Bit
This `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.
ACTION_LAYER_BIT(1)
### 4.2 Toggle switching
Toggle switching changes layer after press then release. You keep being on the layer until you press key to return.
Toggle switching changes layer after press then release. With this you can keep staying on the layer until you press the key again to return.
#### 4.2.1 Toggle Set
This `Layer Set Toggle` action is to set `Layer 1` to `current layer` on release and do none on press.
This is toggle action of 'Layer 2'.
ACTION_LAYER_SET_TOGGLE(1)
ACTION_KEYMAP_TOGGLE(2)
To get back to `default layer` you can use this action.
ACTION_LAYER_DEFAULT
#### 4.2.2 Toggle Bit
This `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.
ACTION_LAYER_BIT_TOGGLE(1)
### 4.3 Momentary switching with Tap key
These actions switch to layer only while holding `Fn` key and register key on tap. **Tap** means to press and release key quickly.
These actions switch layer only while holding `Fn` key and register key on tap. **Tap** means to press and release key quickly.
ACTION_KEYMAP_TAP_KEY(2, KC_SCLN)
With this you can place layer switching function on normal key like ';' without losing its original key register function.
ACTION_LAYER_SET_TAP_KEY(2, KC_SCLN)
ACTION_LAYER_SET_BIT_KEY(2, KC_SCLN)
With these you can place layer switching function on normal alphabet key like `;` without losing its original register function.
### 4.4 Momentary switching with Tap Toggle
This changes layer only while holding `Fn` key and toggle layer after several taps. **Tap** means to press and release key quickly.
This switches layer only while holding `Fn` key and toggle layer after several taps. **Tap** means to press and release key quickly.
ACTION_LAYER_SET_TAP_TOGGLE(layer)
ACTION_LAYER_BIT_TAP_TOGGLE(layer)
ACTION_KEYMAP_TAP_TOGGLE(1)
Number of taps can be defined with `TAPPING_TOGGLE` in `config.h`, `5` by default.
## Tapping
Tapping 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.
### Tap Key
This 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.
Action for modifier with tap key.
ACTION_LMODS_TAP_KEY(mods, key)
Action for `Fn` with tap key.
ACTION_KEYMAP_TAP_KEY(layer, key)
[dual_role]: http://en.wikipedia.org/wiki/Modifier_key#Dual-role_modifier_keys
### Tap Toggle
This 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.
ACTION_KEYMAP_TAP_TOGGLE(layer)
### One Shot Modifier
This adds oneshot feature to modifier key. 'One Shot Modifier' is one time modifier which has effect only on following one alpha key.
It works as normal modifier key when holding but oneshot modifier when tapping.
ACTION_LMODS_ONESHOT(mods)
Say 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.
## Legacy Keymap

View File

@ -204,15 +204,15 @@ static const uint8_t PROGMEM overlays[][MATRIX_ROWS][MATRIX_COLS] = {};
* Fn action definition
*/
static const uint16_t PROGMEM fn_actions[] = {
[0] = ACTION_KEYMAP(4), // FN0
[1] = ACTION_KEYMAP_TAP_KEY(5, KC_SLASH), // FN1
[2] = ACTION_KEYMAP_TAP_KEY(6, KC_SCLN), // FN2
[3] = ACTION_KEYMAP(6), // FN3
[4] = ACTION_KEYMAP(7), // to Layout selector
[5] = ACTION_SET_DEFAULT_LAYER(0), // set qwerty layout
[6] = ACTION_SET_DEFAULT_LAYER(1), // set colemak layout
[7] = ACTION_SET_DEFAULT_LAYER(2), // set dvorak layout
[8] = ACTION_SET_DEFAULT_LAYER(3), // set workman layout
[0] = ACTION_KEYMAP_MOMENTARY(4),
[1] = ACTION_KEYMAP_TAP_KEY(5, KC_SLASH),
[2] = ACTION_KEYMAP_TAP_KEY(6, KC_SCLN),
[3] = ACTION_KEYMAP_MOMENTARY(6),
[4] = ACTION_KEYMAP_MOMENTARY(7), // to Layout selector
[5] = ACTION_DEFAULT_LAYER_SET(0), // set qwerty layout
[6] = ACTION_DEFAULT_LAYER_SET(1), // set colemak layout
[7] = ACTION_DEFAULT_LAYER_SET(2), // set dvorak layout
[8] = ACTION_DEFAULT_LAYER_SET(3), // set workman layout
};
#endif

View File

@ -92,13 +92,13 @@ static const uint8_t PROGMEM overlays[][MATRIX_ROWS][MATRIX_COLS] = {
};
static const uint16_t PROGMEM fn_actions[] = {
/* Poker Layout */
[0] = ACTION_OVERLAY(2), // to Fn overlay
[0] = ACTION_OVERLAY_MOMENTARY(2), // to Fn overlay
[1] = ACTION_OVERLAY_TOGGLE(0), // toggle arrow overlay
[2] = ACTION_OVERLAY_TOGGLE(1), // toggle Esc overlay
[3] = ACTION_RMODS_KEY(MOD_BIT(KC_RCTL)|MOD_BIT(KC_RSFT), KC_ESC), // Task(RControl,RShift+Esc)
[4] = ACTION_OVERLAY(3), // to Layout selector
[5] = ACTION_SET_DEFAULT_LAYER(0), // set qwerty layout
[6] = ACTION_SET_DEFAULT_LAYER(1), // set colemak layout
[7] = ACTION_SET_DEFAULT_LAYER(2), // set dvorak layout
[8] = ACTION_SET_DEFAULT_LAYER(3), // set workman layout
[4] = ACTION_OVERLAY_MOMENTARY(3), // to Layout selector
[5] = ACTION_DEFAULT_LAYER_SET(0), // set qwerty layout
[6] = ACTION_DEFAULT_LAYER_SET(1), // set colemak layout
[7] = ACTION_DEFAULT_LAYER_SET(2), // set dvorak layout
[8] = ACTION_DEFAULT_LAYER_SET(3), // set workman layout
};

View File

@ -67,15 +67,15 @@ static const uint8_t PROGMEM overlays[][MATRIX_ROWS][MATRIX_COLS] = {
*/
static const uint16_t PROGMEM fn_actions[] = {
/* Poker Layout */
[0] = ACTION_OVERLAY_SET_P(3), // FN0 move to Fn'd when press
[1] = ACTION_OVERLAY_SET_P(4), // FN1 move to Fn'd arrow when press
[2] = ACTION_OVERLAY_SET_P(5), // FN2 move to Fn'd Esc when press
[3] = ACTION_OVERLAY_SET_P(6), // FN3 move to Fn'd arrow + Esc when press
[0] = ACTION_OVERLAY_SET(3, ON_PRESS), // FN0 move to Fn'd when press
[1] = ACTION_OVERLAY_SET(4, ON_PRESS), // FN1 move to Fn'd arrow when press
[2] = ACTION_OVERLAY_SET(5, ON_PRESS), // FN2 move to Fn'd Esc when press
[3] = ACTION_OVERLAY_SET(6, ON_PRESS), // FN3 move to Fn'd arrow + Esc when press
[4] = ACTION_OVERLAY_CLEAR, // FN4 clear overlay when release
[5] = ACTION_OVERLAY_SET_R(0), // FN5 move to arrow when release
[6] = ACTION_OVERLAY_SET_R(1), // FN6 move to Esc when release
[7] = ACTION_OVERLAY_SET_R(2), // FN7 move to arrow + Esc when release
[4] = ACTION_OVERLAY_CLEAR(ON_RELEASE), // FN4 clear overlay when release
[5] = ACTION_OVERLAY_SET(0, ON_RELEASE), // FN5 move to arrow when release
[6] = ACTION_OVERLAY_SET(1, ON_RELEASE), // FN6 move to Esc when release
[7] = ACTION_OVERLAY_SET(2, ON_RELEASE), // FN7 move to arrow + Esc when release
[8] = ACTION_RMODS_KEY(MOD_BIT(KC_RCTL)|MOD_BIT(KC_RSFT), KC_ESC), // FN8 Task(RControl,RShift+Esc)
};