Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Distinguish between touch and non-touch pointer events #1608

Closed
wants to merge 3 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions ffi/SDL2_0.lua
Original file line number Diff line number Diff line change
Expand Up @@ -219,11 +219,12 @@ end
-- Keep track of active pointers so we can feed ABS_MT_SLOT 0 and 1 to the frontend for multitouch to work.
-- down, a boolean denoting whether the pointer is currently down for tracking mouse button status.
hrdl-github marked this conversation as resolved.
Show resolved Hide resolved
local pointers = {}
local function setPointerDownState(slot, down)
local function setPointerDownState(slot, down, is_finger)
if not pointers[slot] then
pointers[slot] = { down = down }
pointers[slot] = { down = down , is_finger = is_finger }
else
pointers[slot].down = down
pointers[slot].is_finger = is_finger
end
end

Expand Down Expand Up @@ -375,11 +376,11 @@ function S.waitForEvent(sec, usec)
slot = getFingerSlot(event)
genTouchMoveEvent(event, slot, event.tfinger.x * S.w, event.tfinger.y * S.h)
else
if pointers[0] and pointers[0].down then
if pointers[0] and pointers[0].down and not pointers[0].is_finger then
slot = 0 -- left mouse button down
genTouchMoveEvent(event, slot, event.motion.x, event.motion.y)
end
if pointers[1] and pointers[1].down then
if pointers[1] and pointers[1].down and not pointers[1].is_finger then
slot = 1 -- right mouse button down
genTouchMoveEvent(event, slot, event.motion.x, event.motion.y)
end
Expand Down Expand Up @@ -423,7 +424,7 @@ function S.waitForEvent(sec, usec)
end
local x = is_finger and event.tfinger.x * S.w or event.button.x
local y = is_finger and event.tfinger.y * S.h or event.button.y
setPointerDownState(slot, true)
setPointerDownState(slot, true, is_finger)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh right, in the specific sway bug scenario this one will only trigger once. But in that case this would need a lot of comments to explain what it's doing since this won't solve the generic scenario that a naive reader would expect to be solved.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, more comments would be good; because that MOUSEMOTION event in the middle of the sandwich is hella weird ;o).

(I wouldn't mind a link to koreader/koreader#10417 (comment) in said comment, as this clearly showcases the issue).

genTouchDownEvent(event, slot, x, y)
elseif event.type == SDL.SDL_MULTIGESTURE then
genEmuEvent(C.EV_SDL, SDL.SDL_MULTIGESTURE, event.mgesture)
Expand Down