Skip to content

Commit

Permalink
Migrate more fn_actions stuff (#13502)
Browse files Browse the repository at this point in the history
  • Loading branch information
fauxpark authored Jul 14, 2021
1 parent e69c325 commit fd8628c
Show file tree
Hide file tree
Showing 17 changed files with 497 additions and 791 deletions.
15 changes: 2 additions & 13 deletions keyboards/atreus/keymaps/erlandsona/keymap.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
// this is the style you want to emulate.
// This is the canonical layout file for the Quantum project. If you want to add another keyboard,

#include QMK_KEYBOARD_H

// Each layer gets a name for readability, which is then used in the keymap matrix below.
Expand All @@ -23,21 +20,13 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
KC_GRV , KC_1 , KC_2 , KC_3 , KC_4 , KC_LPRN, KC_RPRN, KC_MINS, KC_EQL , KC_LBRC,
KC_TAB , KC_5 , KC_6 , KC_7 , KC_8 , KC_LEFT, KC_DOWN, KC_UP , KC_RGHT, KC_RBRC,
_______, KC_9 , KC_0 , KC_DOT , KC_COMM, KC_HOME, KC_PGDN, KC_PGUP, KC_END , _______,
_______, _______, _______, _______, KC_DEL , F(MOUS), _______, _______, _______, _______, _______, _______
_______, _______, _______, _______, KC_DEL , TG(MOUS), _______, _______, _______, _______, _______, _______
),

[MOUS] = LAYOUT( /* Mouse and Media Keys */
KC_SLCK, KC_PAUSE, KC_F11 , KC_F10 , KC_F9 , KC_F8 , KC_F7 , KC_F6 , KC_F5 , KC_F4,
KC_VOLD, KC_ACL0 , KC_ACL1, KC_ACL2, KC_VOLU, KC_MS_L, KC_MS_D, KC_MS_U, KC_MS_R, KC_F3,
KC_MUTE, KC_MPRV , KC_MPLY, KC_MNXT, KC_MUTE, KC_WH_R, KC_WH_U, KC_WH_D, KC_WH_L, KC_F2,
_______, _______ , _______, _______, _______, _______, _______, KC_BTN1, F(BASE), RESET , KC_F12 , KC_F1
_______, _______ , _______, _______, _______, _______, _______, KC_BTN1, TO(BASE), RESET , KC_F12 , KC_F1
),
};


// I prefer this layer switching strategy to the TG and MO functions.
// so that I can get out of mouse mode just by tapping/holding my base layer FN key.
const uint16_t PROGMEM fn_actions[] = {
[BASE] = ACTION_LAYER_OFF(2, 1), // switch back to layer 0
[MOUS] = ACTION_LAYER_ON(2, 1) // switch to layer 2
};
24 changes: 0 additions & 24 deletions keyboards/atreus/keymaps/khitsule/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,6 @@ enum layers {
#define KM_DRIGHT LGUI(LCTL(KC_RIGHT))
#define TSKMGR LCTL(LSFT(KC_ESC))

#define tap_mod_macro(record, mod, macro) ( ((record)->event.pressed) ? \
( ((record)->tap.count <= 0 || (record)->tap.interrupted) ? MACRO(D(mod), END) : MACRO_NONE ) : \
( ((record)->tap.count > 0 && !((record)->tap.interrupted)) ? (macro) : MACRO(U(mod), END) ) )



const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
[ALPH] = LAYOUT(
KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P,
Expand Down Expand Up @@ -54,21 +48,3 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
RESET, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS
)
};

const uint16_t PROGMEM fn_actions[] = {
[1] = ACTION_MACRO_TAP(1),
[2] = ACTION_MACRO_TAP(2)
};

const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) {
switch(id) {
case 1:
return tap_mod_macro(record, LGUI, MACRO( D(LSFT), T(9), U(LSFT), END));
break;
case 2:
return tap_mod_macro(record, LALT, MACRO( D(LSFT), T(0), U(LSFT), END));
break;

}
return MACRO_NONE;
};
154 changes: 57 additions & 97 deletions keyboards/bpiphany/kitten_paw/keymaps/ickerwx/keymap.c
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
#include QMK_KEYBOARD_H
#include "mousekey.h"

