summaryrefslogtreecommitdiffstats
path: root/input/input.c
Commit message (Collapse)AuthorAgeFilesLines
* input: fix deadlock in adding gamepad input srcnanahi7 days1-4/+6
| | | | | | | mp_input_sdl_gamepad_add() calls mp_input_add_thread_src() which already locks, so it cannot be called inside a lock. Missed in e8b9476bf706401fa0e57fb117012124264483d2 refactoring.
* input: make mp_input_queue_cmd return a meaningful valuenanahi9 days1-6/+7
| | | | | It's currently always a meaningless 1. Make it so it returns 0 is cmd is NULL. Remove the unused return value from queue_cmd.
* input: don't use recursive mutexnanahi9 days1-1/+1
| | | | | | Previous commits made sure that the lock will never be called for more than once for all public functions. Thus deadlock is impossible, so recursive mutex is unneeded and can be converted to a normal mutex.
* input: avoid unnecessary recursive locksnanahi9 days1-65/+95
| | | | | | | | | | | | | | | | | | The absense of a call hierarchy between public and private functions results in many unnecessary recursive locks: public functions require locks, which are also called by other public and private functions in this file. Fortunately, since the lock is private to this file, this situation can be avoided by establishing a call hierarchy: - Public functions must lock, and can only call private functions in this file - Private functions must not lock, and can only call private functions in this file - No function can call any public function in this file, the only exception being mp_input_wakeup and mp_input_parse_cmd. This arrangement ensures that there will be no locks more than necessary: All public function calls will lock only once, and never recursively.
* input: remove mp prefix for static functionsnanahi9 days1-11/+11
| | | | | This makes it easy to eyeball check the call hierarchy between public and private functions.
* input: fix locking of mp_input_bind_keynanahi9 days1-0/+2
| | | | | | | This is a public function, yet its access to ictx through get_bind_section is not locked. Fixes: 4614d432a8d21ab135af25a183f57efd5059bb62
* mac/apphub: migrate remaining events functionality to new AppHubder richter2024-03-241-1/+1
| | | | | | | | add new app_bridge objc file for bridging between mpv core and app functionality. replace old EventsResponder singleton with AppHub. another step to clean up all App functionality and have one central place for it.
* input: remove max active section limitnanahi2024-03-211-15/+10
| | | | | | | | | | | 585d8c6856e8eaf77c518ad4679e8c66660fc440 increased max active section limit from 5 to 50 but this obviously doesn't properly fix the problem. Input still breaks if more than 25 scripts are loaded, or if some scripts define lots of input sections. Remove the limit completely by using a dynamic array for active sections. Fixes: https://github.com/mpv-player/mpv/issues/13707
* input: raise maximum key down limit to 16nanahi2024-03-211-1/+1
| | | | | The current limit of 4 is stupidly low, and won't be future proof in case proper multi-touch support is added.
* input: centralize VO draggingnanahi2024-03-011-6/+10
| | | | | | | | | | | | | | | | | | | | | | Currently, VO dragging logic is hardcoded into each VO, where a left mouse button down event unconditionally begins dragging if the VO dragging test passes. This method is extremely unflexible as the VO has no knowledge of what is happening in the input system: while begin dragging with the second click of a doubleclick is undesired, it cannot determine whether a click is a double click or not because it's determined by the input system. The better way to do it is to handle it somewhere in the downstream consumers of the events instead, as they have more information to make this decision. The input system is the perfect place for this as the logic for checking doubleclick already exists. So just issue a begin-vo-dragging command if it detects a left mouse button down which isn't also a doubleclick in this case, and delete all hardcoded VO dragging logic in win32, x11, and wayland. Note that this solution hardcodes left mouse button down for now, but because the VO dragging is now centralized, it's possible to make more improvements, such as a deadzone mechanism to fix the conflict with MBTN_LEFT mouse bind.
* osdep/mac: make mac naming of files, folders and function consistentder richter2024-02-281-1/+1
| | | | | rename all macOS namings (osx, macosx, macOS, macos, apple) to mac, to make naming consistent.
* input: add --input-preprocess-wheel optionnanahi2024-02-151-1/+4
| | | | | | | | | | | | | | | | | | | | | | | This adds --input-preprocess-wheel option, which can be used to control whether to preprocess received wheel events. Commit 937128697fbbef6b21e2d23a4785f1334f62b9e3 added preprocessing of wheel events to prevent the accidental scrolling of another direction when one direction is being scrolled for touchpads, which is problematic with the default wheel bindings where unrelated functions (seeking and volume) are used for the 2 directions. However, this behavior is undesirable in the following situations: - When custom wheel bindings are used so that the 2 directions are used for closely related actions, such as panning. With preprocessing, diagonal movement is impossible. - Since the wheel deadzone was introduced to prevent accidental scrolling for touchpads, this filtering provides no benefit for high resolution unidirectional mouse wheels, while causing a regression where scrolling at least 0.125 units is required to trigger the event, causing input delay. By adding this option, these two use cases are addressed.
* command: add load-input-confGuido Cella2024-02-041-0/+8
| | | | | | | | | | | | | | | | This can be used to auto reload the input configuration file, e.g. in vim: autocmd BufWritePost ~/.config/mpv/input.conf silent !echo load-input-conf %:p | socat - /tmp/mpvsocket Partially fixes #6362. Additionally this can be used as a replacement for deprecated input sections if they are ever actually removed. For example, if you want to define different bindings for images, you can load-input-conf an input.conf for images, and load the original again when switching to a video. Though currently you would have to redefine builtin bindings that were overwritten with image ones in the default input.conf.
* input: make parse_config_file return boolGuido Cella2024-02-041-3/+3
| | | | | This return value is only used to set bool config_ok in mp_input_load_config so it makes more sense to return bool.
* input: remove unused parameter from parse_config_fileGuido Cella2024-02-041-3/+3
| | | | This is unused since fb4d26e769.
* input: add value argument for mp_input_put_key_artificialsfan52023-12-171-2/+4
|
* input: fix double click handlingnanahi2023-12-031-0/+1
| | | | | | | | | | On practically all platforms and GUI toolkits, a triggered double click event clears the mouse input buffer so that the next click won't trigger another double click event. mpv doesn't do this, so a third click results in another double click event. Fix this by resetting the double click timer after a double click event is triggered which achieves the same effect.
* mp_thread: add win32 implementationKacper Michajłow2023-11-051-1/+0
|
* mp_thread: prefer tracking threads with idKacper Michajłow2023-11-051-1/+1
| | | | | | | | | | | | | | This change essentially removes mp_thread_self() and instead add mp_thread_id to track threads and have ability to query current thread id during runtime. This will be useful for upcoming win32 implementation, where accessing thread handle is different than on pthreads. Greatly reduces complexity. Otherweis locked map of tid <-> handle is required which is completely unnecessary for all mpv use-cases. Note that this is the mp_thread_id, not to confuse with system tid. For example on threads-posix implementation it is simply pthread_t.
* ALL: use new mp_thread abstractionKacper Michajłow2023-11-051-12/+12
|
* mp_threads: rename threads for consistent naming across all of themKacper Michajłow2023-10-271-1/+1
| | | | | | | | I'd like some names to be more descriptive, but to work with 15 chars limit we have to make some sacrifice. Also because of the limit, remove the `mpv/` prefix and prioritize actuall thread name.
* input: convert autorepeat timing to nanosecondsDudemanguy2023-10-161-7/+7
|
* win32/pthread: define _POSIX_TIMERS to notify they are not supportedKacper Michajłow2023-09-291-1/+1
|
* options: remove ancient option fallbacks/deprecationDudemanguy2023-09-211-4/+0
| | | | | | | | | | | | | We've got an ungodly amount of OPT_REPLACED and OPT_REMOVED sitting around in the code. This is harmless, but the vast majority of these are ancient. 26f4f18c0629998a9b91e94722d166866d8b80a3 is the last commit that touched the majority of these and of course that only changed how options were declared so all of this stuff was deprecated even before that. No use in keeping these, so just delete them all. As an aside, there was actually a cocoa_opts but it had only a single option which was replaced by something else and empty otherwise. So that entire thing was just simply removed. OPT_REPLACED/OPT_REMOVED declarations that were added in 0.35 or later were kept as is.
* build: remove outdated generated directoryDudemanguy2023-07-311-1/+1
| | | | | | | | | | | | | | | | This only existed as essentially a workaround for meson's behavior and to maintain compatibility with the waf build. Since waf put everything in a generated subdirectory, we had to put make a subdirectory called "generated" in the source for meson so stuff could go to the right place. Well now we don't need to do that anymore. Move the meson.build files around so they go in the appropriate place in the subdirectory of the source tree and change the paths of the headers accordingly. A couple of important things to note. 1. mpv.com now gets made in build/player/mpv.com (necessary because of a meson limitation) 2. The macos icon generation path is shortened to TOOLS/osxbundle/icon.icns.inc.
* options: transition commands from OPT_FLAG to OPT_BOOLChristoph Heinrich2023-02-211-0/+1
|
* options: transition options from OPT_FLAG to OPT_BOOLChristoph Heinrich2023-02-211-27/+25
| | | | | | c78482045444c488bb7948305d583a55d17cd236 introduced a bool option type as a replacement for the flag type, but didn't actually transition and remove the flag type because it would have been too much mundane work.
* input: remove unused struct memberChristoph Heinrich2023-02-211-1/+0
|
* various: replace abort() with MP_ASSERT_UNREACHABLE() where appropriatesfan52023-01-121-1/+1
| | | | | | | | In debug mode the macro causes an assertion failure. In release mode it works differently and tells the compiler that it can assume the codepath will never execute. For this reason I was conversative in replacing it, e.g. in mpv-internal code that exhausts all valid values of an enum or when a condition is clear from directly preceding code.
* input: new option: --no-input-builtin-bindingsAvi Halachmi (:avih)2021-10-111-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is similar to [no-]input-default-bindings, but affects only builtin bindings (while input-default-bindings affects anything which config files can override, like scripting mp.add_key_binding). Arguably, this is what input-default-binding should have always done, however, it does not. The reason we add a new option rather than repurpose/modify the existing option is that it behaves differently enough to raise concerns that it will break some use cases for existing users: - The new option is only applied once on startup, while input-default-bindings can be modified effectively at runtime. - They affects different sets of bindings, and it's possible that the set of input-default-bindings is useful enough to keep. Implementation-wise, both options are trivial, so keeping one or the other or both doesn't affect code complexity. It could be argued that it would be useful to make the new option also effective for runtime changes, however, this opens a can of worms of how the bindings are stored beyond the initial setup. TL;DR: it's impossible to differentiate correctly at runtime between builtin bindings, and those added with mp.add_key_bindings. The gist is that technically mpv needs/uses two binding "classes": - weak/builtin bindings - lower priority than config files. - "user" bindings - config files and "forced" runtime bindings. input-default-bindings affects the first class trivially, but input-builtin-bindings would not be able split this class further at runtime without meaningful changes to a lot of delicate code. So a new option it is. It should be useful to some libmpv clients (players) which want to disable mpv's builtin bindings without breaking mp.add_key_bindings for scripts. Fixes #8809 (again. the previous fix 8edfe70b only improved the docs, while now we're actually making the requested behavior possible)
* command: mouse-pos property: add field "hover"Avi Halachmi (:avih)2020-11-161-2/+9
| | | | | | | | | | | | | | | | | | | | | Add a third field: "hover", which is updated from input.c after input keys MP_KEY_MOUSE_LEAVE and MP_KEY_MOUSE_ENTER - which are typically sent by the VO. It's part of mouse-pos and not a new property because it's highly tied to mouse-pos - it makes x/y invalid while the cursor doesn't hover the window. Unike mouse-move, no dummy command was generated, so we add dummy command in order for observer notification to work even while nothing is bound. Like mouse-pos, clients could not detect whether the mouse pointer hovers the window because the OSC force-binds the MOUSE_LEAVE key, and now they can using the hover field. The lua mp.get_mouse_pos() wrapper still returns only x, y because that's what osc.lua needs. Other clients can simply read the property.
* build: change filenames of generated fileswm42020-06-041-1/+1
| | | | Force them into a more consistent naming schema.
* input: remove deprecated --input-file optionwm42020-03-281-8/+0
| | | | | This was deprecated 2 releases ago. The deprecation changelog entry says that there are no plans to remove it short-term, but I guess I lied.
* options: change option macros and all option declarationswm42020-03-181-17/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Change all OPT_* macros such that they don't define the entire m_option initializer, and instead expand only to a part of it, which sets certain fields. This requires changing almost every option declaration, because they all use these macros. A declaration now always starts with {"name", ... followed by designated initializers only (possibly wrapped in macros). The OPT_* macros now initialize the .offset and .type fields only, sometimes also .priv and others. I think this change makes the option macros less tricky. The old code had to stuff everything into macro arguments (and attempted to allow setting arbitrary fields by letting the user pass designated initializers in the vararg parts). Some of this was made messy due to C99 and C11 not allowing 0-sized varargs with ',' removal. It's also possible that this change is pointless, other than cosmetic preferences. Not too happy about some things. For example, the OPT_CHOICE() indentation I applied looks a bit ugly. Much of this change was done with regex search&replace, but some places required manual editing. In particular, code in "obscure" areas (which I didn't include in compilation) might be broken now. In wayland_common.c the author of some option declarations confused the flags parameter with the default value (though the default value was also properly set below). I fixed this with this change.
* stream, demux: redo origin policy thingwm42019-12-201-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | mpv has a very weak and very annoying policy that determines whether a playlist should be used or not. For example, if you play a remote playlist, you usually don't want it to be able to read local filesystem entries. (Although for a media player the impact is small I guess.) It's weak and annoying as in that it does not prevent certain cases which could be interpreted as bad in some cases, such as allowing playlists on the local filesystem to reference remote URLs. It probably barely makes sense, but we just want to exclude some other "definitely not a good idea" things, all while playlists generally just work, so whatever. The policy is: - from the command line anything is played - local playlists can reference anything except "unsafe" streams ("unsafe" means special stream inputs like libavfilter graphs) - remote playlists can reference only remote URLs - things like "memory://" and archives are "transparent" to this This commit does... something. It replaces the weird stream flags with a slightly clearer "origin" value, which is now consequently passed down and used everywhere. It fixes some deviations from the described policy. I wanted to force archives to reference only content within them, but this would probably have been more complicated (or required different abstractions), and I'm too lazy to figure it out, so archives are now "transparent" (playlists within archives behave the same outside). There may be a lot of bugs in this. This is unfortunately a very noisy commit because: - every stream open call now needs to pass the origin - so does every demuxer open call (=> params param. gets mandatory) - most stream were changed to provide the "origin" value - the origin value needed to be passed along in a lot of places - I was too lazy to split the commit Fixes: #7274
* mac: remove Apple Remote supportder richter2019-12-151-15/+3
| | | | | | the Apple Remote has long been deprecated and abandoned by Apple. current macs don't come with support for it anymore. support might be re-added with the next commit.
* input: use array instead of linked list for sectionswm42019-11-231-26/+26
| | | | Shouldn't change behavior.
* input: remove potential minor memory leakwm42019-11-231-0/+1
|
* input: export input.conf comments ot input-bindings propertywm42019-11-231-4/+15
| | | | | | | | | | | | | | This is supposed to turn input.conf comments into inline documentation. Whether this will be useful depends on whether there'll be a script using this field. This changes a small aspect of input.conf parsing fundamentally: this attempts to strip comments/whitespace from the command string, which will later be used to generate the command when a key binding is executed. This should not have any negative effects, but there could be unknown bugs. (For some reason, every command is parsed when input.conf is parsed, but it still only stores the string for the command. I guess that saves some minor amount of memory.)
* command, input: add input-bindings propertywm42019-11-231-0/+48
| | | | | | Read-only information about all bindings. Somewhat hoping someone can make a nice GUI-like overlay thing for it, which provides information about mapped keys.
* input: change mp_cmd.original from bstr to cstrwm42019-11-231-2/+2
| | | | | | | | No reason to have this as bstr, just makes everything more complex. Also clear mp_cmd.sender when it's copied. Otherwise it would be a dangling pointer. Apparently it's never set to non-NULL in this situation, but this is cleaner anyway.
* input: add text produced by key to script key eventswm42019-11-221-0/+5
| | | | | | | Particularly for "any_unicode" mappings, so they don't have to special-case keys like '#' and ' ', which are normally mapped to symbolic names for input.conf reasons. (Though admittedly, this is a pretty minor thing, since API users could map these manually.)
* input: introduce a pseudo key name that grabs all text inputwm42019-11-221-1/+6
| | | | | | | | | The intended target for this is the mpv.repl script, which manually added every single ASCII key as a separate key binding. This provides a simpler mechanism, that will catch any kind of text input. Due to its special nature, explicitly do not give a guarantee for compatibility; thus the warning in input.rst.
* input: fix ineffective mp_msg_test callwm42019-11-221-1/+1
| | | | | | This was supposed not to go through key lookup if the message wasn't going to be output, but for whatever reason the log levels were mismatched.
* options: remove M_OPT_FIXEDwm42019-11-101-1/+1
| | | | | | | | | | | | | | | | | | | | | | | Options marked with this flag were changed to strictly read-only after initialization (mpv_initialize() in the client API, after option parsing and config file loading with the CLI player). This used to be necessary, because there was a single option struct that could be accessed by multiple threads. For example, --config-dir sets MPOpts.force_configdir, which was read whenever anything accessed the mpv config dir (which could be on different threads, e.g. font initialization tries to lookup fonts.conf from an arbitrary thread). This isn't needed anymore, because threads now access these in a thread safe way. In the case of --config-dir, the path is actually just copied on init. This M_OPT_FIXED mechanism is thus not strictly needed anymore. It still prevents writing to some options that cannot take effect at runtime, but even that can be dropped. In general, all mpv options can be changed any time at runtime, even if they never take effect, and there's no need to make an exception for a very low number of options. So just get rid of it.
* Replace uses of FFMIN/MAX with MPMIN/MAXwm42019-10-311-6/+3
| | | | And remove libavutil includes where possible.
* input: disable gamepad code by defaultwm42019-10-251-3/+0
| | | | | | | Enabling this by default probably causes a number of issues, such as breaking vo_sdl, or reacting to various input devices while the window is not focused. It's also pretty obscure, or at least new. Disable it by default.
* input: add gamepad support through SDL2Stefano Pigozzi2019-10-231-0/+13
| | | | | | | | | | | | | | | The code is very basic: - only handles gamepads, could be extended for generic joysticks in the future. - only has button mappings for controllers natively supported by SDL2. I heard more can be added through env vars, there's also ways to load mappings from text files, but I'd rather not go there yet. Common ones like Dualshock are supported natively. - analog buttons (TRIGGER and AXIS) are mapped to discrete buttons using an activation threshold. - only supports one gamepad at a time. the feature is intented to use gamepads as evolved remote controls, not play multiplayer games in mpv :)
* input: add keybind commandDudemanguy9112019-09-211-0/+38
|
* player: get rid of mpv_global.optswm42018-05-241-2/+5
| | | | | | | | This was always a legacy thing. Remove it by applying an orgy of mp_get_config_group() calls, and sometimes m_config_cache_alloc() or mp_read_option_raw(). win32 changes untested.
* input: remove now unused "abort command" and cancel infrastructurewm42018-05-241-31/+2
| | | | The previous commit removed all uses.
* input: rename weirdly named functionwm42018-05-031-2/+2
|
* input: rename cmd_parse.h to cmd.hwm42018-05-031-2/+0
|
* input: remove some explicit uses of command IDswm42018-05-031-1/+1
| | |