DPF

DISTRHO Plugin Framework
Log | Files | Refs | Submodules | README | LICENSE

commit ab6a4920434c22b1b45922b3cbab61fa6c5ab555
parent 8121781749aba5cc3de0b5633ecef31840d7f33d
Author: falkTX <falktx@falktx.com>
Date:   Wed, 29 Mar 2023 00:00:45 +0200

Use old style of mouse position for non-modgui wasm builds

Signed-off-by: falkTX <falktx@falktx.com>

Diffstat:
Mdgl/src/pugl-extra/wasm.c | 20++++++++++++++------
1 file changed, 14 insertions(+), 6 deletions(-)

diff --git a/dgl/src/pugl-extra/wasm.c b/dgl/src/pugl-extra/wasm.c @@ -281,13 +281,21 @@ puglMouseCallback(const int eventType, const EmscriptenMouseEvent* const mouseEv if (emscripten_get_pointerlock_status(&e) == EMSCRIPTEN_RESULT_SUCCESS) view->impl->pointerLocked = e.isActive; +#ifdef __MOD_DEVICES__ + const long canvasX = mouseEvent->canvasX; + const long canvasY = mouseEvent->canvasY; +#else + const long canvasX = mouseEvent->clientX; + const long canvasY = mouseEvent->clientY; +#endif + switch (eventType) { case EMSCRIPTEN_EVENT_MOUSEDOWN: case EMSCRIPTEN_EVENT_MOUSEUP: event.button.type = eventType == EMSCRIPTEN_EVENT_MOUSEDOWN ? PUGL_BUTTON_PRESS : PUGL_BUTTON_RELEASE; event.button.time = time; - event.button.x = mouseEvent->canvasX * scaleFactor; - event.button.y = mouseEvent->canvasY * scaleFactor; + event.button.x = canvasX * scaleFactor; + event.button.y = canvasY * scaleFactor; event.button.xRoot = mouseEvent->screenX * scaleFactor; event.button.yRoot = mouseEvent->screenY * scaleFactor; event.button.state = state; @@ -321,8 +329,8 @@ puglMouseCallback(const int eventType, const EmscriptenMouseEvent* const mouseEv event.motion.yRoot = view->impl->lastMotion.yRoot; } else { // cache values for possible pointer lock movement later - view->impl->lastMotion.x = event.motion.x = mouseEvent->canvasX * scaleFactor; - view->impl->lastMotion.y = event.motion.y = mouseEvent->canvasY * scaleFactor; + view->impl->lastMotion.x = event.motion.x = canvasX * scaleFactor; + view->impl->lastMotion.y = event.motion.y = canvasY * scaleFactor; view->impl->lastMotion.xRoot = event.motion.xRoot = mouseEvent->screenX * scaleFactor; view->impl->lastMotion.yRoot = event.motion.yRoot = mouseEvent->screenY * scaleFactor; } @@ -332,8 +340,8 @@ puglMouseCallback(const int eventType, const EmscriptenMouseEvent* const mouseEv case EMSCRIPTEN_EVENT_MOUSELEAVE: event.crossing.type = eventType == EMSCRIPTEN_EVENT_MOUSEENTER ? PUGL_POINTER_IN : PUGL_POINTER_OUT; event.crossing.time = time; - event.crossing.x = mouseEvent->canvasX * scaleFactor; - event.crossing.y = mouseEvent->canvasY * scaleFactor; + event.crossing.x = canvasX * scaleFactor; + event.crossing.y = canvasY * scaleFactor; event.crossing.xRoot = mouseEvent->screenX * scaleFactor; event.crossing.yRoot = mouseEvent->screenY * scaleFactor; event.crossing.state = state;