#undef C
#undef S
#define C(kc) LCTL(KC_##kc)
#define S(kc) LSFT(KC_##kc)
#define RA(kc) RALT(KC_##kc)
#define KC_SLCT KC_SELECT
#define MEDAPP LT(MEDIA, KC_APP)

uint8_t current_layer_global = 255;
Expand All @@ -21,19 +15,16 @@ enum layers {
MISC,
};

enum function_id {
LSHFT_PAREN,
enum custom_keycodes {
LSHFT_PAREN = SAFE_RANGE,
RSHFT_PAREN,
LCTRL_BRACKET,
RCTRL_BRACKET,
LALT_CURLY,
RALT_CURLY,
CTRL_CLICK
};

enum macro_id {
GRV,
CFLEX
CTRL_CLICK,
M_GRV,
M_CFLEX
};

const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
Expand All @@ -42,25 +33,25 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0,KC_MINS, KC_EQL,KC_BSPC, KC_INS,KC_HOME,KC_PGUP, KC_NLCK,KC_PSLS,KC_PAST,KC_PMNS, \
KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P,KC_LBRC,KC_RBRC,KC_BSLS, KC_DEL, KC_END,KC_PGDN, KC_P7, KC_P8, KC_P9,KC_PPLS, \
TT(MOUSE1), KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L,KC_SCLN,KC_QUOT, KC_ENT, KC_P4, KC_P5, KC_P6, \
F(8),KC_NUBS, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M,KC_COMM, KC_DOT,KC_SLSH, F(9), KC_UP, KC_P1, KC_P2, KC_P3,KC_PENT, \
F(1),KC_LGUI, F(3), LT(MISC, KC_SPC), F(4),TT(PROG1), MEDAPP, F(2), KC_LEFT,KC_DOWN,KC_RGHT, KC_P0,KC_PDOT),
LSHFT_PAREN,KC_NUBS, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M,KC_COMM, KC_DOT,KC_SLSH, RSHFT_PAREN, KC_UP, KC_P1, KC_P2, KC_P3,KC_PENT, \
LCTRL_BRACKET,KC_LGUI, LALT_CURLY, LT(MISC, KC_SPC), RALT_CURLY,TT(PROG1), MEDAPP, RCTRL_BRACKET, KC_LEFT,KC_DOWN,KC_RGHT, KC_P0,KC_PDOT),
/* Layer 1: Programming Layer 1, emulating US l ayout */
[PROG1] = LAYOUT(\
KC_ESC,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______, _______,_______,_______, \
M(GRV),_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,KC_SLSH, S(0),_______, _______,_______,_______, _______,_______,_______,_______, \
_______,_______,_______,_______,_______,_______, KC_Z,_______,_______,_______,_______, RA(8), RA(9),RA(MINS), _______,_______,_______, _______,_______,_______,_______, \
_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,S(COMM),S(BSLS), _______, _______,_______,_______, \
MO(PROG2),_______, KC_Y,_______,_______,_______,_______,_______,_______,_______,_______, S(7), MO(PROG2), _______, _______,_______,_______,_______, \
M_GRV,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,KC_SLSH,S(KC_0),_______, _______,_______,_______, _______,_______,_______,_______, \
_______,_______,_______,_______,_______,_______, KC_Z,_______,_______,_______,_______,ALGR(KC_8),ALGR(KC_9),ALGR(KC_MINS), _______,_______,_______, _______,_______,_______,_______, \
_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,S(KC_COMM),S(KC_BSLS), _______, _______,_______,_______, \
MO(PROG2),_______, KC_Y,_______,_______,_______,_______,_______,_______,_______,_______, S(KC_7), MO(PROG2), _______, _______,_______,_______,_______, \
_______,_______,_______, _______, _______,_______,_______,_______, _______,_______,_______, _______,_______),
/* Layer 2: programming layer 2
all keys that are not FN keys are sent as LSFT+key on this layer
*/
[PROG2] = LAYOUT(\
_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______, _______,_______,_______, \
RA(RBRC),_______, RA(Q),KC_BSLS,_______,_______,M(CFLEX), S(6),S(RBRC), S(8), S(9),S(SLSH),KC_RBRC,_______, _______,_______,_______, _______,_______,_______,_______, \
_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______, RA(7), RA(0),RA(NUBS), _______,_______,_______, _______,_______,_______,_______, \
_______,_______,_______,_______,_______,_______,_______,_______,_______,_______, S(DOT), S(2), _______, _______,_______,_______, \
_______,S(NUBS),_______,_______,_______,_______,_______,_______,_______,KC_NUBS,S(NUBS),S(MINS), _______, _______, _______,_______,_______,_______, \
ALGR(KC_RBRC),_______, ALGR(KC_Q),KC_BSLS,_______,_______,M_CFLEX, S(KC_6),S(KC_RBRC), S(KC_8),S(KC_9),S(KC_SLSH),KC_RBRC,_______, _______,_______,_______, _______,_______,_______,_______, \
_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______, ALGR(KC_7),ALGR(KC_0),ALGR(KC_NUBS), _______,_______,_______, _______,_______,_______,_______, \
_______,_______,_______,_______,_______,_______,_______,_______,_______,_______, S(KC_DOT), S(KC_2), _______, _______,_______,_______, \
_______,S(KC_NUBS),_______,_______,_______,_______,_______,_______,_______,KC_NUBS,S(KC_NUBS),S(KC_MINS), _______, _______, _______,_______,_______,_______, \
_______,_______,_______, _______, _______,_______,_______,_______, _______,_______,_______, _______,_______),
/* Layer 3: media layer */
[MEDIA] = LAYOUT(\
Expand All @@ -72,11 +63,11 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
XXXXXXX,XXXXXXX,XXXXXXX, XXXXXXX, XXXXXXX,XXXXXXX,_______,XXXXXXX, KC_MRWD,KC_MSTP,KC_MFFD, XXXXXXX,XXXXXXX),
/* Layer 4: Mouse layer */
[MOUSE1] = LAYOUT(\
F(6),_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______, _______,_______,_______, \
TO(DEFAULT),_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______, _______,_______,_______, \
_______,KC_ACL0,KC_ACL1,KC_ACL2,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______, _______,_______,_______, _______,_______,_______,_______, \
_______,KC_BTN4,KC_WH_D,KC_MS_U,KC_WH_U,_______, C(Z),_______,_______,_______,_______,_______,_______,_______, _______,_______,_______, _______,_______,_______,_______, \
_______,KC_BTN5,KC_MS_L,KC_MS_D,KC_MS_R, F(7),KC_WH_L,KC_WH_D,KC_WH_U,KC_WH_R,_______,_______, _______, _______,_______,_______, \
MO(MOUSE2),_______, C(Y), C(X), C(C), C(V),_______,KC_BTN2,KC_BTN3,C(PGUP),C(PGDN),_______, KC_RSFT, _______, _______,_______,_______,_______, \
_______,KC_BTN4,KC_WH_D,KC_MS_U,KC_WH_U,_______, C(KC_Z),_______,_______,_______,_______,_______,_______,_______, _______,_______,_______, _______,_______,_______,_______, \
_______,KC_BTN5,KC_MS_L,KC_MS_D,KC_MS_R, CTRL_CLICK,KC_WH_L,KC_WH_D,KC_WH_U,KC_WH_R,_______,_______, _______, _______,_______,_______, \
MO(MOUSE2),_______,C(KC_Y),C(KC_X),C(KC_C),C(KC_V),_______,KC_BTN2,KC_BTN3,C(KC_PGUP),C(KC_PGDN),_______, KC_RSFT, _______, _______,_______,_______,_______, \
KC_LCTL,_______,KC_LALT, KC_BTN1, KC_RALT,KC_RGUI, KC_APP,KC_RCTL, _______,_______,_______, _______,_______),
/* Layer 5: Mouse layer 2*/
[MOUSE2] = LAYOUT(\
Expand All @@ -90,44 +81,12 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
[MISC] = LAYOUT(\
_______, KC_F13, KC_F14, KC_F15, KC_F16, KC_F17, KC_F18, KC_F19, KC_F20, KC_F21, KC_F22, KC_F23, KC_F24, _______,_______,_______, \
_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______, _______,_______,_______, _______,_______,_______,_______, \
_______,KC_SLCT, C(W), KC_UP,_______,_______,_______,_______,KC_BSPC, KC_DEL,_______,_______,_______,_______, _______,_______,_______, _______,_______,_______,_______, \
_______,KC_SLCT, C(KC_W), KC_UP,_______,_______,_______,_______,KC_BSPC, KC_DEL,_______,_______,_______,_______, _______,_______,_______, _______,_______,_______,_______, \
_______,_______,KC_LEFT,KC_DOWN,KC_RGHT,_______,KC_HOME,KC_PGDN,KC_PGUP,_______,_______,_______, _______, _______,_______,_______, \
KC_LSFT,_______, C(Y), C(X), C(C), C(V), KC_SPC, KC_END,_______,C(PGUP),C(PGDN),_______, _______, _______, _______,_______,_______,_______, \
KC_LSFT,_______,C(KC_Y),C(KC_X),C(KC_C),C(KC_V), KC_SPC, KC_END,_______,C(KC_PGUP),C(KC_PGDN),_______, _______, _______, _______,_______,_______,_______, \
_______,_______,_______, LT(MISC, KC_SPC), _______,_______,_______,_______, _______,_______,_______, _______,_______),
};

