Commit Graph

50 Commits

Author SHA1 Message Date
wm4 e0d3dc3857 mplayer: don't hide mouse cursor if mouse is inside mouse area 2013-06-29 22:58:13 +02:00
wm4 831a7cf3ee input: trigger mouse_leave key bindings if mouse leaves mouse area
Also, implement mouse leave events for X11. But evne on other
platforms, these events will be generated if mouse crosses a section's
mouse area boundaries within the mpv window.
2013-06-29 22:58:13 +02:00
wm4 fc422f5aeb command: add commands to enable/disable input sections
For now, it's mostly for testing. It also might allow to create key
binding state machines, but this sounds questionable.
2013-06-29 22:58:13 +02:00
wm4 5b38a522f1 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-06-29 22:58:13 +02:00
wm4 4f5e12136d stream: remove padding parameter from stream_read_complete()
Seems like a completely unnecessary complication. Instead, always add a
1 byte padding (could be extended if a caller needs it), and clear it.

Also add some documentation. There was some, but it was outdated and
incomplete.
2013-06-23 22:33:59 +02:00
wm4 c185b0ba4a command: replace some show_ commands with properties
show_chapters, show_tracks, and show_playlist are killed and replaced
with the properties chapter-list, track-list, and playlist. The code
and the output of these stays the same, this is just moving a lot of
code around and reducing the number of properties.

The "old" commands will still be supported for a while (to avoid making
everyone angry), so handle them with the legacy layer. Add something to
suppress printing the legacy warnings for these commands.
2013-06-07 18:00:34 +02:00
Stefano Pigozzi b9cb011ba5 keycodes: fix copy paste error
Makes 213ad5d behave has intended.
2013-06-05 00:02:29 +02:00
Stefano Pigozzi 213ad5d6c4 osx: improve Media Keys support
This commit addresses some issues with the users had with the previous
implementation in commit c39efb9. Here's the changes:

  * Use Quartz Event Taps to remove Media Key events mpv handles from
    the global OS X queue. This prevents conflicts with iTunes. I did this on
    the main thread since it is mostly idling. It's the playloop thread that
    actually does all the work so there is no danger of blocking the event tap
    callback.
  * Introduce `--no-media-keys` switch so that users can disable all of mpv's
    media key handling at runtime (some prefer iTunes for example).
  * Use mpv's bindings so that users can customize what the media keys do via
    input.conf. Current bindings are:

      MK_PLAY cycle pause
      MK_PREV playlist_prev
      MK_NEXT playlist_next

An additional benefit of this implementation is that it is completly handled
by the `macosx_events` file instead of `macosx_application` making the
project organization more straightforward.
2013-06-04 23:02:23 +02:00
Stefano Pigozzi daf8ed831b fix build on linux
missing ifdef in the previous commit made the build fail
2013-06-03 23:02:16 +02:00
Stefano Pigozzi 72f2942dfa osx: add Apple Remote support
After killing the non functional AR support in c8fd9e5 I got much complaints so
this adds AR support back in (and it works). I am using the HIDRemote class by
Felix Schwarz and that part of the code is under the BSD license. I slightly
modified it replacing [NSApplication sharedApplication] with NSApp. The code
of the class is quite complex (probably because it had to deal with all the
edge cases with IOKit) but it works nicely as a black box.

In a later commit I'll remove the deprecation warnings caused by HIDRemote's
usage of Gestalt.

Check out `etc/input.conf` for the default bindings.

Apple Remote functionality is automatically compiled in when cocoa is enabled.
It can be disabled at runtime with the `--no-ar` option.
2013-06-03 22:35:47 +02:00
Stefano Pigozzi f13f0db33a osx: create macosx_events to deal with keyDown events
On OSX with Cocoa enabled keyDown events are now handled with
addLocalMonitorForEventsMatchingMask:handler:. This allows to respond to
events even when there is no VO initialized but the GUI is focused.
2013-06-03 22:31:13 +02:00
wm4 f44a242258 Replace calls to usec_sleep()
This is just dumb sed replacement to mp_sleep_us().

