blob: 58b7396a1b168045c6763d67d66d8caaa5ea5192 (
plain)
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
|
#include "ortho75.h"
#define MEDIA_KEY_DELAY 10
uint8_t layer = 0;
layer_state_t layer_state_set_kb(layer_state_t state) {
state = layer_state_set_user(state);
layer = get_highest_layer(state);
return state;
}
bool encoder_update_kb(uint8_t index, bool clockwise) {
if (!encoder_update_user(index, clockwise)) return false;
uint16_t mapped_code = 0;
if (index == 0) {
if (clockwise) {
switch (layer) {
case 0:
default:
mapped_code = KC_VOLU;
break;
case 1:
mapped_code = KC_MEDIA_NEXT_TRACK;
break;
case 2:
mapped_code = KC_PGDN;
break;
}
} else {
switch (layer) {
case 0:
default:
mapped_code = KC_VOLD;
break;
case 1:
mapped_code = KC_MEDIA_PREV_TRACK;
break;
case 2:
mapped_code = KC_PGUP;
break;
}
}
uint16_t held_keycode_timer = timer_read();
register_code(mapped_code);
while (timer_elapsed(held_keycode_timer) < MEDIA_KEY_DELAY) { /* no-op */
}
unregister_code(mapped_code);
}
return true;
}
|