const uint16_t PROGMEM fn_actions[] = {
[1] = ACTION_FUNCTION_TAP(LCTRL_BRACKET), // tap to print [
[2] = ACTION_FUNCTION_TAP(RCTRL_BRACKET), // tap to print ]
[3] = ACTION_FUNCTION_TAP(LALT_CURLY), // tap to print {
[4] = ACTION_FUNCTION_TAP(RALT_CURLY), // tap to print }
[6] = ACTION_LAYER_SET_CLEAR(DEFAULT),
[7] = ACTION_FUNCTION_TAP(CTRL_CLICK),
[8] = ACTION_FUNCTION_TAP(LSHFT_PAREN), // tap to print (
[9] = ACTION_FUNCTION_TAP(RSHFT_PAREN), // tap to print )
};

const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
{
// MACRODOWN only works in this function
switch(id) {
case GRV: // macro to print accent grave
return (record->event.pressed ?
MACRO( D(LSFT), T(EQL), U(RALT), T(SPC), END) :
MACRO_NONE );
case CFLEX: // print accent circonflex
return (record->event.pressed ?
MACRO( T(GRV), T(SPC), END ) :
MACRO_NONE );
}
return MACRO_NONE;
};


void matrix_init_user(void) {

}

void matrix_scan_user(void) {
uint8_t layer;
layer = biton32(layer_state);
Expand All @@ -147,10 +106,6 @@ void matrix_scan_user(void) {
}
}

