1 --[==========================================================================[
2 hotkeys
.lua
: hotkey handling
for VLC
3 --[==========================================================================[
4 Copyright (C
) 2007 the VideoLAN team
7 Authors
: Antoine Cellerier
<dionoea at videolan dot org
>
9 This program is free software
; you can redistribute it
and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation
; either version
2 of the License
, or
12 (at your option
) any later version
.
14 This program is distributed
in the hope that it will be useful
,
15 but WITHOUT ANY WARRANTY
; without even the implied warranty of
16 MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE
. See the
17 GNU General Public License
for more details
.
19 You should have received a copy of the GNU General Public License
20 along with this program
; if not, write to the Free Software
21 Foundation
, Inc
., 51 Franklin Street
, Fifth Floor
, Boston MA
02110-1301, USA
.
22 --]==========================================================================]
24 --[==========================================================================[
25 This is meant to replace modules
/control
/hotkeys
.c
26 (which will require some changes
in the VLC core hotkeys stuff
)
27 --]==========================================================================]
30 --common.table_print(vlc,"vlc.\t")
34 ["Space"] = "play-pause",
35 [113] --[[q]] = "quit",
36 [119] --[[w]] = "demo",
37 [120] --[[x]] = "demo2",
46 vlc
.osd
.icon("speaker")
51 channel1
= vlc
.osd
.channel_register()
52 channel2
= vlc
.osd
.channel_register()
54 vlc
.osd
.message("Hey!",channel1
)
55 vlc
.osd
.slider( 10, "horizontal", channel2
)
58 function action(func
,delta
)
59 return { func
= func
, delta
= delta
or 0, last
= 0, times
= 0 }
63 ["quit"] = action(quit
),
64 ["play-pause"] = action(play_pause
),
65 ["demo"] = action(demo
),
66 ["demo2"] = action(demo2
),
73 function action_trigger( action
)
74 print("action_trigger:",tostring(action
))
75 local a
= actions
[action
]
77 local date = vlc
.misc
.mdate()
78 if a
.delta
and date > a
.last
+ a
.delta
then
84 table.insert(queue
,action
)
87 vlc
.msg
.err("Key `"..key
.."' points to unknown action `"..bindings
[key
].."'.")
91 function key_press( var
, old
, new
, data
)
93 print("key_press:",tostring(key
))
95 action_trigger(bindings
[key
])
97 vlc
.msg
.err("Key `"..key
.."' isn't bound to any action.")
101 vlc
.var
.add_callback( vlc
.object
.libvlc(), "key-pressed", key_press
)
102 --vlc.var.add_callback( vlc.object.libvlc(), "action-triggered", action_trigger )
106 local action
= actions
[queue
[1]]
107 local ok
, msg
= pcall( action
.func
)
109 vlc
.msg
.err("Error while executing action `"..queue
[1].."': "..msg
)
111 table.remove(queue
,1)
113 die
= vlc
.misc
.lock_and_wait()
118 vlc
.var
.del_callback( vlc
.object
.libvlc(), "key-pressed", key_press
)
119 --vlc.var.del_callback( vlc.object.libvlc(), "action-triggered", action_trigger )