View Single Post
Old 03-01-2018, 03:34 PM   #63
cola
Junior Member
cola shares his or her toyscola shares his or her toyscola shares his or her toyscola shares his or her toyscola shares his or her toyscola shares his or her toyscola shares his or her toyscola shares his or her toyscola shares his or her toyscola shares his or her toyscola shares his or her toys
 
Posts: 5
Karma: 5814
Join Date: Feb 2018
Device: Kobo Aura H2O2
Yes, I agree. I thought I still needed to have touchAlyssumProtocol because it sets ev.time = TimeVal:now(), but now that I look at it again I think it's redundant.

I think this patch is basically how I want it to be, but I haven't run it! So there's probably some dumb syntax error in there or some other problem.

Spoiler:
Code:
diff -U 3 -r koreader/frontend/device/input.lua koreader2/frontend/device/input.lua
--- koreader/frontend/device/input.lua	2018-02-12 02:36:04.000000000 -0500
+++ koreader2/frontend/device/input.lua	2018-03-01 15:21:21.631488838 -0500
@@ -411,10 +411,32 @@
         if ev.code == SYN_REPORT then
             for _, MTSlot in pairs(self.MTSlots) do
                 self:setMtSlot(MTSlot.slot, "timev", TimeVal:new(ev.time))
+                if self.snow_protocol then
+                    -- if a slot appears in the current touch event, clear "unused"
+                    self:setMtSlot(MTSlot.slot, "unused", nil) 
+                end
+            end
+            if self.snow_protocol then
+                -- reset every slot that doesn't appear in the current touch event
+                -- (because on the H2O2, this is the only way we detect finger-up)
+                self.MTSlots = {}
+                for _, slot in pairs(self.ev_slots) do
+                    table.insert(self.MTSlots, slot)
+                    if slot.unused then
+                        slot.id = -1
+                        slot.timev = TimeVal:new(ev.time)
+                    end
+                end
             end
             -- feed ev in all slots to state machine
             local touch_ges = self.gesture_detector:feedEvent(self.MTSlots)
             self.MTSlots = {}
+            if self.snow_protocol then
+                -- go through all the ev_slots and set them to unused
+                for _, slot in pairs(self.ev_slots) do
+                    slot.unused = true
+                end
+            end
             if touch_ges then
                 self:gestureAdjustHook(touch_ges)
                 return Event:new("Gesture",
diff -U 3 -r koreader/frontend/device/kobo/device.lua koreader2/frontend/device/kobo/device.lua
--- koreader/frontend/device/kobo/device.lua	2018-02-12 02:36:04.000000000 -0500
+++ koreader2/frontend/device/kobo/device.lua	2018-03-01 15:21:34.948594206 -0500
@@ -104,7 +104,8 @@
 local KoboSnow = Kobo:new{
     model = "Kobo_snow",
     hasFrontlight = yes,
-    touch_alyssum_protocol = true,
+    touch_snow_protocol = true,
+    touch_mirrored_x = false,
     touch_probe_ev_epoch_time = true,
     display_dpi = 265,
     -- the bezel covers the top 11 pixels:
@@ -296,6 +297,10 @@
         self.input:registerEventAdjustHook(adjustTouchAlyssum)
     end
 
+    if self.touch_snow_protocol then
+        self.input.snow_protocol = true
+    end
+
     if self.touch_probe_ev_epoch_time then
         self.input:registerEventAdjustHook(function(_, ev)
             probeEvEpochTime(_, ev)
cola is offline   Reply With Quote