Commit Graph

573 Commits

Author SHA1 Message Date
wm4 eaf1547afc input: improve wording of key binding messages 2015-06-30 00:43:16 +02:00
wm4 39a339c813 input: remove some unneeded things
Wakeup FDs are not needed anymore (this code exists only for libwaio
usage by now), and 2 other functions can be made private.
2015-05-26 22:00:25 +02:00
wm4 289705daaf input: allow - as separator between commands, instead of _
Wnile it seems quite logical to me that commands use _ as word
separator, while properties use -, I can't really explain the
difference, and it tends to confuse users as well. So always
prefer - as separator for everything.

Using _ still works, and will probably forever. Not doing so would
probably create too much chaos and confusion.
2015-05-25 21:59:44 +02:00
wm4 51120c9c7f input: filter out redundant mp_input_set_mouse_pos() calls
Prevents the OSC from showing up on start on Cocoa.
2015-05-08 22:00:24 +02:00
Marcin Kurczewski f43017bfe9 Update license headers
Signed-off-by: wm4 <wm4@nowhere>
2015-04-13 12:10:01 +02:00
Philip Sequeira 48dafda7e9 options: add M_OPT_FILE to --input-conf
Someday I'll look through all the options and find whatever else is
missing it...
2015-03-31 15:05:08 +02:00
wm4 9b5a7241e8 input: remove Linux joystick support
Why did this exist in the first place? Other than being completely
useless, this even caused some regressions in the past. For example,
there was the case of a laptop exposing its accelerometer as joystick
device, which led to extremely fun things due to the default mappings of
axis movement being mapped to seeking.

I suppose those who really want to use their joystick to control a media
player (???) can configure it as mouse device or so.
2015-03-24 16:04:44 +01:00
wm4 1e659a9f0f input: remove classic LIRC support
It's much easier to configure remotes as X11 input devices.
2015-03-24 16:04:44 +01:00
wm4 69e6e7b17c input: minor cleanup
Add MP_KEY_MOUSE_ENTER to the ignored input if the user has disabled
mouse input. Remove one instance of code duplication, and add a
MP_KEY_IS_MOUSE_MOVE macro to summarize events that are caused by moving
the mouse.
2015-02-18 21:12:57 +01:00
torque 3b269ac0a0 input: add MOUSE_ENTER keybinding.
Signed-off-by: wm4 <wm4@nowhere>
2015-02-18 00:03:16 +01:00
wm4 11d72b0999 input: handle mixing key press and up/down events better 2015-01-23 13:02:42 +01:00
wm4 3459130e5c client API: reasonable behavior if window is closed
Closing the video window sends CLOSE_WIN, which is normally mapped to
the "quit" command. The client API normally disables all key bindings,
and closing the window does nothing. It's simply left to the application
to handle this. This is fine - an embedded window can not be destroyed
by user interaction.

But sometimes, the window might be destroyed anyway, for example because
the containing window is destroyed. If this happens, CLOSE_WIN should
better not be ignored. We can't expect client API users to handle this
specially (by providing their own input.conf), so provide some fallback
for this pseudo key binding. The "quit" command might be too intrusive
(not every client necessarily handles "unexpected" MPV_EVENT_SHUTDOWN),
but I think it's still reasonable.
2015-01-12 12:53:49 +01:00
wm4 6e7942af50 input: add a hack to fix keyboard navigation with dvd/bd menu
If the user has LEFT/RIGHT/etc. bound in his input.conf, then these were
overriding the menu keys in dvdnav mode.

