Display and control your Android device
Make some mouse processors ops optional
Romain Vimont57f1655d4bb1
diff --git a/app/src/input_manager.c b/app/src/input_manager.cindex aa0708c0..dfd78484 100644--- a/app/src/input_manager.c+++ b/app/src/input_manager.c@@ -657,6 +657,7 @@ input_manager_process_mouse_motion(struct input_manager *im,im->forward_all_clicks),};+ assert(im->mp->ops->process_mouse_motion);im->mp->ops->process_mouse_motion(im->mp, &evt);if (im->vfinger_down) {@@ -671,6 +672,11 @@ input_manager_process_mouse_motion(struct input_manager *im,static voidinput_manager_process_touch(struct input_manager *im,const SDL_TouchFingerEvent *event) {+ if (!im->mp->ops->process_touch) {+ // The mouse processor does not support touch events+ return;+ }+int dw;int dh;SDL_GL_GetDrawableSize(im->screen->window, &dw, &dh);@@ -764,6 +770,7 @@ input_manager_process_mouse_button(struct input_manager *im,im->forward_all_clicks),};+ assert(im->mp->ops->process_mouse_click);im->mp->ops->process_mouse_click(im->mp, &evt);// Pinch-to-zoom simulation.@@ -795,6 +802,11 @@ input_manager_process_mouse_button(struct input_manager *im,static voidinput_manager_process_mouse_wheel(struct input_manager *im,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 windowint mouse_x;int mouse_y;diff --git a/app/src/trait/mouse_processor.h b/app/src/trait/mouse_processor.hindex b08d15bb..0252d2c6 100644--- a/app/src/trait/mouse_processor.h+++ b/app/src/trait/mouse_processor.h@@ -19,18 +19,38 @@ struct sc_mouse_processor {};struct sc_mouse_processor_ops {+ /**+ * Process a mouse motion event+ *+ * This function is mandatory.+ */void(*process_mouse_motion)(struct sc_mouse_processor *mp,const struct sc_mouse_motion_event *event);+ /**+ * Process a mouse click event+ *+ * This function is mandatory.+ */void(*process_mouse_click)(struct sc_mouse_processor *mp,const struct sc_mouse_click_event *event);+ /**+ * Process a mouse scroll event+ *+ * This function is optional.+ */void(*process_mouse_scroll)(struct sc_mouse_processor *mp,const struct sc_mouse_scroll_event *event);+ /**+ * Process a touch event+ *+ * This function is optional.+ */void(*process_touch)(struct sc_mouse_processor *mp,const struct sc_touch_event *event);