2 Copyright 2016 Jun Wako <wakojun@gmail.com>
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 #include "unimap_trans.h"
20 /* id for user defined functions */
31 #define AC_L1 ACTION_LAYER_MOMENTARY(1)
32 #define AC_SLS2 ACTION_LAYER_TAP_KEY(2, KC_SLSH)
33 #define AC_SCL3 ACTION_LAYER_TAP_KEY(3, KC_SCLN)
34 #define AC_SPC4 ACTION_LAYER_TAP_KEY(4, KC_SPC)
35 #define AC_APSW ACTION_MACRO(ALT_TAB)
36 #define AC_BACK ACTION_MODS_KEY(MOD_LALT, KC_LEFT)
37 #define AC_FRWD ACTION_MODS_KEY(MOD_LALT, KC_RIGHT)
38 #define AC_ENT_ ACTION_MODS_TAP_KEY(MOD_RCTL, KC_ENT)
40 // Function: LShift with tap '('
41 #define AC_LPRN ACTION_FUNCTION_TAP(LSHIFT_LPAREN)
43 #define AC_HELO ACTION_MACRO(HELLO)
46 #ifdef KEYMAP_SECTION_ENABLE
47 const action_t actionmaps[][UNIMAP_ROWS][UNIMAP_COLS] __attribute__ ((section (".keymap.keymaps"))) = {
49 const action_t actionmaps[][UNIMAP_ROWS][UNIMAP_COLS] PROGMEM = {
52 ESC, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSLS,GRV ,
53 TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC, BSPC,
54 LCTL,A, S, D, F, G, H, J, K, L, SCLN,QUOT, ENT_,
55 LSFT, Z, X, C, V, B, N, M, COMM,DOT, SLS2, RSFT,L1,
56 LGUI,LALT, SPC4, RALT,RGUI),
59 PWR, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, INS, DEL,
60 CAPS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,PSCR,SLCK,PAUS,UP, TRNS, TRNS,
61 TRNS,VOLD,VOLU,MUTE,TRNS,TRNS,PAST,PSLS,HOME,PGUP,LEFT,RGHT, PENT,
62 TRNS, TRNS,TRNS,TRNS,TRNS,TRNS,PPLS,PMNS,END, PGDN,DOWN, TRNS,TRNS,
63 TRNS,TRNS, TRNS, TRNS,TRNS),
66 GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, INS, DEL,
67 TAB, HOME,PGDN,UP, PGUP,END, HOME,PGDN,PGUP,END, NO, NO, NO, BSPC,
68 LCTL,NO, LEFT,DOWN,RGHT,NO, LEFT,DOWN,UP, RGHT,NO, NO, ENT,
69 LSFT, NO, NO, NO, NO, NO, HOME,PGDN,PGUP,END, TRNS, RSFT,TRNS,
70 LGUI,LALT, SPC, RALT,RGUI),
73 GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, INS, DEL,
74 TAB, NO, NO, NO, NO, NO, WH_L,WH_D,MS_U,WH_U,WH_R,BACK,FRWD, TAB,
75 LCTL,ACL0,ACL1,ACL2,ACL2,NO, NO, MS_L,MS_D,MS_R,TRNS,NO, ENT,
76 LSFT, NO, NO, NO, NO, BTN3,BTN2,BTN1,BACK,FRWD,NO, RSFT,TRNS,
77 LGUI,LALT, BTN1, TRNS,TRNS),
80 GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, INS, DEL,
81 TAB, NO, NO, NO, NO, NO, WH_L,WH_D,MS_U,WH_U,WH_R,BTN4,BTN5, TAB,
82 LCTL,VOLD,VOLU,MUTE,NO, NO, NO, MS_L,MS_D,MS_R,BTN1,NO, ENT,
83 LSFT, NO, NO, NO, NO, BTN3,BTN2,BTN1,BACK,FRWD,NO, RSFT,TRNS,
84 TRNS,TRNS, TRNS, TRNS,TRNS),
92 const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
96 return (record->event.pressed ?
97 MACRO( I(0), T(H), T(E), T(L), T(L), W(255), T(O), END ) :
100 return (record->event.pressed ?
101 MACRO( D(VOLU), U(VOLU), END ) :
104 // XXX: doesn't work after stuck key fix
105 return (record->event.pressed ?
106 MACRO( D(LALT), D(TAB), END ) :
107 MACRO( U(TAB), END ));
115 * user defined action function
117 void action_function(keyrecord_t *record, uint8_t id, uint8_t opt)
119 if (record->event.pressed) dprint("P"); else dprint("R");
120 dprintf("%d", record->tap.count);
121 if (record->tap.interrupted) dprint("i");
126 // XXX: doesn't work with other tap key. iffy at least
127 // Shift parentheses example: LShft + tap '('
128 // http://stevelosh.com/blog/2012/10/a-modern-space-cadet/#shift-parentheses
129 // http://geekhack.org/index.php?topic=41989.msg1304899#msg1304899
130 if (record->event.pressed) {
131 if (record->tap.count > 0 && !record->tap.interrupted) {
132 if (record->tap.interrupted) {
133 dprint("tap interrupted\n");
134 register_mods(MOD_BIT(KC_LSHIFT));
137 register_mods(MOD_BIT(KC_LSHIFT));
140 if (record->tap.count > 0 && !(record->tap.interrupted)) {
141 add_weak_mods(MOD_BIT(KC_LSHIFT));
142 send_keyboard_report();
144 unregister_code(KC_9);
145 del_weak_mods(MOD_BIT(KC_LSHIFT));
146 send_keyboard_report();
147 record->tap.count = 0; // ad hoc: cancel tap
149 unregister_mods(MOD_BIT(KC_LSHIFT));