This hack works because the dvdnav crap happens to be the only user of
MP_INPUT_ON_TOP. If it finds a default key binding in the dvdnav menu
section, it will use that, instead of continuing search and possibly
finding the user key bindings meant for normal playback.
2014-12-04 22:42:06 +01:00
wm4 0c6d85f6c3 input, lua: make removing key bindings work
This just kept adding bindings to the input section, rather than
defining it. One bad effect was that mp.remove_key_binding() in Lua
didn't work.
2014-12-03 15:46:55 +01:00
wm4 d33ae93b89 input: simplify 2014-11-24 16:48:34 +01:00
wm4 5bbd734fff command: don't queue framesteps
If repeated framestep commands are sent, just unpause the player, instead
of playing N frames for N repeated commands.
2014-11-23 15:31:32 +01:00
wm4 ae5df9be98 input, lua: redo input handling
Much of it is the same, but now there's the possibility to distinguish
key down/up events in the Lua API.
2014-11-23 15:13:35 +01:00
wm4 4cdd346246 input: set mouse area by default for all input
Otherwise, mouse button bindings added by mp.add_key_binding() would be
ignored.

It's possible that this "breaks" some older scripts using undocumented
Lua script functions, but it should be safe otherwise.

Fixes #1283.
2014-11-23 09:10:51 +01:00
wm4 0a78a61d89 input: add a prefix to make any binding act on key repeat
The fact that it's a generic command prefix that is parsed even when
using the client API is a bit unclean (because this flag makes sense
for actual key-bindings only), but it's less code this way.
2014-11-20 23:41:01 +01:00
wm4 fb4d26e769 input: cascade-load input.conf
If there are several input.confs in the set of valid config paths, load
them all.
2014-10-29 22:54:03 +01:00
wm4 9ba6641879 Set thread name for debugging
Especially with other components (libavcodec, OSX stuff), the thread
list can get quite populated. Setting the thread name helps when
debugging.

Since this is not portable, we check the OS variants in waf configure.
old-configure just gets a special-case for glibc, since doing a full
check here would probably be a waste of effort.
2014-10-19 23:48:40 +02:00
Alessandro Ghedini 3deb6c3d4f input: implement --input-file on unix using the IPC support 2014-10-17 20:47:43 +02:00
wm4 c9f45ea93e input: use mpv_node parser for char** command parsers
Minor simplification, also drops some useless stuff.
2014-10-10 22:58:28 +02:00
Stefano Pigozzi dba2b90d9a libmpv/cocoa: don't start the event monitor
The event monitor is used to get keyboard events when there is no window, but
since it is a global monitor to the current process, we don't want it in a
library setting.
2014-10-09 22:14:41 +02:00
wm4 e294656cb1 client API: rename --input-x11-keyboard to --input-vo-keyboard
Apparently we need this for Cocoa too. (The option was X11 specific in
the hope that only X11 would need this hack.)
2014-10-09 18:28:37 +02:00
wm4 3273db1ef7 client API, X11: change default keyboard input handling again
Commit 64b7811c tried to do the "right thing" with respect to whether
keyboard input should be enabled or not. It turns out that X11 does
something stupid by design. All modern toolkits work around this native
X11 behavior, but embedding breaks these workarounds.

The only way to handle this correctly is the XEmbed protocol. It needs
to be supported by the toolkit, and probably also some mpv support. But
Qt has inconsistent support for it. In Qt 4, a X11 specific embedding
widget was needed. Qt 5.0 doesn't support it at all. Qt 5.1 apparently
supports it via QWindow, but if it really does, I couldn't get it to
work.

So add a hack instead. The new --input-x11-keyboard option controls
whether mpv should enable keyboard input on the X11 window or not. In
the command line player, it's enabled by default, but in libmpv it's
disabled.

This hack has the same problem as all previous embedding had: move the
mouse outside of the window, and you don't get keyboard input anymore.
Likewise, mpv will steal all keyboard input from the parent application
as long as the mouse is inside of the mpv window.

Also see issue #1090.
2014-09-28 20:11:00 +02:00
wm4 cbf7180c90 input: copy options automatically
Originally, all options were copied to ensure that input_ctx remins
thread-safe, even if options are changed asynchronously. But this got
a bit inconsistent. Copy them automatically and reduce some weirdness.
2014-09-27 16:25:29 +02:00
wm4 b4d1494336 input: separate creation and loading of config
Until now, creating the input_ctx was delayed until the command line
and config files were parsed. Separate creation and loading so that
input_ctx is available from start.

