mirror of
https://github.com/Genymobile/scrcpy.git
synced 2025-08-02 22:29:25 +00:00
Make some mouse processors ops optional
Do not force all mouse processors implementations to implement scroll events or touch events.
This commit is contained in:
parent
05474b0cd6
commit
a0d1c23d8d
2 changed files with 32 additions and 0 deletions
|
@ -659,6 +659,7 @@ input_manager_process_mouse_motion(struct input_manager *im,
|
||||||
im->forward_all_clicks),
|
im->forward_all_clicks),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
assert(im->mp->ops->process_mouse_motion);
|
||||||
im->mp->ops->process_mouse_motion(im->mp, &evt);
|
im->mp->ops->process_mouse_motion(im->mp, &evt);
|
||||||
|
|
||||||
if (im->vfinger_down) {
|
if (im->vfinger_down) {
|
||||||
|
@ -673,6 +674,11 @@ input_manager_process_mouse_motion(struct input_manager *im,
|
||||||
static void
|
static void
|
||||||
input_manager_process_touch(struct input_manager *im,
|
input_manager_process_touch(struct input_manager *im,
|
||||||
const SDL_TouchFingerEvent *event) {
|
const SDL_TouchFingerEvent *event) {
|
||||||
|
if (!im->mp->ops->process_touch) {
|
||||||
|
// The mouse processor does not support touch events
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
int dw;
|
int dw;
|
||||||
int dh;
|
int dh;
|
||||||
SDL_GL_GetDrawableSize(im->screen->window, &dw, &dh);
|
SDL_GL_GetDrawableSize(im->screen->window, &dw, &dh);
|
||||||
|
@ -766,6 +772,7 @@ input_manager_process_mouse_button(struct input_manager *im,
|
||||||
im->forward_all_clicks),
|
im->forward_all_clicks),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
assert(im->mp->ops->process_mouse_click);
|
||||||
im->mp->ops->process_mouse_click(im->mp, &evt);
|
im->mp->ops->process_mouse_click(im->mp, &evt);
|
||||||
|
|
||||||
// Pinch-to-zoom simulation.
|
// Pinch-to-zoom simulation.
|
||||||
|
@ -797,6 +804,11 @@ input_manager_process_mouse_button(struct input_manager *im,
|
||||||
static void
|
static void
|
||||||
input_manager_process_mouse_wheel(struct input_manager *im,
|
input_manager_process_mouse_wheel(struct input_manager *im,
|
||||||
const SDL_MouseWheelEvent *event) {
|
const SDL_MouseWheelEvent *event) {
|
||||||
|
if (!im->mp->ops->process_mouse_scroll) {
|
||||||
|
// The mouse processor does not support scroll events
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// mouse_x and mouse_y are expressed in pixels relative to the window
|
// mouse_x and mouse_y are expressed in pixels relative to the window
|
||||||
int mouse_x;
|
int mouse_x;
|
||||||
int mouse_y;
|
int mouse_y;
|
||||||
|
|
|
@ -19,18 +19,38 @@ struct sc_mouse_processor {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct sc_mouse_processor_ops {
|
struct sc_mouse_processor_ops {
|
||||||
|
/**
|
||||||
|
* Process a mouse motion event
|
||||||
|
*
|
||||||
|
* This function is mandatory.
|
||||||
|
*/
|
||||||
void
|
void
|
||||||
(*process_mouse_motion)(struct sc_mouse_processor *mp,
|
(*process_mouse_motion)(struct sc_mouse_processor *mp,
|
||||||
const struct sc_mouse_motion_event *event);
|
const struct sc_mouse_motion_event *event);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Process a mouse click event
|
||||||
|
*
|
||||||
|
* This function is mandatory.
|
||||||
|
*/
|
||||||
void
|
void
|
||||||
(*process_mouse_click)(struct sc_mouse_processor *mp,
|
(*process_mouse_click)(struct sc_mouse_processor *mp,
|
||||||
const struct sc_mouse_click_event *event);
|
const struct sc_mouse_click_event *event);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Process a mouse scroll event
|
||||||
|
*
|
||||||
|
* This function is optional.
|
||||||
|
*/
|
||||||
void
|
void
|
||||||
(*process_mouse_scroll)(struct sc_mouse_processor *mp,
|
(*process_mouse_scroll)(struct sc_mouse_processor *mp,
|
||||||
const struct sc_mouse_scroll_event *event);
|
const struct sc_mouse_scroll_event *event);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Process a touch event
|
||||||
|
*
|
||||||
|
* This function is optional.
|
||||||
|
*/
|
||||||
void
|
void
|
||||||
(*process_touch)(struct sc_mouse_processor *mp,
|
(*process_touch)(struct sc_mouse_processor *mp,
|
||||||
const struct sc_touch_event *event);
|
const struct sc_touch_event *event);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue