void touchesCancel(int size, int *id, int *x, int *y, float *pressure) { for (int i = 0; i < size; ++i) { ginput_TouchEvent *touchEvent = newTouchEvent(size); touchEvent->touch.x = x[i]; touchEvent->touch.y = y[i]; touchEvent->touch.pressure = pressure[i]; touchEvent->touch.touchType = 0; touchEvent->touch.id = id[i]; for (int j = 0; j < size; ++j) { touchEvent->allTouches[j].x = x[j]; touchEvent->allTouches[j].y = y[j]; touchEvent->allTouches[j].pressure = pressure[j]; touchEvent->allTouches[j].touchType = 0; touchEvent->allTouches[j].id = id[j]; } ginput_MouseEvent *mouseEvent = NULL; if (isTouchToMouseEnabled_ && touchEvent->touch.id == 0) mouseEvent = newMouseEvent(touchEvent->touch.x, touchEvent->touch.y, GINPUT_LEFT_BUTTON); if (mouseTouchOrder_ == 0) { if (mouseEvent) { gevent_EnqueueEvent(gid_, callback_s, GINPUT_MOUSE_UP_EVENT, mouseEvent, 0, this); deleteMouseEvent(mouseEvent); } gevent_EnqueueEvent(gid_, callback_s, GINPUT_TOUCH_CANCEL_EVENT, touchEvent, 0, this); deleteTouchEvent(touchEvent); } else { gevent_EnqueueEvent(gid_, callback_s, GINPUT_TOUCH_CANCEL_EVENT, touchEvent, 0, this); deleteTouchEvent(touchEvent); if (mouseEvent) { gevent_EnqueueEvent(gid_, callback_s, GINPUT_MOUSE_UP_EVENT, mouseEvent, 0, this); deleteMouseEvent(mouseEvent); } } } }
void touchBegin(int size, int *id, int *x, int *y, float *pressure, int actionIndex) { ginput_TouchEvent *touchEvent = newTouchEvent(size); touchEvent->touch.x = x[actionIndex]; touchEvent->touch.y = y[actionIndex]; touchEvent->touch.pressure = pressure[actionIndex]; touchEvent->touch.touchType = 0; touchEvent->touch.id = id[actionIndex]; for (int i = 0; i < size; ++i) { touchEvent->allTouches[i].x = x[i]; touchEvent->allTouches[i].y = y[i]; touchEvent->allTouches[i].pressure = pressure[i]; touchEvent->allTouches[i].touchType = 0; touchEvent->allTouches[i].id = id[i]; } ginput_MouseEvent *mouseEvent = NULL; if (isTouchToMouseEnabled_ && touchEvent->touch.id == 0) mouseEvent = newMouseEvent(touchEvent->touch.x, touchEvent->touch.y, GINPUT_LEFT_BUTTON); if (mouseTouchOrder_ == 0) { if (mouseEvent) { gevent_EnqueueEvent(gid_, callback_s, GINPUT_MOUSE_DOWN_EVENT, mouseEvent, 0, this); deleteMouseEvent(mouseEvent); } gevent_EnqueueEvent(gid_, callback_s, GINPUT_TOUCH_BEGIN_EVENT, touchEvent, 0, this); deleteTouchEvent(touchEvent); } else { gevent_EnqueueEvent(gid_, callback_s, GINPUT_TOUCH_BEGIN_EVENT, touchEvent, 0, this); deleteTouchEvent(touchEvent); if (mouseEvent) { gevent_EnqueueEvent(gid_, callback_s, GINPUT_MOUSE_DOWN_EVENT, mouseEvent, 0, this); deleteMouseEvent(mouseEvent); } } }
void mouseUp(int x, int y, int button) { ginput_MouseEvent *mouseEvent = newMouseEvent(x, y, button); ginput_TouchEvent *touchEvent = NULL; if (isMouseToTouchEnabled_) { touchEvent = newTouchEvent(1); touchEvent->touch.x = x; touchEvent->touch.y = y; touchEvent->touch.id = 0; touchEvent->allTouches[0].x = x; touchEvent->allTouches[0].y = y; touchEvent->allTouches[0].id = 0; } if (mouseTouchOrder_ == 0) { gevent_EnqueueEvent(gid_, callback_s, GINPUT_MOUSE_UP_EVENT, mouseEvent, 0, this); deleteMouseEvent(mouseEvent); if (touchEvent) { gevent_EnqueueEvent(gid_, callback_s, GINPUT_TOUCH_END_EVENT, touchEvent, 0, this); deleteTouchEvent(touchEvent); } } else { if (touchEvent) { gevent_EnqueueEvent(gid_, callback_s, GINPUT_TOUCH_END_EVENT, touchEvent, 0, this); deleteTouchEvent(touchEvent); } gevent_EnqueueEvent(gid_, callback_s, GINPUT_MOUSE_UP_EVENT, mouseEvent, 0, this); deleteMouseEvent(mouseEvent); } }