This should make it possible to simplify some things. For example,
some complications with Cocoa were apparently only because input_ctx
was available only "later". (Although I'm not sure if this is still
relevant, or if the Cocoa code should even be organized this way.)
2014-09-27 16:01:55 +02:00
wm4 5e6c9963d8 input: explain why we use semaphores
Also switch function names for better self-documentation.
2014-09-20 04:22:37 +02:00
Alexander Preisinger 30175538fe input: add locking for repeat info 2014-09-19 17:48:06 +02:00
Alexander Preisinger be516022b6 input: add function for setting repeat info
Let us set a different rate and delay.

Needed for the following commit where we set rate and delay reported by weston.
But only if the option native-keyrepeat is set.
2014-09-19 17:36:37 +02:00
wm4 e0b4daf3ad input: use libwaio for pipe input on Windows
Use libwaio to read from pipes (stdin or named pipes) on Windows. This
liberates us from nasty issues, such as pipes (as created by most
programs) not being possible to read in a non-blocking or event-driven
way. Although it would be possible to do that in a somewhat sane way
on Vista+, it's still not easy, and on XP it's especially hard. libwaio
handles these things for us.

Move pipe.c to pipe-unix.c, and remove Windows specific things. Also
adjust the input.c code to make this work cleanly.
2014-09-14 16:24:01 +02:00
wm4 893f4a0fee input: distinguish playlist navigation and quit commands for abort
Refine the ugly hack from the previous commit, and let the "quit"
command and some others abort playback immediately. For
playlist_next/playlist_prev, still use the old hack, because we can't
know if they would stop playback or not.
2014-09-13 16:47:30 +02:00
wm4 2e91d44e20 stream: redo playback abort handling
This mechanism originates from MPlayer's way of dealing with blocking
network, but it's still useful. On opening and closing, mpv waits for
network synchronously, and also some obscure commands and use-cases can
lead to such blocking. In these situations, the stream is asynchronously
forced to stop by "interrupting" it.

The old design interrupting I/O was a bit broken: polling with a
callback, instead of actively interrupting it. Change the direction of
this. There is no callback anymore, and the player calls
mp_cancel_trigger() to force the stream to return.

libavformat (via stream_lavf.c) has the old broken design, and fixing it
would require fixing libavformat, which won't happen so quickly. So we
have to keep that part. But everything above the stream layer is
prepared for a better design, and more sophisticated methods than
mp_cancel_test() could be easily introduced.

There's still one problem: commands are still run in the central
playback loop, which we assume can block on I/O in the worst case.
That's not a problem yet, because we simply mark some commands as being
able to stop playback of the current file ("quit" etc.), so input.c
could abort playback as soon as such a command is queued. But there are
also commands abort playback only conditionally, and the logic for that
is in the playback core and thus "unreachable". For example,
"playlist_next" aborts playback only if there's a next file. We don't
want it to always abort playback.

As a quite ugly hack, abort playback only if at least 2 abort commands
are queued - this pretty much happens only if the core is frozen and
doesn't react to input.
2014-09-13 16:09:51 +02:00
wm4 a3b393d68c input: simplify
Just some minor things. In particular, don't call mp_input_wakeup()
manually, but make it part of queuing commands (as far as possible).
2014-09-13 01:14:07 +02:00
wm4 fc5df2b970 input: fix autorepeat
Mismatching units in timeout calculation.

