libobs: Enable setting hotkey name and description

This commit is contained in:
vokama 2018-05-29 04:08:28 +03:00
parent bae80a3ec4
commit c457630c39
2 changed files with 67 additions and 0 deletions

View File

@ -79,6 +79,62 @@ obs_hotkey_t *obs_hotkey_binding_get_hotkey(obs_hotkey_binding_t *binding)
return binding->hotkey;
}
static inline bool find_id(obs_hotkey_id id, size_t *idx);
void obs_hotkey_set_name(obs_hotkey_id id, const char *name)
{
size_t idx;
if (!find_id(id, &idx))
return;
obs_hotkey_t *hotkey = &obs->hotkeys.hotkeys.array[idx];
bfree(hotkey->name);
hotkey->name = bstrdup(name);
}
void obs_hotkey_set_description(obs_hotkey_id id, const char *desc)
{
size_t idx;
if (!find_id(id, &idx))
return;
obs_hotkey_t *hotkey = &obs->hotkeys.hotkeys.array[idx];
bfree(hotkey->description);
hotkey->description = bstrdup(desc);
}
static inline bool find_pair_id(obs_hotkey_pair_id id, size_t *idx);
void obs_hotkey_pair_set_names(obs_hotkey_pair_id id,
const char *name0, const char *name1)
{
size_t idx;
obs_hotkey_pair_t pair;
if (!find_pair_id(id, &idx))
return;
pair = obs->hotkeys.hotkey_pairs.array[idx];
obs_hotkey_set_name(pair.id[0], name0);
obs_hotkey_set_name(pair.id[1], name1);
}
void obs_hotkey_pair_set_descriptions(obs_hotkey_pair_id id,
const char *desc0, const char *desc1)
{
size_t idx;
obs_hotkey_pair_t pair;
if (!find_pair_id(id, &idx))
return;
pair = obs->hotkeys.hotkey_pairs.array[idx];
obs_hotkey_set_description(pair.id[0], desc0);
obs_hotkey_set_description(pair.id[1], desc1);
}
static void hotkey_signal(const char *signal, obs_hotkey_t *hotkey)
{
calldata_t data;

View File

@ -60,6 +60,8 @@ enum obs_hotkey_registerer_type {
};
typedef enum obs_hotkey_registerer_type obs_hotkey_registerer_t;
/* getter functions */
EXPORT obs_hotkey_id obs_hotkey_get_id(const obs_hotkey_t *key);
EXPORT const char *obs_hotkey_get_name(const obs_hotkey_t *key);
EXPORT const char *obs_hotkey_get_description(const obs_hotkey_t *key);
@ -76,6 +78,15 @@ EXPORT obs_hotkey_id obs_hotkey_binding_get_hotkey_id(
EXPORT obs_hotkey_t *obs_hotkey_binding_get_hotkey(
obs_hotkey_binding_t *binding);
/* setter functions */
EXPORT void obs_hotkey_set_name(obs_hotkey_id id, const char *name);
EXPORT void obs_hotkey_set_description(obs_hotkey_id id, const char *desc);
EXPORT void obs_hotkey_pair_set_names(obs_hotkey_pair_id id,
const char *name0, const char *name1);
EXPORT void obs_hotkey_pair_set_descriptions(obs_hotkey_pair_id id,
const char *desc0, const char *desc1);
#ifndef SWIG
struct obs_hotkeys_translations {
const char *insert;