Also remove the now unused usec_sleep() wrapper.
2013-05-26 16:44:20 +02:00
wm4 e56d8a200d Replace all calls to GetTimer()/GetTimerMS()
GetTimer() is generally replaced with mp_time_us(). Both calls return
microseconds, but the latter uses int64_t, us defined to never wrap,
and never returns 0 or negative values.

GetTimerMS() has no direct replacement. Instead the other functions are
used.

For some code, switch to mp_time_sec(), which returns the time as double
float value in seconds. The returned time is offset to program start
time, so there is enough precision left to deliver microsecond
resolution for at least 100 years. Unless it's casted to a float
(or the CPU reduces precision), which is why we still use mp_time_us()
out of paranoia in places where precision is clearly needed.

Always switch to the correct time. The whole point of the new timer
calls is that they don't wrap, and storing microseconds in unsigned int
variables would negate this.

In some cases, remove wrap-around handling for time values.
2013-05-26 16:44:20 +02:00
wm4 3c8f8b7714 core: do mouse cursor hiding business in frontend
Do this so that not every VO backend has to setup a timer for cursor
hiding and interpret the --cursor-autohide option.
2013-05-26 16:44:19 +02:00
wm4 541fe30ba9 input: allow quotes around any input command 2013-05-18 17:45:55 +02:00
wm4 58cc0f637f input: do property expansion for all input command string arguments
Also add a "raw" prefix for commands, which prevents property expansion.
The idea is that if the commands are generated by a program, it doesn't
have to know whether the command expands properties or not.
2013-05-18 17:45:55 +02:00
wm4 3e6ec6dfa5 input: accept input command prefixes in any order
This is more consistent, and doesn't bother the user with ordering
rules when new prefixes are added.

Will break obscure uses of legacy commands: if the command is supposed
to be translated by the legacy command bridge, and if that command uses
one of the pausing* prefixes, the command can't be parsed. Well, just
use the new commands in this case.
2013-05-18 17:45:55 +02:00
wm4 f569d245ba core: allow changing filter filters at runtime
Add the "vf" command, which allows changing the video filter chain at
runtime. For example, the 'y' key could be bound to toggle deinterlacing
by adding 'y vf toggle yadif' to the input.conf.

Reconfiguring the video filter chain normally resets the VO, so that it
will be "stuck" until a new video frame is rendered. To mitigate this, a
seek to the current position is issued when the filter chain is changed.
This is done only if playback is paused, because normal playback will
show an actual new frame quickly enough.

If vdpau hardware decoding is used, filter insertion (whether it fails
or not) will break the video for a while. This is because vo_vdpau
resets decoding related things on vo_config().
2013-05-18 17:45:54 +02:00
wm4 ce9a854d54 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 20:08:11 +02:00
wm4 ff549a2f6a 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 20:27:12 +02:00
wm4 97be5ead14 input: don't reset time on each key repeat
Key repeats were skipped when playloop iterations took too long. Fix
this by using the total times for key repeat calculation, instead of the
time difference to the last key repeat event.
2013-04-24 18:07:01 +02:00
wm4 003a930285 input: adjust wait time for key-repeat
Basically, these are additional timers that can expire without making
the central select() exit.
2013-04-24 17:46:40 +02:00
wm4 6ca7b80750 input: don't let multi-key bindings block simple key bindings
Key bindings can include mutiple keys at once (additional to key
modifiers like ctrl etc.). This becomes annoying when quickly switching
between two bound keys, e.g. when seeking back and forth, you might end
up hitting the "left" and "right" keys at once. The user doesn't expect
to invoke the key binding "left-right", but would prefer a key stroke to
invoke the binding it was supposed to invoke.