Also, as a near-cosmetic change, explicitly wake up the core on the
right time. Currently this does nothing, because the core is woken up
anyway - but it will matter with the next commit.
2014-09-13 01:14:07 +02:00
wm4 e9b756c7ad input: remove central select() call
This is now unused. Get rid of it and all surrounding infrastructure,
and replace the remaining "wakeup pipe" with a semaphore.
2014-09-10 03:24:45 +02:00
wm4 ae63702a2c input: remove useless joystick.h/lirc.h include files
These really just waste space.
2014-09-10 00:51:36 +02:00
wm4 e2a093df02 input: use an input thread for joystick 2014-09-10 00:48:59 +02:00
wm4 fe0ca7559c input: use an input thread for lirc 2014-09-10 00:48:45 +02:00
wm4 5be678386b input: add convenience function for running input sources in threads 2014-09-10 00:48:12 +02:00
wm4 256fea7655 input: make some fields internal 2014-09-10 00:48:12 +02:00
wm4 28fc13977e terminal-unix: move to thread
Do terminal input with a thread, instead of using the central select()
loop. This also changes some details how SIGTERM is handled.

Part of my crusade against mp_input_add_fd().
2014-09-10 00:48:12 +02:00
wm4 76f9eede34 input: fix missed wakeups, simplify
mp_input_read_cmd() reset the wakeup flag, but only mp_input_wait()
should be able to do that.
2014-09-09 01:23:09 +02:00
wm4 3b5f28bd0f input: fix exiting with signals
Quitting through SIGTERM etc. was accidentally ignored since commit
f5af5962 from today.
2014-09-08 01:11:32 +02:00
wm4 f5af596237 player: some more input refactoring
Continues commit 348dfd93. Replace other places where input was manually
fetched with common code.

demux_was_interrupted() was a weird function; I'm not entirely sure
about its original purpose, but now we can just replace it with simpler
code as well. One difference is that we always look at the command
queue, rather than just when cache initialization failed. Also, instead
of discarding all but quit/playlist commands (aka abort command), run
all commands. This could possibly lead to unwanted side-effects, like
just ignoring commands that have no effect (consider pressing 'f' for
fullscreen right on start: since the window is not created yet, it would
get discarded). But playlist navigation still works as intended, and
some if not all these problems already existed before that in some
forms, so it should be ok.
2014-09-07 20:44:54 +02:00
shdown 3307af43c5 input: make ar_rate and ar_delay fields of input_ctx signed
ar_rate is set to -1 when autorepeat is disabled; there is no reason
for ar_delay to stay unsigned.
2014-08-30 15:15:37 +02:00
shdown 8ee1bcf1fa input: handle reaching MP_MAX_FDS correctly
Don't dereference fd and increment ictx->num_fds on fail.
2014-08-30 15:15:37 +02:00
wm4 68ff8a0484 Move compat/ and bstr/ directory contents somewhere else
bstr.c doesn't really deserve its own directory, and compat had just
a few files, most of which may as well be in osdep. There isn't really
any justification for these extra directories, so get rid of them.

The compat/libav.h was empty - just delete it. We changed our approach
to API compatibility, and will likely not need it anymore.
2014-08-29 12:31:52 +02:00
wm4 b7f72aa2f4 input: make key bindings like "Shift+X" work (for ASCII)
"Shift+X" didn't actually map any key, as opposed to "Shift+x". This is
because shift usually changes the case of a character, so a plain
printable character like "X" simply can never be combined with shift.

But this is not very intuitive. Always remove the shift code from
printable characters. Also, for ASCII, actually apply the case mapping
to uppercase characters if combined with shift. Doing this for unicode
in general would be nice, but that would require lookup tables. In
general, we don't know anyway what character a key produces when
combined with shift - it could be anything, and depends on the keyboard
layout.
2014-08-26 20:39:28 +02:00
wm4 740f0f61d8 input: redo how --input-file is handled
Abandon the "old" infrastructure for --input-file (mp_input_add_fd(),
select() loop, non-blocking reads). Replace it with something that
starts a reader thread, using blocking input.

This is for the sake of Windows. Windows is a truly insane operating
system, and there's not even a way to read a pipe in a non-blocking
way, or to wait for new input in an interruptible way (like with
poll()). And unfortunately, some want to use pipe to send input to
mpv. There are probably (slightly) better IPC mechanisms available
on Windows, but for the sake of platform uniformity, make this work
again for now.

