1 /*****************************************************************************
2 * action.c: key to action mapping
3 *****************************************************************************
4 * Copyright © 2008 Rémi Denis-Courmont
5 * © 2009 Antoine Cellerier
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.
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.
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 *****************************************************************************/
26 #include <vlc_common.h>
27 #include "../libvlc.h"
31 int vlc_key_to_action (vlc_object_t *libvlc, const char *varname,
32 vlc_value_t prevkey, vlc_value_t curkey, void *priv)
34 const struct hotkey *key = priv;
39 while (key->i_key != curkey.i_int)
41 if (key->psz_action == NULL)
42 return VLC_SUCCESS; /* key is not mapped to anything */
47 return var_SetInteger (libvlc, "key-action", key->i_action);
50 static int actcmp(const void *key, const void *ent)
52 const struct action *act = ent;
53 return strcmp(key, act->name);
56 vlc_key_t vlc_GetActionId(const char *name)
58 const struct action *act;
60 act = bsearch(name, libvlc_actions, libvlc_actions_count, sizeof(*act),
62 return (act != NULL) ? act->value : 0;