static void HandleTouchEvent(MirMotionEvent const motion, int cord_index, SDL_Window* sdl_window) { int device_id = motion.device_id; int id = motion.pointer_coordinates[cord_index].id; int width = sdl_window->w; int height = sdl_window->h; float x = motion.pointer_coordinates[cord_index].x; float y = motion.pointer_coordinates[cord_index].y; float n_x = x / width; float n_y = y / height; float pressure = motion.pointer_coordinates[cord_index].pressure; AddTouchDevice(motion.device_id); switch (motion.action) { case mir_motion_action_down: case mir_motion_action_pointer_down: HandleTouchPress(device_id, id, SDL_TRUE, n_x, n_y, pressure); break; case mir_motion_action_up: case mir_motion_action_pointer_up: HandleTouchPress(device_id, id, SDL_FALSE, n_x, n_y, pressure); break; case mir_motion_action_hover_move: case mir_motion_action_move: HandleTouchMotion(device_id, id, n_x, n_y, pressure); break; default: break; } }
static void HandleTouchEvent(MirTouchEvent const* touch, int device_id, SDL_Window* sdl_window) { int i, point_count; point_count = MIR_mir_touch_event_point_count(touch); AddTouchDevice(device_id); for (i = 0; i < point_count; i++) { int id = MIR_mir_touch_event_id(touch, i); int width = sdl_window->w; int height = sdl_window->h; float x = MIR_mir_touch_event_axis_value(touch, i, mir_touch_axis_x); float y = MIR_mir_touch_event_axis_value(touch, i, mir_touch_axis_y); float n_x = x / width; float n_y = y / height; float pressure = MIR_mir_touch_event_axis_value(touch, i, mir_touch_axis_pressure); switch (MIR_mir_touch_event_action(touch, i)) { case mir_touch_action_up: HandleTouchPress(device_id, id, SDL_FALSE, n_x, n_y, pressure); break; case mir_touch_action_down: HandleTouchPress(device_id, id, SDL_TRUE, n_x, n_y, pressure); break; case mir_touch_action_change: HandleTouchMotion(device_id, id, n_x, n_y, pressure); break; case mir_touch_actions: break; } } }