On Vista+, CancelIoEx() could probably be used. But there's no way on
XP. Also, that function doesn't work on wine, making development
harder. We could forcibly terminate the thread, which might work, but
is unsafe. So what we do is starting a thread, and if we don't want
the pipe input anymore, we just abandon the thread. The thread might
remain blocked forever, but if we exit the process, the kernel will
forcibly kill it. On Unix, just use poll() to handle this.

Unfortunately the code is pretty crappy, but it's ok, because it's late
and I wanted to stop working on this an hour ago.

Tested on wine; might not work on a real Windows.
2014-08-25 01:00:21 +02:00
wm4 20d88a6dea input: change verbosity of some message levels
For --input-test, print messages on terminal by default.

Raise message level for enabling input sections, because the OSC makes
this very extremely annoying.
2014-08-25 00:48:55 +02:00
wm4 ef9b399020 input: fix event wakeup
When a new event was added, merely a flag was set, instead of actually
waking up the core (if needed). This was ok in ancient times when all
event sources were part of the select() loop. But now there are several
cases where other threads can add input, and then you actually need to
wakeup the core in order to make it read the events at all.
2014-08-11 13:50:56 +02:00
wm4 58255e0e2b input: be stricter about rejecting mouse input with --no-input-cursor
Apparently this switch means all mouse input should be strictly
rejected. Some VO backends (such as X11) explicitly disable all mouse
events if this option is set, but others don't. So check them in
input.c, which increases consistency.
2014-07-27 22:00:55 +02:00
wm4 4c533fbb16 vo: remove vo_mouse_movement() wrapper
So that VO backends don't have to access the VO just for that.
2014-07-27 21:53:29 +02:00
wm4 89391e7c94 vo: different hack for VOs which need to mangle mouse input
Follow up on commit 760548da. Mouse handling is a bit confusing, because
there are at least 3 coordinate systems associated with it, and it
should be cleaned up. But that is hard, so just apply a hack which gets
the currently-annoying issue (VO backends needing access to the VO) out
of the way.
2014-07-27 21:33:11 +02:00
wm4 18c432b83a osdep: don't assume errno is positive
Apparently this is not necessarily the case, so just drop the silly idea
that depended on this assumption.
2014-07-25 14:32:45 +02:00
wm4 a09329bcf7 input: skip BOM in input.conf 2014-07-12 21:25:32 +02:00
wm4 4d829d750c input: restore ability to combine mouse buttons
Key bindings are decided on the "down" event, so if the prefix is not
unique, the first/shortest will be used (e.g. when both "a" and "a-b"
are mapped, "a" will always be chosen).

This also breaks combining multiple mouse buttons. But it seems users
expect it to work, and it's indeed a bit strange that it shouldn't work,
as mouse bindings are emitted on the key "up" event, not "down" (if the
shorter binding didn't emit a command yet, why shouldn't it be
combinable).

Deal with this by clearing the key history when a command is actually
emitted, instead of when a command is decided. This means if both
MOUSE_BTN0 and MOUSE_BTN0-MOUSE_BTN1 are mapped, the sequence of holding
down BTN0 and then BTN1 will redecide the current command. On the other
hand, if BTN0 is released before BTN1 is pressed, the command is
emitted, and the key history is deleted. So the BTN1 press will not
trigger BTN0-BTN1.

For normal keys, nothing should change, because commands are emitted on
the "down" event already, so the key history is always cleared.

Might fix #902.

CC: @mpv-player/stable (if this fix is successful)
2014-07-07 18:18:41 +02:00
wm4 9a210ca2d5 Audit and replace all ctype.h uses
Something like "char *s = ...; isdigit(s[0]);" triggers undefined
behavior, because char can be signed, and thus s[0] can be a negative
value. The is*() functions require unsigned char _or_ EOF. EOF is a
special value outside of unsigned char range, thus the argument to the
is*() functions can't be a char.

