blob: 358d0cb764288c383f4e2033b26257ea68c800be (
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
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
|
// Copyright 2022 Vino Rodrigues (@vinorodrigues)
// SPDX-License-Identifier: GPL-2.0-or-later
#include "specialk.h"
bool delkey_registered = false;
uint32_t __keycode_raised = 0;
bool get_keycode_raised(uint8_t n) {
return __keycode_raised & (1 << n);
}
void set_keycode_raised(uint8_t n, bool b) {
if (b) {
__keycode_raised |= 1 << n;
} else {
__keycode_raised &= ~(1 << n);
}
}
bool ID61_process_special_k(uint16_t keycode, keyrecord_t *record, bool arrow_mode, uint8_t k_norm, uint8_t k_spcl, uint8_t k_altr) {
bool is_raised = get_highest_layer(layer_state|default_layer_state) != 0;
if (record->event.pressed) {
set_keycode_raised(keycode - USER00, is_raised); // save for key release event
if (is_raised) {
// *** Fn keyed ***
if (arrow_mode) {
// alternate key
register_code(k_altr);
} else {
// special key
register_code(k_spcl);
}
} else {
// *** normal, un-Fn'ed ***
if (arrow_mode) {
// special key
register_code(k_spcl);
} else {
// normal key
register_code(k_norm);
}
}
} else {
if (get_keycode_raised(keycode - USER00)) {
// *** Fn keyed ***
if (arrow_mode) {
// alternate key
unregister_code(k_altr);
} else {
// special key
unregister_code(k_spcl);
}
} else {
// *** normal, un-Fn'ed ***
if (arrow_mode) {
// special key
unregister_code(k_spcl);
} else {
// normal key
unregister_code(k_norm);
}
}
}
return false;
}
bool ID61_backspace_special(uint16_t keycode, keyrecord_t *record) {
uint8_t mod_state = get_mods();
if (record->event.pressed) {
if (mod_state & MOD_MASK_SHIFT) {
del_mods(MOD_MASK_SHIFT);
register_code(KC_DEL);
delkey_registered = true;
set_mods(mod_state);
return false;
}
} else {
if (delkey_registered) {
unregister_code(KC_DEL);
delkey_registered = false;
return false;
}
}
return true; // normal backspace, pass on
}
|