-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.lua
More file actions
126 lines (99 loc) · 2.37 KB
/
Copy pathmain.lua
File metadata and controls
126 lines (99 loc) · 2.37 KB
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
require "keybow"
-- Keybow MINI --
system = "macOS"
-- system = "Linux" -- Uncomment for Linux!
key_02_pressed = false
audio_status = false
video_status = false
function setup()
keybow.use_mini()
keybow.auto_lights(false)
keybow.clear_lights()
key_02_pressed = false
audio_status = false
video_status = false
set_audio_video_leds()
end
-- Key mappings --
function handle_minikey_00(pressed)
if key_02_pressed then
volume_down(pressed)
else
toggle_audio(pressed)
end
end
function handle_minikey_01(pressed)
if key_02_pressed then
volume_up(pressed)
else
toggle_video(pressed)
end
end
function handle_minikey_02(pressed)
key_02_pressed = pressed
if pressed then
set_volume_leds()
else
set_audio_video_leds()
end
end
function set_audio_video_leds()
button_led(false, 0, audio_status)
button_led(false, 1, video_status)
keybow.set_pixel(2, 0, 0, 0)
end
function set_volume_leds()
keybow.set_pixel(0, 204, 153, 255)
keybow.set_pixel(1, 153, 0, 204)
keybow.set_pixel(2, 255, 255, 0)
end
function press_shortcut(key, pressed)
set_modifiers_key_down()
keybow.set_key(key, pressed)
set_modifiers_key_up()
end
-- Command(⌘)+Shift+A: Mute/unmute audio --
function toggle_audio(pressed)
press_shortcut("a", pressed)
if pressed then
audio_status = not audio_status
end
button_led(pressed, 0, audio_status)
end
-- Command(⌘)+Shift+V: Start/stop video --
function toggle_video(pressed)
press_shortcut("v", pressed)
if pressed then
video_status = not video_status
end
button_led(pressed, 1, video_status)
end
function volume_up(pressed)
keybow.set_media_key(keybow.MEDIA_VOL_UP, pressed)
end
function volume_down(pressed)
keybow.set_media_key(keybow.MEDIA_VOL_DOWN, pressed)
end
function set_modifiers_key_down()
set_modifiers(keybow.KEY_DOWN)
end
function set_modifiers_key_up()
set_modifiers(keybow.KEY_UP)
end
function set_modifiers(status)
if system == "macOS" then
keybow.set_modifier(keybow.RIGHT_META, status)
keybow.set_modifier(keybow.RIGHT_SHIFT, status)
else
keybow.set_modifier(keybow.RIGHT_CTRL, status)
end
end
function button_led(pressed, led, status)
if pressed then
keybow.set_pixel(led, 0, 0, 255)
elseif not pressed and status then
keybow.set_pixel(led, 0, 255, 0)
elseif not pressed and not status then
keybow.set_pixel(led, 255, 0, 0)
end
end