So if there's no binding for a multi-key combination, try to find a
binding for the key last held down. This preserves the ability to define
multi-key combinations, while the common case works as expected.
2013-04-24 17:46:40 +02:00
wm4 4ab283efe6 input: reduce amount of tracked keys per binding
There's no need for key bindings that consist of 32 keys held down. It's
ridiculous and wastes memory.
2013-04-24 17:46:40 +02:00
wm4 274af12694 input: fix handling of MP_KEY_STATE_DOWN
VOs can use the MP_KEY_STATE_DOWN modifier to pass key up/down events to
input.c, instead of just simple key presses. This allows doing key auto-
repeat handling in input.c, if the VO doesn't want to do that.

One issue is that so far, this code has been used only for mouse events,
even though the code was originally written with keyboard keys in mind.
One difference between mouse keys and keyboard keys is that the initial
key down should not generate an input command with mouse buttons
(input.c did that), while keyboard events should (input.c didn't do
that). Likewise, releasing a key should generate input commands for
mouse buttons releases, but not for the keyboard.

Change the code so mouse buttons (recognized via the MP_NO_REPEAT_KEY
flag) follow the old hehavior, while other keys generate input commands
on key down, but not on key release.

Note that a key release event is posted either using
MP_INPUT_RELEASE_ALL, or a normal key press event after having sent a an
event with MP_KEY_STATE_DOWN. This is probably a bit confusing, and a
MP_KEY_STATE_RELEASE should be added.

Fix shift-handling with MP_KEY_STATE_DOWN as well.
2013-04-24 17:46:40 +02:00
wm4 4e55a6e828 Remove some apple remote leftovers
The options and key names don't do anything anymore.
2013-04-05 23:59:39 +02:00
Stefano Pigozzi cae508dfb6 input: remove ar.h include
This is a left over from c8fd9e50e4.
2013-04-05 10:33:52 +02:00
Stefano Pigozzi c8fd9e50e4 remove Apple Remote related code
The OSX part of the Apple Remote was unmaintained for a long time and was not
working anymore. I tried to update the cookies to what the current versions of
OS X expect without much luck. I decided to remove it since Apple is not
including the IR receiver anymore in new hardware and it's clear that wifi
based remotes are the way to go.

A third party iOS app should be used in it's place. In the future we could look
into having a dedicated iOS Remote Control app like VLC and XBMC do.

The Linux side (`appleir.c`) was relatively tidy but it looks like LIRC can be
configured to work with any version of Apple Remote [1] and is more maintained.

[1] LIRC Apple Remote configs: http://lirc.sourceforge.net/remotes/apple/
2013-03-31 12:15:40 +02:00
wm4 05e918be02 input: make input command deprecation warnings visible
Some time ago, all old special-cased commands (like "volume 1" to change
volume by one) have been removed. These commands are still emulated
using simple text replacement. This emulation is done to not break
everyone's input.conf, especially because the input.conf provided by
standard mplayer* still uses the old commands.

Every use of a deprecated command prints a replacement warning, which
was visible only with -v. Make these warnings visible by default.

There's actually not much reason to do this, but since commands like
"volume 5 1" don't work anymore, it's better to be verbose about this.

Also simplify the replacement for "vo_fullscreen".
2013-03-26 01:29:38 +01:00
wm4 ef7975e91b input: fix crash due to dangling pointer
Wrong API usage, has been in the code since 2011. Rarely triggered (if
at all in the current setup).
2013-03-19 13:10:19 +01:00
wm4 7ba6675847 input/ar: remove unused variable 2013-03-19 00:59:55 +01:00
wm4 bc20f2cb00 core: remove a number of global variables
Move them into per-instance structs. This should get rid of all global
variables in mplayer.c (not counting those referenced by cfg-mplayer.h).

In core/input/ar.c, just remove checking the slave_mode variable. I'm
not sure what this code was supposed to achieve, but slave mode is
broken, slave mode is actually infeasible on OSX (ar.c is completely OSX
specific), and the correct way of doing this would be to disable this
input device per command line switch.
2013-03-08 02:12:53 +01:00
wm4 c9088fff86 m_option: don't define OPT_BASE_STRUCT by default
OPT_BASE_STRUCT defines which struct the OPT_ macros (like OPT_INT etc.)
reference implicitly, since these macros take struct member names but no
struct type. Normally, only cfg-mplayer.h should need this, and other
places shouldn't be bothered with having to #undef it.

