hhkb: Change unimap files
[tmk_keyboard.git] / keyboard / hhkb / unimap_hasu.c
1 /*
2 Copyright 2016 Jun Wako <wakojun@gmail.com>
3
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.
8
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.
13
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/>.
16 */
17 #include "unimap_trans.h"
18
19
20 /* id for user defined functions */
21 enum function_id {
22 LSHIFT_LPAREN,
23 };
24
25 enum macro_id {
26 HELLO,
27 VOLUP,
28 ALT_TAB,
29 };
30
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)
39
40 // Function: LShift with tap '('
41 #define AC_LPRN ACTION_FUNCTION_TAP(LSHIFT_LPAREN)
42 // Macro: say hello
43 #define AC_HELO ACTION_MACRO(HELLO)
44
45
46 #ifdef KEYMAP_SECTION_ENABLE
47 const action_t actionmaps[][UNIMAP_ROWS][UNIMAP_COLS] __attribute__ ((section (".keymap.keymaps"))) = {
48 #else
49 const action_t actionmaps[][UNIMAP_ROWS][UNIMAP_COLS] PROGMEM = {
50 #endif
51 [0] = UNIMAP_HHKB(
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 LPRN, Z, X, C, V, B, N, M, COMM,DOT, SLS2, RSFT,L1,
56 LGUI,LALT, SPC4, RALT,RGUI),
57
58 [1] = UNIMAP_HHKB(
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),
64
65 [2] = UNIMAP_HHKB(
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),
71
72 [3] = UNIMAP_HHKB(
73 GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, INS, DEL,
74 APSW,NO, NO, NO, NO, NO, WH_L,WH_D,MS_U,WH_U,WH_R,BACK,FRWD, APSW,
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),
78
79 [4] = UNIMAP_HHKB(
80 GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, INS, DEL,
81 APSW,NO, NO, NO, NO, NO, WH_L,WH_D,MS_U,WH_U,WH_R,BTN4,BTN5, APSW,
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),
85 };
86
87
88
89 /*
90 * Macro definition
91 */
92 const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
93 {
94 switch (id) {
95 case HELLO:
96 return (record->event.pressed ?
97 MACRO( I(0), T(H), T(E), T(L), T(L), W(255), T(O), END ) :
98 MACRO_NONE );
99 case VOLUP:
100 return (record->event.pressed ?
101 MACRO( D(VOLU), U(VOLU), END ) :
102 MACRO_NONE );
103 case ALT_TAB:
104 return (record->event.pressed ?
105 MACRO( D(LALT), D(TAB), END ) :
106 MACRO( U(TAB), END ));
107 }
108 return MACRO_NONE;
109 }
110
111
112
113 /*
114 * user defined action function
115 */
116 void action_function(keyrecord_t *record, uint8_t id, uint8_t opt)
117 {
118 if (record->event.pressed) dprint("P"); else dprint("R");
119 dprintf("%d", record->tap.count);
120 if (record->tap.interrupted) dprint("i");
121 dprint("\n");
122
123 switch (id) {
124 case LSHIFT_LPAREN:
125 // Shift parentheses example: LShft + tap '('
126 // http://stevelosh.com/blog/2012/10/a-modern-space-cadet/#shift-parentheses
127 // http://geekhack.org/index.php?topic=41989.msg1304899#msg1304899
128 if (record->event.pressed) {
129 if (record->tap.count > 0 && !record->tap.interrupted) {
130 if (record->tap.interrupted) {
131 dprint("tap interrupted\n");
132 register_mods(MOD_BIT(KC_LSHIFT));
133 }
134 } else {
135 register_mods(MOD_BIT(KC_LSHIFT));
136 }
137 } else {
138 if (record->tap.count > 0 && !(record->tap.interrupted)) {
139 add_weak_mods(MOD_BIT(KC_LSHIFT));
140 send_keyboard_report();
141 register_code(KC_9);
142 unregister_code(KC_9);
143 del_weak_mods(MOD_BIT(KC_LSHIFT));
144 send_keyboard_report();
145 record->tap.count = 0; // ad hoc: cancel tap
146 } else {
147 unregister_mods(MOD_BIT(KC_LSHIFT));
148 }
149 }
150 break;
151 }
152 }
Imprint / Impressum