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 // Display Brightness Control
41 // https://github.com/tmk/tmk_keyboard/issues/370#issuecomment-279113313
42 // BRTI(increment) and BRTD(decrement) are defined in actionmap.h
44 // Function: LShift with tap '('
45 #define AC_LPRN ACTION_FUNCTION_TAP(LSHIFT_LPAREN)
47 #define AC_HELO ACTION_MACRO(HELLO)
50 #ifdef KEYMAP_SECTION_ENABLE
51 const action_t actionmaps[][UNIMAP_ROWS][UNIMAP_COLS] __attribute__ ((section (".keymap.keymaps"))) = {
53 const action_t actionmaps[][UNIMAP_ROWS][UNIMAP_COLS] PROGMEM = {
56 ESC, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSLS,GRV ,
57 TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC, BSPC,
58 LCTL,A, S, D, F, G, H, J, K, L, SCLN,QUOT, ENT_,
59 LSFT, Z, X, C, V, B, N, M, COMM,DOT, SLS2, RSFT,L1,
60 LGUI,LALT, SPC4, RALT,RGUI),
63 PWR, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, INS, DEL,
64 CAPS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,PSCR,SLCK,PAUS,UP, TRNS, TRNS,
65 TRNS,VOLD,VOLU,MUTE,TRNS,TRNS,PAST,PSLS,HOME,PGUP,LEFT,RGHT, PENT,
66 TRNS, BRTD,BRTI,SLEP,WAKE,TRNS,PPLS,PMNS,END, PGDN,DOWN, TRNS,TRNS,
67 TRNS,TRNS, TRNS, TRNS,TRNS),
70 GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, INS, DEL,
71 TAB, HOME,PGDN,UP, PGUP,END, HOME,PGDN,PGUP,END, NO, NO, NO, BSPC,
72 LCTL,NO, LEFT,DOWN,RGHT,NO, LEFT,DOWN,UP, RGHT,NO, NO, ENT,
73 LSFT, NO, NO, NO, NO, NO, HOME,PGDN,PGUP,END, TRNS, RSFT,TRNS,
74 LGUI,LALT, SPC, RALT,RGUI),
77 GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, INS, DEL,
78 TAB, NO, NO, NO, NO, NO, WH_L,WH_D,MS_U,WH_U,WH_R,BACK,FRWD, TAB,
79 LCTL,ACL0,ACL1,ACL2,ACL2,NO, NO, MS_L,MS_D,MS_R,TRNS,NO, ENT,
80 LSFT, NO, NO, NO, NO, BTN3,BTN2,BTN1,BACK,FRWD,NO, RSFT,TRNS,
81 LGUI,LALT, BTN1, TRNS,TRNS),
84 GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, INS, DEL,
85 TAB, NO, NO, NO, NO, NO, WH_L,WH_D,MS_U,WH_U,WH_R,BTN4,BTN5, TAB,
86 LCTL,VOLD,VOLU,MUTE,NO, NO, NO, MS_L,MS_D,MS_R,BTN1,NO, ENT,
87 LSFT, NO, NO, NO, NO, BTN3,BTN2,BTN1,BACK,FRWD,NO, RSFT,TRNS,
88 TRNS,TRNS, TRNS, TRNS,TRNS),
96 const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
100 return (record->event.pressed ?
101 MACRO( I(0), T(H), T(E), T(L), T(L), W(255), T(O), END ) :
104 return (record->event.pressed ?
105 MACRO( D(VOLU), U(VOLU), END ) :
108 // XXX: doesn't work after stuck key fix
109 return (record->event.pressed ?
110 MACRO( D(LALT), D(TAB), END ) :
111 MACRO( U(TAB), END ));
119 * user defined action function
121 void action_function(keyrecord_t *record, uint8_t id, uint8_t opt)
123 if (record->event.pressed) dprint("P"); else dprint("R");
124 dprintf("%d", record->tap.count);
125 if (record->tap.interrupted) dprint("i");
130 // XXX: doesn't work with other tap key. iffy at least
131 // Shift parentheses example: LShft + tap '('
132 // http://stevelosh.com/blog/2012/10/a-modern-space-cadet/#shift-parentheses
133 // http://geekhack.org/index.php?topic=41989.msg1304899#msg1304899
134 if (record->event.pressed) {
135 if (record->tap.count > 0 && !record->tap.interrupted) {
136 if (record->tap.interrupted) {
137 dprint("tap interrupted\n");
138 register_mods(MOD_BIT(KC_LSHIFT));
141 register_mods(MOD_BIT(KC_LSHIFT));
144 if (record->tap.count > 0 && !(record->tap.interrupted)) {
145 add_weak_mods(MOD_BIT(KC_LSHIFT));
146 send_keyboard_report();
148 unregister_code(KC_9);
149 del_weak_mods(MOD_BIT(KC_LSHIFT));
150 send_keyboard_report();
151 record->tap.count = 0; // ad hoc: cancel tap
153 unregister_mods(MOD_BIT(KC_LSHIFT));