-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkeyboard.lua
More file actions
121 lines (106 loc) · 8.8 KB
/
keyboard.lua
File metadata and controls
121 lines (106 loc) · 8.8 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
require( "globals" )
local actions = require( "actions" )
local util = require( "util" )
local keyboard = {}
keyboard.modkeys = { shift = false, ctrl = false, alt = false }
keyboard.shortcuts =
{
[ "Play (x)" ] = { modshift = false, modctrl = false, modalt = false, key = "x", action = actions.play },
[ "Pause (c)" ] = { modshift = false, modctrl = false, modalt = false, key = "c", action = actions.pause },
[ "Stop (v)" ] = { modshift = false, modctrl = false, modalt = false, key = "v", action = actions.stop },
[ "Next track (b)" ] = { modshift = false, modctrl = false, modalt = false, key = "b", action = actions.next },
[ "Next track (Keypad 6)" ] = { modshift = false, modctrl = false, modalt = false, key = "kp6", action = actions.next },
[ "Previous track (z)" ] = { modshift = false, modctrl = false, modalt = false, key = "z", action = actions.prev },
[ "Previous track(Keypad 4)" ] = { modshift = false, modctrl = false, modalt = false, key = "kp4", action = actions.prev },
[ "Toggle EQ (Alt+g)" ] = { modshift = false, modctrl = false, modalt = true, key = "g", action = actions.toggle_eq },
[ "Toggle PL (Alt+e)" ] = { modshift = false, modctrl = false, modalt = true, key = "e", action = actions.toggle_pl },
-- add toggle fullscreen?
[ "Minimize (Alt+m)" ] = { modshift = false, modctrl = false, modalt = true, key = "m", action = actions.minimize },
-- "open presets" clashes with toggle shuffle
[ "Load preset (Ctrl+Alt+s)" ] = { modshift = false, modctrl = true, modalt = true, key = "s", action = actions.load_preset },
-- save preset - no shortcut
-- delete preset - no shortcut
[ "Toggle time display mode (Ctrl+t)" ] = { modshift = false, modctrl = true, modalt = false, key = "t", action = actions.toggle_time_display_mode },
[ "Toggle shuffle (s)" ] = { modshift = false, modctrl = false, modalt = false, key = "s", action = actions.toggle_shuffle },
[ "Toggle repeat (r)" ] = { modshift = false, modctrl = false, modalt = false, key = "r", action = actions.toggle_repeat },
[ "Toggle EQ enabled (n)" ] = { modshift = false, modctrl = false, modalt = false, key = "n", action = actions.toggle_eq_enabled },
[ "Toggle EQ auto (a)" ] = { modshift = false, modctrl = false, modalt = false, key = "a", action = actions.toggle_eq_auto },
[ "Open file(s) (l)" ] = { modshift = false, modctrl = false, modalt = false, key = "l", action = actions.open_play_files },
[ "Open file(s) (Keypad 0)" ] = { modshift = false, modctrl = false, modalt = false, key = "kp0", action = actions.open_play_files },
[ "Open directory (Shift+l)" ] = { modshift = true, modctrl = false, modalt = false, key = "l", action = actions.open_play_directory },
[ "Open directory (Insert)" ] = { modshift = false, modctrl = false, modalt = false, key = "insert", action = actions.open_play_directory },
[ "Turn volume up (Up Arrow)" ] = { modshift = false, modctrl = false, modalt = false, key = "up", action = actions.set_volume, val = 1 },
[ "Turn volume up (Keypad 8)" ] = { modshift = false, modctrl = false, modalt = false, key = "kp8", action = actions.set_volume, val = 1 },
[ "Turn volume down (Down Arrow)" ] = { modshift = false, modctrl = false, modalt = false, key = "down", action = actions.set_volume, val = -1 },
[ "Turn volume down (Keypad 2)" ] = { modshift = false, modctrl = false, modalt = false, key = "kp2", action = actions.set_volume, val = -1 },
[ "FF 5 seconds (Right Arrow)" ] = { modshift = false, modctrl = false, modalt = false, key = "right", action = actions.seek, val = 0 },
[ "RW 5 seconds (Left Arrow)" ] = { modshift = false, modctrl = false, modalt = false, key = "left", action = actions.seek, val = 1 },
[ "Increase preamp (`)" ] = { modshift = false, modctrl = false, modalt = false, key = "`", action = actions.eq_set_preamp, val = -1 },
[ "Decrease preamp (Tab)" ] = { modshift = false, modctrl = false, modalt = false, key = "tab", action = actions.eq_set_preamp, val = 1 },
[ "Increase EQ band 1 (Shift+1)" ] = { modshift = true, modctrl = false, modalt = false, key = "1", action = actions.eq_set_band, val = -1, index = 1 },
[ "Increase EQ band 2 (Shift+2)" ] = { modshift = true, modctrl = false, modalt = false, key = "2", action = actions.eq_set_band, val = -1, index = 2 },
[ "Increase EQ band 3 (Shift+3)" ] = { modshift = true, modctrl = false, modalt = false, key = "3", action = actions.eq_set_band, val = -1, index = 3 },
[ "Increase EQ band 4 (Shift+4)" ] = { modshift = true, modctrl = false, modalt = false, key = "4", action = actions.eq_set_band, val = -1, index = 4 },
[ "Increase EQ band 5 (Shift+5)" ] = { modshift = true, modctrl = false, modalt = false, key = "5", action = actions.eq_set_band, val = -1, index = 5 },
[ "Increase EQ band 6 (Shift+6)" ] = { modshift = true, modctrl = false, modalt = false, key = "6", action = actions.eq_set_band, val = -1, index = 6 },
[ "Increase EQ band 7 (Shift+7)" ] = { modshift = true, modctrl = false, modalt = false, key = "7", action = actions.eq_set_band, val = -1, index = 7 },
[ "Increase EQ band 8 (Shift+8)" ] = { modshift = true, modctrl = false, modalt = false, key = "8", action = actions.eq_set_band, val = -1, index = 8 },
[ "Increase EQ band 9 (Shift+9)" ] = { modshift = true, modctrl = false, modalt = false, key = "9", action = actions.eq_set_band, val = -1, index = 9 },
[ "Increase EQ band 10 (Shift+0)" ] = { modshift = true, modctrl = false, modalt = false, key = "0", action = actions.eq_set_band, val = -1, index = 10 },
[ "Decrease EQ band 1 (Shift+1)" ] = { modshift = false, modctrl = true, modalt = false, key = "1", action = actions.eq_set_band, val = 1, index = 1 },
[ "Decrease EQ band 2 (Shift+2)" ] = { modshift = false, modctrl = true, modalt = false, key = "2", action = actions.eq_set_band, val = 1, index = 2 },
[ "Decrease EQ band 3 (Shift+3)" ] = { modshift = false, modctrl = true, modalt = false, key = "3", action = actions.eq_set_band, val = 1, index = 3 },
[ "Decrease EQ band 4 (Shift+4)" ] = { modshift = false, modctrl = true, modalt = false, key = "4", action = actions.eq_set_band, val = 1, index = 4 },
[ "Decrease EQ band 5 (Shift+5)" ] = { modshift = false, modctrl = true, modalt = false, key = "5", action = actions.eq_set_band, val = 1, index = 5 },
[ "Decrease EQ band 6 (Shift+6)" ] = { modshift = false, modctrl = true, modalt = false, key = "6", action = actions.eq_set_band, val = 1, index = 6 },
[ "Decrease EQ band 7 (Shift+7)" ] = { modshift = false, modctrl = true, modalt = false, key = "7", action = actions.eq_set_band, val = 1, index = 7 },
[ "Decrease EQ band 8 (Shift+8)" ] = { modshift = false, modctrl = true, modalt = false, key = "8", action = actions.eq_set_band, val = 1, index = 8 },
[ "Decrease EQ band 9 (Shift+9)" ] = { modshift = false, modctrl = true, modalt = false, key = "9", action = actions.eq_set_band, val = 1, index = 9 },
[ "Decrease EQ band 10 (Shift+0)" ] = { modshift = false, modctrl = true, modalt = false, key = "0", action = actions.eq_set_band, val = 1, index = 10 },
[ "Jump 10 songs forward (Keypad 3)" ] = { modshift = false, modctrl = false, modalt = false, key = "kp3", action = actions.jump_10_songs_forward },
[ "Jump 10 songs back (Keypad 1)" ] = { modshift = false, modctrl = false, modalt = false, key = "kp1", action = actions.jump_10_songs_forward },
[ "Cycle background mode (F1)" ] = { modshift = false, modctrl = false, modalt = false, key = "f1", action = actions.cycle_background_mode },
[ "Cycle background (F2)" ] = { modshift = false, modctrl = false, modalt = false, key = "f2", action = actions.cycle_background },
[ "Cycle shader (F3)" ] = { modshift = false, modctrl = false, modalt = false, key = "f3", action = actions.cycle_vis_shader },
[ "Close About app (Esc)" ] = { modshift = false, modctrl = false, modalt = false, key = "escape", action = actions.close_about_app }
}
function keyboard.on_keypressed( key )
if key == "lshift" or key == "rshift" then
keyboard.modkeys.shift = true
end
if key == "lalt" or key == "ralt" then
keyboard.modkeys.alt = true
end
if key == "lctrl" or key == "rctrl" then
keyboard.modkeys.ctrl = true
end
for k, v in pairs( keyboard.shortcuts ) do
local t = keyboard.shortcuts
local mshift = keyboard.modkeys.shift
local mctrl = keyboard.modkeys.ctrl
local malt = keyboard.modkeys.alt
local modshift = t[ k ].modshift
local modctrl = t[ k ].modctrl
local modalt = t[ k ].modalt
local ak = t[ k ].key
local val = t[ k ].val
local index = t[ k ].index
if mshift == modshift and mctrl == modctrl and malt == modalt and ak == key then
t[ k ].action( val, index )
end
end
end
function keyboard.on_keyreleased( key )
if key == "lshift" or key == "rshift" then
keyboard.modkeys.shift = false
end
if key == "lalt" or key == "ralt" then
keyboard.modkeys.alt = false
end
if key == "lctrl" or key == "rctrl" then
keyboard.modkeys.ctrl = false
end
lovr.system.setKeyRepeat( false )
sync_interval = 0.2
end
return keyboard