Merge branch 'transparent'
commit
7054203e16
13
README.md
13
README.md
|
@ -7,7 +7,7 @@ Source code is available here: <http://github.com/tmk/tmk_keyboard>
|
||||||
|
|
||||||
Features
|
Features
|
||||||
--------
|
--------
|
||||||
* Multi-layer keymap - Multiple keyboard layouts with layer switching.
|
* Multi-layer Keymap - Multiple keyboard layouts with layer switching.
|
||||||
* Mouse key - Mouse control with keyboard
|
* Mouse key - Mouse control with keyboard
|
||||||
* System Control Key - Power Down, Sleep, Wake Up and USB Remote Wake up
|
* System Control Key - Power Down, Sleep, Wake Up and USB Remote Wake up
|
||||||
* Media Control Key - Volume Down/Up, Mute, Next/Prev track, Play, Stop and etc
|
* Media Control Key - Volume Down/Up, Mute, Next/Prev track, Play, Stop and etc
|
||||||
|
@ -283,8 +283,11 @@ See `common/keycode.h`. Keycode is 8bit internal code to inidicate action perfor
|
||||||
|
|
||||||
***In `KEYMAP` definition you need to 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`.
|
***In `KEYMAP` definition you need to 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`.
|
||||||
|
|
||||||
#### 1.1 Normal key
|
#### 1.0 Other key
|
||||||
- `KC_NO` for no aciton
|
- `KC_NO` for no aciton
|
||||||
|
- `KC_TRNS` for transparent layer
|
||||||
|
|
||||||
|
#### 1.1 Normal key
|
||||||
- `KC_A` to `KC_Z`, `KC_1` to `KC_0` for alpha numeric key
|
- `KC_A` to `KC_Z`, `KC_1` to `KC_0` for alpha numeric key
|
||||||
- `KC_MINS`, `KC_EQL`, `KC_GRV`, `KC_RBRC`, `KC_LBRC`, `KC_COMM`, `KC_DOT`, `KC_BSLS`, `KC_SLSH`, `KC_SCLN`, `KC_QUOT`
|
- `KC_MINS`, `KC_EQL`, `KC_GRV`, `KC_RBRC`, `KC_LBRC`, `KC_COMM`, `KC_DOT`, `KC_BSLS`, `KC_SLSH`, `KC_SCLN`, `KC_QUOT`
|
||||||
- `KC_ESC`, `KC_TAB`, `KC_SPC`, `KC_BSPC`, `KC_ENT`, `KC_DEL`, `KC_INS`
|
- `KC_ESC`, `KC_TAB`, `KC_SPC`, `KC_BSPC`, `KC_ENT`, `KC_DEL`, `KC_INS`
|
||||||
|
@ -301,7 +304,7 @@ There are 8 modifiers which has discrimination between left and right.
|
||||||
- `KC_LGUI` and `KC_RGUI` for Windows key or Command key in Mac
|
- `KC_LGUI` and `KC_RGUI` for Windows key or Command key in Mac
|
||||||
|
|
||||||
#### 1.3 Fn key
|
#### 1.3 Fn key
|
||||||
**`KC_FNnn`** are `Fn` keys which not given any action at the beginning unlike most of keycodes has its own action. To use these keys in `KEYMAP` you need to assign action you want at first. Action of `Fn` is defined in `fn_actions[]` and index of the array is identical with number part of `KC_FNnn`. Thus `KC_FN0` designates action defined in first element of the array. ***32 `Fn` keys can be defined at most.***
|
`KC_FNnn` are `Fn` keys which not given any action at the beginning unlike most of keycodes has its own action. To use these keys in `KEYMAP` you need to assign action you want at first. Action of `Fn` is defined in `fn_actions[]` and index of the array is identical with number part of `KC_FNnn`. Thus `KC_FN0` designates action defined in first element of the array. ***32 `Fn` keys can be defined at most.***
|
||||||
|
|
||||||
#### 1.4 Mousekey
|
#### 1.4 Mousekey
|
||||||
- `KC_MS_U`, `KC_MS_D`, `KC_MS_L`, `KC_MS_R` for mouse cursor
|
- `KC_MS_U`, `KC_MS_D`, `KC_MS_L`, `KC_MS_R` for mouse cursor
|
||||||
|
@ -359,7 +362,7 @@ This sets `default layer` into `current layer`. With this action you can return
|
||||||
ACTION_LAYER_SET_TAP_KEY(layer, key)
|
ACTION_LAYER_SET_TAP_KEY(layer, key)
|
||||||
ACTION_LAYER_SET_TAP_TOGGLE(layer)
|
ACTION_LAYER_SET_TAP_TOGGLE(layer)
|
||||||
|
|
||||||
`Layer Bit` action XOR bits with `current layer`. `Layer Bit` action can take 0 to 8 as argument.
|
`Layer Bit` action XOR given bits with `current layer`. `Layer Bit` action can take 0 to 15 as argument.
|
||||||
|
|
||||||
ACTION_LAYER_BIT(bits)
|
ACTION_LAYER_BIT(bits)
|
||||||
ACTION_LAYER_BIT_TOGGLE(bits)
|
ACTION_LAYER_BIT_TOGGLE(bits)
|
||||||
|
@ -659,4 +662,4 @@ Files & Directories
|
||||||
License
|
License
|
||||||
-------
|
-------
|
||||||
Under `GPL` 2 or later. Some protocol files are under `Modified BSD License`.
|
Under `GPL` 2 or later. Some protocol files are under `Modified BSD License`.
|
||||||
LUFA and PJRC stack have their own license respectively.
|
LUFA, PJRC and V-USB stack have their own license respectively.
|
||||||
|
|
|
@ -201,6 +201,19 @@ void action_exec(keyevent_t event)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static action_t get_action(key_t key)
|
||||||
|
{
|
||||||
|
action_t action = keymap_get_action(current_layer, key.pos.row, key.pos.col);
|
||||||
|
|
||||||
|
/* Transparently use default layer */
|
||||||
|
if (action.code == ACTION_TRANSPARENT) {
|
||||||
|
// TODO: layer stacking
|
||||||
|
action = keymap_get_action(default_layer, key.pos.row, key.pos.col);
|
||||||
|
debug("TRNASPARENT: "); debug_hex16(action.code); debug("\n");
|
||||||
|
}
|
||||||
|
return action;
|
||||||
|
}
|
||||||
|
|
||||||
static void process_action(keyrecord_t *record)
|
static void process_action(keyrecord_t *record)
|
||||||
{
|
{
|
||||||
keyevent_t event = record->event;
|
keyevent_t event = record->event;
|
||||||
|
@ -208,8 +221,7 @@ static void process_action(keyrecord_t *record)
|
||||||
|
|
||||||
if (IS_NOEVENT(event)) { return; }
|
if (IS_NOEVENT(event)) { return; }
|
||||||
|
|
||||||
action_t action = keymap_get_action(current_layer, event.key.pos.row, event.key.pos.col);
|
action_t action = get_action(event.key);
|
||||||
//debug("action: "); debug_hex16(action.code); if (event.pressed) debug("d\n"); else debug("u\n");
|
|
||||||
debug("ACTION: "); debug_action(action); debug("\n");
|
debug("ACTION: "); debug_action(action); debug("\n");
|
||||||
|
|
||||||
switch (action.kind.id) {
|
switch (action.kind.id) {
|
||||||
|
@ -358,6 +370,7 @@ static void process_action(keyrecord_t *record)
|
||||||
layer_switch(action.layer.val);
|
layer_switch(action.layer.val);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
// NOTE: This is needed by legacy keymap support
|
||||||
layer_switch(default_layer);
|
layer_switch(default_layer);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -421,7 +434,7 @@ static void process_action(keyrecord_t *record)
|
||||||
unregister_code(action.layer.code);
|
unregister_code(action.layer.code);
|
||||||
} else {
|
} else {
|
||||||
//debug("LAYER_PRESSED: No tap: NO ACTION\n");
|
//debug("LAYER_PRESSED: No tap: NO ACTION\n");
|
||||||
//TODO: this is ok?
|
// NOTE: This is needed by legacy keymap support
|
||||||
debug("LAYER_PRESSED: No tap: return to default layer\n");
|
debug("LAYER_PRESSED: No tap: return to default layer\n");
|
||||||
layer_switch(default_layer);
|
layer_switch(default_layer);
|
||||||
}
|
}
|
||||||
|
@ -808,7 +821,8 @@ void layer_switch(uint8_t new_layer)
|
||||||
|
|
||||||
bool is_tap_key(key_t key)
|
bool is_tap_key(key_t key)
|
||||||
{
|
{
|
||||||
action_t action = keymap_get_action(current_layer, key.pos.row, key.pos.col);
|
action_t action = get_action(key);
|
||||||
|
|
||||||
switch (action.kind.id) {
|
switch (action.kind.id) {
|
||||||
case ACT_LMODS_TAP:
|
case ACT_LMODS_TAP:
|
||||||
case ACT_RMODS_TAP:
|
case ACT_RMODS_TAP:
|
||||||
|
|
|
@ -106,12 +106,14 @@ Keyboard Keys
|
||||||
-------------
|
-------------
|
||||||
ACT_LMODS(0000):
|
ACT_LMODS(0000):
|
||||||
0000|0000|000000|00 No action
|
0000|0000|000000|00 No action
|
||||||
|
0000|0000|000000|01 Transparent
|
||||||
0000|0000| keycode Key
|
0000|0000| keycode Key
|
||||||
0000|mods|000000|00 Left mods
|
0000|mods|000000|00 Left mods
|
||||||
0000|mods| keycode Key & Left mods
|
0000|mods| keycode Key & Left mods
|
||||||
|
|
||||||
ACT_RMODS(0001):
|
ACT_RMODS(0001):
|
||||||
0001|0000|000000|00 No action
|
0001|0000|000000|00 No action(not used)
|
||||||
|
0001|0000|000000|01 Transparent(not used)
|
||||||
0001|0000| keycode Key(no used)
|
0001|0000| keycode Key(no used)
|
||||||
0001|mods|000000|00 Right mods
|
0001|mods|000000|00 Right mods
|
||||||
0001|mods| keycode Key & Right mods
|
0001|mods| keycode Key & Right mods
|
||||||
|
@ -157,7 +159,7 @@ ACT_LAYER_BIT(1001): Bit-op layer
|
||||||
1000|LLLL|0000 0001 set L to layer on press
|
1000|LLLL|0000 0001 set L to layer on press
|
||||||
1000|LLLL|0000 0010 set L to layer on release
|
1000|LLLL|0000 0010 set L to layer on release
|
||||||
1000|----|0000 0011 set default to layer on both(return to default layer)
|
1000|----|0000 0011 set default to layer on both(return to default layer)
|
||||||
1000|LLLL|xxxx xxxx set L to layer while hold and send key on tap
|
1000|LLLL| keycode set L to layer while hold and send key on tap
|
||||||
1000|LLLL|1111 0000 set L to layer while hold and toggle on several taps
|
1000|LLLL|1111 0000 set L to layer while hold and toggle on several taps
|
||||||
1000|LLLL|1111 1111 set L to default and layer(on press)
|
1000|LLLL|1111 1111 set L to default and layer(on press)
|
||||||
|
|
||||||
|
@ -165,7 +167,7 @@ ACT_LAYER_BIT(1001): Bit-op layer
|
||||||
1001|BBBB|0000 0001 bit-xor layer with B on press
|
1001|BBBB|0000 0001 bit-xor layer with B on press
|
||||||
1001|BBBB|0000 0010 bit-xor layer with B on release
|
1001|BBBB|0000 0010 bit-xor layer with B on release
|
||||||
1001|BBBB|0000 0011 bit-xor layer with B on both(momentary)
|
1001|BBBB|0000 0011 bit-xor layer with B on both(momentary)
|
||||||
1001|BBBB|xxxx xxxx bit-xor layer with B while hold and send key on tap
|
1001|BBBB| keycode bit-xor layer with B while hold and send key on tap
|
||||||
1001|BBBB|1111 0000 bit-xor layer with B while hold and toggle on several taps
|
1001|BBBB|1111 0000 bit-xor layer with B while hold and toggle on several taps
|
||||||
1001|BBBB|1111 1111 bit-xor default with B and set layer(on press)
|
1001|BBBB|1111 1111 bit-xor default with B and set layer(on press)
|
||||||
|
|
||||||
|
@ -207,16 +209,17 @@ enum action_kind_id {
|
||||||
|
|
||||||
/* action utility */
|
/* action utility */
|
||||||
#define ACTION_NO 0
|
#define ACTION_NO 0
|
||||||
|
#define ACTION_TRANSPARENT 1
|
||||||
#define ACTION(kind, param) ((kind)<<12 | (param))
|
#define ACTION(kind, param) ((kind)<<12 | (param))
|
||||||
#define MODS4(mods) (((mods)>>4 | (mods)) & 0x0F)
|
#define MODS4(mods) (((mods)>>4 | (mods)) & 0x0F)
|
||||||
|
|
||||||
/* Key */
|
/* Key */
|
||||||
#define ACTION_KEY(key) ACTION(ACT_LMODS, key)
|
#define ACTION_KEY(key) ACTION(ACT_LMODS, key)
|
||||||
/* Mods & key */
|
/* Mods & key */
|
||||||
#define ACTION_LMODS(mods) ACTION(ACT_LMODS, (mods)<<8 | 0x00)
|
#define ACTION_LMODS(mods) ACTION(ACT_LMODS, MODS4(mods)<<8 | 0x00)
|
||||||
#define ACTION_LMODS_KEY(mods, key) ACTION(ACT_LMODS, (mods)<<8 | (key))
|
#define ACTION_LMODS_KEY(mods, key) ACTION(ACT_LMODS, MODS4(mods)<<8 | (key))
|
||||||
#define ACTION_RMODS(mods) ACTION(ACT_RMODS, (mods)<<8 | 0x00)
|
#define ACTION_RMODS(mods) ACTION(ACT_RMODS, MODS4(mods)<<8 | 0x00)
|
||||||
#define ACTION_RMODS_KEY(mods, key) ACTION(ACT_RMODS, (mods)<<8 | (key))
|
#define ACTION_RMODS_KEY(mods, key) ACTION(ACT_RMODS, MODS4(mods)<<8 | (key))
|
||||||
/* Mod & key */
|
/* Mod & key */
|
||||||
#define ACTION_LMOD(mod) ACTION(ACT_LMODS, MODS4(MOD_BIT(mod))<<8 | 0x00)
|
#define ACTION_LMOD(mod) ACTION(ACT_LMODS, MODS4(MOD_BIT(mod))<<8 | 0x00)
|
||||||
#define ACTION_LMOD_KEY(mod, key) ACTION(ACT_LMODS, MODS4(MOD_BIT(mod))<<8 | (key))
|
#define ACTION_LMOD_KEY(mod, key) ACTION(ACT_LMODS, MODS4(MOD_BIT(mod))<<8 | (key))
|
||||||
|
@ -268,8 +271,9 @@ enum layer_vals_default {
|
||||||
/*
|
/*
|
||||||
* Set layer
|
* Set layer
|
||||||
*/
|
*/
|
||||||
/* set layer on press and set default on release */
|
/* set layer on press and none on release */
|
||||||
#define ACTION_LAYER_SET(layer) ACTION_LAYER_SET_MOMENTARY(layer)
|
#define ACTION_LAYER_SET(layer) ACTION_LAYER_SET_P(layer)
|
||||||
|
/* set layer on press and set default on release (This is needed by legacy keymap support.) */
|
||||||
#define ACTION_LAYER_SET_MOMENTARY(layer) ACTION(ACT_LAYER, (layer)<<8 | LAYER_MOMENTARY)
|
#define ACTION_LAYER_SET_MOMENTARY(layer) ACTION(ACT_LAYER, (layer)<<8 | LAYER_MOMENTARY)
|
||||||
/* set layer on press and none on release */
|
/* set layer on press and none on release */
|
||||||
#define ACTION_LAYER_SET_TOGGLE(layer) ACTION_LAYER_SET_R(layer)
|
#define ACTION_LAYER_SET_TOGGLE(layer) ACTION_LAYER_SET_R(layer)
|
||||||
|
|
|
@ -263,23 +263,16 @@ static bool command_common(uint8_t code)
|
||||||
#endif
|
#endif
|
||||||
case KC_0:
|
case KC_0:
|
||||||
case KC_F10:
|
case KC_F10:
|
||||||
|
clear_keyboard();
|
||||||
switch_layer(0);
|
switch_layer(0);
|
||||||
break;
|
break;
|
||||||
case KC_1:
|
case KC_1 ... KC_9:
|
||||||
case KC_F1:
|
clear_keyboard();
|
||||||
switch_layer(1);
|
switch_layer((code - KC_1) + 1);
|
||||||
break;
|
break;
|
||||||
case KC_2:
|
case KC_F1 ... KC_F9:
|
||||||
case KC_F2:
|
clear_keyboard();
|
||||||
switch_layer(2);
|
switch_layer((code - KC_F1) + 1);
|
||||||
break;
|
|
||||||
case KC_3:
|
|
||||||
case KC_F3:
|
|
||||||
switch_layer(3);
|
|
||||||
break;
|
|
||||||
case KC_4:
|
|
||||||
case KC_F4:
|
|
||||||
switch_layer(4);
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
print("?");
|
print("?");
|
||||||
|
|
|
@ -28,6 +28,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#define IS_KEY(code) (KC_A <= (code) && (code) <= KC_EXSEL)
|
#define IS_KEY(code) (KC_A <= (code) && (code) <= KC_EXSEL)
|
||||||
#define IS_MOD(code) (KC_LCTRL <= (code) && (code) <= KC_RGUI)
|
#define IS_MOD(code) (KC_LCTRL <= (code) && (code) <= KC_RGUI)
|
||||||
|
|
||||||
|
|
||||||
|
#define IS_SPECIAL(code) ((0xA5 <= (code) && (code) <= 0xDF) || (0xE8 <= (code) && (code) <= 0xFF))
|
||||||
|
#define IS_SYSTEM(code) (KC_POWER <= (code) && (code) <= KC_WAKE)
|
||||||
|
#define IS_CONSUMER(code) (KC_MUTE <= (code) && (code) <= KC_WFAV)
|
||||||
#define IS_FN(code) (KC_FN0 <= (code) && (code) <= KC_FN31)
|
#define IS_FN(code) (KC_FN0 <= (code) && (code) <= KC_FN31)
|
||||||
#define IS_MOUSEKEY(code) (KC_MS_UP <= (code) && (code) <= KC_MS_ACCEL2)
|
#define IS_MOUSEKEY(code) (KC_MS_UP <= (code) && (code) <= KC_MS_ACCEL2)
|
||||||
#define IS_MOUSEKEY_MOVE(code) (KC_MS_UP <= (code) && (code) <= KC_MS_RIGHT)
|
#define IS_MOUSEKEY_MOVE(code) (KC_MS_UP <= (code) && (code) <= KC_MS_RIGHT)
|
||||||
|
@ -35,10 +39,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#define IS_MOUSEKEY_WHEEL(code) (KC_MS_WH_UP <= (code) && (code) <= KC_MS_WH_RIGHT)
|
#define IS_MOUSEKEY_WHEEL(code) (KC_MS_WH_UP <= (code) && (code) <= KC_MS_WH_RIGHT)
|
||||||
#define IS_MOUSEKEY_ACCEL(code) (KC_MS_ACCEL0 <= (code) && (code) <= KC_MS_ACCEL2)
|
#define IS_MOUSEKEY_ACCEL(code) (KC_MS_ACCEL0 <= (code) && (code) <= KC_MS_ACCEL2)
|
||||||
|
|
||||||
#define IS_SPECIAL(code) ((0xA5 <= (code) && (code) <= 0xDF) || (0xE8 <= (code) && (code) <= 0xFF))
|
|
||||||
#define IS_CONSUMER(code) (KC_MUTE <= (code) && (code) <= KC_WFAV)
|
|
||||||
#define IS_SYSTEM(code) (KC_POWER <= (code) && (code) <= KC_WAKE)
|
|
||||||
|
|
||||||
#define MOD_BIT(code) (1<<MOD_INDEX(code))
|
#define MOD_BIT(code) (1<<MOD_INDEX(code))
|
||||||
#define MOD_INDEX(code) ((code) & 0x07)
|
#define MOD_INDEX(code) ((code) & 0x07)
|
||||||
#define FN_BIT(code) (1<<FN_INDEX(code))
|
#define FN_BIT(code) (1<<FN_INDEX(code))
|
||||||
|
@ -149,6 +149,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#define KC_WSTP KC_WWW_STOP
|
#define KC_WSTP KC_WWW_STOP
|
||||||
#define KC_WREF KC_WWW_REFRESH
|
#define KC_WREF KC_WWW_REFRESH
|
||||||
#define KC_WFAV KC_WWW_FAVORITES
|
#define KC_WFAV KC_WWW_FAVORITES
|
||||||
|
/* Transparent */
|
||||||
|
#define KC_TRANSPARENT 1
|
||||||
|
#define KC_TRNS KC_TRANSPARENT
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* USB HID Keyboard/Keypad Usage(0x07) */
|
/* USB HID Keyboard/Keypad Usage(0x07) */
|
||||||
|
|
|
@ -17,6 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#include "keymap.h"
|
#include "keymap.h"
|
||||||
#include "report.h"
|
#include "report.h"
|
||||||
#include "keycode.h"
|
#include "keycode.h"
|
||||||
|
#include "action.h"
|
||||||
|
|
||||||
|
|
||||||
/* layer */
|
/* layer */
|
||||||
|
@ -24,46 +25,61 @@ uint8_t default_layer = 0;
|
||||||
uint8_t current_layer = 0;
|
uint8_t current_layer = 0;
|
||||||
|
|
||||||
|
|
||||||
|
action_t keymap_keycode_to_action(uint8_t keycode)
|
||||||
|
{
|
||||||
|
action_t action;
|
||||||
|
switch (keycode) {
|
||||||
|
case KC_A ... KC_EXSEL:
|
||||||
|
action.code = ACTION_KEY(keycode);
|
||||||
|
break;
|
||||||
|
case KC_LCTRL ... KC_LGUI:
|
||||||
|
action.code = ACTION_LMOD(keycode);
|
||||||
|
break;
|
||||||
|
case KC_RCTRL ... KC_RGUI:
|
||||||
|
action.code = ACTION_RMOD(keycode);
|
||||||
|
break;
|
||||||
|
case KC_SYSTEM_POWER ... KC_SYSTEM_WAKE:
|
||||||
|
action.code = ACTION_USAGE_SYSTEM(KEYCODE2SYSTEM(keycode));
|
||||||
|
break;
|
||||||
|
case KC_AUDIO_MUTE ... KC_WWW_FAVORITES:
|
||||||
|
action.code = ACTION_USAGE_CONSUMER(KEYCODE2CONSUMER(keycode));
|
||||||
|
break;
|
||||||
|
case KC_MS_UP ... KC_MS_ACCEL2:
|
||||||
|
action.code = ACTION_MOUSEKEY(keycode);
|
||||||
|
break;
|
||||||
|
case KC_TRNS:
|
||||||
|
action.code = ACTION_TRANSPARENT;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
action.code = ACTION_NO;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return action;
|
||||||
|
}
|
||||||
|
|
||||||
#ifndef NO_LEGACY_KEYMAP_SUPPORT
|
#ifndef NO_LEGACY_KEYMAP_SUPPORT
|
||||||
/* legacy support with weak reference */
|
/* legacy support with weak reference */
|
||||||
__attribute__ ((weak))
|
__attribute__ ((weak))
|
||||||
action_t keymap_get_action(uint8_t layer, uint8_t row, uint8_t col)
|
action_t keymap_get_action(uint8_t layer, uint8_t row, uint8_t col)
|
||||||
{
|
{
|
||||||
/* convert from legacy keycode to action */
|
/* convert from legacy keycode to action */
|
||||||
uint8_t key = keymap_get_keycode(layer, row, col);
|
uint8_t keycode = keymap_get_keycode(layer, row, col);
|
||||||
action_t action;
|
action_t action;
|
||||||
switch (key) {
|
switch (keycode) {
|
||||||
case KC_A ... KC_EXSEL:
|
|
||||||
action.code = ACTION_KEY(key);
|
|
||||||
break;
|
|
||||||
case KC_LCTRL ... KC_LGUI:
|
|
||||||
action.code = ACTION_LMOD(key);
|
|
||||||
break;
|
|
||||||
case KC_RCTRL ... KC_RGUI:
|
|
||||||
action.code = ACTION_RMOD(key);
|
|
||||||
break;
|
|
||||||
case KC_SYSTEM_POWER ... KC_SYSTEM_WAKE:
|
|
||||||
action.code = ACTION_USAGE_SYSTEM(KEYCODE2SYSTEM(key));
|
|
||||||
break;
|
|
||||||
case KC_AUDIO_MUTE ... KC_WWW_FAVORITES:
|
|
||||||
action.code = ACTION_USAGE_CONSUMER(KEYCODE2CONSUMER(key));
|
|
||||||
break;
|
|
||||||
case KC_MS_UP ... KC_MS_ACCEL2:
|
|
||||||
action.code = ACTION_MOUSEKEY(key);
|
|
||||||
break;
|
|
||||||
case KC_FN0 ... KC_FN31:
|
case KC_FN0 ... KC_FN31:
|
||||||
{
|
{
|
||||||
uint8_t layer = keymap_fn_layer(FN_INDEX(key));
|
uint8_t layer = keymap_fn_layer(FN_INDEX(keycode));
|
||||||
uint8_t code = keymap_fn_keycode(FN_INDEX(key));
|
uint8_t key = keymap_fn_keycode(FN_INDEX(keycode));
|
||||||
action.code = ACTION_LAYER_SET_TAP_KEY(layer, code);
|
if (key) {
|
||||||
|
action.code = ACTION_LAYER_SET_TAP_KEY(layer, key);
|
||||||
|
} else {
|
||||||
|
action.code = ACTION_LAYER_SET_MOMENTARY(layer);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
return action;
|
||||||
case KC_NO ... KC_UNDEFINED:
|
|
||||||
default:
|
default:
|
||||||
action.code = ACTION_NO;
|
return keymap_keycode_to_action(keycode);
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
return action;
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -30,14 +30,23 @@ extern uint8_t current_layer;
|
||||||
extern uint8_t default_layer;
|
extern uint8_t default_layer;
|
||||||
|
|
||||||
|
|
||||||
|
/* translates key_t to keycode */
|
||||||
|
uint8_t keymap_key_to_keycode(uint8_t layer, key_t key);
|
||||||
|
/* translates keycode to action */
|
||||||
|
action_t keymap_keycode_to_action(uint8_t keycode);
|
||||||
|
/* translates Fn keycode to action */
|
||||||
|
action_t keymap_fn_to_action(uint8_t keycode);
|
||||||
|
|
||||||
|
|
||||||
/* action for key */
|
/* action for key */
|
||||||
// TODO: should use struct key_t?
|
// TODO: should use struct key_t? move to action.h?
|
||||||
action_t keymap_get_action(uint8_t layer, uint8_t row, uint8_t col);
|
action_t keymap_get_action(uint8_t layer, uint8_t row, uint8_t col);
|
||||||
|
|
||||||
/* user defined special function */
|
/* user defined special function */
|
||||||
void keymap_call_function(keyrecord_t *record, uint8_t id, uint8_t opt);
|
void keymap_call_function(keyrecord_t *record, uint8_t id, uint8_t opt);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef NO_LEGACY_KEYMAP_SUPPORT
|
#ifndef NO_LEGACY_KEYMAP_SUPPORT
|
||||||
/* keycode of key */
|
/* keycode of key */
|
||||||
uint8_t keymap_get_keycode(uint8_t layer, uint8_t row, uint8_t col);
|
uint8_t keymap_get_keycode(uint8_t layer, uint8_t row, uint8_t col);
|
||||||
|
|
|
@ -119,5 +119,8 @@ include $(TOP_DIR)/protocol/lufa.mk
|
||||||
include $(TOP_DIR)/common.mk
|
include $(TOP_DIR)/common.mk
|
||||||
include $(TOP_DIR)/rules.mk
|
include $(TOP_DIR)/rules.mk
|
||||||
|
|
||||||
plain: OPT_DEFS += -DPLAIN_MAP
|
plain: OPT_DEFS += -DKEYMAP_PLAIN
|
||||||
plain: all
|
plain: all
|
||||||
|
|
||||||
|
poker: OPT_DEFS += -DKEYMAP_POKER
|
||||||
|
poker: all
|
||||||
|
|
|
@ -89,5 +89,8 @@ include $(TOP_DIR)/protocol/pjrc.mk
|
||||||
include $(TOP_DIR)/common.mk
|
include $(TOP_DIR)/common.mk
|
||||||
include $(TOP_DIR)/rules.mk
|
include $(TOP_DIR)/rules.mk
|
||||||
|
|
||||||
plain: OPT_DEFS += -DPLAIN_MAP
|
plain: OPT_DEFS += -DKEYMAP_PLAIN
|
||||||
plain: all
|
plain: all
|
||||||
|
|
||||||
|
poker: OPT_DEFS += -DKEYMAP_POKER
|
||||||
|
poker: all
|
||||||
|
|
|
@ -12,23 +12,28 @@ Move to this directory then just run `make` like:
|
||||||
|
|
||||||
$ make -f Makfile.[pjrc|lufa]
|
$ make -f Makfile.[pjrc|lufa]
|
||||||
|
|
||||||
|
Use `Makefile.pjrc` if you want to use PJRC stack or use `Makefile.lufa` for LUFA stack.
|
||||||
|
|
||||||
|
|
||||||
## Boot Magic
|
## Boot Magic
|
||||||
|
Plugin pressing these `Boot Magic` key.
|
||||||
|
|
||||||
- `Fn` key for bootloader kick up.
|
- `Fn` key for bootloader kick up.
|
||||||
- `D` key for Debug enable.
|
- `D` key for Debug enable.
|
||||||
|
|
||||||
|
|
||||||
## Keymap
|
## Keymap
|
||||||
Two version of keymap are available. `Plan` and `Funky`.
|
Two version of keymap are available. `Plan`, `Poker` and `Funky`(default).
|
||||||
See keymap.c to define your own favourite keymap.
|
See keymap.c to define your own favourite keymap.
|
||||||
|
|
||||||
|
$ make -f Makefile.[pjrc|lufa] [plain|poker]
|
||||||
|
|
||||||
### 1. Plain keymap
|
### 1. Plain keymap
|
||||||
This will be useful if you want to use key mapping tool like AHK.
|
This will be useful if you want to use key mapping tool like AHK.
|
||||||
To get this plain keymap do `make`:
|
|
||||||
|
|
||||||
$ make -f Makefile.[pjrc|lufa] plain
|
See [keymap_plain.h](keymap_plain.h) for detail.
|
||||||
|
|
||||||
### Layer 0
|
#### 1.0 Plain Default Layer
|
||||||
,-----------------------------------------------------------.
|
,-----------------------------------------------------------.
|
||||||
|Esc| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Backsp |
|
|Esc| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Backsp |
|
||||||
|-----------------------------------------------------------|
|
|-----------------------------------------------------------|
|
||||||
|
@ -41,12 +46,71 @@ To get this plain keymap do `make`:
|
||||||
|Ctrl|Gui |Alt | Space |Alt |Gui |App |Ctrl|
|
|Ctrl|Gui |Alt | Space |Alt |Gui |App |Ctrl|
|
||||||
`-----------------------------------------------------------'
|
`-----------------------------------------------------------'
|
||||||
|
|
||||||
|
### 2 Poker keymap
|
||||||
|
Poker layer emulation without Esc/grave bug :)
|
||||||
|
|
||||||
### 2. Funky layers.
|
See [keymap_poker.h](keymap_poker.h) for detail.
|
||||||
|
|
||||||
$ make -f Makefile.[pjrc|lufa]
|
#### 2.0 Poker Default Layer
|
||||||
|
,-----------------------------------------------------------.
|
||||||
|
| `| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Backsp |
|
||||||
|
|-----------------------------------------------------------|
|
||||||
|
|Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| \|
|
||||||
|
|-----------------------------------------------------------|
|
||||||
|
|Caps | A| S| D| F| G| H| J| K| L| ;| '|Return |
|
||||||
|
|-----------------------------------------------------------|
|
||||||
|
|Shift | Z| X| C| V| B| N| M| ,| .| /|Shift |
|
||||||
|
|-----------------------------------------------------------|
|
||||||
|
|Ctrl|Gui |Alt | Space |Fn |Gui |App |Ctrl|
|
||||||
|
`-----------------------------------------------------------'
|
||||||
|
|
||||||
#### Layer 0: Default Layer
|
#### 2.1 Poker Arrow Layer
|
||||||
|
,-----------------------------------------------------------.
|
||||||
|
| | | | | | | | | | | | | | |
|
||||||
|
|-----------------------------------------------------------|
|
||||||
|
| | | | | | | | | | | | | | |
|
||||||
|
|-----------------------------------------------------------|
|
||||||
|
| | | | | | | | | | | | | |
|
||||||
|
|-----------------------------------------------------------|
|
||||||
|
| | | | | | | | | | | | Up |
|
||||||
|
|-----------------------------------------------------------|
|
||||||
|
| | | | |Fn |Left|Down|Righ|
|
||||||
|
`-----------------------------------------------------------'
|
||||||
|
|
||||||
|
#### 2.2 Poker Esc Layer
|
||||||
|
,-----------------------------------------------------------.
|
||||||
|
|Esc| | | | | | | | | | | | | |
|
||||||
|
|-----------------------------------------------------------|
|
||||||
|
| | | | | | | | | | | | | | |
|
||||||
|
|-----------------------------------------------------------|
|
||||||
|
| | | | | | | | | | | | | |
|
||||||
|
|-----------------------------------------------------------|
|
||||||
|
| | | | | | | | | | | | |
|
||||||
|
|-----------------------------------------------------------|
|
||||||
|
| | | | |Fn | | | |
|
||||||
|
`-----------------------------------------------------------'
|
||||||
|
|
||||||
|
#### 2.1 Poker Fn Layer
|
||||||
|
,-----------------------------------------------------------.
|
||||||
|
|Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12| |
|
||||||
|
|-----------------------------------------------------------|
|
||||||
|
| |FnQ| Up| | | | | | |Cal| |Hom|Ins| |
|
||||||
|
|-----------------------------------------------------------|
|
||||||
|
| |Lef|Dow|Rig| | |Psc|Slk|Pau| |Tsk|End| |
|
||||||
|
|-----------------------------------------------------------|
|
||||||
|
| |Del| |Web|Mut|VoU|VoD| |PgU|PgD|Del| |
|
||||||
|
|-----------------------------------------------------------|
|
||||||
|
| | | | FnS |Fn | | | |
|
||||||
|
`-----------------------------------------------------------'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
### 3. Funky keymap
|
||||||
|
This is my keymap(default) with HHKB, Vi cursor and Mousekey layer.
|
||||||
|
|
||||||
|
See [keymap.h](keymap.h) for detail.
|
||||||
|
|
||||||
|
#### 3.0 Funky Default Layer
|
||||||
,-----------------------------------------------------------.
|
,-----------------------------------------------------------.
|
||||||
|Esc| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Backsp |
|
|Esc| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Backsp |
|
||||||
|-----------------------------------------------------------|
|
|-----------------------------------------------------------|
|
||||||
|
@ -59,7 +123,7 @@ To get this plain keymap do `make`:
|
||||||
|Ctrl|Gui |Alt | Space |Alt |*L3 |*L3 |*L1 |
|
|Ctrl|Gui |Alt | Space |Alt |*L3 |*L3 |*L1 |
|
||||||
`-----------------------------------------------------------'
|
`-----------------------------------------------------------'
|
||||||
|
|
||||||
#### Layer 1: HHKB mode
|
#### 3.1 Funky HHKB mode
|
||||||
,-----------------------------------------------------------.
|
,-----------------------------------------------------------.
|
||||||
|Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Delete |
|
|Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Delete |
|
||||||
|-----------------------------------------------------------|
|
|-----------------------------------------------------------|
|
||||||
|
@ -72,7 +136,7 @@ To get this plain keymap do `make`:
|
||||||
|Ctrl|Gui |Alt | Space |Alt |Gui |App |*L0 |
|
|Ctrl|Gui |Alt | Space |Alt |Gui |App |*L0 |
|
||||||
`-----------------------------------------------------------'
|
`-----------------------------------------------------------'
|
||||||
|
|
||||||
#### Layer 2: Vi mode
|
#### 3.2 Funky Vi mode
|
||||||
,-----------------------------------------------------------.
|
,-----------------------------------------------------------.
|
||||||
| `| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Backsp |
|
| `| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Backsp |
|
||||||
|-----------------------------------------------------------|
|
|-----------------------------------------------------------|
|
||||||
|
@ -85,7 +149,7 @@ To get this plain keymap do `make`:
|
||||||
|Ctrl|Gui |Alt | Space |Alt |Gui |App |Ctrl|
|
|Ctrl|Gui |Alt | Space |Alt |Gui |App |Ctrl|
|
||||||
`-----------------------------------------------------------'
|
`-----------------------------------------------------------'
|
||||||
|
|
||||||
#### Layer 3: Mouse mode
|
#### 3.3 Funky Mouse mode
|
||||||
,-----------------------------------------------------------.
|
,-----------------------------------------------------------.
|
||||||
| `| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Backsp |
|
| `| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Backsp |
|
||||||
|-----------------------------------------------------------|
|
|-----------------------------------------------------------|
|
||||||
|
@ -98,4 +162,3 @@ To get this plain keymap do `make`:
|
||||||
|Ctrl|Gui |Alt | Space |Alt |*L0 |*L0 |Ctrl|
|
|Ctrl|Gui |Alt | Space |Alt |*L0 |*L0 |Ctrl|
|
||||||
`-----------------------------------------------------------'
|
`-----------------------------------------------------------'
|
||||||
Mc: Mouse Cursor / Mb: Mouse Button / Mw: Mouse Wheel
|
Mc: Mouse Cursor / Mb: Mouse Button / Mw: Mouse Wheel
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
Copyright 2012 Jun Wako <wakojun@gmail.com>
|
Copyright 2012,2013 Jun Wako <wakojun@gmail.com>
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
|
@ -18,9 +18,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <avr/pgmspace.h>
|
#include <avr/pgmspace.h>
|
||||||
#include "keycode.h"
|
#include "keycode.h"
|
||||||
|
#include "action.h"
|
||||||
|
#include "action_macro.h"
|
||||||
|
#include "report.h"
|
||||||
|
#include "host.h"
|
||||||
#include "print.h"
|
#include "print.h"
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
#include "util.h"
|
|
||||||
#include "keymap.h"
|
#include "keymap.h"
|
||||||
|
|
||||||
|
|
||||||
|
@ -56,55 +59,16 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
K40, K41, K42, K45, K4A, K4B, K4C, K4D \
|
K40, K41, K42, K45, K4A, K4B, K4C, K4D \
|
||||||
)
|
)
|
||||||
|
|
||||||
#define KEYCODE(layer, row, col) (pgm_read_byte(&keymaps[(layer)][(row)][(col)]))
|
|
||||||
|
|
||||||
|
#if defined(KEYMAP_PLAIN)
|
||||||
// Assign Fn key(0-7) to a layer to which switch with the Fn key pressed.
|
#include "keymap_plain.h"
|
||||||
static const uint8_t PROGMEM fn_layer[] = {
|
#elif defined(KEYMAP_POKER)
|
||||||
0, // Fn0
|
#include "keymap_poker.h"
|
||||||
1, // Fn1
|
|
||||||
2, // Fn2
|
|
||||||
3, // Fn3
|
|
||||||
3, // Fn4
|
|
||||||
0, // Fn5
|
|
||||||
0, // Fn6
|
|
||||||
0 // Fn7
|
|
||||||
};
|
|
||||||
|
|
||||||
// Assign Fn key(0-7) to a keycode sent when release Fn key without use of the layer.
|
|
||||||
// See layer.c for details.
|
|
||||||
static const uint8_t PROGMEM fn_keycode[] = {
|
|
||||||
KC_NO, // Fn0
|
|
||||||
KC_NO, // Fn1
|
|
||||||
KC_SLSH, // Fn2
|
|
||||||
KC_SCLN, // Fn3
|
|
||||||
KC_NO, // Fn4
|
|
||||||
KC_NO, // Fn5
|
|
||||||
KC_NO, // Fn6
|
|
||||||
KC_NO // Fn7
|
|
||||||
};
|
|
||||||
|
|
||||||
static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
|
||||||
#ifdef PLAIN_MAP
|
|
||||||
/* Layer 0: Default Layer
|
|
||||||
* ,-----------------------------------------------------------.
|
|
||||||
* |Esc| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Backsp |
|
|
||||||
* |-----------------------------------------------------------|
|
|
||||||
* |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| \|
|
|
||||||
* |-----------------------------------------------------------|
|
|
||||||
* |Caps | A| S| D| F| G| H| J| K| L| ;| '|Return |
|
|
||||||
* |-----------------------------------------------------------|
|
|
||||||
* |Shift | Z| X| C| V| B| N| M| ,| .| /|Shift |
|
|
||||||
* |-----------------------------------------------------------|
|
|
||||||
* |Ctrl|Gui |Alt | Space |Alt |Gui |App |Ctrl|
|
|
||||||
* `-----------------------------------------------------------'
|
|
||||||
*/
|
|
||||||
KEYMAP(ESC, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSPC, \
|
|
||||||
TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC,BSLS, \
|
|
||||||
CAPS,A, S, D, F, G, H, J, K, L, SCLN,QUOT,NO, ENT, \
|
|
||||||
LSFT,NO, Z, X, C, V, B, N, M, COMM,DOT, SLSH,NO, RSFT, \
|
|
||||||
LCTL,LGUI,LALT, SPC, RALT,RGUI,APP, RCTL),
|
|
||||||
#else
|
#else
|
||||||
|
static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||||
|
/*
|
||||||
|
* Funky
|
||||||
|
*/
|
||||||
/* Layer 0: Default Layer
|
/* Layer 0: Default Layer
|
||||||
* ,-----------------------------------------------------------.
|
* ,-----------------------------------------------------------.
|
||||||
* |Esc| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Backsp |
|
* |Esc| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Backsp |
|
||||||
|
@ -134,7 +98,7 @@ static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||||
* |-----------------------------------------------------------|
|
* |-----------------------------------------------------------|
|
||||||
* |Shift | | | | | | +| -|End|PgD|Dow|Shift |
|
* |Shift | | | | | | +| -|End|PgD|Dow|Shift |
|
||||||
* |-----------------------------------------------------------|
|
* |-----------------------------------------------------------|
|
||||||
* |Ctrl|Gui |Alt | Space |Alt |Gui |App |xxx |
|
* |Ctrl|Gui |Alt | Space |Alt |Gui |App |Fn0 |
|
||||||
* `-----------------------------------------------------------'
|
* `-----------------------------------------------------------'
|
||||||
*/
|
*/
|
||||||
KEYMAP_ANSI(
|
KEYMAP_ANSI(
|
||||||
|
@ -142,7 +106,7 @@ static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||||
CAPS,NO, NO, NO, NO, NO, NO, NO, PSCR,SLCK,PAUS,UP, NO, INS, \
|
CAPS,NO, NO, NO, NO, NO, NO, NO, PSCR,SLCK,PAUS,UP, NO, INS, \
|
||||||
LCTL,VOLD,VOLU,MUTE,NO, NO, PAST,PSLS,HOME,PGUP,LEFT,RGHT, ENT, \
|
LCTL,VOLD,VOLU,MUTE,NO, NO, PAST,PSLS,HOME,PGUP,LEFT,RGHT, ENT, \
|
||||||
LSFT,NO, NO, NO, NO, NO, PPLS,PMNS,END, PGDN,DOWN, RSFT, \
|
LSFT,NO, NO, NO, NO, NO, PPLS,PMNS,END, PGDN,DOWN, RSFT, \
|
||||||
LCTL,LGUI,LALT, SPC, RALT,RGUI,APP, FN1),
|
LCTL,LGUI,LALT, SPC, RALT,RGUI,APP, FN0),
|
||||||
/* Layer 2: Vi mode (Slash)
|
/* Layer 2: Vi mode (Slash)
|
||||||
* ,-----------------------------------------------------------.
|
* ,-----------------------------------------------------------.
|
||||||
* | `| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Backsp |
|
* | `| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Backsp |
|
||||||
|
@ -151,7 +115,7 @@ static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||||
* |-----------------------------------------------------------|
|
* |-----------------------------------------------------------|
|
||||||
* |Contro| |Lef|Dow|Rig| |Lef|Dow|Up |Rig| | |Return |
|
* |Contro| |Lef|Dow|Rig| |Lef|Dow|Up |Rig| | |Return |
|
||||||
* |-----------------------------------------------------------|
|
* |-----------------------------------------------------------|
|
||||||
* |Shift | | | | | |Hom|PgD|PgU|End|xxx|Shift |
|
* |Shift | | | | | |Hom|PgD|PgU|End|Fn0|Shift |
|
||||||
* |-----------------------------------------------------------|
|
* |-----------------------------------------------------------|
|
||||||
* |Ctrl|Gui |Alt | Space |Alt |Gui |App |Ctrl|
|
* |Ctrl|Gui |Alt | Space |Alt |Gui |App |Ctrl|
|
||||||
* `-----------------------------------------------------------'
|
* `-----------------------------------------------------------'
|
||||||
|
@ -160,7 +124,7 @@ static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||||
GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, BSPC, \
|
GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, BSPC, \
|
||||||
TAB, HOME,PGDN,UP, PGUP,END, HOME,PGDN,PGUP,END, NO, NO, NO, NO, \
|
TAB, HOME,PGDN,UP, PGUP,END, HOME,PGDN,PGUP,END, NO, NO, NO, NO, \
|
||||||
LCTL,NO, LEFT,DOWN,RGHT,NO, LEFT,DOWN,UP, RGHT,NO, NO, ENT, \
|
LCTL,NO, LEFT,DOWN,RGHT,NO, LEFT,DOWN,UP, RGHT,NO, NO, ENT, \
|
||||||
LSFT,NO, NO, NO, NO, NO, HOME,PGDN,PGUP,END, FN2, RSFT, \
|
LSFT,NO, NO, NO, NO, NO, HOME,PGDN,PGUP,END, FN0, RSFT, \
|
||||||
LCTL,LGUI,LALT, SPC, RALT,RGUI,APP, RCTL),
|
LCTL,LGUI,LALT, SPC, RALT,RGUI,APP, RCTL),
|
||||||
/* Layer 3: Mouse mode (Semicolon/App)
|
/* Layer 3: Mouse mode (Semicolon/App)
|
||||||
* ,-----------------------------------------------------------.
|
* ,-----------------------------------------------------------.
|
||||||
|
@ -168,35 +132,65 @@ static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||||
* |-----------------------------------------------------------|
|
* |-----------------------------------------------------------|
|
||||||
* |Tab | | | | | |MwL|MwD|MwU|MwR| | | | |
|
* |Tab | | | | | |MwL|MwD|MwU|MwR| | | | |
|
||||||
* |-----------------------------------------------------------|
|
* |-----------------------------------------------------------|
|
||||||
* |Contro| |Ac0|Ac1|Ac1| |McL|McD|McU|McR|xxx| |Return |
|
* |Contro| |Ac0|Ac1|Ac1| |McL|McD|McU|McR|Fn0| |Return |
|
||||||
* |-----------------------------------------------------------|
|
* |-----------------------------------------------------------|
|
||||||
* |Shift | | | | |Mb3|Mb2|Mb1|Mb4|Mb5| |Shift |
|
* |Shift | | | | |Mb3|Mb2|Mb1|Mb4|Mb5| |Shift |
|
||||||
* |-----------------------------------------------------------|
|
* |-----------------------------------------------------------|
|
||||||
* |Ctrl|Gui |Alt | Space | |xxx |xxx | |
|
* |Ctrl|Gui |Alt | Space | |Fn0 |Fn0 | |
|
||||||
* `-----------------------------------------------------------'
|
* `-----------------------------------------------------------'
|
||||||
* Mc: Mouse Cursor / Mb: Mouse Button / Mw: Mouse Wheel
|
* Mc: Mouse Cursor / Mb: Mouse Button / Mw: Mouse Wheel
|
||||||
*/
|
*/
|
||||||
KEYMAP_ANSI(
|
KEYMAP_ANSI(
|
||||||
GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, BSPC, \
|
GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, BSPC, \
|
||||||
TAB, NO, NO, NO, NO, NO, WH_L,WH_D,WH_U,WH_R,NO, NO, NO, NO, \
|
TAB, NO, NO, NO, NO, NO, WH_L,WH_D,WH_U,WH_R,NO, NO, NO, NO, \
|
||||||
LCTL,NO, ACL0,ACL1,ACL2,NO, MS_L,MS_D,MS_U,MS_R,FN3, NO, ENT, \
|
LCTL,NO, ACL0,ACL1,ACL2,NO, MS_L,MS_D,MS_U,MS_R,FN0, NO, ENT, \
|
||||||
LSFT,NO, NO, NO, NO, BTN3,BTN2,BTN1,BTN4,BTN5,NO, RSFT, \
|
LSFT,NO, NO, NO, NO, BTN3,BTN2,BTN1,BTN4,BTN5,NO, RSFT, \
|
||||||
LCTL,LGUI,LALT, BTN1, NO, FN4, FN4, NO ),
|
LCTL,LGUI,LALT, BTN1, NO, FN0, FN0, NO ),
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Fn action definition
|
||||||
|
*/
|
||||||
|
static const uint16_t PROGMEM fn_actions[] = {
|
||||||
|
ACTION_LAYER_DEFAULT, // FN0
|
||||||
|
ACTION_LAYER_SET(1), // FN1
|
||||||
|
ACTION_LAYER_SET_TAP_KEY(2, KC_SLASH), // FN2 Layer with Slash
|
||||||
|
ACTION_LAYER_SET_TAP_KEY(3, KC_SCLN), // FN3 Layer with Semicolon
|
||||||
|
ACTION_LAYER_SET(3), // FN4
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
uint8_t keymap_get_keycode(uint8_t layer, uint8_t row, uint8_t col)
|
|
||||||
|
|
||||||
|
/* translates key to keycode */
|
||||||
|
uint8_t keymap_key_to_keycode(uint8_t layer, key_t key)
|
||||||
{
|
{
|
||||||
return KEYCODE(layer, row, col);
|
return pgm_read_byte(&keymaps[(layer)][(key.pos.row)][(key.pos.col)]);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t keymap_fn_layer(uint8_t index)
|
/* translates Fn index to action */
|
||||||
|
action_t keymap_fn_to_action(uint8_t keycode)
|
||||||
{
|
{
|
||||||
return pgm_read_byte(&fn_layer[index]);
|
action_t action;
|
||||||
|
if (FN_INDEX(keycode) < sizeof(fn_actions) / sizeof(fn_actions[0])) {
|
||||||
|
action.code = pgm_read_word(&fn_actions[FN_INDEX(keycode)]);
|
||||||
|
} else {
|
||||||
|
action.code = ACTION_NO;
|
||||||
|
}
|
||||||
|
return action;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t keymap_fn_keycode(uint8_t index)
|
/* convert key to action */
|
||||||
|
action_t keymap_get_action(uint8_t layer, uint8_t row, uint8_t col)
|
||||||
{
|
{
|
||||||
return pgm_read_byte(&fn_keycode[index]);
|
key_t key;
|
||||||
|
key.pos.row = row;
|
||||||
|
key.pos.col = col;
|
||||||
|
uint8_t keycode = keymap_key_to_keycode(layer, key);
|
||||||
|
switch (keycode) {
|
||||||
|
case KC_FN0 ... KC_FN31:
|
||||||
|
return keymap_fn_to_action(keycode);
|
||||||
|
default:
|
||||||
|
return keymap_keycode_to_action(keycode);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,24 @@
|
||||||
|
static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||||
|
/*
|
||||||
|
* Plain
|
||||||
|
*/
|
||||||
|
/* Layer 0: Default Layer
|
||||||
|
* ,-----------------------------------------------------------.
|
||||||
|
* |Esc| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Backsp |
|
||||||
|
* |-----------------------------------------------------------|
|
||||||
|
* |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| \|
|
||||||
|
* |-----------------------------------------------------------|
|
||||||
|
* |Caps | A| S| D| F| G| H| J| K| L| ;| '|Return |
|
||||||
|
* |-----------------------------------------------------------|
|
||||||
|
* |Shift | Z| X| C| V| B| N| M| ,| .| /|Shift |
|
||||||
|
* |-----------------------------------------------------------|
|
||||||
|
* |Ctrl|Gui |Alt | Space |Alt |Gui |App |Ctrl|
|
||||||
|
* `-----------------------------------------------------------'
|
||||||
|
*/
|
||||||
|
KEYMAP(ESC, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSPC, \
|
||||||
|
TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC,BSLS, \
|
||||||
|
CAPS,A, S, D, F, G, H, J, K, L, SCLN,QUOT,NO, ENT, \
|
||||||
|
LSFT,NO, Z, X, C, V, B, N, M, COMM,DOT, SLSH,NO, RSFT, \
|
||||||
|
LCTL,LGUI,LALT, SPC, RALT,RGUI,APP, RCTL),
|
||||||
|
};
|
||||||
|
|
|
@ -0,0 +1,88 @@
|
||||||
|
static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||||
|
/*
|
||||||
|
* Poker Layer
|
||||||
|
*/
|
||||||
|
/* Layer x000: Poker Default Layer
|
||||||
|
* ,-----------------------------------------------------------.
|
||||||
|
* | `| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Backsp |
|
||||||
|
* |-----------------------------------------------------------|
|
||||||
|
* |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| \|
|
||||||
|
* |-----------------------------------------------------------|
|
||||||
|
* |Caps | A| S| D| F| G| H| J| K| L| ;| '|Return |
|
||||||
|
* |-----------------------------------------------------------|
|
||||||
|
* |Shift | Z| X| C| V| B| N| M| ,| .| /|Shift |
|
||||||
|
* |-----------------------------------------------------------|
|
||||||
|
* |Ctrl|Gui |Alt | Space |Fn |Gui |App |Ctrl|
|
||||||
|
* `-----------------------------------------------------------'
|
||||||
|
*/
|
||||||
|
KEYMAP_ANSI(
|
||||||
|
GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSPC, \
|
||||||
|
TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC,BSLS, \
|
||||||
|
LCTL,A, S, D, F, G, H, J, K, L, SCLN,QUOT, ENT, \
|
||||||
|
LSFT,Z, X, C, V, B, N, M, COMM,DOT, SLSH, RSFT, \
|
||||||
|
LCTL,LGUI,LALT, SPC, FN2, RGUI,APP, RCTL),
|
||||||
|
/* Layer x001: Poker with Arrow */
|
||||||
|
KEYMAP_ANSI(
|
||||||
|
TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, \
|
||||||
|
TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, \
|
||||||
|
TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, TRNS, \
|
||||||
|
TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, UP, \
|
||||||
|
TRNS,TRNS,TRNS, TRNS, FN2, LEFT,DOWN,RGHT),
|
||||||
|
/* Layer x010: Poker with Esc */
|
||||||
|
KEYMAP_ANSI(
|
||||||
|
ESC, TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, \
|
||||||
|
TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, \
|
||||||
|
TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, TRNS, \
|
||||||
|
TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, TRNS, \
|
||||||
|
TRNS,TRNS,TRNS, TRNS, FN2, TRNS,TRNS,TRNS),
|
||||||
|
/* Layer x011: Poker with Arrow and Esc */
|
||||||
|
KEYMAP_ANSI(
|
||||||
|
ESC, TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, \
|
||||||
|
TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, \
|
||||||
|
TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, TRNS, \
|
||||||
|
TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, UP, \
|
||||||
|
TRNS,TRNS,TRNS, TRNS, FN2, LEFT,DOWN,RGHT),
|
||||||
|
/*
|
||||||
|
* Poker Momentary Fn Layer
|
||||||
|
*/
|
||||||
|
/* Layer x100: Poker Default + Fn'd */
|
||||||
|
KEYMAP_ANSI(
|
||||||
|
ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, TRNS, \
|
||||||
|
TRNS,FN1, UP, TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,CALC,TRNS,HOME,INS, TRNS, \
|
||||||
|
TRNS,LEFT,DOWN,RGHT,TRNS,TRNS,PSCR,SLCK,PAUS,TRNS,FN3, END, TRNS, \
|
||||||
|
TRNS,DEL, TRNS,WHOM,MUTE,VOLU,VOLD,TRNS,PGUP,PGDN,DEL, TRNS, \
|
||||||
|
TRNS,TRNS,TRNS, FN0, FN2, TRNS,TRNS,TRNS),
|
||||||
|
/* Layer x101: Poker with Arrow + Fn'd */
|
||||||
|
KEYMAP_ANSI(
|
||||||
|
ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, TRNS, \
|
||||||
|
TRNS,FN1, UP, TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,CALC,TRNS,HOME,INS, TRNS, \
|
||||||
|
TRNS,LEFT,DOWN,RGHT,TRNS,TRNS,PSCR,SLCK,PAUS,TRNS,FN3, END, TRNS, \
|
||||||
|
TRNS,DEL, TRNS,WHOM,MUTE,VOLU,VOLD,TRNS,PGUP,PGDN,DEL, UP, \
|
||||||
|
TRNS,TRNS,TRNS, FN0, FN2, LEFT,DOWN,RGHT),
|
||||||
|
/* Layer x110: Poker with Esc + Fn'd */
|
||||||
|
KEYMAP_ANSI(
|
||||||
|
GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, TRNS, \
|
||||||
|
TRNS,FN1, UP, TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,CALC,TRNS,HOME,INS, TRNS, \
|
||||||
|
TRNS,LEFT,DOWN,RGHT,TRNS,TRNS,PSCR,SLCK,PAUS,TRNS,FN3, END, TRNS, \
|
||||||
|
TRNS,DEL, TRNS,WHOM,MUTE,VOLU,VOLD,TRNS,PGUP,PGDN,DEL, TRNS, \
|
||||||
|
TRNS,TRNS,TRNS, FN0, FN2, TRNS,TRNS,TRNS),
|
||||||
|
/* Layer x111: Poker with Arrow and Esc + Fn'd */
|
||||||
|
KEYMAP_ANSI(
|
||||||
|
GRV, F9, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, TRNS, \
|
||||||
|
TRNS,FN1, UP, TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,CALC,TRNS,HOME,INS, TRNS, \
|
||||||
|
TRNS,LEFT,DOWN,RGHT,TRNS,TRNS,PSCR,SLCK,PAUS,TRNS,FN3, END, TRNS, \
|
||||||
|
TRNS,DEL, TRNS,WHOM,MUTE,VOLU,VOLD,TRNS,PGUP,PGDN,DEL, UP, \
|
||||||
|
TRNS,TRNS,TRNS, FN0, FN2, LEFT,DOWN,RGHT),
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Fn action definition
|
||||||
|
*/
|
||||||
|
static const uint16_t PROGMEM fn_actions[] = {
|
||||||
|
/* Poker Layout */
|
||||||
|
[0] = ACTION_LAYER_BIT_TOGGLE(1), // FN0 Poker Arrow toggle(Space)
|
||||||
|
[1] = ACTION_LAYER_BIT_TOGGLE(2), // FN1 Poker Esc toggle(Q)
|
||||||
|
[2] = ACTION_LAYER_BIT(4), // FN2 Poker Fn
|
||||||
|
[3] = ACTION_RMODS_KEY(MOD_BIT(KC_RCTL)|MOD_BIT(KC_RSFT), KC_ESC), // FN3 Task(RControl,RShift+Esc)
|
||||||
|
};
|
||||||
|
|
|
@ -24,6 +24,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#include "keycode.h"
|
#include "keycode.h"
|
||||||
#include "action.h"
|
#include "action.h"
|
||||||
#include "action_macro.h"
|
#include "action_macro.h"
|
||||||
|
#include "report.h"
|
||||||
#include "host.h"
|
#include "host.h"
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
#include "keymap.h"
|
#include "keymap.h"
|
||||||
|
@ -48,7 +49,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// TODO: use [1] = KEYMAP(...) to prevent from changing index of element?
|
|
||||||
static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||||
/* Layer 0: Default Layer
|
/* Layer 0: Default Layer
|
||||||
* ,-----------------------------------------------------------.
|
* ,-----------------------------------------------------------.
|
||||||
|
@ -309,40 +309,37 @@ void keymap_call_function(keyrecord_t *record, uint8_t id, uint8_t opt)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* convert keycode to action */
|
|
||||||
action_t keymap_get_action(uint8_t layer, uint8_t row, uint8_t col) {
|
|
||||||
uint8_t key = (pgm_read_byte(&keymaps[(layer)][(row)][(col)]));
|
/* translates key to keycode */
|
||||||
|
uint8_t keymap_key_to_keycode(uint8_t layer, key_t key)
|
||||||
|
{
|
||||||
|
return pgm_read_byte(&keymaps[(layer)][(key.pos.row)][(key.pos.col)]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* translates Fn index to action */
|
||||||
|
action_t keymap_fn_to_action(uint8_t keycode)
|
||||||
|
{
|
||||||
action_t action;
|
action_t action;
|
||||||
switch (key) {
|
if (FN_INDEX(keycode) < sizeof(fn_actions) / sizeof(fn_actions[0])) {
|
||||||
case KC_A ... KC_EXSEL:
|
action.code = pgm_read_word(&fn_actions[FN_INDEX(keycode)]);
|
||||||
action.code = ACTION_KEY(key);
|
} else {
|
||||||
break;
|
action.code = ACTION_NO;
|
||||||
case KC_LCTRL ... KC_LGUI:
|
|
||||||
action.code = ACTION_LMOD(key);
|
|
||||||
break;
|
|
||||||
case KC_RCTRL ... KC_RGUI:
|
|
||||||
action.code = ACTION_RMOD(key);
|
|
||||||
break;
|
|
||||||
case KC_SYSTEM_POWER ... KC_SYSTEM_WAKE:
|
|
||||||
action.code = ACTION_USAGE_SYSTEM(KEYCODE2SYSTEM(key));
|
|
||||||
break;
|
|
||||||
case KC_AUDIO_MUTE ... KC_WWW_FAVORITES:
|
|
||||||
action.code = ACTION_USAGE_CONSUMER(KEYCODE2CONSUMER(key));
|
|
||||||
break;
|
|
||||||
case KC_MS_UP ... KC_MS_ACCEL2:
|
|
||||||
action.code = ACTION_MOUSEKEY(key);
|
|
||||||
break;
|
|
||||||
case KC_FN0 ... KC_FN31:
|
|
||||||
if (FN_INDEX(key) < sizeof(fn_actions) / sizeof(fn_actions[0])) {
|
|
||||||
action.code = pgm_read_word(&fn_actions[FN_INDEX(key)]);
|
|
||||||
} else {
|
|
||||||
action.code = ACTION_NO;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case KC_NO ... KC_UNDEFINED:
|
|
||||||
default:
|
|
||||||
action.code = ACTION_NO;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
return action;
|
return action;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* convert key to action */
|
||||||
|
action_t keymap_get_action(uint8_t layer, uint8_t row, uint8_t col)
|
||||||
|
{
|
||||||
|
key_t key;
|
||||||
|
key.pos.row = row;
|
||||||
|
key.pos.col = col;
|
||||||
|
uint8_t keycode = keymap_key_to_keycode(layer, key);
|
||||||
|
switch (keycode) {
|
||||||
|
case KC_FN0 ... KC_FN31:
|
||||||
|
return keymap_fn_to_action(keycode);
|
||||||
|
default:
|
||||||
|
return keymap_keycode_to_action(keycode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue