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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
|
#include "edvorakjp.h"
#if TAP_DANCE_ENABLE != yes
static uint16_t time_on_pressed;
#endif
/*
* Each process_record_* methods defined here are
* return false if handle edvorak_keycodes, or return true others.
*/
bool process_record_edvorakjp_ext(uint16_t keycode, keyrecord_t *record) {
if (!(default_layer_state == 1UL<<_EDVORAK &&
get_enable_jp_extra_layer() && get_japanese_mode())) {
return true;
}
// consonant keys
// layer_on(J1) or layer_on(J2) are defined based on key positions.
switch (keycode) {
// right hand's left side w/o N
case KC_F:
case KC_G:
case KC_R:
case KC_D:
case KC_T:
case KC_B:
case KC_H:
case KC_J:
if (record->event.pressed) {
layer_on(_EDVORAKJ1);
}
return true;
// N: toggle layer
case KC_N:
if (record->event.pressed) {
biton32(layer_state) == _EDVORAK ? layer_on(_EDVORAKJ1) : dvorakj_layer_off();
}
return true;
// left hand up and right hand's right side
case KC_Y:
case KC_P:
case KC_W:
case KC_Q:
case KC_S:
case KC_M:
case KC_K:
case KC_L:
if (record->event.pressed) {
layer_on(_EDVORAKJ2);
}
return true;
// left hand down
// If return true, QMK sends keycode in new layer,
// but these keys are only available in old layer.
case KC_X:
case KC_C:
case KC_V:
case KC_Z:
if (record->event.pressed) {
layer_on(_EDVORAKJ2);
tap_code(keycode);
}
return false;
}
// vowel keys, symbol keys and modifier keys
if (record->event.pressed) {
dvorakj_layer_off();
}
switch (keycode) {
// combination vowel keys
case KC_AI:
if (record->event.pressed) {
SEND_STRING("ai");
}
return false;
case KC_OU:
if (record->event.pressed) {
SEND_STRING("ou");
}
return false;
case KC_EI:
if (record->event.pressed) {
SEND_STRING("ei");
}
return false;
case KC_ANN:
if (record->event.pressed) {
SEND_STRING("ann");
}
return false;
case KC_ONN:
if (record->event.pressed) {
SEND_STRING("onn");
}
return false;
case KC_ENN:
if (record->event.pressed) {
SEND_STRING("enn");
}
return false;
case KC_INN:
if (record->event.pressed) {
SEND_STRING("inn");
}
return false;
case KC_UNN:
if (record->event.pressed) {
SEND_STRING("unn");
}
return false;
}
// AOEIU and other (symbol, modifier) keys
return true;
}
bool process_record_edvorakjp_swap_scln(uint16_t keycode, keyrecord_t *record) {
#ifdef SWAP_SCLN
static const uint8_t shift_bits = MOD_BIT(KC_LSFT) | MOD_BIT(KC_RSFT);
static uint8_t last_mods_status;
if (keycode == KC_SCLN) {
if (record->event.pressed) {
last_mods_status = get_mods();
// invert shift_bits
if (last_mods_status & shift_bits) {
set_mods(last_mods_status & ~shift_bits);
} else {
set_mods(last_mods_status | MOD_BIT(KC_LSFT));
}
} else {
set_mods(last_mods_status);
last_mods_status = 0;
}
}
#endif
return true;
}
bool process_record_edvorakjp_config(uint16_t keycode, keyrecord_t *record) {
switch (keycode) {
case KC_MAC:
case KC_WIN:
if (record->event.pressed) {
set_enable_kc_lang(keycode == KC_MAC);
}
return false;
case KC_EXTON:
case KC_EXTOFF:
if (record->event.pressed) {
set_enable_jp_extra_layer(keycode == KC_EXTON);
}
return false;
}
return true;
}
bool process_record_layer(uint16_t keycode, keyrecord_t *record) {
switch (keycode) {
case EDVORAK:
if (record->event.pressed) {
set_single_persistent_default_layer(_EDVORAK);
}
return false;
case QWERTY:
if (record->event.pressed) {
dvorakj_layer_off();
set_single_persistent_default_layer(_QWERTY);
}
return false;
#if TAP_DANCE_ENABLE != yes
case LOWER:
if (record->event.pressed) {
layer_on(_LOWER);
time_on_pressed = record->event.time;
} else {
layer_off(_LOWER);
if (TIMER_DIFF_16(record->event.time, time_on_pressed) < TAPPING_TERM) {
set_japanese_mode(false);
}
time_on_pressed = 0;
}
return false;
case RAISE:
if (record->event.pressed) {
layer_on(_RAISE);
time_on_pressed = record->event.time;
} else {
layer_off(_RAISE);
if (TIMER_DIFF_16(record->event.time, time_on_pressed) < TAPPING_TERM) {
set_japanese_mode(true);
}
time_on_pressed = 0;
}
return false;
#endif
}
return true;
}
bool process_record_ime(uint16_t keycode, keyrecord_t *record) {
switch (keycode) {
case KC_JPN:
case KC_ENG:
if (record->event.pressed) {
set_japanese_mode(keycode == KC_JPN);
}
return false;
}
return true;
}
|