summaryrefslogtreecommitdiffstats
path: root/mpvcore/input/input.c
Commit message (Collapse)AuthorAgeFilesLines
* Move mpvcore/input/ to input/wm42013-12-171-2560/+0
|
* input: remove LIRCCD supportwm42013-12-161-13/+0
| | | | | | | This removes support for the "LIRC Client Daemon", which is separate from LIRC, and hasn't been maintained for 10 years. See github issue #413.
* input: move multi-command parsing somewhere elsewm42013-12-161-32/+38
| | | | | I'm planning to add a mode to pass commands as a pre-split list of strings, and this will probably be useful to reach this goal.
* input: adjust code to make quoted/not quoted cases more unifiedwm42013-12-161-8/+11
|
* input: better error reporting for missing commandswm42013-12-161-7/+12
| | | | Don't print an empty string if the command is missing.
* input: move some command flags into a bitfieldwm42013-12-161-30/+28
|
* input: remove weird syntax for skipping optional argumentswm42013-12-161-10/+4
|
* input: avoid using wakeup pipe if it's not neededwm42013-12-161-1/+9
| | | | | | | | | | | | | | If input is not waiting for select(), writing to the wakeup pipe is wasteful, and, if there are many wakeups, might even block the wakeup threads if the pipe gets full. However, if it's waiting for select(), the wakup pipe must be used to unblock the waiting thread. Actually there's a small race condition: we might determine that the main thread is in select(), and write to the wakeup pipe (whether we do this while unlocked or locked doesn't really matter). Then, the main thread might leave select() before reading from the wakup pipe. This should be harmless, because at worst more wakeups than needed happen, but never fewer.
* input: don't quit with exit status 1 when receiving SIGTERMwm42013-12-151-1/+1
| | | | | Instead, do whatever the normal "quit" command does, which currently is returning a status of 0.
* Allow some options taking filenames to refer to mpv config dirwm42013-12-141-8/+16
| | | | | | | | | | Add the mp_get_user_path() function, and make it expand special path prefixes. Use it for some things in mpv which take filenames (--input-config, --screenshot-template, opengl icc-profile suboption). This allows accessing files in the mpv config dir without hardcoding the config path by prefixing the path with ~~/. Details see manpage additions.
* Add prelimimary (basic, possibly broken) dvdnav supportwm42013-12-121-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | 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?
* input: fix bogus section disabling, add debugging outputwm42013-12-121-3/+11
| | | | | | | | The code to remove a section from the active section array wasn't correct (it should have tried to copy the elements in reverse), so just replace it with a macro that does the intended thing. Add some debug output to print the section stack.
* options: add option to disable using right Alt key as Alt GrVivek Jain2013-12-021-0/+11
| | | | | | | | | mpv was hardcoded to always consider the right Alt key as Alt Gr, but there are parituclar combinations of platforms and keyboard layouts where it's more convenient to treat the right Alt as a keyboard modifier just like the left one. Fixes #388
* input: don't emit command when using multiple mouse buttons at oncewm42013-12-011-5/+21
| | | | | | | | | | | | | | | | | | | | | | This is for key bindings that use multiple mouse buttons at once. (Yes, this is weird, but MPlayer always had this feature, and apparently there are people using it!) Before this commit, clicking another mouse button while still holding the previous mouse button forced the command bound to the previous mouse button to be emitted. This is usually needed to make sure the input consumer (the player and the OSC) stays in sync with the actual mouse button state. If there's no command sent, the OSC in particular would think the button is still held down. However, sending the command is undesired behavior if you want to use these multiple-key binds. Solve this by emitting commands in this situation only if a key down command was sent earlier. Since mouse button key bindings are normally executed on key-up only, this happens with special commands like script_dispatch only (used by the OSD to track mouse buttons, but also used for other OSC bindings). See github issue #390.
* input: improve some commentswm42013-12-011-4/+4
| | | | | I have the feeling some of these were written before everything was changed all over again.
* command: add a revert_seek commandwm42013-12-011-0/+1
| | | | As discussed on IRC.
* Use O_CLOEXEC when creating FDswm42013-11-301-6/+11
| | | | | | | | | | | | | | This is needed so that new processes (created with fork+exec) don't inherit open files, which can be important for a number of reasons. Since O_CLOEXEC is relatively new (POSIX.1-2008, before that Linux specific), we #define it to 0 in io.h to prevent compilation errors on older/crappy systems. At least this is the plan. input.c creates a pipe. For that, add a mp_set_cloexec() function (which is based on Weston's code in vo_wayland.c, but more correct). We could use pipe2() instead, but that is Linux specific. Technically, we have a race condition, but it won't matter.
* command: add a cycle_values input commandwm42013-11-301-1/+4
|
* command: change the syntax and semantics of the "run" commandwm42013-11-301-4/+14
| | | | | | | See the changes in input.rst for explanations. Technically speaking, this also gets rid of some undefined behavior: passing NULL as a vararg (execl()) is always a bug.
* input: require space before '#' commentswm42013-11-301-8/+5
| | | | | | | | | | So e.g. show_text abc#def will now print "abc#def" instead of "#def". It's simpler, more consistent with how ";" and other things are handled, and also possibly avoids bothering the user with extra escaping.
* input: rearrange command parsingwm42013-11-301-44/+31
| | | | This simplifies some things as preparation for the next commits.
* build: make pthreads mandatorywm42013-11-281-13/+2
| | | | | | | | | | | pthreads should be available anywhere. Even if not, for environment without threads a pthread wrapper could be provided that can't actually start threads, thus disabling features that require threads. Make pthreads mandatory in order to simplify build dependencies and to reduce ifdeffery. (Admittedly, there wasn't much complexity, but maybe we will use pthreads more in the future, and then it'd become a real bother.)
* command: allow "current" as argument to playlist_remove commandwm42013-11-281-1/+4
| | | | Feature request from github issue #376.
* input: use separate type for command definitionswm42013-11-281-48/+72
| | | | | | | | | | | | | Introduce a mp_cmd_def struct to define commands, instead of using mp_cmd for this. This way each command parameter can be a m_option, instead of m_option plus some more stuff. Define the ARG_ macros directly in terms of the OPT_ macros. Not sure if this makes it easier to read (maybe not, even if it looks simpler), but at least it makes it easier to add other option types. Another idea was adding a name for each parameter (so you could have named parameters), but not today.
* input: discard precise scrolling commands with no valueStefano Pigozzi2013-11-251-0/+2
| | | | | | | | | | | Apparently Cocoa precise scrolling generates a lot of spurious events with a delta that is equal to 0.0. Make sure that they are discarded and not added to the input queue. Even though this only known to happen with Cocoa, I implemented this at core level since it makes sense in general. Fixes: #310
* input: remove unused key_down_event commandwm42013-11-061-1/+0
| | | | | There's no real use-case for this, and is wasn't documented (didn't even appear on the "undocumented commands" list).
* input: disallow autorepeat by default for most commandswm42013-11-061-12/+23
| | | | | | | | | | This drops autorepeated key events for a number of commands. This should help with slow situations accidentally triggering too many repeats. (I'm not sure if this actually happened to users - maybe.) It's not clear whether MP_CMD_COMMAND_LIST (multiple commands on one binding separated by ';') should be repeated, or whether it should try to do something clever. For now, disallow autorepeat with it.
* configure: uniform the defines to #define HAVE_xxx (0|1)Stefano Pigozzi2013-11-031-10/+10
| | | | | | | | | | | | | | | | | | | | | The configure followed 5 different convetions of defines because the next guy always wanted to introduce a new better way to uniform it[1]. For an hypothetic feature 'hurr' you could have had: * #define HAVE_HURR 1 / #undef HAVE_DURR * #define HAVE_HURR / #undef HAVE_DURR * #define CONFIG_HURR 1 / #undef CONFIG_DURR * #define HAVE_HURR 1 / #define HAVE_DURR 0 * #define CONFIG_HURR 1 / #define CONFIG_DURR 0 All is now uniform and uses: * #define HAVE_HURR 1 * #define HAVE_DURR 0 We like definining to 0 as opposed to `undef` bcause it can help spot typos and is very helpful when doing big reorganizations in the code. [1]: http://xkcd.com/927/ related
* Enable -Wshadowwm42013-11-011-2/+2
| | | | | | | | | This one really did bite me hard (see previous commit), so enable it by default. Fix some cases of shadowing throughout the codebase. None of these change behavior, and all of these were correct code, and just tripped up the warning.
* input: show deprecation warnings for some recently replaced commandswm42013-11-011-4/+4
| | | | Let's see if I get annoyed reactions...
* command: replace speed_mult with multiply commandwm42013-10-311-1/+1
| | | | The compatibility layer still takes care of the old speed_mult command.
* command: add generic "multiply" commandwm42013-10-311-0/+1
| | | | Essentially works like "add".
* command: disable autorepeat for some commands (actually properties)wm42013-10-281-1/+3
| | | | | | | | | | | | Disable autorepeat for the "add"/"cycle" commands when changing properties that are choices (such as fullscreen, pause, and more). In these cases, autorepeat is not very useful, and can rather harmful effects (like triggering too many repeated commands if command execution is slow). (Actually, the commands are just dropped _after_ being repeated, since input.c itself does not know enough about the commands to decide whether or not they should be repeated.)
* input: fix --input-ar-rate=0wm42013-10-201-1/+1
| | | | Crashed, instead of disabling auto-repeat.
* command: add commands for displaying overlayswm42013-10-051-0/+5
| | | | | | Requested by github issue #255. Does not work where mmap is not available (i.e. Windows).
* command: add sub_seek input commandwm42013-10-021-0/+1
| | | | | | | Essentially reuses the sub_step command, and is subject to the same restrictions. Seems to behave a bit strange sometimes, but generally works.
* input: handle MOUSE_LEAVE speciallywm42013-09-271-0/+8
| | | | | | Do this so that MOUSE_LEAVE can't be combined with other keys. (E.g. keep 'w' pressed, then move the mouse outside of the mpv window; it will print a warning what w-MOUSE_LEAVE is not mapped.)
* input: more mp_msg conversionwm42013-09-271-62/+54
| | | | | | | | It appears the last run missed all mp_tmsg(). Since the command parser also prints messages, it needs a new parameter to pass a log context. We go the easy way and just require the input_ctx to be passed, and use its mp_log.
* Add initial Lua scripting supportwm42013-09-261-0/+5
| | | | | | | | | | | | | | | | | | | | | | 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.
* input: fix accidental NULL pointer dereferencewm42013-09-111-2/+2
| | | | | | | This could happen if the input queue was full, and an unmapped key was used, or something like this. Possibly fixes github issue #224.
* input: convert to new msg APIStefano Pigozzi2013-09-101-24/+23
|
* input: rearrange codewm42013-09-081-44/+44
| | | | | | Let all key events go through mp_input_feed_key() internally, and also do double click and MP_INPUT_RELEASE_ALL handling there. Move check_autorepeat() to where it's actually used.
* input: don't deliver mouse events if mouse area is not setwm42013-09-081-4/+10
| | | | | | | | | | | | | | | | | | | | | 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.)
* input: merge consecutive mouse move eventswm42013-09-081-0/+14
| | | | Might give better behavior on load.
* input: split queue_add() functionwm42013-09-081-20/+20
| | | | | Split it into queue_add_head() and queue_add_tail(). Gets rid of the weird, rarely used boolean parameter.
* input: redo what input events can be droppedwm42013-09-081-57/+65
| | | | | | | | | | | | | | | | Until now, any command was dropped as soon as the input queue was full, and the command was not an abort command (i.e. a command that exits the player or goes to the next file). This could cause issues with key down events (especially mouse buttons) not being released. Change it so that key up events can never be dropped. This is a bit involved, because we know whether a key maps to an abort command only after interpreting it, and interpreting it changes global state, which in turn requires undoing the event if the input is dropped. Refactor the code a bit to move more functionality into interpret_key() to make this easier.
* input: remove separation between key and control queuewm42013-09-081-16/+10
| | | | | This is actually quite useless. It also allows the control queue to starve the key queue, because the control queue is always checked first.
* input: don't print warning if certain internal keys are not boundwm42013-09-061-2/+5
| | | | | | | | | | | This affects MOUSE_MOVE and MOUSE_LEAVE. Both are needed internally (such as for the OSC), but not really useful for input.conf. Since the warning has the purpose of notifying the user that a key is unmapped and what key name to use for setting up a binding in input.conf, the warning is rather useless in this case. It's also annoying in combination with the --no-input-default-bindings option, since that removes the default bindings to "ignore" for these keys.
* mpvcore/input: Fix build without pthreadsMartin Herkt2013-09-051-3/+5
|
* input: unlock playloop thread during selectStefano Pigozzi2013-09-011-0/+2
| | | | | | This allows other threads to use mp_input_put_key without blocking if the playloop is doing the 500ms select call (i.e.: during pause). Makes Cocoa GUI responsive again (regression since 2d363c3).
* osx: use MP_KEY_* instead of MK_* for media keysStefano Pigozzi2013-09-011-4/+0
| | | | | In 213ad5d6c I added `MK_*` key bindings overlooking the fact that mpv already has `MP_KEY_*` for media keys.
* input: allow window dragging even if mouse is in a mouse areawm42013-09-011-4/+11
| | | | | | If the input section is enabled with MP_INPUT_ALLOW_VO_DRAGGING, then the VO will be allowed to drag the window with mouse button down + mouse move even if the mouse is inside the section's mouse area.
* input: deal with spurious X11 LeaveNotify eventswm42013-09-011-6/+0
| | | | | | | | | | | | | | | | | | | | | If the mpv window is unfocus, clicking on the OSC should focus the window (done by the window manager) and allow interaction with the OSC. But somehow X sends a spurious LeaveNotify event, immediately followed by an EnterNotify event. This happens at least with IceWM. The result is that the OSC will disappear (due to receiving MOUSE_LEAVE). The OSC will stay invisible, because EnterNotify isn't handled, and there's nothing that could make the OSC appear again. Solve this by handling EnterNotify. We cause a redundant MOUSE_MOVE event to be sent, which triggers the code to make the OSC visible. We have to remove the code from input.c, which ignores redundant mouse move events. Since the code ignoring redundant mouse move events is still needed on Windows, move that code to w32_common.c. The need for this is documented in the code, also see commit 03fd2fe. (The original idea was to save some code by having this code in the core, but now it turns out that this didn't quite work out.)
* input: print more debug infos, raise loglevelwm42013-09-011-2/+20
|
* input: stay in current input section if mouse button is downwm42013-09-011-28/+63
| | | | | | | | | | | | | | | | | Normally, moving the mouse outside of the mouse area of an input section will send mouse events somewhere else (because input section mouse areas are similar to windows/widgets in real GUI toolkits). This was done even if a mouse button was held down. This is quite different from how GUI toolkits behave. Change the code so that if a mouse button is down, the mouse area of the current input section can't be left. Releasing the mouse button (while the mouse pointer is outside of the mouse area) will actually leave the mouse area. As a side-effect, this commit also tests more often whether the current mouse input section is valid. This is needed to make releasing a mouse button trigger the mouse input section change.
* input: add some more X11 multimedia/internet keyswm42013-09-011-0/+6
| | | | | | | | These keys can be found on various "multimedia" and "internet" keyboard. X defines many keycodes, so I'm not adding all, just what I found on my own keyboard. Other key codes can be added on request.
* input: comment all default bindings in input.confwm42013-09-011-1/+9
| | | | | | | | | | | | | | I suspect most users will just copy etc/input.conf when they want to remap some default bindings. But usually this means the user even copies bindings he doesn't care about, and it's better if the user maps only the bindings in his input.conf the user intends to remap. Comment all bindings in etc/input.conf. Since this file also defines the builtin defaults and is baked into the mpv binary, we have to do something to get them anyway, even though they are commented. Do this by having input.c "uncomment" the bindings in the baked in input.conf. (Of course this is done only for the builtin config, not configs loaded from disk.)
* input: lock for accessing struct input_ctxStefano Pigozzi2013-09-011-67/+114
| | | | | | | | | | | | | | The previous code was locking only the input queue. That was too weak since it didn't protect the input_ctx data structure. So remove the locking on the queue and lock all the public functions that interact with the input_ctx. The private functions and public functions that do not act on the input_ctx (there are quite some functions doing mp_cmd manipulations for instance) are not locked. Some changes by wm4. Use a recursive mutex, and restructure some code to be less annoying with locks, such as converting code to single return, or making use of the recursive mutex.