1
0
Fork 0

function stuff too

This commit is contained in:
Jack Humbert 2015-03-20 22:49:32 -04:00
parent a94beded1a
commit 5c45ba947c
3 changed files with 18 additions and 4 deletions

View file

@ -33,10 +33,12 @@ action_t action_for_key(uint8_t layer, keypos_t key)
uint16_t keycode = keymap_key_to_keycode(layer, key);
// Handle mods in keymap
if (keycode > 0x00FF) {
if (keycode > 0x00FF && keycode < 0x2000) {
action_t action;
action.code = ACTION_MODS_KEY(keycode >> 8, keycode & 0xFF);
return action;
} else if (keycode > 0x1FFF && keycode < 0x3000) {
return keymap_func_to_action(keycode & 0xFFF);
}
switch (keycode) {
@ -169,3 +171,9 @@ action_t keymap_fn_to_action(uint16_t keycode)
{
return (action_t){ .code = pgm_read_word(&fn_actions[FN_INDEX(keycode)]) };
}
/* translates Fn keycode to action */
action_t keymap_func_to_action(uint16_t keycode)
{
return (action_t){ .code = pgm_read_word(&fn_actions[(int)keycode]) };
}

View file

@ -54,6 +54,9 @@ uint16_t keymap_key_to_keycode(uint8_t layer, keypos_t key);
/* translates Fn keycode to action */
action_t keymap_fn_to_action(uint16_t keycode);
/* translates Fn keycode to action */
action_t keymap_func_to_action(uint16_t keycode);
extern const uint16_t keymaps[][MATRIX_ROWS][MATRIX_COLS];
extern const uint16_t fn_actions[];
@ -67,6 +70,9 @@ extern const uint16_t fn_actions[];
#define RALT(kc) kc | 0x1400
#define RGUI(kc) kc | 0x1800
#define FUNC(kc) kc | 0x2000
#define S(kc) LSFT(kc)
#define F(kc) FUNC(kc)
#endif

View file

@ -5,7 +5,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
{KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSPC},
{KC_ESC, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT},
{KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_ENT},
{KC_RSFT, KC_LCTL, KC_LALT, KC_LGUI, KC_FN2, KC_SPC, KC_NO, KC_FN1, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT}
{KC_RSFT, KC_LCTL, KC_LALT, KC_LGUI, FUNC(2), KC_SPC, KC_NO, KC_FN1, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT}
},
[1] = { /* Jack colemak */
{KC_TAB, KC_Q, KC_W, KC_F, KC_P, KC_G, KC_J, KC_L, KC_U, KC_Y, KC_SCLN, KC_BSPC},
@ -21,7 +21,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
},
[3] = { /* Jack LOWER */
{S(KC_GRV), S(KC_1), S(KC_2), S(KC_3), S(KC_4), S(KC_5), S(KC_6), S(KC_7), S(KC_8), S(KC_9), S(KC_0), KC_BSPC},
{KC_TRNS, KC_FN3, KC_FN4, KC_PAUSE, KC_TRNS, KC_TRNS, KC_TRNS, S(KC_MINS), S(KC_EQL), S(KC_LBRC), S(KC_RBRC), S(KC_BSLS)},
{KC_TRNS, FUNC(3), KC_FN4, LSFT(RSFT(KC_PAUSE)), KC_TRNS, KC_TRNS, KC_TRNS, S(KC_MINS), S(KC_EQL), S(KC_LBRC), S(KC_RBRC), S(KC_BSLS)},
{KC_TRNS, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_TRNS},
{KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_FN2, KC_TRNS, KC_NO, KC_TRNS, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY}
}
@ -33,4 +33,4 @@ const uint16_t PROGMEM fn_actions[] = {
[3] = ACTION_DEFAULT_LAYER_SET(0),
[4] = ACTION_DEFAULT_LAYER_SET(1),
};
};