void led_set_user(uint8_t usb_led) {

}

void tap_helper(keyrecord_t *record, uint16_t orig_mod, uint16_t macro_mod, uint16_t macro_kc ) {
if (record->event.pressed) {
if (record->tap.count > 0 && !record->tap.interrupted) {
Expand All @@ -175,28 +130,45 @@ void tap_helper(keyrecord_t *record, uint16_t orig_mod, uint16_t macro_mod, uint
}
}

/* if LCTRL is tabbed, print (, or ) if RCTRL is tabbed, same for LALT/RALT and [/] */
void action_function(keyrecord_t *record, uint8_t id, uint8_t opt) {
// The code is copied from keymap_hasu.c in the tmk keyboards hhkb folder
switch (id) {
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
uint8_t layer;
layer = biton32(layer_state);
if (layer == PROG2) {
if (keycode >= KC_A && keycode <= KC_EXSEL && \
!( // do not send LSFT + these keycodes, they are needed for emulating the US layout
keycode == KC_NONUS_BSLASH ||
keycode == KC_RBRC ||
keycode == KC_BSLS ||
keycode == KC_GRV
)) {
// LSFT is the modifier for this layer, so we set LSFT for every key to get the expected behavior
if (record->event.pressed) {
register_mods(MOD_LSFT);
} else {
unregister_mods(MOD_LSFT);
}
}
}

switch (keycode) {
case LCTRL_BRACKET:
tap_helper(record, KC_LCTL, KC_RALT, KC_8);
break;
return false;
case RCTRL_BRACKET:
tap_helper(record, KC_RCTL, KC_RALT, KC_9);
break;
return false;
case LALT_CURLY:
tap_helper(record, KC_LALT, KC_RALT, KC_7);
break;
return false;
case RALT_CURLY:
tap_helper(record, KC_RALT, KC_RALT, KC_0);
break;
return false;
case LSHFT_PAREN:
tap_helper(record, KC_LSFT, KC_LSFT, KC_8);
break;
return false;
case RSHFT_PAREN:
tap_helper(record, KC_RSFT, KC_LSFT, KC_9);
break;
return false;
case CTRL_CLICK:
if (record->event.pressed) {
mousekey_clear();
Expand All @@ -212,28 +184,16 @@ void action_function(keyrecord_t *record, uint8_t id, uint8_t opt) {
unregister_mods(MOD_BIT(KC_LCTL));
send_keyboard_report();
}
break;
return false;
case M_GRV:
tap_code16(S(KC_EQL));
tap_code(KC_SPC);
return false;
case M_CFLEX:
tap_code(KC_GRV);
tap_code(KC_SPC);
return false;
}
}

bool process_record_user(uint16_t keycode, keyrecord_t *record) {
uint8_t layer;
layer = biton32(layer_state);
if (layer == PROG2) {
if (keycode >= KC_A && keycode <= KC_EXSEL && \
!( // do not send LSFT + these keycodes, they are needed for emulating the US layout
keycode == KC_NONUS_BSLASH ||
keycode == KC_RBRC ||
keycode == KC_BSLS ||
keycode == KC_GRV
)) {
// LSFT is the modifier for this layer, so we set LSFT for every key to get the expected behavior
if (record->event.pressed) {
register_mods(MOD_LSFT);
} else {
unregister_mods(MOD_LSFT);
}
}
}
return true;
}
30 changes: 13 additions & 17 deletions keyboards/clueboard/66/keymaps/magicmonty/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@
// CTRL when held, ESC when tapped
#define CTL_ESC CTL_T(KC_ESC)

// Reset RGB mode to layer signalling
#define RGB_RST F(0)
enum custom_keycodes {
RGB_RST = SAFE_RANGE
};

const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
/* Keymap _BL: Base Layer (Default Layer) */
Expand Down Expand Up @@ -103,21 +104,16 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
#endif
};

/* This is a list of user defined functions. F(N) corresponds to item N
of this list.
*/
const uint16_t PROGMEM fn_actions[] = {
[0] = ACTION_FUNCTION(0), // Calls action_function()
};

void action_function(keyrecord_t *record, uint8_t id, uint8_t opt) {
switch (id) {
case 0:
if (record->event.pressed) {
rgblight_mode(1);
rgblight_sethsv(206, 255, 255);
}
}
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
switch (keycode) {
case RGB_RST:
if (record->event.pressed) {
rgblight_mode(1);
rgblight_sethsv(206, 255, 255);
}
return false;
}
return true;
}

enum layer_id {
Expand Down
Loading

0 comments on commit fd8628c

Please sign in to comment.