Commit Graph

529 Commits

Author SHA1 Message Date
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 46966b942d input: keycodes: reorder flags
MP_KEY_EMIT_ON_UP and MP_NO_REPEAT_KEY are not modifiers, just static
flags that some keycodes set.

This is just a cosmetic change.
2014-04-18 17:50:36 +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 78128bddda Kill all tabs
I hate tabs.

This replaces all tabs in all source files with spaces. The only
exception is old-makefile. The replacement was made by running the
GNU coreutils "expand" command on every file. Since the replacement was
automatic, it's possible that some formatting was destroyed (but perhaps
only if it was assuming that the end of a tab does not correspond to
aligning the end to multiples of 8 spaces).
2014-04-13 18:03:01 +02:00
reimar 39b2e20698 joystick: Fix incorrect pointer offset code.
I have some doubts that short reads are even allowed/
possible for /dev/js*, does someone know for sure?

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@37132 b3059339-0415-0410-9bf9-f77b7e298cf2
2014-04-10 00:08:08 +02:00
xylosper fb47f2f940 player: rename dvdnav to discnav
Now, navigation works both of DVD and non-BD-J Blu-ray. Therefore,
rename all 'dvdnav' strings which are not DVD specific to 'discnav'
2014-03-30 11:42:49 +09:00
wm4 637664d95a command, lua: change script_message semantics
Change script_message to broadcast the message to all clients. Add a new
script_message_to command, which does what the old script_message
command did.

This is intended as simplification, although it might lead to chaos too.
2014-03-17 18:26:56 +01: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 761975d47b command: fix loadfile command
This was broken by commit bb6b543812. Note that the original pull
request was fine, but it was broken by my own stupidity when I was
"improving" it.

The problem is that the new loadfile argument was not considered
optional anymore after my changes. The original pull request did handle
this by setting .defval to a dummy value, but I removed that part.

Fix it again by introducing a flag that designates that the parameter is
optional. (I didn't want to add it to m_option.h, because technically,
all options are optional, and it's not possible to have non-optional
options.)
2014-02-24 23:02:20 +01:00
xylosper bb6b543812 command: provide per-file-options for loadfile command
Signed-off-by: wm4 <wm4@nowhere>

Closes #575. Minor changes over original pull request.
2014-02-23 17:49:34 +01:00
wm4 f5c781b0d5 command: remove special casing for strings in input commands
Until now, strings were the only allowed dynamically allocated argument
type in input commands. Extend it so that it works for any type. (The
string expansion in command.c is of course still string specific.)
2014-02-23 17:43:38 +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 75d3267b43 client API: add a client message event
This comes with a "script_message" input command, which sends these
messages. Used by the following commits.
2014-02-17 02:52:58 +01:00
wm4 fe586dbbdb keycodes: add const to a function argument 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
wm4 7c6bb321eb video/out: remove some code duplication between X11 and wayland
Both X11 and Wayland support the same format for drag & drop operations
(text/uri-list), and the code for that was copied from x11_common.c to
wayland_common.c. Factor it out.
2014-01-04 19:33:40 +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 066ecfcbfb common: simplify and optimize string escape parsing
This code is shared between input.conf parser and option parser. Until
now, the performance didn't really matter. But I want to use this code
for JSON parsing too, and since JSON will have to be parsed a lot, it
should probably try to avoid realloc'ing too much.

This commit moves parsing of C-style escaped strings into a common
function, and allows using it in a way realloc can be completely
avoided, if the already allocated buffer is large enough.
2013-12-30 22:49:50 +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
wm4 34bee16faf input: split off some code from input.c to separate files
This is mostly just moving code around.
2013-12-26 17:13:25 +01:00
wm4 eef36f03ea msg: rename mp_msg_log -> mp_msg
Same for companion functions.
2013-12-21 22:13:04 +01:00
wm4 eba5d025d2 msg: convert defines to enum
Also get rid of MSGL_HINT and the many MSGL_DBG* levels.
2013-12-21 22:13:04 +01:00
wm4 ad2199128d path lookup functions: mp_msg conversions
There's a single mp_msg() in path.c, but all path lookup functions seem
to depend on it, so we get a rat-tail of stuff we have to change. This
is probably a good thing though, because we can have the path lookup
functions also access options, so we could allow overriding the default
config path, or ignore the MPV_HOME environment variable, and such
things.

Also take the chance to consistently add talloc_ctx parameters to the
path lookup functions.

Also, this change causes a big mess on configfiles.c. It's the same
issue: everything suddenly needs a (different) context argument. Make it
less wild by providing a mp_load_auto_profiles() function, which
isolates most of it to configfiles.c.
2013-12-21 21:43:17 +01:00
wm4 0335011f11 stream: mp_msg conversions
We also drop some slave mode stuff from stream_vcd.
2013-12-21 21:43:16 +01:00
wm4 d8d42b44fc m_option, m_config: mp_msg conversions
Always pass around mp_log contexts in the option parser code. This of
course affects all users of this API as well.

In stream.c, pass a mp_null_log, because we can't do it properly yet.
This will be fixed later.
2013-12-21 21:05:02 +01:00
wm4 ed71606e65 input: rework how input sources are added
Until now, there were two functions to add input sources (stuff like
stdin input, slave mode, lirc, joystick). Unify them to a single
function (mp_input_add_fd()), and make sure the associated callbacks
always have a context parameter.

Change the lirc and joystick code such that they take store their state
in a context struct (probably worthless), and use the new mp_msg
replacements (the point of this refactoring).

Additionally, get rid of the ugly USE_FD0_CMD_SELECT etc. ifdeffery in
the terminal handling code.
2013-12-21 20:50:13 +01:00
Martin Herkt 2d3c7f3b90 input: make parse_cmd_strv take const args 2013-12-20 19:32:45 +01:00
wm4 18930ba7dd input, lua: add functions to take pre-split input commands
So you can pass a command as list of strings (each item is an argument),
instead of having to worry about escaping and such.

These functions also take an argument for the default command flags. In
particular, this allows setting saner defaults for commands sent by
program code.

Expose this to Lua as mp.send_commandv command (suggestions for a better
name welcome). The Lua version doesn't allow setting the default command
flags, but it can still use command prefixes. The default flags are
different from input.conf, and disable OSD and property expansion.
2013-12-20 18:01:04 +01:00
wm4 25d4ae74f1 Rename getch2....c/h to terminal....c/h
"getch2" really tells nothing about what the heck this code does. It'd
be even worse when moving the rest of terminal handling code there.
2013-12-19 21:31:27 +01:00