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
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
|
/* Copyright 2019 niltea
*
* 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 QMK_KEYBOARD_H
#ifdef OLED_DRIVER_ENABLE
#include <string.h>
#include "lib/oled_helper.h"
#endif
enum custom_keycode {
Mac_CS = SAFE_RANGE,
Mac_PS,
Win_CS,
Win_PS,
IOS_CS,
};
enum layerID {
MAC_CS_1 = 0,
MAC_CS_2,
MAC_PS_1,
MAC_PS_2,
WIN_CS_1,
WIN_CS_2,
WIN_PS_1,
WIN_PS_2,
IOS_CS_1,
IOS_CS_2,
SETTING,
};
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
// Mac
// Clip Studio
[MAC_CS_1] = LAYOUT(
KC_TAB, LGUI(KC_A), KC_E, KC_P, LGUI(KC_0),
MO(MAC_CS_2), KC_M, KC_BSPC, KC_B, KC_HYPR,
KC_LSFT, KC_LGUI, LGUI(KC_Z), KC_SPC
),
[MAC_CS_2] = LAYOUT(
MO(SETTING), KC_ESC, KC_G, KC_R, LGUI(KC_GRV),
_______, LGUI(KC_D), KC_K, KC_F, LGUI(KC_S),
KC_LALT, KC_I, SGUI(KC_Z), KC_H
),
// Photoshop
[MAC_PS_1] = LAYOUT(
KC_TAB, LGUI(KC_A), KC_E, KC_B, LGUI(KC_1),
MO(MAC_PS_2), KC_L, LGUI(KC_DEL), LGUI(KC_QUOT), KC_MEH,
KC_LSFT, KC_LGUI, LGUI(KC_Z), KC_SPC
),
[MAC_PS_2] = LAYOUT(
MO(SETTING), KC_ESC, KC_G, KC_R, KC_ESC,
_______, LGUI(KC_D), KC_V, LGUI(KC_T), LGUI(KC_S),
KC_LALT, KC_I, SGUI(KC_Z), KC_H
),
// Windows
// Clip Studio
[WIN_CS_1] = LAYOUT(
KC_TAB, LCTL(KC_A), KC_E, KC_P, LCTL(KC_0),
MO(WIN_CS_2), KC_M, KC_BSPC, KC_B, KC_HYPR,
KC_LSFT, KC_LCTRL, LCTL(KC_Z), KC_SPC
),
[WIN_CS_2] = LAYOUT(
MO(SETTING), KC_ESC, KC_G, KC_R, LCTL(KC_GRV),
_______, LCTL(KC_D), KC_K, KC_F, LCTL(KC_S),
KC_LALT, KC_I, C(S(KC_Z)), KC_H
),
// Photoshop
[WIN_PS_1] = LAYOUT(
KC_TAB, LCTL(KC_A), KC_E, KC_B, LCTL(KC_1),
MO(WIN_PS_2), KC_L, LCTL(KC_DEL), LCTL(KC_QUOT), KC_MEH,
KC_LSFT, KC_LCTRL, LCTL(KC_Z), KC_SPC
),
[WIN_PS_2] = LAYOUT(
MO(SETTING), KC_ESC, KC_G, KC_R, KC_ESC,
_______, LCTL(KC_D), KC_V, LCTL(KC_T), LCTL(KC_S),
KC_LALT, KC_I, C(S(KC_Z)), KC_H
),
// iOS
// Clip Studio
[IOS_CS_1] = LAYOUT(
KC_TAB, LGUI(KC_A), KC_E, KC_P, LGUI(KC_0),
MO(IOS_CS_2), KC_M, KC_BSPC, KC_B, LGUI(KC_LALT),
KC_LSFT, KC_LGUI, LGUI(KC_Z), KC_SPC
),
[IOS_CS_2] = LAYOUT(
MO(SETTING), KC_ESC, KC_G, KC_R, LGUI(KC_EQL),
_______, LGUI(KC_D), KC_K, KC_F, LGUI(KC_S),
KC_LALT, KC_I, SGUI(KC_Z), KC_H
),
[SETTING] = LAYOUT(
_______, IOS_CS, Win_CS, Mac_CS, KC_NO,
_______, KC_NO, Win_PS, Mac_PS, KC_NO,
KC_NO, KC_NO, KC_NO, KC_NO
),
};
bool encoder_update_user(uint8_t index, bool clockwise) {
uint8_t currentDefault = get_highest_layer(default_layer_state);
uint8_t currentLayer = get_highest_layer(layer_state);
if (index == 0) { /* the upper encoder */
switch (currentDefault) {
case MAC_CS_1:
if (currentLayer % 2 == 0) {
// default layer
// Zoom
tap_code16(!clockwise ? G(KC_MINS) : G(KC_EQL));
} else {
// Fn Layer
// rotate canvas
tap_code(!clockwise ? KC_MINS : KC_QUOT);
}
break;
case MAC_PS_1:
if (currentLayer % 2 == 0) {
// default layer
// Zoom
tap_code16(!clockwise ? G(KC_MINS) : G(KC_EQL));
} else {
// Fn Layer
// undo / redo
tap_code16(!clockwise ? G(KC_Z) : S(G(KC_Z)));
}
break;
case WIN_CS_1:
if (currentLayer % 2 == 0) {
// default layer
// Zoom
tap_code16(!clockwise ? C(KC_MINS) : C(KC_EQL));
} else {
// Fn Layer
// rotate canvas
tap_code(!clockwise ? KC_MINS : KC_QUOT);
}
break;
case WIN_PS_1:
if (currentLayer % 2 == 0) {
// default layer
// Zoom
tap_code16(!clockwise ? C(KC_MINS) : C(KC_SCLN));
} else {
// Fn Layer
// undo / redo
tap_code16(!clockwise ? C(KC_Z) : C(S(KC_Z)));
}
break;
case IOS_CS_1:
if (currentLayer % 2 == 0) {
// default layer
// Zoom
tap_code16(!clockwise ? G(KC_MINS) : G(KC_SCLN));
} else {
// Fn Layer
// rotate canvas
tap_code(!clockwise ? KC_MINS : KC_EQL);
}
break;
default:
break;
}
} else if (index == 1) { /* the lower encoder */
switch (currentDefault) {
case MAC_CS_1:
if (currentLayer % 2 == 0) {
// default layer
// size of brush
tap_code(!clockwise ? KC_LBRC : KC_RBRC);
} else {
// Fn Layer
// opacity of brush
tap_code16(!clockwise ? G(KC_LBRC) : G(KC_RBRC));
}
break;
case MAC_PS_1:
if (currentLayer % 2 == 0) {
// default layer
// size of brush
tap_code(!clockwise ? KC_LBRC : KC_RBRC);
} else {
// Fn Layer
// opacity of brush
tap_code16(!clockwise ? KC_LCBR : KC_RCBR);
}
break;
case WIN_CS_1:
if (currentLayer % 2 == 0) {
// default layer
// rotate canvas
tap_code(!clockwise ? KC_LBRC : KC_RBRC);
} else {
// Fn Layer
// opacity of brush
tap_code16(!clockwise ? C(KC_LBRC) : C(KC_RBRC));
}
break;
case WIN_PS_1:
if (currentLayer % 2 == 0) {
// default layer
// rotate canvas
tap_code(!clockwise ? KC_LBRC : KC_RBRC);
} else {
// Fn Layer
// opacity of brush
tap_code16(!clockwise ? KC_LCBR : KC_RCBR);
}
break;
case IOS_CS_1:
if (currentLayer % 2 == 0) {
// default layer
// size of brush
tap_code(!clockwise ? KC_RBRC : KC_BSLS);
} else {
// Fn Layer
// opacity of brush
tap_code16(!clockwise ? G(KC_RBRC) : G(KC_BSLS));
}
break;
default:
break;
}
}
return true;
}
// custom keycode
// switch default layer
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
switch (keycode) {
case Mac_CS:
if (record->event.pressed) {
set_single_persistent_default_layer(MAC_CS_1);
}
return false;
break;
case Mac_PS:
if (record->event.pressed) {
set_single_persistent_default_layer(MAC_PS_1);
}
return false;
break;
case Win_CS:
if (record->event.pressed) {
set_single_persistent_default_layer(WIN_CS_1);
}
return false;
break;
case Win_PS:
if (record->event.pressed) {
set_single_persistent_default_layer(WIN_PS_1);
}
return false;
break;
case IOS_CS:
if (record->event.pressed) {
set_single_persistent_default_layer(IOS_CS_1);
}
return false;
break;
}
return true;
}
// OLED Display
#ifdef OLED_DRIVER_ENABLE
void oled_task_user(void) {
// get layer Number
uint8_t currentDefault = get_highest_layer(default_layer_state);
uint8_t currentLayer = get_highest_layer(layer_state);
// write OS mode / 1st line of the logo
switch (currentDefault) {
case MAC_CS_1:
case MAC_PS_1:
render_row(0, "Mac ");
break;
case WIN_CS_1:
case WIN_PS_1:
render_row(0, "Win ");
break;
case IOS_CS_1:
render_row(0, "iOS ");
break;
default:
render_row(0, " ");
}
// write Application mode / 2nd line of the logo
switch (currentDefault) {
case MAC_CS_1:
case WIN_CS_1:
case IOS_CS_1:
render_row(1, "A:CS");
break;
case MAC_PS_1:
case WIN_PS_1:
render_row(1, "A:Ps");
break;
default:
render_row(1, " ");
}
if (currentLayer == SETTING) {
// 3rd & 4th line of the logo
render_row(2, "****");
render_row(3, "LSEL");
} else {
// Layer Status / 3rd line of the logo
if (currentLayer % 2 == 0) {
// default layer
render_row(2, "L:DF");
} else {
// Fn Layer
render_row(2, "L:Fn");
}
// pressed key / 4th line of the logo
render_row(3, " ");
}
}
#endif // #ifdef OLED_DRIVER_ENABLE
|