| 1174 | |
| 1175 | #if defined(__EMSCRIPTEN__) |
| 1176 | void RenderViewImpl::onWebTouchCallback(int eventType, const EmscriptenTouchEvent* touchEvent) |
| 1177 | { |
| 1178 | float boundingX = EM_ASM_INT(return canvas.getBoundingClientRect().left); |
| 1179 | float boundingY = EM_ASM_INT(return canvas.getBoundingClientRect().top); |
| 1180 | int canvasWidth, canvasHeight; |
| 1181 | emscripten_get_canvas_element_size("#canvas", &canvasWidth, &canvasHeight); |
| 1182 | double cssWidth, cssHeight; |
| 1183 | emscripten_get_element_css_size("#canvas", &cssWidth, &cssHeight); |
| 1184 | const auto zoomX = canvasWidth / cssWidth; |
| 1185 | const auto zommY = canvasHeight / cssHeight; |
| 1186 | |
| 1187 | int numTouches = touchEvent->numTouches; |
| 1188 | _touchesId.resize(numTouches); |
| 1189 | _touchesX.resize(numTouches); |
| 1190 | _touchesY.resize(numTouches); |
| 1191 | for (int i = 0; i < numTouches; i++) |
| 1192 | { |
| 1193 | _touchesId[i] = (touchEvent->touches[i].identifier); |
| 1194 | // convert coords screen(origin:left-top) to canvas |
| 1195 | _touchesX[i] = ((touchEvent->touches[i].targetX - boundingX) * zoomX); |
| 1196 | _touchesY[i] = ((touchEvent->touches[i].targetY - boundingY) * zommY); |
| 1197 | } |
| 1198 | if (numTouches) |
| 1199 | { |
| 1200 | switch (eventType) |
| 1201 | { |
| 1202 | case EMSCRIPTEN_EVENT_TOUCHSTART: |
| 1203 | _captured = true; |
| 1204 | handleTouchesBegin(numTouches, _touchesId.data(), _touchesX.data(), _touchesY.data()); |
| 1205 | break; |
| 1206 | case EMSCRIPTEN_EVENT_TOUCHEND: |
| 1207 | handleTouchesEnd(numTouches, _touchesId.data(), _touchesX.data(), _touchesY.data()); |
| 1208 | _captured = false; |
| 1209 | break; |
| 1210 | case EMSCRIPTEN_EVENT_TOUCHMOVE: |
| 1211 | if (_captured) |
| 1212 | handleTouchesMove(numTouches, _touchesId.data(), _touchesX.data(), _touchesY.data()); |
| 1213 | break; |
| 1214 | case EMSCRIPTEN_EVENT_TOUCHCANCEL: |
| 1215 | handleTouchesCancel(numTouches, _touchesId.data(), _touchesX.data(), _touchesY.data()); |
| 1216 | _captured = false; |
| 1217 | break; |
| 1218 | } |
| 1219 | } |
| 1220 | } |
| 1221 | |
| 1222 | void RenderViewImpl::onWebClickCallback() |
| 1223 | { |
no test coverage detected