X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fconfig%2Fkeys.c;h=7fcbc378a174d544dd247e8dba4191d6bcf7aaae;hb=a7d3284e7ed2676c78b519397f3a15473c214f3d;hp=7b429ed716fed5e6777178e334dec72a99c0f20b;hpb=d66f3ddc20969df03a670422a829c930e495a8ad;p=vlc diff --git a/src/config/keys.c b/src/config/keys.c index 7b429ed716..7fcbc378a1 100644 --- a/src/config/keys.c +++ b/src/config/keys.c @@ -38,6 +38,7 @@ #ifdef HAVE_SEARCH_H # include #endif +#include #include #include @@ -274,6 +275,7 @@ static const struct action actions[] = { "audiodevice-cycle", ACTIONID_AUDIODEVICE_CYCLE, }, { "chapter-next", ACTIONID_CHAPTER_NEXT, }, { "chapter-prev", ACTIONID_CHAPTER_PREV, }, + { "clear-playlist", ACTIONID_PLAY_CLEAR, }, { "crop", ACTIONID_CROP, }, { "crop-bottom", ACTIONID_CROP_BOTTOM, }, { "crop-left", ACTIONID_CROP_LEFT, }, @@ -287,6 +289,7 @@ static const struct action actions[] = { "frame-next", ACTIONID_FRAME_NEXT, }, { "incr-scalefactor", ACTIONID_SCALE_UP, }, { "intf-boss", ACTIONID_INTF_BOSS, }, + { "intf-popup-menu", ACTIONID_INTF_POPUP_MENU, }, { "intf-show", ACTIONID_INTF_TOGGLE_FSC, }, { "jump+extrashort", ACTIONID_JUMP_FORWARD_EXTRASHORT, }, { "jump+long", ACTIONID_JUMP_FORWARD_LONG, }, @@ -319,7 +322,8 @@ static const struct action actions[] = { "play-pause", ACTIONID_PLAY_PAUSE, }, { "position", ACTIONID_POSITION, }, { "prev", ACTIONID_PREV, }, - { "program-sid", ACTIONID_PROGRAM_SID, }, + { "program-sid-next", ACTIONID_PROGRAM_SID_NEXT, }, + { "program-sid-prev", ACTIONID_PROGRAM_SID_PREV, }, { "quit", ACTIONID_QUIT, }, { "random", ACTIONID_RANDOM, }, { "rate-faster-fine", ACTIONID_RATE_FASTER_FINE, }, @@ -343,6 +347,10 @@ static const struct action actions[] = { "subdelay-up", ACTIONID_SUBDELAY_UP, }, { "subpos-down", ACTIONID_SUBPOS_DOWN, }, { "subpos-up", ACTIONID_SUBPOS_UP, }, + { "subsync-apply", ACTIONID_SUBSYNC_APPLY, }, + { "subsync-markaudio", ACTIONID_SUBSYNC_MARKAUDIO, }, + { "subsync-marksub", ACTIONID_SUBSYNC_MARKSUB, }, + { "subsync-reset", ACTIONID_SUBSYNC_RESET, }, { "subtitle-track", ACTIONID_SUBTITLE_TRACK, }, { "title-next", ACTIONID_TITLE_NEXT, }, { "title-prev", ACTIONID_TITLE_PREV, }, @@ -405,14 +413,36 @@ static int vlc_key_to_action (vlc_object_t *obj, const char *varname, return var_SetInteger (obj, "key-action", (*pent)->action); } +/** + * Adds a mapping from a certain key code to a certain action. + */ +static int vlc_AddMapping (void **map, uint32_t keycode, vlc_action_t action) +{ + struct mapping *entry = malloc (sizeof (*entry)); + if (entry == NULL) + return ENOMEM; + entry->key = keycode; + entry->action = action; + + struct mapping **pent = tsearch (entry, map, keycmp); + if (unlikely(pent == NULL)) + return ENOMEM; + if (*pent != entry) + { + free (entry); + return EEXIST; + } + return 0; +} + /** * Sets up all key mappings for a given action. * \param map tree (of struct mapping entries) to write mappings to * \param confname VLC configuration item to read mappings from * \param action action ID */ -static void vlc_MapAction (vlc_object_t *obj, void **map, - const char *confname, vlc_action_t action) +static void vlc_InitAction (vlc_object_t *obj, void **map, + const char *confname, vlc_action_t action) { char *keys = var_InheritString (obj, confname); if (keys == NULL) @@ -429,25 +459,12 @@ static void vlc_MapAction (vlc_object_t *obj, void **map, continue; } - struct mapping *entry = malloc (sizeof (*entry)); - if (entry == NULL) - continue; - entry->key = code; - entry->action = action; - - struct mapping **pent = tsearch (entry, map, keycmp); - if (unlikely(pent == NULL)) - continue; - if (*pent != entry) - { - free (entry); + if (vlc_AddMapping (map, code, action) == EEXIST) msg_Warn (obj, "Key \"%s\" bound to multiple actions", key); - } } free (keys); } - /** * Initializes the key map from configuration. */ @@ -485,12 +502,30 @@ struct vlc_actions *vlc_InitActions (libvlc_int_t *libvlc) char name[12 + MAXACTION]; snprintf (name, sizeof (name), "global-key-%s", actions[i].name); - vlc_MapAction (obj, &as->map, name + 7, actions[i].value); - vlc_MapAction (obj, &as->global_map, name, actions[i].value); + vlc_InitAction (obj, &as->map, name + 7, actions[i].value); + vlc_InitAction (obj, &as->global_map, name, actions[i].value); } - keys->psz_action = NULL; + /* Initialize mouse wheel events */ + int mousemode = var_InheritInteger (obj, "hotkeys-mousewheel-mode"); + if (mousemode < 2) + { + vlc_AddMapping (&as->map, + mousemode ? KEY_MOUSEWHEELRIGHT : KEY_MOUSEWHEELUP, + ACTIONID_VOL_UP); + vlc_AddMapping (&as->map, + mousemode ? KEY_MOUSEWHEELLEFT : KEY_MOUSEWHEELDOWN, + ACTIONID_VOL_DOWN); + vlc_AddMapping (&as->map, + mousemode ? KEY_MOUSEWHEELUP : KEY_MOUSEWHEELRIGHT, + ACTIONID_JUMP_FORWARD_EXTRASHORT); + vlc_AddMapping (&as->map, + mousemode ? KEY_MOUSEWHEELDOWN : KEY_MOUSEWHEELLEFT, + ACTIONID_JUMP_BACKWARD_EXTRASHORT); + } + + libvlc->p_hotkeys = as->keys; var_AddCallback (obj, "key-pressed", vlc_key_to_action, &as->map); var_AddCallback (obj, "global-key-pressed", vlc_key_to_action,