This undefined behavior can actually trigger crashes if the
implementation of these functions e.g. uses lookup tables, which are
then indexed with out-of-range values.

Replace all <ctype.h> uses with our own custom mp_is*() functions added
with misc/ctype.h. As a bonus, these functions are locale-independent.
(Although currently, we _require_ C locale for other reasons.)
2014-07-01 23:11:08 +02:00
wm4 be5725ebc4 input: make option struct local
Similar to previous commits.

This also renames --doubleclick-time to --input-doubleclick-time, and
--key-fifo-size to --input-key-fifo-size. We could keep the old names,
but these options are very obscure, and renaming them seems better for
consistency.
2014-06-11 01:54:03 +02:00
wm4 a854583b57 input: don't print warning when aboting playback via commands
I don't really see a reason for this.
2014-06-06 17:17:22 +02:00
wm4 ec18df8466 input: separate wakeup pipe creation into a separate function
Error handling is slightly reduced: we assume that setting a pipe
to non-blocking can never fail.
2014-05-30 02:16:20 +02:00
wm4 6710527a83 input: make combined commands repeatable
Binding multiple commands at once where always considered not
repeatable, because the MP_CMD_COMMAND_LIST wasn't considered
repeatable.

Fixes #807 (probably).
2014-05-26 21:59:30 +02:00
wm4 2f65f0e254 input: allow disabling window dragging with --no-window-dragging
Requested in github issue #608.
2014-05-20 02:40:28 +02:00
wm4 15c22fb0eb input: fix compilation on windows
Currently I don't have a crosscompilation toolchain, so I couldn't test
whether this actually compiles (and still can't).
2014-05-20 02:40:28 +02:00
Martin Herkt 32c63fc119 options: rename input-related options
--ar              → --input-appleremote
--consolecontrols → --input-terminal
--media-keys      → --input-media-keys
--joystick        → --input-joystick
--lirc            → --input-lirc
--lircconf        → --input-lirc-conf
--mouse-movements → --input-cursor
--right-alt-gr    → --input-right-alt-gr
2014-05-04 02:46:05 +02:00
wm4 585d8c6856 input: increase number of maximum sections
This is because Lua scripts creating key bindings create 2 input
sections per script.

Probably fixes #759.
2014-05-02 01:27:17 +02:00
wm4 a29597cb65 input: fix mouse_leave/OSC behavior
This essentially reverts commit cca13efb. The code in the if was
supposed to be run only if the mouse button was down, because in this
case the mouse area is never considered to be left. Since it was run
for every mouse button, mouse_leave wasn't sent.

Fixes #745.
2014-04-26 20:30:24 +02:00
wm4 d44dd30ac7 input: fix inverted condition
pthread_equal() returns 0 if the threads are not the same, and somehow
I got that wrong. The worst is that I actually explicitly checked the
manpage when I wrote this code.
2014-04-26 16:58:23 +02:00
wm4 93de4c81b9 stream: make mp_input_check_interrupt thread-safe
The interrupt callback will can be called from another thread if the
cache is enabled, and the stream disconnects. Then stream_reconnect()
will call this function from within the cache thread.

mp_input_check_interrupt() is not thread-safe due to read_events() not
being thread-safe. It will call input callbacks added with
mp_input_add_fd() - these callbacks lead to code not protected by locks,
such as reading X11 events.

Solve this by adding a stupid hack, which checks whether the calling
thread is the main playback thread (i.e. calling the input callbacks
will be safe). We can remove this hack later, but it requires at least
moving the VO to its own thread first.
2014-04-25 19:13:03 +02:00
wm4 e0cf983e53 stream: remove interrupt callback global variables
This used global variables for the asynchronous interrupt callback.

Pick the simple and dumb solution and stuff the callback into
mpv_global. Do this because interrupt checking should also work in the
connect phase, and currently stream creation equates connecting.
Ideally, this would be passed to the stream on creation instead, or
connecting would be separated from creation. But since I don't know yet
which is better, and since moving stream/demuxer into their own thread
is something that will happen later, go with the mpv_global solution.
2014-04-25 19:12:24 +02:00
wm4 14421f732b input: make key binds order-independent again
This is for the sake of multi-key commands again. This could break:

   SPACE ignore
   SPACE-SPACE command

while this worked:

   SPACE-SPACE command
   SPACE ignore

The reason being that if the shorter command was first in the list,
it would obviously match, and searching was stopped.
2014-04-19 14:31:54 +02:00
wm4 d910677937 input: discard key history when a key is mapped
This is for the sake of multi-key combinations (see github issue #718).
Now a multi-key sequence isn't matched if any of the previous keys were
actually mapped.
2014-04-19 14:27:26 +02:00
wm4 ec18d24683 input: remove minor code duplication 2014-04-19 14:11:55 +02:00
wm4 8f3850e7ed input: ignore modifiers on MOUSE_LEAVE
Just in case something adds shift/alt/ctrl state to it.
2014-04-19 14:11:25 +02:00
wm4 3ded6077ae input: don't wakeup core if key repeat is requested but not possible
There's no need to wakeup the core in this situation.
2014-04-18 18:15:41 +02:00
wm4 395fd9aded input: remove minor redundancy 2014-04-18 18:06:19 +02:00
wm4 6b9ec41a43 input: simplify by not tracking key up/down states
We only need to track key up/down for a single key. There may be some
minor loss of robustness, but this can (probably) happen only if a VO or
user sends strange or complicated sequences of events. In the normal
case, what we do is more than enough. Most simplification comes from the
fact that mpv is not a game console, and users normally execute only one
action at once.
2014-04-18 17:46:00 +02:00
wm4 46e0ede228 input: rename a variable
Squashing this with the following commit would be confusing.
2014-04-18 17:16:33 +02:00
wm4 cca13efb19 input: slightly simplify mouse dispatching
I admit I don't really understand anymore why this was needed. Delete it
anyway. It was added with commit 42fa7cbbf.
2014-04-18 17:00:24 +02:00
wm4 b87191d176 input: move a function 2014-04-18 16:48:13 +02:00
wm4 ecb4c08ee2 input: close window when window close button is pressed with --input-test
The window close button is usually mapped to the CLOSE_WIN pseudo-key.
Until now, --input-test treated this pseudo-key like any other key (like
the rest of the input handling code), so you couldn't close the window
in this mode. The manpage had silly instructions and warnings how to
deal with this.

Just always quit when CLOSE_WIN is received, and improve the
instructions.
2014-04-18 16:37:27 +02:00
wm4 3b12d0add9 input: handle multi-combinations as key sequences
The input code always supported combinations of multiple keys (even in
MPlayer, although there the code was active really only for mouse
buttons). This was arcance and also made the code more complicated. I
only know of a single person who ever made use of this feature.

Remove this feature, and repurpose some of the support code (e.g.
parsing, display of key combinations, etc.) to handle such multi-
combinations as sequences, instead of keys to be pressed at the same
time. This is much simpler and implements the feature requested in
github issue #718.

This commit will probably cause a bunch of regressions, since the input
handling code has some weird corner cases. I couldn't find any problems
when testing, though.
2014-04-18 16:27:02 +02:00
wm4 3004661bf2 input: deal with playback thread wakeup on windows
The recent change of waking up the playback thread using a wakeup pipe
doesn't work on windows, because windows is horrible. So use a condition
variable instead to wake up the thread. To make things worse, jackaudio
is also horrible and "disallows" the use of mutexes, so all we can do is
implementing a half-solution that is not race condition free.

It would probably better to give up on this lock-free crap in the pull-
API audio path.

Mostly untested.
2014-04-15 23:12:15 +02:00
wm4 5aeec9aa70 audio: wake up the core when audio buffer is running low (2)
Same change as in e2184fcb, but this time for pull based AOs. This is
slightly controversial, because it will make a fast syscall from e.g.
ao_jack. And according to JackAudio developers, syscalls are evil and
will destroy realtime operation. But I don't think this is an issue at
all.

Still avoid locking a mutex. I'm not sure what jackaudio does in the
worst case - but if they set the jackaudio thread (and only this thread)
to realtime, we might run into deadlock situations due to priority
inversion and such. I'm not quite sure whether this can happen, but I'll
readily follow the cargo cult if it makes hack happy.
2014-04-15 22:50:16 +02:00
wm4 70ff543029 input: allow input.conf bindings to be declared as builtin
This might be helpful if we ever want cascading config files. Also, we
will probably need it if we change the default input.conf bindings, and
want to provide compatibility input.conf files.
2014-02-25 22:09:20 +01:00
wm4 857952dce3 input: check for abort cmd in multi-commands
MP_CMD_COMMAND_LIST commands (used to implement key bindings with
multiple commands) were not checked for abort commands. Implement it.

Remove the remarks about multi-commands being special from the manpage.
Seek coalescing is handled differently now, and the issue with abort
commands is fixed with this commit.
2014-02-20 13:40:32 +01:00
James Ross-Gowan 1d0730d22d input: ignore modifiers when releasing keys
This prevents keys from getting stuck if the modifier is released before
the base key.
2014-02-20 23:07:53 +11:00
wm4 57c9f5236a input, dvdnav: fix osc stealing input from dvdnav
This is a regression introduced from moving Lua scripts (including the
OSC) to their own threads. Now OSC and dvdnav can add their bindings at
the same time without coordination, which seems to result in the OSC
winning most time, and thus overriding the dvdnav menu bindings.

Fix this by adding a flag that makes dvdnav menu bindings take priority
over all other bindings.
2014-02-19 15:40:04 +01:00
wm4 8b57e4bc12 input: minor simplification for --input-test 2014-02-19 15:39:59 +01:00
wm4 12b7850f11 input: debug output for registered bindings 2014-02-17 02:52:58 +01:00
wm4 03624a1747 input: don't let builtin bindings overwrite user bindings
This was already done, except when the bindings were in different input
sections. This commit fixed it. Useful for scripts, probably.
2014-02-17 02:52:58 +01:00
wm4 a17be5576f threads: add wrapper for initializing recursive mutexes
Damn this overly verbose pthread API.
2014-01-31 19:50:25 +01:00
wm4 5d57a338ce input: change mp_input_run_cmd signature
I don't like this function at all, but it's basically a trick to get the
input's mp_log instance in a case the mp_input_parse_cmd_strv() is
almost certainly not going to output anything. But still make it
somewhat more consistent with mp_input_parse_cmd_strv() - why force the
caller to always use MP_ON_OSD_AUTO?
2014-01-04 19:42:16 +01:00
Stefano Pigozzi 082c5c19a1 input: move files drag and drop to a new event.c file
event.c will be used to feed the input queue with 'global' events that don't
mesh well with the usual check_events path in mpv.
2014-01-04 17:28:55 +01:00
wm4 b0efd3f36a input: use bstr_xappend()
To get rid of mp_append_utf8_buffer().
2013-12-30 22:49:51 +01:00
wm4 4b695e7972 input: print an error if reading input.conf fails
stream_read_complete() fails if the file is larger than the requested
maximum size. But input.c didn't check for this case, and no indication
that something went wrong was printed.
2013-12-28 15:06:43 +01:00
wm4 dacb6ad98f options: simplify handling of some help options 2013-12-26 19:25:51 +01:00
wm4 4ea8612b40 input: cosmetics: move code around
Rearrange the code in an attempt to make its organization more logical.
2013-12-26 17:41:28 +01:00