(Some files, like demux_lavf.c, still store their options in MPOpts. In
the long term, this should be removed, and handled like e.g. with VO
suboptions instead.)
2013-03-01 11:27:59 +01:00
wm4 2254416a5d commands: parse seek time arguments like time options
This means a commands like "seek 13:00 absolute" actually behaves like
"--start=13:00", instead of interpreting the argument as fraction as
with normal float options. This is probably slightly closer to what
you'd expect.

As a consequence, the seek argument's type changes from float to double
internally.
2013-02-26 01:55:52 +01:00
wm4 af54ff826b Remove --rootwin option and rootwin property
You can just use --wid=0 if you really want this.

This only worked/works for X11, and even then it might interact badly
with most desktop environments. All the option did was setting --wid to
0, and the property did nothing.
2013-02-24 17:00:52 +01:00
wm4 80e9b3c0f2 cleanup: remove duplicated function, move escape parsing function 2013-02-16 23:24:46 +01:00
wm4 75e6584ab3 Prefix keycode defines with MP_
Do this to reduce conflicts with <linux/input.h>, which contains some
conflicting defines.

This changes the meaning of MP_KEY_DOWN:

  KEY_DOWN is renamed to MP_KEY_DOWN (cursor down key)
  MP_KEY_DOWN is renamed to MP_KEY_STATE_DOWN (modifier for key down state)
2013-02-12 10:27:00 +01:00
wm4 a1be0e1aec options: change --no-config option, make it apply to input.conf as well
Simplify --no-config and make it a normal flag option, and doesn't take
an argument anymore. You can get the same behavior by using --no-config
and then --include to explicitly load a certain config file.

Make --no-config work for input.conf as well. Make it so that
--input:conf=file still works in this case. As a  technically unrelated
change, the file argument now works as one would expect, instead of
making it relatively to "~/.mpv/". This makes for simpler code and
easier to understand option semantics. We can also print better error
messages.
2013-02-09 00:21:18 +01:00
wm4 88d843f909 cleanup: replace OPT_FLAG_ON and OPT_MAKE_FLAGS with OPT_FLAG
OPT_MAKE_FLAGS() used to emit two options (one with "no" prefixed),
but that has been long removed by special casing flag options in the
option parser. OPT_FLAG_ON() used to imply that there's no "no-"
prefixed option, but this hasn't been the case for a while either.
(Conceptually, it has been replaced by OPT_FLAG_STORE().)

Remove OPT_FLAG_OFF, which was unused.
2013-02-09 00:21:17 +01:00
wm4 c5340512dd core: remove --edlout functionality
This could write .edl files in MPlayer's format. Support for playing
these files has been removed from mplayer2 quite a while ago. (mplayer2
can play its own, "new" .edl format, but does not support writing it.)

Since this is a rather obscure functionality, and it's not really clear
how it should behave (e.g. what should it do if a new file is played),
and wasn't all that great to begin with (what if you made a mistake?
the "edl_mark" command sucks for editing), get rid of it.

Suggestions how to reimplement this in a nicer way are welcome. If it's
just about retrieving timecodes, this in input.conf will do:

    KEY print_text "position: ${=time-pos}"
