2013-12-26 16:10:35 +00:00
|
|
|
/*
|
2015-04-13 07:36:54 +00:00
|
|
|
* This file is part of mpv.
|
2013-12-26 16:10:35 +00:00
|
|
|
*
|
input: change license to LGPL
cehoyos adds the step_property command in 7a71da01d, and it could be
argued that copyright of this still applies to the later add/cycle
commands (a668ae0ff90c4). While I'm not sure if this is really the case,
stay conservative for now and mark these commands as GPL-only. Mark the
command.c code too, although that is not being relicensed yet.
I'm leaving the MP_CMD_* enum items, as they are obviously different.
In commit 116ca0c7682, "veal" (essentially an anonymous author) adds an
"osd_show_property_text" command (well, the commit message says "based
on" that person's code, so it's not clear how much is from him or from
albeu, who agreed to LGPL). This was later merged again with the
"osd_show_text" command, and then all original code was removed in
commit 58cc0f637f, so I claim that no copyright applies anymore. (Though
technically the input.conf addition still might be copyrighted, so I'm
just dropping it to get rid of the thought.)
"kiriuja" added 2f376d1b39 (sub_load etc.) and be54f4813 (switch_audio).
The latter is gone. I would argue that the former is fully rewritten
with commits b7052b431c9 and 0f155921b0. But like in the step_property
case, I will be overly conservative for now, and mark them as GPL-only,
as this is potentially shaky and should be thought through first. (Not
bothering with the command define/enum in the header, as it will be
unused in LGPL mode anyway.)
keycodes.c/h can be GPL, except for commit 2b1f95dcc2f8, which is a
patch by someone who wasn't asked yet. Before doing something radical, I
will wait for a reply.
2017-06-19 11:02:35 +00:00
|
|
|
* mpv is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
2013-12-26 16:10:35 +00:00
|
|
|
*
|
2015-04-13 07:36:54 +00:00
|
|
|
* mpv is distributed in the hope that it will be useful,
|
2013-12-26 16:10:35 +00:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
input: change license to LGPL
cehoyos adds the step_property command in 7a71da01d, and it could be
argued that copyright of this still applies to the later add/cycle
commands (a668ae0ff90c4). While I'm not sure if this is really the case,
stay conservative for now and mark these commands as GPL-only. Mark the
command.c code too, although that is not being relicensed yet.
I'm leaving the MP_CMD_* enum items, as they are obviously different.
In commit 116ca0c7682, "veal" (essentially an anonymous author) adds an
"osd_show_property_text" command (well, the commit message says "based
on" that person's code, so it's not clear how much is from him or from
albeu, who agreed to LGPL). This was later merged again with the
"osd_show_text" command, and then all original code was removed in
commit 58cc0f637f, so I claim that no copyright applies anymore. (Though
technically the input.conf addition still might be copyrighted, so I'm
just dropping it to get rid of the thought.)
"kiriuja" added 2f376d1b39 (sub_load etc.) and be54f4813 (switch_audio).
The latter is gone. I would argue that the former is fully rewritten
with commits b7052b431c9 and 0f155921b0. But like in the step_property
case, I will be overly conservative for now, and mark them as GPL-only,
as this is potentially shaky and should be thought through first. (Not
bothering with the command define/enum in the header, as it will be
unused in LGPL mode anyway.)
keycodes.c/h can be GPL, except for commit 2b1f95dcc2f8, which is a
patch by someone who wasn't asked yet. Before doing something radical, I
will wait for a reply.
2017-06-19 11:02:35 +00:00
|
|
|
* GNU Lesser General Public License for more details.
|
2013-12-26 16:10:35 +00:00
|
|
|
*
|
input: change license to LGPL
cehoyos adds the step_property command in 7a71da01d, and it could be
argued that copyright of this still applies to the later add/cycle
commands (a668ae0ff90c4). While I'm not sure if this is really the case,
stay conservative for now and mark these commands as GPL-only. Mark the
command.c code too, although that is not being relicensed yet.
I'm leaving the MP_CMD_* enum items, as they are obviously different.
In commit 116ca0c7682, "veal" (essentially an anonymous author) adds an
"osd_show_property_text" command (well, the commit message says "based
on" that person's code, so it's not clear how much is from him or from
albeu, who agreed to LGPL). This was later merged again with the
"osd_show_text" command, and then all original code was removed in
commit 58cc0f637f, so I claim that no copyright applies anymore. (Though
technically the input.conf addition still might be copyrighted, so I'm
just dropping it to get rid of the thought.)
"kiriuja" added 2f376d1b39 (sub_load etc.) and be54f4813 (switch_audio).
The latter is gone. I would argue that the former is fully rewritten
with commits b7052b431c9 and 0f155921b0. But like in the step_property
case, I will be overly conservative for now, and mark them as GPL-only,
as this is potentially shaky and should be thought through first. (Not
bothering with the command define/enum in the header, as it will be
unused in LGPL mode anyway.)
keycodes.c/h can be GPL, except for commit 2b1f95dcc2f8, which is a
patch by someone who wasn't asked yet. Before doing something radical, I
will wait for a reply.
2017-06-19 11:02:35 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with mpv. If not, see <http://www.gnu.org/licenses/>.
|
2013-12-26 16:10:35 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef MP_COMMAND_LIST_H
|
|
|
|
#define MP_COMMAND_LIST_H
|
|
|
|
|
|
|
|
#include <stdbool.h>
|
|
|
|
#include "options/m_option.h"
|
|
|
|
|
2018-01-10 00:20:58 +00:00
|
|
|
#define MP_CMD_DEF_MAX_ARGS 9
|
2013-12-26 16:10:35 +00:00
|
|
|
|
2014-02-24 22:02:20 +00:00
|
|
|
#define MP_CMD_OPT_ARG 0x1000
|
|
|
|
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
struct mp_cmd_ctx;
|
|
|
|
|
2013-12-26 16:10:35 +00:00
|
|
|
struct mp_cmd_def {
|
|
|
|
const char *name; // user-visible name (as used in input.conf)
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
void (*handler)(void *ctx);
|
2018-01-10 00:20:58 +00:00
|
|
|
const struct m_option args[MP_CMD_DEF_MAX_ARGS];
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
const void *priv; // for free use by handler()
|
2013-12-26 16:10:35 +00:00
|
|
|
bool allow_auto_repeat; // react to repeated key events
|
2014-11-24 15:48:34 +00:00
|
|
|
bool on_updown; // always emit it on both up and down key events
|
2013-12-26 16:10:35 +00:00
|
|
|
bool vararg; // last argument can be given 0 to multiple times
|
2017-04-24 12:04:25 +00:00
|
|
|
bool scalable;
|
2018-04-30 18:33:05 +00:00
|
|
|
bool is_abort;
|
|
|
|
bool is_soft_abort;
|
|
|
|
bool is_ignore;
|
2013-12-26 16:10:35 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
extern const struct mp_cmd_def mp_cmds[];
|
|
|
|
|
2014-09-13 14:47:30 +00:00
|
|
|
// Executing this command will maybe abort playback (play something else, or quit).
|
2014-02-20 12:38:39 +00:00
|
|
|
struct mp_cmd;
|
2014-09-13 14:47:30 +00:00
|
|
|
bool mp_input_is_maybe_abort_cmd(struct mp_cmd *cmd);
|
|
|
|
// This command will definitely abort playback.
|
2014-02-20 12:38:39 +00:00
|
|
|
bool mp_input_is_abort_cmd(struct mp_cmd *cmd);
|
2013-12-26 16:10:35 +00:00
|
|
|
|
2014-05-26 19:49:14 +00:00
|
|
|
bool mp_input_is_repeatable_cmd(struct mp_cmd *cmd);
|
|
|
|
|
2017-04-24 12:04:25 +00:00
|
|
|
bool mp_input_is_scalable_cmd(struct mp_cmd *cmd);
|
|
|
|
|
2013-12-26 16:10:35 +00:00
|
|
|
struct mp_log;
|
|
|
|
void mp_print_cmd_list(struct mp_log *out);
|
|
|
|
|
|
|
|
#endif
|