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
Unified · Split
| @@ -0,0 +1 @@ | |||
| 1 | add `touch-pos` property | ||
| @@ -2800,7 +2800,7 @@ Property list · 2799 unmodified lines | |||
| 2800 | not being opened yet or not being supported by the VO. | 2800 | not being opened yet or not being supported by the VO. |
| 2801 | 2801 | ||
| 2802 | ``mouse-pos`` | 2802 | ``mouse-pos`` |
| 2803 | Read-only - last known mouse position, normalizd to OSD dimensions. | 2803 | Read-only - last known mouse position, normalized to OSD dimensions. |
| 2804 | 2804 | ||
| 2805 | Has the following sub-properties (which can be read as ``MPV_FORMAT_NODE`` | 2805 | Has the following sub-properties (which can be read as ``MPV_FORMAT_NODE`` |
| 2806 | or Lua table with ``mp.get_property_native``): | 2806 | or Lua table with ``mp.get_property_native``): |
| @@ -2813,6 +2813,35 @@ Property list · 6 unmodified lines | |||
| 2813 | coordinates should be ignored when this value is false, because the | 2813 | coordinates should be ignored when this value is false, because the |
| 2814 | video backends update them only when the pointer hovers the window. | 2814 | video backends update them only when the pointer hovers the window. |
| 2815 | 2815 | ||
| 2816 | ``touch-pos`` | ||
| 2817 | Read-only - last known touch point positions, normalized to OSD dimensions. | ||
| 2818 | |||
| 2819 | This has a number of sub-properties. Replace ``N`` with the 0-based touch | ||
| 2820 | point index. Whenever a new finger touches the screen, a new touch point is | ||
| 2821 | added to the list of touch points with the smallest unused ``N`` available. | ||
| 2822 | |||
| 2823 | ``touch-pos/count`` | ||
| 2824 | Number of active touch points. | ||
| 2825 | |||
| 2826 | ``touch-pos/N/x``, ``touch-pos/N/y`` | ||
| 2827 | Position of the Nth touch point. | ||
| 2828 | |||
| 2829 | ``touch-pos/N/id`` | ||
| 2830 | Unique identifier of the touch point. This can be used to identify | ||
| 2831 | individual touch points when their indexes change. | ||
| 2832 | |||
| 2833 | When querying the property with the client API using ``MPV_FORMAT_NODE``, | ||
| 2834 | or with Lua ``mp.get_property_native``, this will return a mpv_node with | ||
| 2835 | the following contents: | ||
| 2836 | |||
| 2837 | :: | ||
| 2838 | |||
| 2839 | MPV_FORMAT_NODE_ARRAY | ||
| 2840 | MPV_FORMAT_NODE_MAP (for each touch point) | ||
| 2841 | "x" MPV_FORMAT_INT64 | ||
| 2842 | "y" MPV_FORMAT_INT64 | ||
| 2843 | "id" MPV_FORMAT_INT64 | ||
| 2844 | |||
| 2816 | ``sub-ass-extradata`` | 2845 | ``sub-ass-extradata`` |
| 2817 | The current ASS subtitle track's extradata. There is no formatting done. | 2846 | The current ASS subtitle track's extradata. There is no formatting done. |
| 2818 | The extradata is returned as a string as-is. This property is not | 2847 | The extradata is returned as a string as-is. This property is not |
| @@ -2897,6 +2897,32 @@ static int mp_property_mouse_pos(void *ctx, struct m_property *prop, · 2896 unmodified lines | |||
| 2897 | return M_PROPERTY_NOT_IMPLEMENTED; | 2897 | return M_PROPERTY_NOT_IMPLEMENTED; |
| 2898 | } | 2898 | } |
| 2899 | 2899 | ||
| 2900 | static int get_touch_pos(int item, int action, void *arg, void *ctx) | ||
| 2901 | { | ||
| 2902 | const int **pos = (const int **)ctx; | ||
| 2903 | struct m_sub_property props[] = { | ||
| 2904 | {"x", SUB_PROP_INT(pos[0][item])}, | ||
| 2905 | {"y", SUB_PROP_INT(pos[1][item])}, | ||
| 2906 | {"id", SUB_PROP_INT(pos[2][item])}, | ||
| 2907 | {0} | ||
| 2908 | }; | ||
| 2909 | |||
| 2910 | int r = m_property_read_sub(props, action, arg); | ||
| 2911 | return r; | ||
| 2912 | } | ||
| 2913 | |||
| 2914 | #define MAX_TOUCH_POINTS 10 | ||
| 2915 | static int mp_property_touch_pos(void *ctx, struct m_property *prop, | ||
| 2916 | int action, void *arg) | ||
| 2917 | { | ||
| 2918 | MPContext *mpctx = ctx; | ||
| 2919 | int xs[MAX_TOUCH_POINTS], ys[MAX_TOUCH_POINTS], ids[MAX_TOUCH_POINTS]; | ||
| 2920 | int count = mp_input_get_touch_pos(mpctx->input, MAX_TOUCH_POINTS, xs, ys, ids); | ||
| 2921 | const int *pos[3] = {xs, ys, ids}; | ||
| 2922 | return m_property_read_list(action, arg, MPMIN(MAX_TOUCH_POINTS, count), | ||
| 2923 | get_touch_pos, (void *)pos); | ||
| 2924 | } | ||
| 2925 | |||
| 2900 | /// Video fps (RO) | 2926 | /// Video fps (RO) |
| 2901 | static int mp_property_fps(void *ctx, struct m_property *prop, | 2927 | static int mp_property_fps(void *ctx, struct m_property *prop, |
| 2902 | int action, void *arg) | 2928 | int action, void *arg) |
| @@ -4045,6 +4071,7 @@ static const struct m_property mp_properties_base[] = { · 1142 unmodified lines | |||
| 4045 | {"osd-ass-cc", mp_property_osd_ass}, | 4071 | {"osd-ass-cc", mp_property_osd_ass}, |
| 4046 | 4072 | ||
| 4047 | {"mouse-pos", mp_property_mouse_pos}, | 4073 | {"mouse-pos", mp_property_mouse_pos}, |
| 4074 | {"touch-pos", mp_property_touch_pos}, | ||
| 4048 | 4075 | ||
| 4049 | // Subs | 4076 | // Subs |
| 4050 | {"sid", property_switch_track, .priv = (void *)(const int[]){0, STREAM_SUB}}, | 4077 | {"sid", property_switch_track, .priv = (void *)(const int[]){0, STREAM_SUB}}, |
| @@ -4182,7 +4209,7 @@ static const char *const *const mp_event_property_change[] = { · 131 unmodified lines | |||
| 4182 | E(MP_EVENT_CHANGE_PLAYLIST, "playlist", "playlist-pos", "playlist-pos-1", | 4209 | E(MP_EVENT_CHANGE_PLAYLIST, "playlist", "playlist-pos", "playlist-pos-1", |
| 4183 | "playlist-count", "playlist/count", "playlist-current-pos", | 4210 | "playlist-count", "playlist/count", "playlist-current-pos", |
| 4184 | "playlist-playing-pos"), | 4211 | "playlist-playing-pos"), |
| 4185 | E(MP_EVENT_INPUT_PROCESSED, "mouse-pos"), | 4212 | E(MP_EVENT_INPUT_PROCESSED, "mouse-pos", "touch-pos"), |
| 4186 | E(MP_EVENT_CORE_IDLE, "core-idle", "eof-reached"), | 4213 | E(MP_EVENT_CORE_IDLE, "core-idle", "eof-reached"), |
| 4187 | }; | 4214 | }; |
| 4188 | #undef E | 4215 | #undef E |