wasm: fix Pen input

This also adds the ability to distinguish between a Pen and a Touch.

Fixes: QTBUG-116989
Change-Id: Iffc5d20c9b46c1746a03c45dd12017d5dd5172a5
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
(cherry picked from commit 0367aace14b61e72433fa7cb7aab18b3def0030c)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit 82a32ac7ab78d449531f3d5681c1dc943e681d00)
This commit is contained in:
Lorn Potter 2023-11-21 14:04:20 +10:00 committed by Qt Cherry-pick Bot
parent 129ab89c5d
commit c2bcf9c2fb
3 changed files with 4 additions and 1 deletions

View File

@ -177,6 +177,8 @@ PointerEvent::PointerEvent(EventType type, emscripten::val event) : MouseEvent(t
return PointerType::Mouse;
if (type == "touch")
return PointerType::Touch;
if (type == "pen")
return PointerType::Pen;
return PointerType::Other;
})();
width = event["width"].as<qreal>();

View File

@ -35,6 +35,7 @@ enum class EventType {
enum class PointerType {
Mouse,
Touch,
Pen,
Other,
};

View File

@ -99,7 +99,7 @@ bool ClientArea::deliverEvent(const PointerEvent &event)
pointInTargetWindowCoords.y() / m_window->window()->height());
const auto tp = m_pointerIdToTouchPoints.find(event.pointerId);
if (tp != m_pointerIdToTouchPoints.end()) {
if (event.pointerType != PointerType::Pen && tp != m_pointerIdToTouchPoints.end()) {
touchPoint = &tp.value();
} else {
touchPoint = &m_pointerIdToTouchPoints