-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add multi-touch support #14003
add multi-touch support #14003
Conversation
The goal of multitouch support is to interpret as little as possible: mpv just stores the touch point information and makes the position available for query. Does not participate in the deprecated input section system. The API is modeled after the common part of the touch input APIs of Win32, X11, and Wayland, to make sure the platform-specific implementations are as simple as possible.
Download the artifacts for this pull request: |
得益于 verygoodlee/mpv-menu-plugin@e59bf0f 提出的方法,现在可以切换到 mpv 的内部实现了 归档 C 插件
1d04647
to
932c7ae
Compare
{ | ||
// queue dummy cmd so that touch-pos can notify observers | ||
mp_cmd_t *cmd = mp_input_parse_cmd(ictx, bstr0("ignore"), "<internal>"); | ||
queue_cmd(ictx, cmd); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this seems to be necessary because mouse-pos
is married to MP_EVENT_INPUT_PROCESSED
which is triggered in mp_process_input
. could be improved some day..
7164ea8
to
baaf07a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have a device to test this so a code review is the best I can do
This adds touch-pos property, which contains the information of all current touch points. The property has sub properties: touch-pos/count: the number of current touch points touch-pos/N/x,y: the position of touch point N touch-pos/N/id: unique identifier of the touch point
This adds --input-touch-emulate-mouse option, which controls whether to enable legacy touch handling where touch inputs are emulated as mouse inputs. This establishes a primary touch point (the one with the lowest index) as the emulated mouse position, and MBTN_LEFT up/down with the appearance of the first touch point and the disappearance of the last touch point. This fixes some problems with touch handling on Wayland, for example attempting to pinch results in a double click.
Release all touch points. Used by some VOs like Wayland touch cancel event.
786d1d5
to
a5e55a1
Compare
Use the multitouch API. No need to emulate mouse input as it's already done by the input system.
For platforms which send emulated mouse inputs for touch-unaware clients, such as Win32 and X11, this option enables the native multitouch handling and disables emulated mouse inputs. This enables interested scripts to handle multitouch events while keeping compatibility with touch-unaware scripts.
Use the multitouch API. To disable system's defualt mouse emulation, set --native-touch=yes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. There will likely be quirks with touch support, but we can work them out.
Currently, mpv's input system has no real touch handling. Touch messages are either not requested, or very awkwardly translated to emulated mouse, which results in some bugs on Wayland and severely limits mpv's gesture recognition ability.
This adds multi-touch support to mpv, in the form of added
touch-pos
property, and implements the support for Win32 and Wayland. The property contains the positions of all current touch points, each corresponds to a finger on the touch surface. Scripts can implement custom gesture recognition algorithms to process these values and determine the appropriate action to perform.For compatibility,
--input-touch-emulate-mouse
and--native-touch
options are added to control whether touch events need to be emulated as mouse events.The following example script demonstrates the recognition of 2-finger vertical scroll gesture to control the video brightness: