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