VLC 4.0.0-dev
actions.c File Reference

This file defines functions and structures for hotkey handling in vlc. More...

Include dependency graph for actions.c:

Data Structures

struct  key_descriptor
 
struct  name2action
 
struct  mapping
 
struct  vlc_actions_t
 

Macros

#define MAXACTION   27
 

Functions

static int keystrcmp (const void *key, const void *elem)
 
static char * utf8_cp (uint_fast32_t cp, char *buf)
 
uint_fast32_t vlc_str2keycode (const char *name)
 Parse a human-readable string representation of a VLC key code. More...
 
static const char * nooptext (const char *txt)
 
char * vlc_keycode2str (uint_fast32_t code, bool locale)
 Format a human-readable and unique representation of a VLC key code (including modifiers). More...
 
static int keycmp (const void *a, const void *b)
 
static int vlc_key_to_action (vlc_object_t *obj, const char *varname, vlc_value_t prevkey, vlc_value_t curkey, void *d)
 
static int add_mapping (void **map, uint32_t keycode, vlc_action_id_t action)
 Adds a mapping from a certain key code to a certain action. More...
 
static void add_wheel_mapping (void **map, uint32_t kmore, uint32_t kless, int mode)
 
static void init_action (vlc_object_t *obj, void **map, const char *confname, vlc_action_id_t action)
 Sets up all key mappings for a given action. More...
 
int libvlc_InternalActionsInit (libvlc_int_t *libvlc)
 Initializes the key map from configuration. More...
 
void libvlc_InternalActionsClean (libvlc_int_t *libvlc)
 Destroys the key map. More...
 
static int actcmp (const void *key, const void *ent)
 
vlc_action_id_t vlc_actions_get_id (const char *name)
 Get the action ID from the action name in the configuration subsystem. More...
 
size_t vlc_actions_get_keycodes (vlc_object_t *p_obj, const char *psz_key_name, bool b_global, uint_fast32_t **pp_keycodes)
 Get keycodes from a action key name and vlc configuration. More...
 
const char *const * vlc_actions_get_key_names (vlc_object_t *p_obj)
 Get a list a key names. More...
 

Variables

static const struct key_descriptor s_keys []
 
static const struct name2action s_names2actions []
 

Detailed Description

This file defines functions and structures for hotkey handling in vlc.

Macro Definition Documentation

◆ MAXACTION

#define MAXACTION   27

Function Documentation

◆ actcmp()

static int actcmp ( const void *  key,
const void *  ent 
)
static

References name2action::psz.

Referenced by vlc_actions_get_id().

◆ add_mapping()

static int add_mapping ( void **  map,
uint32_t  keycode,
vlc_action_id_t  action 
)
static

Adds a mapping from a certain key code to a certain action.

References mapping::action, keycmp(), tsearch(), and unlikely.

Referenced by add_wheel_mapping(), and init_action().

◆ add_wheel_mapping()

static void add_wheel_mapping ( void **  map,
uint32_t  kmore,
uint32_t  kless,
int  mode 
)
static

◆ init_action()

static void init_action ( vlc_object_t obj,
void **  map,
const char *  confname,
vlc_action_id_t  action 
)
static

Sets up all key mappings for a given action.

Parameters
maptree (of struct mapping entries) to write mappings to
confnameVLC configuration item to read mappings from
actionaction ID

References mapping::action, add_mapping(), mapping::key, KEY_UNSET, msg_Warn, strtok_r(), var_InheritString(), and vlc_str2keycode().

Referenced by libvlc_InternalActionsInit().

◆ keycmp()

static int keycmp ( const void *  a,
const void *  b 
)
static

References mapping::key.

Referenced by add_mapping(), and vlc_key_to_action().

◆ keystrcmp()

static int keystrcmp ( const void *  key,
const void *  elem 
)
static

Referenced by vlc_str2keycode().

◆ libvlc_InternalActionsClean()

void libvlc_InternalActionsClean ( libvlc_int_t libvlc)

◆ libvlc_InternalActionsInit()

◆ nooptext()

static const char * nooptext ( const char *  txt)
static

Referenced by vlc_keycode2str().

◆ utf8_cp()

static char * utf8_cp ( uint_fast32_t  cp,
char *  buf 
)
static

Referenced by vlc_keycode2str().

◆ vlc_actions_get_id()

vlc_action_id_t vlc_actions_get_id ( const char *  name)

Get the action ID from the action name in the configuration subsystem.

Get the action ID from an action key name.

Returns
the action ID or ACTIONID_NONE on error.

References actcmp(), ACTIONID_NONE, ARRAY_SIZE, name2action::id, name, and s_names2actions.

◆ vlc_actions_get_key_names()

const char *const * vlc_actions_get_key_names ( vlc_object_t p_obj)

Get a list a key names.

Returns
A NULL terminated list of const char *

References libvlc_priv_t::actions, libvlc_priv(), vlc_actions_t::ppsz_keys, and vlc_object_instance.

◆ vlc_actions_get_keycodes()

size_t vlc_actions_get_keycodes ( vlc_object_t p_obj,
const char *  psz_key_name,
bool  b_global,
uint_fast32_t **  pp_keycodes 
)

Get keycodes from a action key name and vlc configuration.

Returns
The number of keycodes for this action, or 0 in case of an error. The list needs to be released with free()

References MAXACTION, strtok_r(), unlikely, var_InheritString(), vlc_alloc(), and vlc_str2keycode().

◆ vlc_key_to_action()

static int vlc_key_to_action ( vlc_object_t obj,
const char *  varname,
vlc_value_t  prevkey,
vlc_value_t  curkey,
void *  d 
)
static

◆ vlc_keycode2str()

char * vlc_keycode2str ( uint_fast32_t  code,
bool  locale 
)

Format a human-readable and unique representation of a VLC key code (including modifiers).

Parameters
codekey code to translate to a string
localetrue to get a localized string, false to get a C string suitable for 'vlcrc'
Returns
a heap-allocated string, or NULL on error.

References ARRAY_SIZE, asprintf(), key_descriptor::i_code, KEY_MODIFIER_ALT, KEY_MODIFIER_COMMAND, KEY_MODIFIER_CTRL, KEY_MODIFIER_META, KEY_MODIFIER_SHIFT, N_, name, nooptext(), key_descriptor::psz, s_keys, utf8_cp(), and vlc_gettext().

◆ vlc_str2keycode()

uint_fast32_t vlc_str2keycode ( const char *  name)

Parse a human-readable string representation of a VLC key code.

Note
This only works with the American English representation (a.k.a. C or POSIX), not with the local representation returned from vlc_keycode2str().
Returns
a VLC key code, or KEY_UNSET on failure.

References ARRAY_SIZE, key_descriptor::i_code, KEY_MODIFIER_ALT, KEY_MODIFIER_COMMAND, KEY_MODIFIER_CTRL, KEY_MODIFIER_META, KEY_MODIFIER_SHIFT, KEY_UNSET, keystrcmp(), name, s_keys, and vlc_towc().

Referenced by init_action(), and vlc_actions_get_keycodes().

Variable Documentation

◆ s_keys

const struct key_descriptor s_keys[]
static

Referenced by vlc_keycode2str(), and vlc_str2keycode().

◆ s_names2actions

const struct name2action s_names2actions[]
static