2008-12-13 18:28:00 +00:00
|
|
|
/*
|
|
|
|
* This file is part of MPlayer.
|
|
|
|
*
|
|
|
|
* MPlayer is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* MPlayer is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with MPlayer; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*/
|
|
|
|
|
2008-02-22 09:09:46 +00:00
|
|
|
#ifndef MPLAYER_INPUT_H
|
|
|
|
#define MPLAYER_INPUT_H
|
2008-01-01 21:35:58 +00:00
|
|
|
|
2012-03-21 00:23:35 +00:00
|
|
|
#include <stdbool.h>
|
2013-12-17 01:39:45 +00:00
|
|
|
#include "bstr/bstr.h"
|
2013-12-17 01:02:25 +00:00
|
|
|
#include "options/m_option.h"
|
2012-03-21 00:23:35 +00:00
|
|
|
|
2003-09-14 17:52:59 +00:00
|
|
|
// All command IDs
|
2011-07-16 15:17:48 +00:00
|
|
|
enum mp_command_type {
|
2012-09-22 13:17:15 +00:00
|
|
|
MP_CMD_IGNORE,
|
2011-07-16 14:47:02 +00:00
|
|
|
MP_CMD_SEEK,
|
2013-12-01 01:07:32 +00:00
|
|
|
MP_CMD_REVERT_SEEK,
|
2011-07-16 14:47:02 +00:00
|
|
|
MP_CMD_QUIT,
|
core: add playback resume feature (manual/opt-in)
A "watch later" command is now mapped to Shift+Q. This quits the player
and stores the playback state in a config file in ~/.mpv/watch_later/.
When calling the player with the same file again, playback is resumed
at that time position.
It's also possible to make mpv save playback state always on quit with
the --save-position-on-quit option. Likewise, resuming can be disabled
with the --no-resume-playback option.
This also attempts to save some playback parameters, like fullscreen
state or track selection. This will unconditionally override config
settings and command line options (which is probably not what you would
expect, but in general nobody will really care about this). Some things
are not backed up, because that would cause various problems. Additional
subtitle files, video filters, etc. are not stored because that would be
too hard and fragile. Volume/mute state are not stored because it would
mess up if the system mixer is used, or if the system mixer was
readjusted in the meantime.
Basically, the tradeoff between perfect state restoration and
complexity/fragility makes it not worth to attempt to implement
it perfectly, even if the result is a little bit inconsistent.
2013-05-05 17:37:29 +00:00
|
|
|
MP_CMD_QUIT_WATCH_LATER,
|
mplayer: turn playtree into a list, and change per-file option handling
Summary:
- There is no playtree anymore. It's reduced to a simple list.
- Options are now always global. You can still have per-file options,
but these are optional and require special syntax.
- The slave command pt_step has been removed, and playlist_next
and playlist_prev added. (See etc/input.conf changes.)
This is a user visible incompatible change, and will break slave-mode
applications.
- The pt_clear slave command is renamed to playlist_clear.
- Playtree entries could have multiple files. This is not the case
anymore, and playlist entries have always exactly one entry. Whenever
something adds more than one file (like ASX playlists or dvd:// or
dvdnav:// on the command line), all files are added as separate
playlist entries.
Note that some of the changes are quite deep and violent. Expect
regressions.
The playlist parsing code in particular is of low quality. I didn't try
to improve it, and merely spent to least effort necessary to keep it
somehow working. (Especially ASX playlist handling.)
The playtree code was complicated and bloated. It was also barely used.
Most users don't even know that mplayer manages the playlist as tree,
or how to use it. The most obscure features was probably specifying a
tree on command line (with '{' and '}' to create/close tree nodes). It
filled the player code with complexity and confused users with weird
slave commands like pt_up.
Replace the playtree with a simple flat playlist. Playlist parsers that
actually return trees are changed to append all files to the playlist
pre-order.
It used to be the responsibility of the playtree code to change per-file
config options. Now this is done by the player core, and the playlist
code is free of such details.
Options are not per-file by default anymore. This was a very obscure and
complicated feature that confused even experienced users. Consider the
following command line:
mplayer file1.mkv file2.mkv --no-audio file3.mkv
This will disable the audio for file2.mkv only, because options are
per-file by default. To make the option affect all files, you're
supposed to put it before the first file.
This is bad, because normally you don't need per-file options. They are
very rarely needed, and the only reasonable use cases I can imagine are
use of the encode backend (mplayer encode branch), or for debugging. The
normal use case is made harder, and the feature is perceived as bug.
Even worse, correct usage is hard to explain for users.
Make all options global by default. The position of an option isn't
significant anymore (except for options that compensate each other,
consider --shuffle --no-shuffle).
One other important change is that no options are reset anymore if a
new file is started. If you change settings with slave mode commands,
they will not be changed by playing a new file. (Exceptions include
settings that are too file specific, like audio/subtitle stream
selection.)
There is still some need for per-file options. Debugging and encoding
are use cases that profit from per-file options. Per-file profiles (as
well as per-protocol and per-VO/AO options) need the implementation
related mechanisms to backup and restore options when the playback file
changes.
Simplify the save-slot stuff, which is possible because there is no
hierarchical play tree anymore. Now there's a simple backup field.
Add a way to specify per-file options on command line. Example:
mplayer f1.mkv -o0 --{ -o1 f2.mkv -o2 f3.mkv --} f4.mkv -o3
will have the following options per file set:
f1.mkv, f4.mkv: -o0 -o3
f2.mkv, f3.mkv: -o0 -o3 -o1 -o2
The options --{ and --} start and end per-file options. All files inside
the { } will be affected by the options equally (similar to how global
options and multiple files are handled). When playback of a file starts,
the per-file options are set according to the command line. When
playback ends, the per-file options are restored to the values when
playback started.
2012-07-31 19:33:26 +00:00
|
|
|
MP_CMD_PLAYLIST_NEXT,
|
|
|
|
MP_CMD_PLAYLIST_PREV,
|
2011-07-16 14:47:02 +00:00
|
|
|
MP_CMD_OSD,
|
|
|
|
MP_CMD_TV_STEP_CHANNEL,
|
|
|
|
MP_CMD_TV_STEP_NORM,
|
|
|
|
MP_CMD_TV_STEP_CHANNEL_LIST,
|
|
|
|
MP_CMD_SCREENSHOT,
|
2013-07-08 18:34:26 +00:00
|
|
|
MP_CMD_SCREENSHOT_TO_FILE,
|
2011-07-16 14:47:02 +00:00
|
|
|
MP_CMD_LOADFILE,
|
|
|
|
MP_CMD_LOADLIST,
|
mplayer: turn playtree into a list, and change per-file option handling
Summary:
- There is no playtree anymore. It's reduced to a simple list.
- Options are now always global. You can still have per-file options,
but these are optional and require special syntax.
- The slave command pt_step has been removed, and playlist_next
and playlist_prev added. (See etc/input.conf changes.)
This is a user visible incompatible change, and will break slave-mode
applications.
- The pt_clear slave command is renamed to playlist_clear.
- Playtree entries could have multiple files. This is not the case
anymore, and playlist entries have always exactly one entry. Whenever
something adds more than one file (like ASX playlists or dvd:// or
dvdnav:// on the command line), all files are added as separate
playlist entries.
Note that some of the changes are quite deep and violent. Expect
regressions.
The playlist parsing code in particular is of low quality. I didn't try
to improve it, and merely spent to least effort necessary to keep it
somehow working. (Especially ASX playlist handling.)
The playtree code was complicated and bloated. It was also barely used.
Most users don't even know that mplayer manages the playlist as tree,
or how to use it. The most obscure features was probably specifying a
tree on command line (with '{' and '}' to create/close tree nodes). It
filled the player code with complexity and confused users with weird
slave commands like pt_up.
Replace the playtree with a simple flat playlist. Playlist parsers that
actually return trees are changed to append all files to the playlist
pre-order.
It used to be the responsibility of the playtree code to change per-file
config options. Now this is done by the player core, and the playlist
code is free of such details.
Options are not per-file by default anymore. This was a very obscure and
complicated feature that confused even experienced users. Consider the
following command line:
mplayer file1.mkv file2.mkv --no-audio file3.mkv
This will disable the audio for file2.mkv only, because options are
per-file by default. To make the option affect all files, you're
supposed to put it before the first file.
This is bad, because normally you don't need per-file options. They are
very rarely needed, and the only reasonable use cases I can imagine are
use of the encode backend (mplayer encode branch), or for debugging. The
normal use case is made harder, and the feature is perceived as bug.
Even worse, correct usage is hard to explain for users.
Make all options global by default. The position of an option isn't
significant anymore (except for options that compensate each other,
consider --shuffle --no-shuffle).
One other important change is that no options are reset anymore if a
new file is started. If you change settings with slave mode commands,
they will not be changed by playing a new file. (Exceptions include
settings that are too file specific, like audio/subtitle stream
selection.)
There is still some need for per-file options. Debugging and encoding
are use cases that profit from per-file options. Per-file profiles (as
well as per-protocol and per-VO/AO options) need the implementation
related mechanisms to backup and restore options when the playback file
changes.
Simplify the save-slot stuff, which is possible because there is no
hierarchical play tree anymore. Now there's a simple backup field.
Add a way to specify per-file options on command line. Example:
mplayer f1.mkv -o0 --{ -o1 f2.mkv -o2 f3.mkv --} f4.mkv -o3
will have the following options per file set:
f1.mkv, f4.mkv: -o0 -o3
f2.mkv, f3.mkv: -o0 -o3 -o1 -o2
The options --{ and --} start and end per-file options. All files inside
the { } will be affected by the options equally (similar to how global
options and multiple files are handled). When playback of a file starts,
the per-file options are set according to the command line. When
playback ends, the per-file options are restored to the values when
playback started.
2012-07-31 19:33:26 +00:00
|
|
|
MP_CMD_PLAYLIST_CLEAR,
|
2013-07-02 11:17:50 +00:00
|
|
|
MP_CMD_PLAYLIST_REMOVE,
|
|
|
|
MP_CMD_PLAYLIST_MOVE,
|
2011-07-16 14:47:02 +00:00
|
|
|
MP_CMD_SUB_STEP,
|
2013-10-02 19:05:04 +00:00
|
|
|
MP_CMD_SUB_SEEK,
|
2011-07-16 14:47:02 +00:00
|
|
|
MP_CMD_TV_SET_CHANNEL,
|
|
|
|
MP_CMD_TV_LAST_CHANNEL,
|
|
|
|
MP_CMD_TV_SET_FREQ,
|
|
|
|
MP_CMD_TV_SET_NORM,
|
|
|
|
MP_CMD_FRAME_STEP,
|
core: add backstep support
Allows stepping back one frame via the frame_back_step inout command,
bound to "," by default.
This uses the precise seeking facility, and a perfect frame index built
on the fly. The index is built during playback and precise seeking, and
contains (as of this commit) the last 100 displayed or skipped frames.
This index is used to find the PTS of the previous frame, which is then
used as target for a precise seek. If no PTS is found, the core attempts
to do a seek before the current frame, and skip decoded frames until the
current frame is reached; this will create a sufficient index and the
normal backstep algorithm can be applied.
This can be rather slow. The worst case for backstepping is about the
same as the worst case for precise seeking if the previous frame can be
deduced from the index. If not, the worst case will be twice as slow.
There's also some minor danger that the index is incorrect in case
framedropping is involved. For framedropping due to --framedrop, this
problem is ignored (use of --framedrop is discouraged anyway). For
framedropping during precise seeking (done to make it faster), we try
to not add frames to the index that are produced when this can happen.
I'm not sure how well that works (or if the logic is sane), and it's
sure to break with some video filters. In the worst case, backstepping
might silently skip frames if you backstep after a user-initiated
precise seek. (Precise seeks to do indexing are not affected.)
Likewise, video filters that somehow change timing of frames and do not
do this in a deterministic way (i.e. if you seek to a position, frames
with different timings are produced than when the position is reached
during normal playback) will make backstepping silently jump to the
wrong frame. Enabling/disabling filters during playback (like for
example deinterlacing) will have similar bad effects.
2013-04-24 17:31:48 +00:00
|
|
|
MP_CMD_FRAME_BACK_STEP,
|
2011-07-16 14:47:02 +00:00
|
|
|
MP_CMD_RUN,
|
2012-11-15 19:26:52 +00:00
|
|
|
MP_CMD_SUB_ADD,
|
|
|
|
MP_CMD_SUB_REMOVE,
|
|
|
|
MP_CMD_SUB_RELOAD,
|
2012-09-09 00:08:08 +00:00
|
|
|
MP_CMD_SET,
|
2011-07-16 14:47:02 +00:00
|
|
|
MP_CMD_GET_PROPERTY,
|
2012-10-11 00:24:13 +00:00
|
|
|
MP_CMD_PRINT_TEXT,
|
2012-09-15 00:04:57 +00:00
|
|
|
MP_CMD_SHOW_TEXT,
|
|
|
|
MP_CMD_SHOW_PROGRESS,
|
2012-09-22 04:15:36 +00:00
|
|
|
MP_CMD_ADD,
|
|
|
|
MP_CMD_CYCLE,
|
2013-10-31 22:23:38 +00:00
|
|
|
MP_CMD_MULTIPLY,
|
2013-11-29 23:18:24 +00:00
|
|
|
MP_CMD_CYCLE_VALUES,
|
2011-07-16 14:47:02 +00:00
|
|
|
MP_CMD_TV_STEP_FREQ,
|
|
|
|
MP_CMD_TV_START_SCAN,
|
|
|
|
MP_CMD_STOP,
|
|
|
|
|
2013-06-22 23:28:28 +00:00
|
|
|
MP_CMD_ENABLE_INPUT_SECTION,
|
|
|
|
MP_CMD_DISABLE_INPUT_SECTION,
|
|
|
|
|
Add prelimimary (basic, possibly broken) dvdnav support
This readds a more or less completely new dvdnav implementation, though
it's based on the code from before commit 41fbcee. Note that this is
rather basic, and might be broken or not quite usable in many cases.
Most importantly, navigation highlights are not correctly implemented.
This would require changes in the FFmpeg dvdsub decoder (to apply a
different internal CLUT), so supporting it is not really possible right
now. And in fact, I don't think I ever want to support it, because it's
a very small gain for a lot of work. Instead, mpv will display fake
highlights, which are an approximate bounding box around the real
highlights.
Some things like mouse input or switching audio/subtitles stream using
the dvdnav VM are not supported.
Might be quite fragile on transitions: if dvdnav initiates a transition,
and doesn't give us enough mpeg data to initialize video playback, the
player will just quit.
This is added only because some users seem to want it. I don't intend to
make mpv a good DVD player, so the very basic minimum will have to do.
How about you just convert your DVD to proper video files?
2013-12-12 00:44:28 +00:00
|
|
|
MP_CMD_DVDNAV,
|
|
|
|
|
2011-07-16 14:47:02 +00:00
|
|
|
/// DVB commands
|
2013-10-02 18:48:50 +00:00
|
|
|
MP_CMD_DVB_SET_CHANNEL,
|
2011-07-16 14:47:02 +00:00
|
|
|
|
|
|
|
/// Audio Filter commands
|
2013-07-22 12:43:58 +00:00
|
|
|
MP_CMD_AF,
|
2011-10-23 03:26:30 +00:00
|
|
|
|
2013-05-18 09:44:17 +00:00
|
|
|
/// Video filter commands
|
|
|
|
MP_CMD_VF,
|
|
|
|
|
2012-07-31 23:06:59 +00:00
|
|
|
/// Video output commands
|
|
|
|
MP_CMD_VO_CMDLINE,
|
2013-07-08 17:27:45 +00:00
|
|
|
|
Add initial Lua scripting support
This is preliminary. There are still tons of issues, and any aspect
of scripting may change in the future. I decided to merge this
(preliminary) work now because it makes it easier to develop it, not
because it's done. lua.rst is clear enough about it (plus some
sarcasm).
This requires linking to Lua. Lua has no official pkg-config file, but
there are distribution specific .pc files, all with different names.
Adding a non-pkg-config based configure test was considered, but we'd
rather not.
One major complication is that libquvi links against Lua too, and if
the Lua version is different from mpv's, you will get a crash as soon
as libquvi uses Lua. (libquvi by design always runs when a file is
opened.) I would consider this the problem of distros and whoever
builds mpv, but to make things easier for users, we add a terrible
runtime test to the configure script, which probes whether libquvi
will crash. This is disabled when cross-compiling, but in that case
we hope the user knows what he is doing.
2013-09-25 22:41:14 +00:00
|
|
|
/// Internal for Lua scripts
|
|
|
|
MP_CMD_SCRIPT_DISPATCH,
|
|
|
|
|
2013-09-30 20:27:37 +00:00
|
|
|
MP_CMD_OVERLAY_ADD,
|
|
|
|
MP_CMD_OVERLAY_REMOVE,
|
|
|
|
|
2013-07-08 17:27:45 +00:00
|
|
|
// Internal
|
|
|
|
MP_CMD_COMMAND_LIST, // list of sub-commands in args[0].v.p
|
2011-07-16 15:17:48 +00:00
|
|
|
};
|
2002-11-14 23:41:44 +00:00
|
|
|
|
2002-01-30 12:46:03 +00:00
|
|
|
#define MP_CMD_MAX_ARGS 10
|
2002-03-19 13:29:28 +00:00
|
|
|
|
|
|
|
// Error codes for the drivers
|
2002-01-30 12:46:03 +00:00
|
|
|
|
2003-12-24 22:00:51 +00:00
|
|
|
// An error occurred but we can continue
|
2002-01-30 12:46:03 +00:00
|
|
|
#define MP_INPUT_ERROR -1
|
2003-12-24 22:00:51 +00:00
|
|
|
// A fatal error occurred, this driver should be removed
|
2002-01-30 12:46:03 +00:00
|
|
|
#define MP_INPUT_DEAD -2
|
2003-09-14 17:52:59 +00:00
|
|
|
// No input was available
|
2002-01-30 12:46:03 +00:00
|
|
|
#define MP_INPUT_NOTHING -3
|
2005-06-27 08:16:23 +00:00
|
|
|
//! Input will be available if you try again
|
|
|
|
#define MP_INPUT_RETRY -4
|
2011-05-01 12:57:39 +00:00
|
|
|
// Key FIFO was full - release events may be lost, zero button-down status
|
|
|
|
#define MP_INPUT_RELEASE_ALL -5
|
|
|
|
|
2013-12-15 22:35:36 +00:00
|
|
|
enum mp_cmd_flags {
|
2012-09-25 01:24:38 +00:00
|
|
|
MP_ON_OSD_NO = 0, // prefer not using OSD
|
|
|
|
MP_ON_OSD_AUTO = 1, // use default behavior of the specific command
|
|
|
|
MP_ON_OSD_BAR = 2, // force a bar, if applicable
|
|
|
|
MP_ON_OSD_MSG = 4, // force a message, if applicable
|
2013-12-15 22:35:36 +00:00
|
|
|
MP_EXPAND_PROPERTIES = 8, // expand strings as properties
|
|
|
|
MP_PAUSING = 16, // pause after running command
|
|
|
|
MP_PAUSING_TOGGLE = 32, // toggle pause after running command
|
|
|
|
|
|
|
|
MP_ON_OSD_FLAGS = MP_ON_OSD_NO | MP_ON_OSD_AUTO |
|
|
|
|
MP_ON_OSD_BAR | MP_ON_OSD_MSG,
|
|
|
|
MP_PAUSING_FLAGS = MP_PAUSING | MP_PAUSING_TOGGLE,
|
2012-09-09 00:08:08 +00:00
|
|
|
};
|
|
|
|
|
2012-08-24 11:29:28 +00:00
|
|
|
enum mp_input_section_flags {
|
input: handle mouse movement differently
Before this commit, mouse movement events emitted a special command
("set_mouse_pos"), which was specially handled in command.c. This was
once special-cased to the dvdnav and menu code, and did nothing after
libmenu and dvdnav were removed.
Change it so that mouse movement triggers a pseudo-key ("MOUSE_MOVE"),
which then can be bound to an arbitrary command. The mouse position is
now managed in input.c. A command which actually needs the mouse
position can use either mp_input_get_mouse_pos() or mp_get_osd_mouse_pos()
to query it. The former returns raw window-space coordinates, while the
latter returns coordinates transformed to OSD- space. (Both are the same
for most VOs, except vo_xv and vo_x11, which can't render OSD in
window-space. These require extra code for mapping mouse position.)
As of this commit, there is still nothing that uses mouse movement, so
MOUSE_MOVE is mapped to "ignore" to silence warnings when moving the
mouse (much like MOUSE_BTN0).
Extend the concept of input sections. Allow multiple sections to be
active at once, and organize them as stack. Bindings from the top of
the stack are preferred to lower ones.
Each section has a mouse input section associated, inside which mouse
events are associated with the bindings. If the mouse pointer is
outside of a section's mouse area, mouse events will be dispatched to
an input section lower on the stack of active sections. This is intended
for scripting, which is to be added later. Two scripts could occupy
different areas of the screen without conflicting with each other. (If
it turns out that this mechanism is useless, we'll just remove it
again.)
2013-04-26 00:13:30 +00:00
|
|
|
// If a key binding is not defined in the current section, do not search the
|
|
|
|
// other sections for it (like the default section). Instead, an unbound
|
|
|
|
// key warning will be printed.
|
|
|
|
MP_INPUT_EXCLUSIVE = 1,
|
2013-08-31 19:59:37 +00:00
|
|
|
// Let mp_input_test_dragging() return true, even if inside the mouse area.
|
|
|
|
MP_INPUT_ALLOW_VO_DRAGGING = 2,
|
input: don't deliver mouse events if mouse area is not set
This caused the OSC to be always visible at startup on X11:
- EnterNotify event send a mouse event to input.c
- OSC has not completely initialized yet, and no mouse area is set
- mouse event is dispatched to "showhide" OSC section
- OSC becomes visible, regardless of mouse position
Fix this by treating the mouse area as empty if it's not set, instead of
infinite as it was before this commit. This means an input section must
set a mouse area to receive mouse events at all. We also have to change
the default section to receive mouse events with the new behavior.
Also, if MOUSE_MOVE is unmapped (or mapped to something that doesn't
parse), and produces no command, the mouse position wouldn't be updated
(because the mouse position is bound to input commands), so we have to
generate a dummy command in this case.
(This matters only for the OSC, On Screen Controller, which isn't merged
yet, so these changes shouldn't have much effect right now.)
2013-09-05 21:58:51 +00:00
|
|
|
// Don't force mouse pointer visible, even if inside the mouse area.
|
|
|
|
MP_INPUT_ALLOW_HIDE_CURSOR = 4,
|
2012-08-24 11:29:28 +00:00
|
|
|
};
|
2002-01-30 12:46:03 +00:00
|
|
|
|
2008-04-30 04:15:52 +00:00
|
|
|
struct input_ctx;
|
2013-12-20 17:01:04 +00:00
|
|
|
struct mp_log;
|
2008-04-30 04:15:52 +00:00
|
|
|
|
2011-07-16 15:17:48 +00:00
|
|
|
struct mp_cmd_arg {
|
2013-11-28 18:04:16 +00:00
|
|
|
const struct m_option *type;
|
2011-07-16 15:17:48 +00:00
|
|
|
union {
|
|
|
|
int i;
|
|
|
|
float f;
|
2013-02-24 20:16:23 +00:00
|
|
|
double d;
|
2011-07-16 15:17:48 +00:00
|
|
|
char *s;
|
2013-07-08 17:27:45 +00:00
|
|
|
void *p;
|
2011-07-16 15:17:48 +00:00
|
|
|
} v;
|
|
|
|
};
|
2002-01-30 12:46:03 +00:00
|
|
|
|
|
|
|
typedef struct mp_cmd {
|
2011-07-16 14:47:02 +00:00
|
|
|
int id;
|
|
|
|
char *name;
|
2011-07-16 15:17:48 +00:00
|
|
|
struct mp_cmd_arg args[MP_CMD_MAX_ARGS];
|
2012-03-21 00:23:35 +00:00
|
|
|
int nargs;
|
2013-12-15 22:35:36 +00:00
|
|
|
int flags; // mp_cmd_flags bitfield
|
2012-10-13 19:10:20 +00:00
|
|
|
bstr original;
|
2013-06-19 16:19:45 +00:00
|
|
|
char *input_section;
|
input: handle mouse movement differently
Before this commit, mouse movement events emitted a special command
("set_mouse_pos"), which was specially handled in command.c. This was
once special-cased to the dvdnav and menu code, and did nothing after
libmenu and dvdnav were removed.
Change it so that mouse movement triggers a pseudo-key ("MOUSE_MOVE"),
which then can be bound to an arbitrary command. The mouse position is
now managed in input.c. A command which actually needs the mouse
position can use either mp_input_get_mouse_pos() or mp_get_osd_mouse_pos()
to query it. The former returns raw window-space coordinates, while the
latter returns coordinates transformed to OSD- space. (Both are the same
for most VOs, except vo_xv and vo_x11, which can't render OSD in
window-space. These require extra code for mapping mouse position.)
As of this commit, there is still nothing that uses mouse movement, so
MOUSE_MOVE is mapped to "ignore" to silence warnings when moving the
mouse (much like MOUSE_BTN0).
Extend the concept of input sections. Allow multiple sections to be
active at once, and organize them as stack. Bindings from the top of
the stack are preferred to lower ones.
Each section has a mouse input section associated, inside which mouse
events are associated with the bindings. If the mouse pointer is
outside of a section's mouse area, mouse events will be dispatched to
an input section lower on the stack of active sections. This is intended
for scripting, which is to be added later. Two scripts could occupy
different areas of the screen without conflicting with each other. (If
it turns out that this mechanism is useless, we'll just remove it
again.)
2013-04-26 00:13:30 +00:00
|
|
|
bool key_up_follows;
|
2013-10-27 23:33:52 +00:00
|
|
|
bool repeated;
|
input: handle mouse movement differently
Before this commit, mouse movement events emitted a special command
("set_mouse_pos"), which was specially handled in command.c. This was
once special-cased to the dvdnav and menu code, and did nothing after
libmenu and dvdnav were removed.
Change it so that mouse movement triggers a pseudo-key ("MOUSE_MOVE"),
which then can be bound to an arbitrary command. The mouse position is
now managed in input.c. A command which actually needs the mouse
position can use either mp_input_get_mouse_pos() or mp_get_osd_mouse_pos()
to query it. The former returns raw window-space coordinates, while the
latter returns coordinates transformed to OSD- space. (Both are the same
for most VOs, except vo_xv and vo_x11, which can't render OSD in
window-space. These require extra code for mapping mouse position.)
As of this commit, there is still nothing that uses mouse movement, so
MOUSE_MOVE is mapped to "ignore" to silence warnings when moving the
mouse (much like MOUSE_BTN0).
Extend the concept of input sections. Allow multiple sections to be
active at once, and organize them as stack. Bindings from the top of
the stack are preferred to lower ones.
Each section has a mouse input section associated, inside which mouse
events are associated with the bindings. If the mouse pointer is
outside of a section's mouse area, mouse events will be dispatched to
an input section lower on the stack of active sections. This is intended
for scripting, which is to be added later. Two scripts could occupy
different areas of the screen without conflicting with each other. (If
it turns out that this mechanism is useless, we'll just remove it
again.)
2013-04-26 00:13:30 +00:00
|
|
|
bool mouse_move;
|
|
|
|
int mouse_x, mouse_y;
|
2011-07-17 01:47:50 +00:00
|
|
|
struct mp_cmd *queue_next;
|
2013-11-05 23:05:12 +00:00
|
|
|
double scale; // for scaling numeric arguments
|
2013-11-28 18:04:16 +00:00
|
|
|
const struct mp_cmd_def *def;
|
2002-01-30 12:46:03 +00:00
|
|
|
} mp_cmd_t;
|
|
|
|
|
|
|
|
|
mplayer: turn playtree into a list, and change per-file option handling
Summary:
- There is no playtree anymore. It's reduced to a simple list.
- Options are now always global. You can still have per-file options,
but these are optional and require special syntax.
- The slave command pt_step has been removed, and playlist_next
and playlist_prev added. (See etc/input.conf changes.)
This is a user visible incompatible change, and will break slave-mode
applications.
- The pt_clear slave command is renamed to playlist_clear.
- Playtree entries could have multiple files. This is not the case
anymore, and playlist entries have always exactly one entry. Whenever
something adds more than one file (like ASX playlists or dvd:// or
dvdnav:// on the command line), all files are added as separate
playlist entries.
Note that some of the changes are quite deep and violent. Expect
regressions.
The playlist parsing code in particular is of low quality. I didn't try
to improve it, and merely spent to least effort necessary to keep it
somehow working. (Especially ASX playlist handling.)
The playtree code was complicated and bloated. It was also barely used.
Most users don't even know that mplayer manages the playlist as tree,
or how to use it. The most obscure features was probably specifying a
tree on command line (with '{' and '}' to create/close tree nodes). It
filled the player code with complexity and confused users with weird
slave commands like pt_up.
Replace the playtree with a simple flat playlist. Playlist parsers that
actually return trees are changed to append all files to the playlist
pre-order.
It used to be the responsibility of the playtree code to change per-file
config options. Now this is done by the player core, and the playlist
code is free of such details.
Options are not per-file by default anymore. This was a very obscure and
complicated feature that confused even experienced users. Consider the
following command line:
mplayer file1.mkv file2.mkv --no-audio file3.mkv
This will disable the audio for file2.mkv only, because options are
per-file by default. To make the option affect all files, you're
supposed to put it before the first file.
This is bad, because normally you don't need per-file options. They are
very rarely needed, and the only reasonable use cases I can imagine are
use of the encode backend (mplayer encode branch), or for debugging. The
normal use case is made harder, and the feature is perceived as bug.
Even worse, correct usage is hard to explain for users.
Make all options global by default. The position of an option isn't
significant anymore (except for options that compensate each other,
consider --shuffle --no-shuffle).
One other important change is that no options are reset anymore if a
new file is started. If you change settings with slave mode commands,
they will not be changed by playing a new file. (Exceptions include
settings that are too file specific, like audio/subtitle stream
selection.)
There is still some need for per-file options. Debugging and encoding
are use cases that profit from per-file options. Per-file profiles (as
well as per-protocol and per-VO/AO options) need the implementation
related mechanisms to backup and restore options when the playback file
changes.
Simplify the save-slot stuff, which is possible because there is no
hierarchical play tree anymore. Now there's a simple backup field.
Add a way to specify per-file options on command line. Example:
mplayer f1.mkv -o0 --{ -o1 f2.mkv -o2 f3.mkv --} f4.mkv -o3
will have the following options per file set:
f1.mkv, f4.mkv: -o0 -o3
f2.mkv, f3.mkv: -o0 -o3 -o1 -o2
The options --{ and --} start and end per-file options. All files inside
the { } will be affected by the options equally (similar to how global
options and multiple files are handled). When playback of a file starts,
the per-file options are set according to the command line. When
playback ends, the per-file options are restored to the values when
playback started.
2012-07-31 19:33:26 +00:00
|
|
|
// Executing this command will abort playback (play something else, or quit).
|
|
|
|
bool mp_input_is_abort_cmd(int cmd_id);
|
|
|
|
|
2011-07-16 14:47:02 +00:00
|
|
|
/* Add a new command input source.
|
2013-12-21 18:33:45 +00:00
|
|
|
* "fd" is a file descriptor (use -1 if you don't use any fd)
|
2011-07-16 14:47:02 +00:00
|
|
|
* "select" tells whether to use select() on the fd to determine when to
|
|
|
|
* try reading.
|
2013-12-21 18:33:45 +00:00
|
|
|
* "read_cmd_func" is optional. It must return either text data or one of the
|
|
|
|
* MP_INPUT error codes above. For return values >= 0, it behaves like UNIX
|
|
|
|
* read() and returns the number of bytes copied to the dest buffer.
|
|
|
|
* "read_key_func" is optional. It returns either key codes (ASCII, keycodes.h),
|
|
|
|
* or MP_INPUT error codes.
|
2011-07-16 15:17:48 +00:00
|
|
|
* "close_func" will be called when closing. Can be NULL. Its return value
|
|
|
|
* is ignored (it's only there to allow using standard close() as the func).
|
2013-12-21 18:33:45 +00:00
|
|
|
* "ctx" is for free use, and is passed to the callbacks.
|
2011-07-16 14:47:02 +00:00
|
|
|
*/
|
2013-12-21 18:33:45 +00:00
|
|
|
int mp_input_add_fd(struct input_ctx *ictx, int fd, int select,
|
|
|
|
int read_cmd_func(void *ctx, int fd, char *dest, int size),
|
|
|
|
int read_key_func(void *ctx, int fd),
|
|
|
|
int close_func(void *ctx, int fd), void *ctx);
|
2002-01-30 12:46:03 +00:00
|
|
|
|
2013-12-21 18:33:45 +00:00
|
|
|
/* Can be passed as read_func for above function in order to read() from the FD.
|
2011-07-16 14:47:02 +00:00
|
|
|
*/
|
2013-12-21 18:33:45 +00:00
|
|
|
int input_default_read_cmd(void *ctx, int fd, char *buf, int l);
|
2002-01-30 12:46:03 +00:00
|
|
|
|
2013-07-02 12:00:24 +00:00
|
|
|
// Process keyboard input. code is a key code from keycodes.h, possibly
|
|
|
|
// with modifiers applied. MP_INPUT_RELEASE_ALL is also a valid value.
|
|
|
|
void mp_input_put_key(struct input_ctx *ictx, int code);
|
|
|
|
|
|
|
|
// Like mp_input_put_key(), but process all UTF-8 characters in the given
|
|
|
|
// string as key events.
|
|
|
|
void mp_input_put_key_utf8(struct input_ctx *ictx, int mods, struct bstr t);
|
2011-07-17 01:47:50 +00:00
|
|
|
|
2013-07-25 16:08:57 +00:00
|
|
|
// Process scrolling input. Support for precise scrolling. Scales the given
|
|
|
|
// scroll amount add multiplies it with the command (seeking, sub-delay, etc)
|
|
|
|
void mp_input_put_axis(struct input_ctx *ictx, int direction, double value);
|
|
|
|
|
input: handle mouse movement differently
Before this commit, mouse movement events emitted a special command
("set_mouse_pos"), which was specially handled in command.c. This was
once special-cased to the dvdnav and menu code, and did nothing after
libmenu and dvdnav were removed.
Change it so that mouse movement triggers a pseudo-key ("MOUSE_MOVE"),
which then can be bound to an arbitrary command. The mouse position is
now managed in input.c. A command which actually needs the mouse
position can use either mp_input_get_mouse_pos() or mp_get_osd_mouse_pos()
to query it. The former returns raw window-space coordinates, while the
latter returns coordinates transformed to OSD- space. (Both are the same
for most VOs, except vo_xv and vo_x11, which can't render OSD in
window-space. These require extra code for mapping mouse position.)
As of this commit, there is still nothing that uses mouse movement, so
MOUSE_MOVE is mapped to "ignore" to silence warnings when moving the
mouse (much like MOUSE_BTN0).
Extend the concept of input sections. Allow multiple sections to be
active at once, and organize them as stack. Bindings from the top of
the stack are preferred to lower ones.
Each section has a mouse input section associated, inside which mouse
events are associated with the bindings. If the mouse pointer is
outside of a section's mouse area, mouse events will be dispatched to
an input section lower on the stack of active sections. This is intended
for scripting, which is to be added later. Two scripts could occupy
different areas of the screen without conflicting with each other. (If
it turns out that this mechanism is useless, we'll just remove it
again.)
2013-04-26 00:13:30 +00:00
|
|
|
// Update mouse position (in window coordinates).
|
|
|
|
void mp_input_set_mouse_pos(struct input_ctx *ictx, int x, int y);
|
|
|
|
|
|
|
|
void mp_input_get_mouse_pos(struct input_ctx *ictx, int *x, int *y);
|
|
|
|
|
2003-09-14 17:52:59 +00:00
|
|
|
// As for the cmd one you usually don't need this function.
|
2008-04-30 08:06:55 +00:00
|
|
|
void mp_input_rm_key_fd(struct input_ctx *ictx, int fd);
|
2002-01-30 12:46:03 +00:00
|
|
|
|
2011-07-16 14:47:02 +00:00
|
|
|
// Get input key from its name.
|
2007-12-04 10:42:59 +00:00
|
|
|
int mp_input_get_key_from_name(const char *name);
|
|
|
|
|
2011-07-16 14:47:02 +00:00
|
|
|
// Add a command to the command queue.
|
|
|
|
int mp_input_queue_cmd(struct input_ctx *ictx, struct mp_cmd *cmd);
|
2002-02-23 21:13:35 +00:00
|
|
|
|
2011-07-16 14:47:02 +00:00
|
|
|
/* Return next available command, or sleep up to "time" ms if none is
|
|
|
|
* available. If "peek_only" is true return a reference to the command
|
|
|
|
* but leave it queued.
|
|
|
|
*/
|
|
|
|
struct mp_cmd *mp_input_get_cmd(struct input_ctx *ictx, int time,
|
|
|
|
int peek_only);
|
2002-01-30 12:46:03 +00:00
|
|
|
|
2012-10-13 19:09:42 +00:00
|
|
|
// Parse text and return corresponding struct mp_cmd.
|
|
|
|
// The location parameter is for error messages.
|
2013-09-27 13:30:59 +00:00
|
|
|
struct mp_cmd *mp_input_parse_cmd(struct input_ctx *ictx, bstr str,
|
|
|
|
const char *location);
|
2002-11-14 23:41:44 +00:00
|
|
|
|
2013-12-20 17:01:04 +00:00
|
|
|
// Similar to mp_input_parse_cmd(), but takes a list of strings instead.
|
|
|
|
// Also, def_flags contains initial command flags (see mp_cmd_flags; the default
|
|
|
|
// as used by mp_input_parse_cmd is MP_ON_OSD_AUTO | MP_EXPAND_PROPERTIES).
|
|
|
|
// Keep in mind that these functions (naturally) don't take multiple commands,
|
|
|
|
// i.e. a ";" argument does not start a new command.
|
|
|
|
// The _strv version is limitted to MP_CMD_MAX_ARGS argv array items.
|
|
|
|
struct mp_cmd *mp_input_parse_cmd_strv(struct mp_log *log, int def_flags,
|
2013-12-20 18:32:45 +00:00
|
|
|
const char **argv, const char *location);
|
2013-12-20 17:01:04 +00:00
|
|
|
struct mp_cmd *mp_input_parse_cmd_bstrv(struct mp_log *log, int def_flags,
|
|
|
|
int argc, bstr *argv,
|
|
|
|
const char *location);
|
|
|
|
|
2002-03-19 13:29:28 +00:00
|
|
|
// After getting a command from mp_input_get_cmd you need to free it using this
|
|
|
|
// function
|
2011-07-16 14:47:02 +00:00
|
|
|
void mp_cmd_free(struct mp_cmd *cmd);
|
2002-01-30 12:46:03 +00:00
|
|
|
|
2003-09-14 17:52:59 +00:00
|
|
|
// This creates a copy of a command (used by the auto repeat stuff).
|
2011-07-16 14:47:02 +00:00
|
|
|
struct mp_cmd *mp_cmd_clone(struct mp_cmd *cmd);
|
2002-02-11 11:42:08 +00:00
|
|
|
|
input: handle mouse movement differently
Before this commit, mouse movement events emitted a special command
("set_mouse_pos"), which was specially handled in command.c. This was
once special-cased to the dvdnav and menu code, and did nothing after
libmenu and dvdnav were removed.
Change it so that mouse movement triggers a pseudo-key ("MOUSE_MOVE"),
which then can be bound to an arbitrary command. The mouse position is
now managed in input.c. A command which actually needs the mouse
position can use either mp_input_get_mouse_pos() or mp_get_osd_mouse_pos()
to query it. The former returns raw window-space coordinates, while the
latter returns coordinates transformed to OSD- space. (Both are the same
for most VOs, except vo_xv and vo_x11, which can't render OSD in
window-space. These require extra code for mapping mouse position.)
As of this commit, there is still nothing that uses mouse movement, so
MOUSE_MOVE is mapped to "ignore" to silence warnings when moving the
mouse (much like MOUSE_BTN0).
Extend the concept of input sections. Allow multiple sections to be
active at once, and organize them as stack. Bindings from the top of
the stack are preferred to lower ones.
Each section has a mouse input section associated, inside which mouse
events are associated with the bindings. If the mouse pointer is
outside of a section's mouse area, mouse events will be dispatched to
an input section lower on the stack of active sections. This is intended
for scripting, which is to be added later. Two scripts could occupy
different areas of the screen without conflicting with each other. (If
it turns out that this mechanism is useless, we'll just remove it
again.)
2013-04-26 00:13:30 +00:00
|
|
|
// Set current input section. The section is appended on top of the list of
|
|
|
|
// active sections, so its bindings are considered first. If the section was
|
|
|
|
// already active, it's moved to the top as well.
|
|
|
|
// name==NULL will behave as if name=="default"
|
2012-08-24 11:29:28 +00:00
|
|
|
// flags is a bitfield of enum mp_input_section_flags values
|
input: handle mouse movement differently
Before this commit, mouse movement events emitted a special command
("set_mouse_pos"), which was specially handled in command.c. This was
once special-cased to the dvdnav and menu code, and did nothing after
libmenu and dvdnav were removed.
Change it so that mouse movement triggers a pseudo-key ("MOUSE_MOVE"),
which then can be bound to an arbitrary command. The mouse position is
now managed in input.c. A command which actually needs the mouse
position can use either mp_input_get_mouse_pos() or mp_get_osd_mouse_pos()
to query it. The former returns raw window-space coordinates, while the
latter returns coordinates transformed to OSD- space. (Both are the same
for most VOs, except vo_xv and vo_x11, which can't render OSD in
window-space. These require extra code for mapping mouse position.)
As of this commit, there is still nothing that uses mouse movement, so
MOUSE_MOVE is mapped to "ignore" to silence warnings when moving the
mouse (much like MOUSE_BTN0).
Extend the concept of input sections. Allow multiple sections to be
active at once, and organize them as stack. Bindings from the top of
the stack are preferred to lower ones.
Each section has a mouse input section associated, inside which mouse
events are associated with the bindings. If the mouse pointer is
outside of a section's mouse area, mouse events will be dispatched to
an input section lower on the stack of active sections. This is intended
for scripting, which is to be added later. Two scripts could occupy
different areas of the screen without conflicting with each other. (If
it turns out that this mechanism is useless, we'll just remove it
again.)
2013-04-26 00:13:30 +00:00
|
|
|
void mp_input_enable_section(struct input_ctx *ictx, char *name, int flags);
|
|
|
|
|
|
|
|
// Undo mp_input_enable_section().
|
|
|
|
// name==NULL will behave as if name=="default"
|
|
|
|
void mp_input_disable_section(struct input_ctx *ictx, char *name);
|
|
|
|
|
|
|
|
// Like mp_input_set_section(ictx, ..., 0) for all sections.
|
|
|
|
void mp_input_disable_all_sections(struct input_ctx *ictx);
|
|
|
|
|
|
|
|
// Set the contents of an input section.
|
|
|
|
// name: name of the section, for mp_input_set_section() etc.
|
|
|
|
// location: location string (like filename) for error reporting
|
|
|
|
// contents: list of keybindings, like input.conf
|
|
|
|
// a value of NULL deletes the section
|
|
|
|
// builtin: create as builtin section; this means if the user defines bindings
|
|
|
|
// using "{name}", they won't be ignored or overwritten - instead,
|
|
|
|
// they are preferred to the bindings defined with this call
|
|
|
|
// If the section already exists, its bindings are removed and replaced.
|
|
|
|
void mp_input_define_section(struct input_ctx *ictx, char *name, char *location,
|
|
|
|
char *contents, bool builtin);
|
|
|
|
|
|
|
|
// Define where on the screen the named input section should receive.
|
|
|
|
// Setting a rectangle of size 0 unsets the mouse area.
|
|
|
|
// A rectangle with negative size disables mouse input for this section.
|
|
|
|
void mp_input_set_section_mouse_area(struct input_ctx *ictx, char *name,
|
|
|
|
int x0, int y0, int x1, int y1);
|
2007-06-07 18:06:53 +00:00
|
|
|
|
2013-05-16 21:17:46 +00:00
|
|
|
// Used to detect mouse movement.
|
2013-05-25 16:31:06 +00:00
|
|
|
unsigned int mp_input_get_mouse_event_counter(struct input_ctx *ictx);
|
2013-05-16 21:17:46 +00:00
|
|
|
|
input: handle mouse movement differently
Before this commit, mouse movement events emitted a special command
("set_mouse_pos"), which was specially handled in command.c. This was
once special-cased to the dvdnav and menu code, and did nothing after
libmenu and dvdnav were removed.
Change it so that mouse movement triggers a pseudo-key ("MOUSE_MOVE"),
which then can be bound to an arbitrary command. The mouse position is
now managed in input.c. A command which actually needs the mouse
position can use either mp_input_get_mouse_pos() or mp_get_osd_mouse_pos()
to query it. The former returns raw window-space coordinates, while the
latter returns coordinates transformed to OSD- space. (Both are the same
for most VOs, except vo_xv and vo_x11, which can't render OSD in
window-space. These require extra code for mapping mouse position.)
As of this commit, there is still nothing that uses mouse movement, so
MOUSE_MOVE is mapped to "ignore" to silence warnings when moving the
mouse (much like MOUSE_BTN0).
Extend the concept of input sections. Allow multiple sections to be
active at once, and organize them as stack. Bindings from the top of
the stack are preferred to lower ones.
Each section has a mouse input section associated, inside which mouse
events are associated with the bindings. If the mouse pointer is
outside of a section's mouse area, mouse events will be dispatched to
an input section lower on the stack of active sections. This is intended
for scripting, which is to be added later. Two scripts could occupy
different areas of the screen without conflicting with each other. (If
it turns out that this mechanism is useless, we'll just remove it
again.)
2013-04-26 00:13:30 +00:00
|
|
|
// Test whether there is any input section which wants to receive events.
|
|
|
|
// Note that the mouse event is always delivered, even if this returns false.
|
|
|
|
bool mp_input_test_mouse_active(struct input_ctx *ictx, int x, int y);
|
|
|
|
|
|
|
|
// Whether input.c wants mouse drag events at this mouse position. If this
|
|
|
|
// returns false, some VOs will initiate window dragging.
|
|
|
|
bool mp_input_test_dragging(struct input_ctx *ictx, int x, int y);
|
|
|
|
|
2011-07-16 14:47:02 +00:00
|
|
|
// Initialize the input system
|
2013-09-10 06:29:45 +00:00
|
|
|
struct mpv_global;
|
|
|
|
struct input_ctx *mp_input_init(struct mpv_global *global);
|
2002-01-30 12:46:03 +00:00
|
|
|
|
2013-07-27 19:26:00 +00:00
|
|
|
void mp_input_uninit(struct input_ctx *ictx);
|
2008-08-12 11:22:26 +00:00
|
|
|
|
2012-03-25 19:58:48 +00:00
|
|
|
// Wake up sleeping input loop from another thread.
|
|
|
|
void mp_input_wakeup(struct input_ctx *ictx);
|
|
|
|
|
2012-11-09 00:06:43 +00:00
|
|
|
// Interruptible usleep: (used by demux)
|
2011-07-16 14:47:02 +00:00
|
|
|
int mp_input_check_interrupt(struct input_ctx *ictx, int time);
|
2002-10-23 14:46:20 +00:00
|
|
|
|
2013-12-01 05:23:39 +00:00
|
|
|
// If this returns true, use Right Alt key as Alt Gr to produce special
|
|
|
|
// characters. If false, count Right Alt as the modifier Alt key.
|
|
|
|
bool mp_input_use_alt_gr(struct input_ctx *ictx);
|
|
|
|
|
2008-01-08 21:40:44 +00:00
|
|
|
extern int async_quit_request;
|
|
|
|
|
2008-02-22 09:09:46 +00:00
|
|
|
#endif /* MPLAYER_INPUT_H */
|