+
+
+/*
+ * user defined action function
+ */
+void action_function(keyrecord_t *record, uint8_t id, uint8_t opt)
+{
+ keyevent_t event = record->event;
+ uint8_t tap_count = record->tap_count;
+
+ debug("action_call_function: ");
+ if (event.pressed) debug("pressed"); else debug("released");
+ debug(" id: "); debug_hex(id);
+ debug(" tap_count: "); debug_dec(tap_count);
+ debug("\n");
+
+ switch (id) {
+ case LSHIFT_LPAREN:
+ // LShft + tap '('
+ if (event.pressed) {
+ if (tap_count == 0) {
+ add_mods(MOD_BIT(KC_LSHIFT));
+ } else {
+ if (waiting_buffer_has_anykey_pressed()) {
+ // ad hoc: set 0 to cancel tap
+ record->tap_count = 0;
+ add_mods(MOD_BIT(KC_LSHIFT));
+ } else {
+ // NOTE to avoid conflicting command key bind(LShift+RShift)
+ //register_code(KC_LSHIFT);
+ //register_code(KC_9);
+ host_add_mods(MOD_BIT(KC_LSHIFT));
+ host_add_key(KC_9);
+ host_send_keyboard_report();
+ }
+ }
+ } else {
+ if (tap_count == 0) {
+ del_mods(MOD_BIT(KC_LSHIFT));
+ } else {
+ //unregister_code(KC_9);
+ //unregister_code(KC_LSHIFT);
+ host_del_mods(MOD_BIT(KC_LSHIFT));
+ host_del_key(KC_9);
+ host_send_keyboard_report();
+ }
+ }
+ break;
+ case RSHIFT_RPAREN:
+ // RShift + tap ')'
+ if (event.pressed) {
+ if (tap_count == 0) {
+ add_mods(MOD_BIT(KC_RSHIFT));
+ } else {
+ if (waiting_buffer_has_anykey_pressed()) {
+ // ad hoc: set 0 to cancel tap
+ record->tap_count = 0;
+ add_mods(MOD_BIT(KC_RSHIFT));
+ } else {
+ //register_code(KC_RSHIFT);
+ //register_code(KC_0);
+ host_add_mods(MOD_BIT(KC_RSHIFT));
+ host_add_key(KC_0);
+ host_send_keyboard_report();
+ }
+ }
+ } else {
+ if (tap_count == 0) {
+ del_mods(MOD_BIT(KC_RSHIFT));
+ } else {
+ //unregister_code(KC_0);
+ //unregister_code(KC_RSHIFT);
+ host_del_mods(MOD_BIT(KC_RSHIFT));
+ host_del_key(KC_0);
+ host_send_keyboard_report();
+ }
+ }
+ break;
+ case MACRO:
+ action_macro_play(get_macro(opt, event.pressed));
+ break;
+ }
+}
+
+
+
+/* translates key to keycode */
+uint8_t keymap_key_to_keycode(uint8_t layer, key_t key)