mirror of
https://github.com/koreader/koreader.git
synced 2025-12-24 12:14:05 +01:00
Kobo: Fix input on Mk. 3 (i.e., Kobo Touch A/B). (#9474)
* Kobo: Discriminate between the Touch A/B and the Touch C properly, and implement actual support for the A/B input quirks. This means the clunky touchscreen probe widget shown on fresh installs on those devices is now gone :}. * Input: Fix an off-by-one in most adjustTouchMirrorX/Y callers (only rM was doing it right), and adjust their documentation to avoid similar mistakes in the future. * GestureDetector: Unify logging to always display transformed coordinates for simple gestures. * GestureDetector: Fix two-contact hold lifts to be computed at the midpoint between the two contacts, like their holds counterpart already did.
This commit is contained in:
@@ -341,17 +341,17 @@ function Input:adjustTouchScale(ev, by)
|
||||
end
|
||||
end
|
||||
|
||||
function Input:adjustTouchMirrorX(ev, width)
|
||||
function Input:adjustTouchMirrorX(ev, max_x)
|
||||
if ev.type == C.EV_ABS
|
||||
and (ev.code == C.ABS_X or ev.code == C.ABS_MT_POSITION_X) then
|
||||
ev.value = width - ev.value
|
||||
ev.value = max_x - ev.value
|
||||
end
|
||||
end
|
||||
|
||||
function Input:adjustTouchMirrorY(ev, height)
|
||||
function Input:adjustTouchMirrorY(ev, max_y)
|
||||
if ev.type == C.EV_ABS
|
||||
and (ev.code == C.ABS_Y or ev.code == C.ABS_MT_POSITION_Y) then
|
||||
ev.value = height - ev.value
|
||||
ev.value = max_y - ev.value
|
||||
end
|
||||
end
|
||||
|
||||
@@ -847,6 +847,20 @@ function Input:handleTouchEvLegacy(ev)
|
||||
self:setMtSlot(MTSlot.slot, "timev", time.timeval(ev.time))
|
||||
end
|
||||
|
||||
-- On Kobo Mk. 3 devices, the frame that reports a contact lift *actually* does the coordinates transform for us...
|
||||
-- Unfortunately, our own transforms are not stateful, so, just revert 'em here,
|
||||
-- since we can't simply avoid not doing 'em for that frame...
|
||||
-- c.f., https://github.com/koreader/koreader/issues/2128#issuecomment-1236289909 for logs on a Touch B
|
||||
if self.touch_kobo_mk3_protocol then
|
||||
if self:getCurrentMtSlotData("id") == -1 then
|
||||
-- Technically, it's the frame where ABS_PRESSURE is set to 0 ;).
|
||||
local y = 599 - self:getCurrentMtSlotData("x") -- Mk. 3 devices are all 600x800, so just hard-code it here.
|
||||
local x = self:getCurrentMtSlotData("y")
|
||||
self:setCurrentMtSlot("x", x)
|
||||
self:setCurrentMtSlot("y", y)
|
||||
end
|
||||
end
|
||||
|
||||
-- feed ev in all slots to state machine
|
||||
local touch_gestures = self.gesture_detector:feedEvent(self.MTSlots)
|
||||
self:newFrame()
|
||||
|
||||
Reference in New Issue
Block a user