forked from technomancy/atreus-firmware
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlayout_common.h
42 lines (34 loc) · 981 Bytes
/
layout_common.h
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
int fn_decay = 0;
void activate_fn() {
fn_decay = 20;
};
int layer_to_jump = 0;
// jump to this layer when fn is released
void layer_jump() {
layer_to_jump = 2;
};
void (*layer_functions[])(void) = {reset, activate_fn, layer_jump};
// When we are sending key combinations that include modifiers, the OS
// can do some level of error-correction to prevent this scenario:
// - shift down
// - a key down
// - A inserted
// - shift up
// - a inserted
// However, fn is unlike other modifiers since the OS knows nothing
// about it; from the OS's perspective the keycodes it gets before and
// after the release of fn are unrelated. Because of this, we must let
// fn apply a little after it's been released; this is what fn_decay
// does.
void per_cycle() {
if(fn_decay > 1) {
current_layer = layers[1];
fn_decay--;
} else if(fn_decay == 1) {
current_layer_number = layer_to_jump;
fn_decay--;
} else {
layer_to_jump = 0;
fn_decay = 0;
}
};