2013-02-06 23:03:39 +01:00
wm4 74817a77d4 command: add command to show playlist on OSD 2013-02-06 23:03:39 +01:00
wm4 cc5cf98348 input: free all queued/allocated commands on exit
These were memory leaks in theory, though not in practice (all memory is
free'd on exit anyway). However, it was still annoying when leak
reporting is enabled.

I'm not sure if there was an actual leak in check_autorepeat(), maybe
not.
2013-02-03 21:08:26 +01:00
Stefano Pigozzi 68fa3c49db cocoa_events: remove this functionality
This functionality looked smart but created problems with some kinds of
multi touch events. Moreover some events coming from the windows server – like
hovering a corner for window resize – didn't cause the player to wake up
immediately.

The "correct" non hacky way to implement async event polling with cocoa would
be having the vanilla cocoa event loop driving the player and setting up mpv's
terminal FDs as event sources for the cocoa event loop.

Fixes #20
2013-02-02 14:36:05 +01:00
Rudolf Polzer 3b22404e07 mp_msg, getch2: unix tty background support
Now, when backgrounded, mpv plays and outputs messages to stdout, but
statusline is not output.

Background<->foreground transitions are detected by signals and polling
the process groups.
2013-01-23 18:05:34 +01:00
Stefano Pigozzi 60755108a6 input: enqueue commands to the end of the queue
`mp_input_queue_cmd` erroneusly added commands to the head of the queue
resulting in LIFO behaviour instead of the intended FIFO.
2013-01-16 22:16:28 +01:00
Stefano Pigozzi fab9febdc3 path: add mp_find_config_file and reorganize some of the code
Add `mp_find_config_file` to search different known paths and use that in
ass_mp to look for the fontconfig configuration file.

Some incidental changes spawned by this feature where:

 * Buffer allocation for the strings containing the paths is now performed
   with talloc. All of the allocations are done on a NULL context, but it still
   improves readability of the code.
 * Move the OSX function for lookup inside of a bundle: this code path was
   currently not used by the bundle generated with `make osxbundle`. The plan
   is to use it again in a future commit to get a fontconfig config file.
2012-12-15 17:38:00 +01:00
wm4 b7052b431c command: add sub_reload and sub_remove commands
sub_remove remove an external subtitle track, for whatever this may be
needed.

sub_reload removes and re-adds an external subtitle track.

Also rename sub_load to sub_add, because that seems to be more in line
with sub_remove.
2012-11-16 21:21:15 +01:00
wm4 88cfe47614 input: silence warning if input.conf is missing
It's silly to print a warning if an optional config file is missing.
Don't print anything at the default message level if an input config
is not found.

Unfortunately, the behavior is the same for explicitly passed input
config files (with --input=conf=file.conf).
2012-11-16 21:21:14 +01:00
wm4 4873b32c59 Rename directories, move files (step 2 of 2)
Finish renaming directories and moving files. Adjust all include
statements to make the previous commit compile.

The two commits are separate, because git is bad at tracking renames
and content changes at the same time.

Also take this as an opportunity to remove the separation between
"common" and "mplayer" sources in the Makefile. ("common" used to be
shared between mplayer and mencoder.)
2012-11-12 20:08:18 +01:00
wm4 d4bdd0473d Rename directories, move files (step 1 of 2) (does not compile)
Tis drops the silly lib prefixes, and attempts to organize the tree in
a more logical way. Make the top-level directory less cluttered as
well.

Renames the following directories:
    libaf -> audio/filter
    libao2 -> audio/out
    libvo -> video/out
    libmpdemux -> demux

Split libmpcodecs:
    vf* -> video/filter
    vd*, dec_video.* -> video/decode
    mp_image*, img_format*, ... -> video/
    ad*, dec_audio.* -> audio/decode

libaf/format.* is moved to audio/ - this is similar to how mp_image.*
is located in video/.

Move most top-level .c/.h files to core. (talloc.c/.h is left on top-
level, because it's external.) Park some of the more annoying files
in compat/. Some of these are relicts from the time mplayer used
ffmpeg internals.

sub/ is not split, because it's too much of a mess (subtitle code is
mixed with OSD display and rendering).

Maybe the organization of core is not ideal: it mixes playback core
(like mplayer.c) and utility helpers (like bstr.c/h). Should the need
arise, the playback core will be moved somewhere else, while core
contains all helper and common code.
2012-11-12 20:06:14 +01:00