Git Product home page Git Product logo

mpv-pointer-event's Introduction

pointer-event

Mouse/Touch input event detection for mpv

Low latency detection of single-click, double-click, long-click and dragging.
Each event is detected in a mutually exclusive manner, so e.g. a double-click won't also detect single-click events.

Dragging will emit a start and stop event, as well as a drag event that includes a change in coordinates which can be used for detecting gestures.

Beware that window dragging interferes with gesture detection unless you use --no-window-dragging. See ignore_left_single_long_while_window_dragging option for more information.

Installation

  1. Save pointer-event.lua to your scripts directory.
  2. Configure the events you want to listen to in your pointer-event.conf

Usage

Upon detecting an event the corresponding command from the pointer-event.conf in your script-opts directory (next to the scripts directory, create if it doesn't exist) gets executed.

The command configuration follows the <button>_<event_type>=command pattern.

The available buttons are

left
right
mid

Touch input is recognized as left. Each of those can listen to the following event types

single
double
long
drag_start
drag_end
drag

drag appends the change in pointer position dx dy to the command.

Additionally there are also

long_click_time
double_click_time
drag_distance
margin_left
margin_right
margin_top
margin_bottom
ignore_left_single_long_while_window_dragging

They all have sensible default values with double_click_time following input-doubleclick-time. Time is interpreted as milliseconds.
drag_distance determines how far the input has to be dragged to count as a drag instead of a click/touch. The margin_* options allow for easier interaction with the osd without triggering any events.

It can be desirable to have window dragging enabled and also want gesture detection. ignore_left_single_long_while_window_dragging exists to avoid triggering single and long click events while dragging the window. Those events will still work while in fullscreen or maximized mode.
Keep in mind that window dragging already starts on button down, even without moving the mouse/finger.

Beware of conflicts with mpvs built-in key bindings as well as your key configuration in input.conf.

Example

touch-gestures is an example of what can be done with this.

mpv-pointer-event's People

Contributors

christoph-heinrich avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

mpv-pointer-event's Issues

Not work on touchscreen

My environment is ubuntu22.04.1 with gnome on wayland. The mouse click events work fine, but the touchscreen doesn't work properly. I use the example, but when I single tap the screen, it calls the uosc menu, and I can't close the menu by any gestures. What's worse, the dragging events don't work at all on touch screen.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.