-
Notifications
You must be signed in to change notification settings - Fork 0
/
code.py
113 lines (98 loc) · 5.17 KB
/
code.py
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
from keyboard import *
# Utilities
___ = TRANSPARENT
XXX = NO
BOOT = BOOTLOADER
_S = lambda a: MODS_KEY(MODS(RSHIFT), a) # hold SHIFT + tap character
_A = lambda a: MODS_KEY(MODS(RALT), a) # hold ALT + tap character
_C = lambda a: MODS_KEY(MODS(RCTRL), a) # hold CONTROL+ tap character
LT = lambda a,b=None: LAYER_TAP(a,b) # layer "a" if held, "b" if tapped (b is optional)
MT = lambda a,b: MODS_TAP(MODS(a),b) # modifier "a" if held, "b" if tapped
# ITALIAN CHARMAP FOR ANSI LAYOUT
# Set the computer in the Italian keyboard input mode
Eeeeeeeee
# layer definitions
QWERT=0
SHIFT=1
NUMBE=2
SYMBO=3
FUNCT=4
BLUET=5
ACCEN=6
MOUSE=7
NAVIG=8
keyboard = Keyboard()
keyboard.keymap = (
# layer 0 QWERT: remapped to match the ANSI layout with the Italian keyboard on the computer
(
ESC, Q, W, E, R, T, Y, U, I, O, P, BACKSPACE,
MT(LSHIFT, TAB), A, S, LT(NAVIG,D), F, G, H, J, K, L, IT_SCLN, MT(RSHIFT, ENTER),
LT(SHIFT, DEL), Z, X, C, V, LT(BLUET, B), N, M, IT_COMM, IT_FULL, UP, LT(SHIFT, IT_SLSH),
LCTRL, LALT, LT(FUNCT), LGUI, LT(NUMBE), LT(ACCEN, SPACE), LT(SYMBO), LT(NAVIG, IT_QUOT), LEFT, DOWN, RIGHT
),
# layer 1 SHIFT: remapped to match the ANSI layout with the Italian keyboard on the computer
(
ESC, _S(Q), _S(W), _S(E), _S(R), _S(T), _S(Y), _S(U), _S(I), _S(O), _S(P), BACKSPACE,
TAB, _S(A), _S(S), _S(D), _S(F), _S(G), _S(H), _S(J), _S(K), _S(L), IT_COLN, _S(ENTER),
LSHIFT, _S(Z), _S(X), _S(C), _S(V), _S(B), _S(N), _S(M), IT_MINO, IT_MAJO, _S(UP), IT_QSTN,
_S(LCTRL), _S(LALT), _S(LGUI), _S(LGUI), LT(SYMBO), LT(ACCEN, SPACE), LT(SYMBO), LT(NAVIG, IT_DQUO), _S(LEFT), _S(DOWN), _S(RIGHT)
),
# layer 0 NUMBE: remapped to match the ANSI layout with the Italian keyboard on the computer
(
ESC, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, BACKSPACE,
MT(LSHIFT, TAB), IT_PLUS, IT_MINU, IT_SLSH, IT_STAR, IT_EQAL, XXX, XXX, IT_LSQR, IT_RSQR, IT_BSLS, ENTER,
LT(SHIFT, DEL), XXX, XXX, XXX, XXX, XXX, XXX, XXX, XXX, XXX, XXX, XXX,
LCTRL, LALT, LGUI, LGUI, LT(NUMBE), LT(ACCEN, SPACE), LT(SYMBO), LT(NAVIG, LGUI), LEFT, DOWN, RIGHT
),
# layer 1 SYMBO: remapped to match the ANSI layout with the Italian keyboard on the computer
(
ESC, IT_EXCL, IT_AT, IT_SHRP, IT_DOLL, IT_PERC, IT_POWE, IT_ECOM, IT_STAR, IT_LPAR, IT_RPAR, BACKSPACE,
MT(LSHIFT, TAB), IT_EQAL, IT_UNDS, IT_QSTN, IT_STAR, IT_EQAL, XXX, XXX, IT_LBRK, IT_RBRK, IT_PIPE, ENTER,
LT(SHIFT, DEL), XXX, XXX, XXX, XXX, XXX, XXX, XXX, XXX, XXX, XXX, XXX,
LCTRL, LALT, LGUI, LGUI, LT(NUMBE), LT(ACCEN, SPACE), LT(SYMBO), LT(NAVIG, LGUI), LEFT, DOWN, RIGHT
),
# layer 2 FUNCT: MACRO(0) to read the battery level (requires a 3 wires JST connector from the battery)
(
ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, DEL,
XXX, XXX, XXX, XXX, SHUTDOWN, XXX, XXX, XXX,SUSPEND,AUDIO_VOL_DOWN,AUDIO_VOL_UP,AUDIO_MUTE,
LSHIFT, XXX, XXX, XXX, XXX,BOOT, XXX,MACRO(0), XXX, XXX, UP, RSHIFT,
LCTRL, LALT, LGUI, LGUI, LT(NUMBE), LT(ACCEN, SPACE), LT(SYMBO), LT(NAVIG, LGUI), LEFT, DOWN, RIGHT
),
# layer 3 BLUET: default bluetooth functionality plus the RGB effects
(
BT_TOGGLE,BT1,BT2, BT3,BT4,BT5,BT6,BT7, BT8, BT9, BT0, BOOTLOADER,
XXX, XXX, XXX, XXX, XXX, XXX, XXX, XXX, XXX, XXX, XXX, XXX,
XXX, XXX, XXX, XXX, XXX, XXX, XXX, XXX, XXX, XXX, XXX, XXX,
XXX, XXX, XXX, XXX, XXX, XXX, XXX, XXX, XXX, XXX, XXX,
),
# layer 4 ACCEN: hit space and the corresponding letter to get the accent letter and the euro sign
(
'`', IT_EURO,XXX, IT_EGRV, XXX, XXX, XXX, IT_UGRV,IT_IGRV,IT_OGRV, XXX, MODS_KEY(MODS(LGUI,LSHIFT), 3),
XXX, IT_AGRV,XXX, XXX, XXX, XXX, XXX, XXX, XXX, XXX, XXX, XXX,
LSHIFT, XXX, XXX, XXX, XXX, XXX, XXX, XXX, XXX, XXX, XXX, RSHIFT,
XXX, XXX, XXX, XXX, XXX, XXX, XXX, XXX, XXX, XXX, XXX,
),
# layer 5 MOUSE: mouse movements
(
___, ___, ___, ___, ___, ___,MS_W_UP,MS_UL,MS_UP,MS_UR, ___, ___,
___, ___, ___, ___, ___, ___,MS_BTN1,MS_LT,MS_DN,MS_RT,MS_BTN2, ___,
LSHIFT, ___, ___, ___, ___, ___,MS_W_DN,MS_DL,MS_DN,MS_DR, ___, RSHIFT,
___, ___, ___, ___, ___, ___, ___, ___, ___, ___, ___, ___
),
# layer 6 NAVIG: navigation movements using j, k, l, i
(
___, ___, ___, ___, ___, ___, ___, HOME, UP, PGUP, ___, ___,
___, ___, ___, ___, RSHIFT, ___, ___, LEFT, DOWN,RIGHT,___, ___,
LSHIFT, ___, ___, ___, ___, ___, ___, END, DOWN, PGDN, ___, UP,
___, ___, ___, ___, ___, ___, ___, ___, ___, LEFT, DOWN, RIGHT
),
)
def macro_handler(dev, n, is_down):
if is_down:
pass
else:
dev.send_text('battery level is {}%'.format(battery_level()))
keyboard.macro_handler = macro_handler
keyboard.verbose = False
keyboard.fast_type_thresh = 60 # lower value to avoid navigation issue when hitting right shift too fast. Default is 200
keyboard.run()