]> git.sesse.net Git - vlc/blob - src/misc/action.c
Add vlc_GetActionId().
[vlc] / src / misc / action.c
1 /*****************************************************************************
2  * action.c: key to action mapping
3  *****************************************************************************
4  * Copyright © 2008 Rémi Denis-Courmont
5  *           © 2009 Antoine Cellerier
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
20  *****************************************************************************/
21
22 #ifdef HAVE_CONFIG_H
23 # include "config.h"
24 #endif
25
26 #include <vlc_common.h>
27 #include "../libvlc.h"
28 #include <vlc_keys.h>
29
30 int vlc_key_to_action (vlc_object_t *libvlc, const char *varname,
31                        vlc_value_t prevkey, vlc_value_t curkey, void *priv)
32 {
33     const struct hotkey *key = priv;
34
35     (void)varname;
36     (void)prevkey;
37
38     while (key->i_key != curkey.i_int)
39     {
40         if (key->psz_action == NULL)
41             return VLC_SUCCESS; /* key is not mapped to anything */
42
43         key++;
44     }
45
46     return var_SetInteger (libvlc, "key-action", key->i_action);
47 }
48
49 vlc_key_t vlc_GetActionId(const char *name)
50 {
51     for (size_t i = 0; i < libvlc_actions_count; i++)
52         if (!strcmp(libvlc_actions[i].name, name))
53             return libvlc_actions[i].value;
54     return 0;
55 }
56