diff options
-rw-r--r-- | command.c | 33 | ||||
-rw-r--r-- | etc/input.conf | 128 | ||||
-rw-r--r-- | input/input.c | 71 | ||||
-rw-r--r-- | input/input.h | 3 | ||||
-rw-r--r-- | m_property.c | 8 | ||||
-rw-r--r-- | m_property.h | 20 |
6 files changed, 135 insertions, 128 deletions
@@ -404,9 +404,6 @@ static int mp_property_edition(m_option_t *prop, int action, void *arg, *(struct m_option *)arg = opt; return M_PROPERTY_OK; } - case M_PROPERTY_GET_WRAP: - *(bool *)arg = true; - return M_PROPERTY_OK; } return M_PROPERTY_NOT_IMPLEMENTED; } @@ -480,9 +477,6 @@ static int mp_property_angle(m_option_t *prop, int action, void *arg, resync_audio_stream(sh_audio); } return M_PROPERTY_OK; - case M_PROPERTY_GET_WRAP: - *(bool *)arg = true; - return M_PROPERTY_OK; } return M_PROPERTY_NOT_IMPLEMENTED; } @@ -508,7 +502,7 @@ static int mp_property_metadata(m_option_t *prop, int action, void *arg, return M_PROPERTY_OK; } case M_PROPERTY_KEY_ACTION: { - struct m_property_action *ka = arg; + struct m_property_action_arg *ka = arg; char *meta = demux_info_get(demuxer, ka->key); if (!meta) return M_PROPERTY_UNKNOWN; @@ -561,13 +555,15 @@ static int mp_property_volume(m_option_t *prop, int action, void *arg, case M_PROPERTY_SET: mixer_setvolume(&mpctx->mixer, *(float *) arg, *(float *) arg); return M_PROPERTY_OK; - case M_PROPERTY_SWITCH: - if (*(double *) arg <= 0) + case M_PROPERTY_SWITCH: { + struct m_property_switch_arg *sarg = arg; + if (sarg->inc <= 0) mixer_decvolume(&mpctx->mixer); else mixer_incvolume(&mpctx->mixer); return M_PROPERTY_OK; } + } return M_PROPERTY_NOT_IMPLEMENTED; } @@ -775,10 +771,12 @@ static int property_switch_track(m_option_t *prop, int action, void *arg, } return M_PROPERTY_OK; - case M_PROPERTY_SWITCH: + case M_PROPERTY_SWITCH: { + struct m_property_switch_arg *sarg = arg; mp_switch_track(mpctx, type, - track_next(mpctx, type, *(double *)arg >= 0 ? +1 : -1, track)); + track_next(mpctx, type, sarg->inc >= 0 ? +1 : -1, track)); return M_PROPERTY_OK; + } case M_PROPERTY_SET: mp_switch_track(mpctx, type, mp_track_by_tid(mpctx, type, *(int *)arg)); return M_PROPERTY_OK; @@ -1793,11 +1791,16 @@ void run_command(MPContext *mpctx, mp_cmd_t *cmd) break; } - case MP_CMD_SWITCH: { + case MP_CMD_ADD: + case MP_CMD_CYCLE: + { cmd->args[0].v.s = translate_legacy_property(cmd, cmd->args[0].v.s); - double s = 1; + struct m_property_switch_arg s = { + .inc = 1, + .wrap = cmd->id == MP_CMD_CYCLE, + }; if (cmd->args[1].v.f) - s = cmd->args[1].v.f; + s.inc = cmd->args[1].v.f; int r = mp_property_do(cmd->args[0].v.s, M_PROPERTY_SWITCH, &s, mpctx); if (r == M_PROPERTY_UNKNOWN) mp_msg(MSGT_CPLAYER, MSGL_WARN, @@ -1805,7 +1808,7 @@ void run_command(MPContext *mpctx, mp_cmd_t *cmd) else if (r <= 0) mp_msg(MSGT_CPLAYER, MSGL_WARN, "Failed to increment property '%s' by %g.\n", - cmd->args[0].v.s, s); + cmd->args[0].v.s, s.inc); else if (cmd->on_osd) show_property_osd(mpctx, cmd->args[0].v.s); break; diff --git a/etc/input.conf b/etc/input.conf index 2fd24080a6..a32495ab3a 100644 --- a/etc/input.conf +++ b/etc/input.conf @@ -26,12 +26,12 @@ # key combinations is only supported through the video windows of certain # output drivers (not in output windows of other drivers or in a terminal). -MOUSE_BTN0_DBL switch fullscreen # toggle fullscreen on/off -MOUSE_BTN2 switch pause # toggle pause on/off +MOUSE_BTN0_DBL cycle fullscreen # toggle fullscreen on/off +MOUSE_BTN2 cycle pause # toggle pause on/off MOUSE_BTN3 seek 10 MOUSE_BTN4 seek -10 -MOUSE_BTN5 switch volume 1 -MOUSE_BTN6 switch volume -1 +MOUSE_BTN5 add volume 1 +MOUSE_BTN6 add volume -1 # Seek units are in seconds, but note that these are limited by keyframes RIGHT seek 10 @@ -45,8 +45,8 @@ Shift+UP seek 5 0 1 Shift+DOWN seek -5 0 1 PGUP seek 600 PGDWN seek -600 -+ switch audio-delay 0.100 # this changes audio/video sync -- switch audio-delay -0.100 ++ add audio-delay 0.100 # this changes audio/video sync +- add audio-delay -0.100 [ speed_mult 0.9091 # scale playback speed ] speed_mult 1.1 { speed_mult 0.5 @@ -55,78 +55,78 @@ BS set speed 1.0 # reset speed to normal q quit q {encode} quit ESC quit -p switch pause # toggle pause/playback mode +p cycle pause # toggle pause/playback mode . frame_step # advance one frame and pause -SPACE switch pause +SPACE cycle pause > playlist_next # skip to next file ENTER playlist_next 1 # skip to next file or quit < playlist_prev # skip to previous file o osd # cycle through OSD mode I show_text "${filename}" # display filename in osd P show_progress -z switch sub-delay -0.1 # subtract 100 ms delay from subs -x switch sub-delay +0.1 # add +z add sub-delay -0.1 # subtract 100 ms delay from subs +x add sub-delay +0.1 # add g sub_step -1 # immediately display next subtitle y sub_step +1 # previous -9 switch volume -1 -/ switch volume -1 -0 switch volume 1 -* switch volume 1 -( switch balance -0.1 # adjust audio balance in favor of left -) switch balance 0.1 # right -m switch mute -1 switch contrast -1 -2 switch contrast 1 -3 switch brightness -1 -4 switch brightness 1 -5 switch hue -1 -6 switch hue 1 -7 switch saturation -1 -8 switch saturation 1 -d switch framedrop # cycle through framedrop modes +9 add volume -1 +/ add volume -1 +0 add volume 1 +* add volume 1 +( add balance -0.1 # adjust audio balance in favor of left +) add balance 0.1 # right +m cycle mute +1 add contrast -1 +2 add contrast 1 +3 add brightness -1 +4 add brightness 1 +5 add hue -1 +6 add hue 1 +7 add saturation -1 +8 add saturation 1 +d cycle framedrop # cycle through framedrop modes # toggle deinterlacer; requires either vdpau output, -vf yadif or kerndeint -D switch deinterlace -c switch colormatrix +D cycle deinterlace +c cycle colormatrix # Next 3 currently only work with --no-ass -r switch sub-pos -1 # move subtitles up -t switch sub-pos +1 # down -v switch sub-visibility +r add sub-pos -1 # move subtitles up +t add sub-pos +1 # down +v cycle sub-visibility # stretch SSA/ASS subtitles with anamorphic videos to match historical -V switch ass-vsfilter-aspect-compat -j switch sub # cycle through subtitles -J switch sub -1 # ...backwards -F switch sub-forced-only -SHARP switch audio # switch audio streams -_ switch video -TAB switch program +V cycle ass-vsfilter-aspect-compat +j cycle sub # cycle through subtitles +J cycle sub -1 # ...backwards +F cycle sub-forced-only +SHARP cycle audio # switch audio streams +_ cycle video +TAB cycle program i edl_mark # for use with --edlout mode -T switch ontop # toggle video window ontop of other windows -f switch fullscreen # toggle fullscreen +T cycle ontop # toggle video window ontop of other windows +f cycle fullscreen # toggle fullscreen s screenshot 0 # take a png screenshot S screenshot 1 # ...on every frame Alt+s screenshot 0 1 # take a screenshot of window contents Alt+S screenshot 1 1 # ...on every frame -w switch panscan -0.1 # zoom out with -panscan 0 -fs -e switch panscan +0.1 # in +w add panscan -0.1 # zoom out with -panscan 0 -fs +e add panscan +0.1 # in POWER quit -MENU switch osd -PLAY switch pause -PAUSE switch pause -PLAYPAUSE switch pause +MENU cycle osd +PLAY cycle pause +PAUSE cycle pause +PLAYPAUSE cycle pause STOP quit FORWARD seek 60 REWIND seek -60 NEXT playlist_next PREV playlist_prev -VOLUME_UP switch volume 1 -VOLUME_DOWN switch volume -1 -MUTE switch mute +VOLUME_UP add volume 1 +VOLUME_DOWN add volume -1 +MUTE cycle mute CLOSE_WIN quit CLOSE_WIN {encode} quit -! switch chapter -1 # skip to previous chapter -@ switch chapter 1 # next -E switch edition # next edition -A switch angle 1 +! add chapter -1 # skip to previous chapter +@ add chapter 1 # next +E cycle edition # next edition +A cycle angle U stop # TV @@ -139,16 +139,16 @@ u tv_step_chanlist # Apple Remote section # -AR_PLAY switch pause +AR_PLAY cycle pause AR_PLAY_HOLD quit AR_NEXT seek 30 AR_NEXT_HOLD seek 120 AR_PREV seek -10 AR_PREV_HOLD seek -120 -AR_MENU switch osd -AR_MENU_HOLD switch mute -AR_VUP switch volume 1 -AR_VDOWN switch volume -1 +AR_MENU cycle osd +AR_MENU_HOLD cycle mute +AR_VUP add volume 1 +AR_VDOWN add volume -1 # # Joystick section @@ -160,15 +160,15 @@ JOY_AXIS0_PLUS seek 10 JOY_AXIS0_MINUS seek -10 JOY_AXIS1_MINUS seek 60 JOY_AXIS1_PLUS seek -60 -JOY_BTN0 switch pause -JOY_BTN1 switch osd -JOY_BTN2 switch volume 1 -JOY_BTN3 switch volume -1 +JOY_BTN0 cycle pause +JOY_BTN1 cycle osd +JOY_BTN2 add volume 1 +JOY_BTN3 add volume -1 # # Not assigned by default # (not an exhaustive list of unbound commands) # -#? switch sub-scale +0.1 # increase subtitle font size -#? switch sub-scale -0.1 # decrease subtitle font size +#? add sub-scale +0.1 # increase subtitle font size +#? add sub-scale -0.1 # decrease subtitle font size diff --git a/input/input.c b/input/input.c index d3ad18075d..6c3e0d709f 100644 --- a/input/input.c +++ b/input/input.c @@ -135,7 +135,8 @@ static const mp_cmd_t mp_cmds[] = { { MP_CMD_KEYDOWN_EVENTS, "key_down_event", { ARG_INT } }, { MP_CMD_SET, "set", { ARG_STRING, ARG_STRING } }, { MP_CMD_GET_PROPERTY, "get_property", { ARG_STRING } }, - { MP_CMD_SWITCH, "switch", { ARG_STRING, OARG_FLOAT(0) } }, + { MP_CMD_ADD, "add", { ARG_STRING, OARG_FLOAT(0) } }, + { MP_CMD_CYCLE, "cycle", { ARG_STRING, OARG_FLOAT(0) } }, { MP_CMD_SET_MOUSE_POS, "set_mouse_pos", { ARG_INT, ARG_INT } }, @@ -158,40 +159,40 @@ struct legacy_cmd { const char *old, *new; }; static const struct legacy_cmd legacy_cmds[] = { - {"loop", "switch loop"}, - {"seek_chapter", "switch chapter"}, - {"switch_angle", "switch angle"}, - {"pause", "switch pause"}, - {"volume", "switch volume"}, - {"mute", "switch mute"}, - {"audio_delay", "switch audio-delay"}, - {"switch_audio", "switch audio"}, - {"balance", "switch balance"}, - {"vo_fullscreen", "no-osd switch fullscreen"}, - {"panscan", "switch panscan"}, - {"vo_ontop", "switch ontop"}, - {"vo_rootwin", "switch rootwin"}, - {"vo_border", "switch border"}, - {"frame_drop", "switch framedrop"}, - {"gamma", "switch gamma"}, - {"brightness", "switch brightness"}, - {"contrast", "switch contrast"}, - {"saturation", "switch saturation"}, - {"hue", "switch hue"}, - {"switch_vsync", "switch vsync"}, - {"sub_select", "switch sub"}, - {"sub_pos", "switch sub-pos"}, - {"sub_delay", "switch sub-delay"}, - {"sub_visibility", "switch sub-visibility"}, - {"forced_subs_only", "switch sub-forced-only"}, - {"sub_scale", "switch sub-scale"}, - {"ass_use_margins", "switch ass-use-margins"}, - {"tv_set_brightness", "switch tv-brightness"}, - {"tv_set_hue", "switch tv-hue"}, - {"tv_set_saturation", "switch tv-saturation"}, - {"tv_set_contrast", "switch tv-contrast"}, - {"step_property_osd", "switch"}, - {"step_property", "no-osd switch"}, + {"loop", "cycle loop"}, + {"seek_chapter", "add chapter"}, + {"switch_angle", "cycle angle"}, + {"pause", "cycle pause"}, + {"volume", "add volume"}, + {"mute", "cycle mute"}, + {"audio_delay", "add audio-delay"}, + {"switch_audio", "cycle audio"}, + {"balance", "add balance"}, + {"vo_fullscreen", "no-osd cycle fullscreen"}, + {"panscan", "add panscan"}, + {"vo_ontop", "cycle ontop"}, + {"vo_rootwin", "cycle rootwin"}, + {"vo_border", "cycle border"}, + {"frame_drop", "cycle framedrop"}, + {"gamma", "add gamma"}, + {"brightness", "add brightness"}, + {"contrast", "add contrast"}, + {"saturation", "add saturation"}, + {"hue", "add hue"}, + {"switch_vsync", "cycle vsync"}, + {"sub_select", "cycle sub"}, + {"sub_pos", "add sub-pos"}, + {"sub_delay", "add sub-delay"}, + {"sub_visibility", "cycle sub-visibility"}, + {"forced_subs_only", "cycle sub-forced-only"}, + {"sub_scale", "add sub-scale"}, + {"ass_use_margins", "cycle ass-use-margins"}, + {"tv_set_brightness", "add tv-brightness"}, + {"tv_set_hue", "add tv-hue"}, + {"tv_set_saturation", "add tv-saturation"}, + {"tv_set_contrast", "add tv-contrast"}, + {"step_property_osd", "cycle"}, + {"step_property", "no-osd cycle"}, {"set_property", "no-osd set"}, {"set_property_osd", "set"}, {"speed_set", "set speed"}, diff --git a/input/input.h b/input/input.h index 158d71b8ac..d3abc6f4c8 100644 --- a/input/input.h +++ b/input/input.h @@ -54,7 +54,8 @@ enum mp_command_type { MP_CMD_RADIO_SET_CHANNEL, MP_CMD_RADIO_SET_FREQ, MP_CMD_SET_MOUSE_POS, - MP_CMD_SWITCH, + MP_CMD_ADD, + MP_CMD_CYCLE, MP_CMD_RADIO_STEP_FREQ, MP_CMD_TV_STEP_FREQ, MP_CMD_TV_START_SCAN, diff --git a/m_property.c b/m_property.c index 4952c3a29c..dc856966f3 100644 --- a/m_property.c +++ b/m_property.c @@ -44,7 +44,7 @@ static int do_action(const m_option_t *prop_list, const char *name, memcpy(base, name, len); base[len] = 0; prop = m_option_list_find(prop_list, base); - struct m_property_action ka = { + struct m_property_action_arg ka = { .key = sep + 1, .action = action, .arg = arg, @@ -105,6 +105,7 @@ int m_property_do(const m_option_t *prop_list, const char *name, return r; } case M_PROPERTY_SWITCH: { + struct m_property_switch_arg *sarg = arg; if ((r = do_action(prop_list, name, M_PROPERTY_SWITCH, arg, ctx)) != M_PROPERTY_NOT_IMPLEMENTED) return r; @@ -113,10 +114,7 @@ int m_property_do(const m_option_t *prop_list, const char *name, return M_PROPERTY_NOT_IMPLEMENTED; if ((r = do_action(prop_list, name, M_PROPERTY_GET, &val, ctx)) <= 0) return r; - bool wrap = opt.type == &m_option_type_choice || - opt.type == &m_option_type_flag; - do_action(prop_list, name, M_PROPERTY_GET_WRAP, &wrap, ctx); - opt.type->add(&opt, &val, *(double*)arg, wrap); + opt.type->add(&opt, &val, sarg->inc, sarg->wrap); r = do_action(prop_list, name, M_PROPERTY_SET, &val, ctx); m_option_free(&opt, &val); return r; diff --git a/m_property.h b/m_property.h index 33bd7f3f7c..249a22e969 100644 --- a/m_property.h +++ b/m_property.h @@ -19,7 +19,9 @@ #ifndef MPLAYER_M_PROPERTY_H #define MPLAYER_M_PROPERTY_H -#include "m_option.h" +#include <stdbool.h> + +struct m_option; enum mp_property_action { // Get the property type. This defines the fundamental data type read from @@ -47,7 +49,7 @@ enum mp_property_action { // Switch the property up/down by a given value. // If unimplemented, the property wrapper uses the property type as // fallback. - // arg: double* (value to add to the property) + // arg: struct m_property_switch_arg* M_PROPERTY_SWITCH, // Set a new value from a string. The property wrapper parses this using the @@ -62,16 +64,18 @@ enum mp_property_action { M_PROPERTY_TO_STRING, // Pass down an action to a sub-property. - // arg: struct m_property_action* + // arg: struct m_property_action_arg* M_PROPERTY_KEY_ACTION, +}; - // Get wrap method. - // arg: bool* (true: wrap/cycle, false: clamp) - M_PROPERTY_GET_WRAP, +// Argument for M_PROPERTY_SWITCH +struct m_property_switch_arg { + double inc; // value to add to property, or cycle direction + bool wrap; // whether value should wrap around on over/underflow }; // Argument for M_PROPERTY_KEY_ACTION -struct m_property_action { +struct m_property_action_arg { const char* key; int action; void* arg; @@ -103,7 +107,7 @@ int m_property_do(const struct m_option* prop_list, const char* property_name, int action, void* arg, void *ctx); // Print a list of properties. -void m_properties_print_help_list(const m_option_t* list); +void m_properties_print_help_list(const struct m_option* list); // Expand a property string. /* This function allows to print strings containing property values. |