summaryrefslogtreecommitdiffstats
path: root/core/input
Commit message (Collapse)AuthorAgeFilesLines
* audio/filter: use new option APIwm42013-07-222-10/+2
| | | | | | | | | | | | | Make the VF/VO/AO option parser available to audio filters. No audio filter uses this yet, but it's still a quite intrusive change. In particular, the commands for manipulating filters at runtime completely change. We delete the old code, and use the same infrastructure as for video filters. (This forces complete reinitialization of the filter chain, which hopefully isn't a problem for any use cases. The old code forced reinitialization too, but it could potentially allow a filter to cache things; e.g. consider loaded ladspa plugins and such.)
* input: Ignore spurious mouse movesDiogo Franco (Kovensky)2013-07-211-0/+4
| | | | | | | | | | | | Windows generates WM_MOUSEMOVE messages internally whenever the window manager wants to know where the mouse is[1] and broadcasts that to everyone; w32_common doesn't check whether the position is different and just (indirectly) calls this. Do the check on input.c since it's possible some other VO or frontend also do the same thing. [1]: http://blogs.msdn.com/b/oldnewthing/archive/2003/10/01/55108.aspx
* Merge branch 'remove_old_demuxers'wm42013-07-141-1/+1
|\ | | | | | | | | | | | | | | The merged branch doesn't actually just remove old demuxers, but also includes a branch of cleanups and some refactoring. Conflicts: stream/stream.c
| * core: change open_stream and demux_open signaturewm42013-07-121-1/+1
| | | | | | | | | | | | | | | | | | | | | | This removes the dependency on DEMUXER_TYPE_* and the file_format parameter from the stream open functions. Remove some of the playlist handling code. It looks like this was needed only for loading linked mov files with demux_mov (which was removed long ago). Delete a minor bit of dead network-related code from stream.c as well.
* | input: never wait if there are new events in the input queuewm42013-07-141-22/+20
| | | | | | | | | | | | | | | | | | | | | | | | Move the reading loop from read_all_fd_events to read_events. If got_new_events is set when calling read_events, don't actually wait and set the timeout to 0. (Note that not waiting is sort of transparent to the caller: the caller is just supposed to execute the event loop again, and then it will actually wait. mplayer.c handles this correctly.) This might reduce latency with some input sources.
* | input: invert negated boolean fieldwm42013-07-141-7/+6
| |
* | input: use only one array for input sourceswm42013-07-142-145/+128
| | | | | | | | | | | | | | Removes some code duplication. Also restructure the input waiting code a bit: split the select() loop into a input_wait_read() function. On systems which do not have POSIX select(), this function has an alternate implementation, which waits unconditionally.
* | w32: silence some warningsJames Ross-Gowan2013-07-131-0/+2
|/
* command: add screenshot_to_file commandwm42013-07-082-0/+7
|
* input: actually copy sub commandswm42013-07-081-0/+12
| | | | | | | | | This was missing from the previous commit. It worked by luck, because the sub-commands weren't freed either (as long as the original command was around), but this is proper. Also, set the original string for command lists (needed for input-test only).
* input: allow binding multiple commands to a keywm42013-07-082-5/+58
| | | | Separate the commands with ';'.
* core: cleanup more mp_fifo leftoverswm42013-07-021-1/+0
| | | | Now only the OSX and Wayland parts are using this.
* core: remove mp_fifo indirectionwm42013-07-022-3/+46
| | | | | | | | | | For some reason mp_fifo specifically handled double clicks, and other than that was a pointless wrapper around input.c functionality. Move the double click handling into input.c, and get rid of mp_fifo. Add some compatibility wrappers, because so much VO code uses these functions. Where struct mp_fifo is still used it's just a casted struct input_ctx.
* command: add some playlist manipulation commandswm42013-07-022-0/+4
| | | | playlist_remove and playlist_move.
* input: require VOs to send key up events, redo input key lookupwm42013-07-023-73/+78
| | | | | | | | | | | | | | Making key up events implicit was sort-of a nice idea, but it's too tricky and unreliable and makes the key lookup code (interpret_keys()) hard to reason about. See e.g. previous commit for subtle bugs and issues this caused. Make key-up events explicit instead. Add key up events to all VOs. Any time MP_KEY_STATE_DOWN is used, the matching key up event must use MP_KEY_STATE_UP. Rewrite the key lookup code. It should be simpler and more robust now. (Even though the LOC increases, because the new code is less "compact".)
* input: fix behavior if there are actually key up eventswm42013-07-021-1/+2
| | | | | | | | | Wayland is the only backend that actually sends per-key key up events (the X11 one just sends MP_INPUT_RELEASE_ALL for simplicity). Handling was broken with Wayland, and each key event was interpreted twice, once on key down and once on key up. This commit should fix it.
* input: don't ignore press-only mouse button eventswm42013-06-301-1/+2
| | | | | | | | Before this commit, only mouse events with both down and up events were processed. This caused a regression with ignoring mouse wheel events in cocoa, because these don't distinguish between up and down. Regression caused by 5b38a52.
* input: store number of binds, instead of using 0-terminationwm42013-06-291-60/+54
|
* input: store number of keys, instead of using 0-terminationwm42013-06-291-21/+24
|
* input: don't keep separate sections for builtin key bindingswm42013-06-291-62/+76
| | | | | | | | | | Instead mark individual key bindings as builtin. Not sure whether this is conceptually simpler or more complicated. For one, it requires the annoying remove_binds() function to wipe existing bindings instead of just killing the section, on the other hand it gets rid of almost all special handling of builtin vs. normal sections.
* mplayer: don't hide mouse cursor if mouse is inside mouse areawm42013-06-291-0/+4
|
* input: trigger mouse_leave key bindings if mouse leaves mouse areawm42013-06-293-12/+52
| | | | | | 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.
* command: add commands to enable/disable input sectionswm42013-06-292-0/+10
| | | | | For now, it's mostly for testing. It also might allow to create key binding state machines, but this sounds questionable.
* input: handle mouse movement differentlywm42013-06-293-97/+313
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.)
* stream: remove padding parameter from stream_read_complete()wm42013-06-231-1/+1
| | | | | | | | 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.
* command: replace some show_ commands with propertieswm42013-06-072-18/+15
| | | | | | | | | | | 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.
* keycodes: fix copy paste errorStefano Pigozzi2013-06-051-3/+3
| | | | Makes 213ad5d behave has intended.
* osx: improve Media Keys supportStefano Pigozzi2013-06-042-2/+21
| | | | | | | | | | | | | | | | | | | | | | | 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.
* fix build on linuxStefano Pigozzi2013-06-031-0/+2
| | | | missing ifdef in the previous commit made the build fail
* osx: add Apple Remote supportStefano Pigozzi2013-06-033-2/+47
| | | | | | | | | | | | | | | | | 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.
* osx: create macosx_events to deal with keyDown eventsStefano Pigozzi2013-06-031-0/+7
| | | | | | 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.
* Replace calls to usec_sleep()wm42013-05-261-1/+1
| | | | | | This is just dumb sed replacement to mp_sleep_us(). Also remove the now unused usec_sleep() wrapper.
* Replace all calls to GetTimer()/GetTimerMS()wm42013-05-262-10/+10
| | | | | | | | | | | | | | | | | | | | | | 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.
* core: do mouse cursor hiding business in frontendwm42013-05-262-7/+20
| | | | | Do this so that not every VO backend has to setup a timer for cursor hiding and interpret the --cursor-autohide option.
* input: allow quotes around any input commandwm42013-05-181-3/+1
|
* input: do property expansion for all input command string argumentswm42013-05-182-0/+7
| | | | | | 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.
* input: accept input command prefixes in any orderwm42013-05-181-20/+22
| | | | | | | | | | 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.
* core: allow changing filter filters at runtimewm42013-05-182-0/+5
| | | | | | | | | | | | | | | | 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().
* core: add playback resume feature (manual/opt-in)wm42013-05-052-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | 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.
* core: add backstep supportwm42013-04-242-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* input: don't reset time on each key repeatwm42013-04-241-2/+4
| | | | | | 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.
* input: adjust wait time for key-repeatwm42013-04-241-0/+4
| | | | | Basically, these are additional timers that can expire without making the central select() exit.
* input: don't let multi-key bindings block simple key bindingswm42013-04-241-4/+16
| | | | | | | | | | | | | 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.
* input: reduce amount of tracked keys per bindingwm42013-04-241-1/+1
| | | | | There's no need for key bindings that consist of 32 keys held down. It's ridiculous and wastes memory.
* input: fix handling of MP_KEY_STATE_DOWNwm42013-04-242-6/+16
| | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Remove some apple remote leftoverswm42013-04-052-25/+0
| | | | The options and key names don't do anything anymore.
* input: remove ar.h includeStefano Pigozzi2013-04-051-2/+0
| | | | This is a left over from c8fd9e50e47.
* remove Apple Remote related codeStefano Pigozzi2013-03-314-673/+0
| | | | | | | | | | | | | | | | 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/
* input: make input command deprecation warnings visiblewm42013-03-261-2/+2
| | | | | | | | | | | | | | | | 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".
* input: fix crash due to dangling pointerwm42013-03-191-1/+1
| | | | | Wrong API usage, has been in the code since 2011. Rarely triggered (if at all in the current setup).
* input/ar: remove unused variablewm42013-03-191-1/+0
|
*