From 1ac35cb865b57d90f91e030d466449ab8e0cd4a9 Mon Sep 17 00:00:00 2001 From: NiLuJe Date: Mon, 5 Sep 2022 22:44:06 +0200 Subject: [PATCH] Input: Minor simplification for the Mk. 3 input quirk (#9481) I was afraid that ABS_PRESSURE could be sent out of order, but that appears to never be the case, so we can simplify the code a bit :}. --- frontend/device/input.lua | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/frontend/device/input.lua b/frontend/device/input.lua index f7923653b..bc63f2c65 100644 --- a/frontend/device/input.lua +++ b/frontend/device/input.lua @@ -839,6 +839,19 @@ function Input:handleTouchEvLegacy(ev) self:setCurrentMtSlotChecked("id", 1) else self:setCurrentMtSlotChecked("id", -1) + + -- 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 + -- NOTE: We can afford to do this here instead of on SYN_REPORT because the kernel *always* + -- reports ABS_PRESSURE after ABS_X/ABS_Y. + if self.touch_kobo_mk3_protocol then + 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 end elseif ev.type == C.EV_SYN then @@ -847,20 +860,6 @@ 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()