-action_t keymap_get_action(uint8_t layer, uint8_t row, uint8_t col) {
- /* convert from legacy keycode to action */
- uint8_t key = KEYCODE(layer, row, col);
- action_t action;
- switch (key) {
- case KC_A ... KC_EXSEL:
- case KC_LCTRL ... KC_LGUI:
- case KC_RCTRL ... KC_RGUI:
- action.code = ACTION_KEY(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;
-/* TODO
- case KC_LCTRL ... KC_LGUI:
- action.code = ACTION_LMODS(MOD_BIT(key));
- break;
- case KC_RCTRL ... KC_RGUI:
- action.code = ACTION_RMODS(MOD_BIT(key)>>4);
- break;
-*/
- case KC_FN0 ... KC_FN7:
- action.code = pgm_read_word(&fn_actions[FN_INDEX(key)]);
+
+/*
+ * Fn action definition
+ */
+static const uint16_t PROGMEM fn_actions[] = {
+ [0] = ACTION_DEFAULT_LAYER_SET(0), // Default layer(not used)
+ [1] = ACTION_LAYER_TAP_TOGGLE(1), // HHKB layer(toggle with 5 taps)
+ [2] = ACTION_LAYER_TAP_KEY(2, KC_SLASH), // Cursor layer with Slash*
+ [3] = ACTION_LAYER_TAP_KEY(3, KC_SCLN), // Mousekey layer with Semicolon*
+ [4] = ACTION_MODS_TAP_KEY(MOD_RCTL, KC_ENT), // RControl with tap Enter*
+ [5] = ACTION_MODS_ONESHOT(MOD_LSFT), // Oneshot Shift*
+ [6] = ACTION_LAYER_TAP_KEY(5, KC_SPC), // Mousekey layer with Space
+ [7] = ACTION_LAYER_TOGGLE(3), // Mousekey layer(toggle)
+ [8] = ACTION_MODS_KEY(MOD_LCTL, KC_W), // Close Tab
+
+// [8] = ACTION_LMOD_TAP_KEY(KC_LCTL, KC_BSPC), // LControl with tap Backspace
+// [9] = ACTION_LMOD_TAP_KEY(KC_LCTL, KC_ESC), // LControl with tap Esc
+// [11] = ACTION_FUNCTION_TAP(LSHIFT_LPAREN), // Function: LShift with tap '('
+// [12] = ACTION_FUNCTION_TAP(RSHIFT_RPAREN), // Function: RShift with tap ')'
+// [13] = ACTION_MACRO_TAP(LSHIFT_PAREN), // Macro: LShift with tap '('
+// [14] = ACTION_MACRO_TAP(RSHIFT_PAREN), // Macro: RShift with tap ')'
+// [15] = ACTION_MACRO(HELLO), // Macro: say hello
+// [9] = ACTION_MACRO(VOLUP), // Macro: media key
+};
+
+
+/*
+ * Macro definition
+ */
+const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
+{
+ keyevent_t event = record->event;
+ tap_t tap = record->tap;
+
+ switch (id) {
+ case LSHIFT_PAREN:
+ if (tap.count > 0 && !tap.interrupted) {
+ return (event.pressed ?
+ MACRO( D(LSHIFT), D(9), U(9), U(LSHIFT), END ) : MACRO_NONE);
+ } else {
+ return (event.pressed ?
+ MACRO( D(LSHIFT), END ) : MACRO( U(LSHIFT), END ) );
+ }
+ case RSHIFT_PAREN:
+ if (tap.count > 0 && !tap.interrupted) {
+ return (event.pressed ?
+ MACRO( D(RSHIFT), D(0), U(0), U(RSHIFT), END ) : MACRO_NONE);
+ } else {
+ return (event.pressed ?
+ MACRO( D(RSHIFT), END ) : MACRO( U(RSHIFT), END ) );
+ }
+ case HELLO:
+ return (event.pressed ?
+ MACRO( I(0), T(H), T(E), T(L), T(L), W(255), T(O), END ) :
+ MACRO_NONE );
+ case VOLUP:
+ return (event.pressed ?
+ MACRO( D(VOLU), U(VOLU), END ) :
+ MACRO_NONE );
+ }
+ return MACRO_NONE;
+}
+
+
+
+/*
+ * user defined action function
+ */
+void action_function(keyrecord_t *record, uint8_t id, uint8_t opt)
+{
+ keyevent_t event = record->event;
+ tap_t tap = record->tap;
+
+ switch (id) {
+ case LSHIFT_LPAREN:
+ // LShft + tap '('
+ // NOTE: cant use register_code to avoid conflicting with magic key bind
+ if (event.pressed) {
+ if (tap.count == 0 || tap.interrupted) {
+ add_mods(MOD_BIT(KC_LSHIFT));
+ } else {
+ host_add_mods(MOD_BIT(KC_LSHIFT));
+ host_add_key(KC_9);
+ host_send_keyboard_report();
+ host_del_mods(MOD_BIT(KC_LSHIFT));
+ host_del_key(KC_9);
+ host_send_keyboard_report();
+ }
+ } else {
+ if (tap.count == 0 || tap.interrupted) {
+ del_mods(MOD_BIT(KC_LSHIFT));
+ }
+ }