diff --git a/frontend/device/input.lua b/frontend/device/input.lua old mode 100644 new mode 100755 index 5b99e7dd7..088f0e885 --- a/frontend/device/input.lua +++ b/frontend/device/input.lua @@ -376,16 +376,22 @@ end. Upon receiving an MT event, one simply updates the appropriate attribute of the current slot. --]] function Input:handleTouchEv(ev) + local function switchSlotTo(value) + if self.cur_slot ~= value then + table.insert(self.MTSlots, self:getMtSlot(value)) + end + self.cur_slot = value + end if ev.type == EV_ABS then if #self.MTSlots == 0 then table.insert(self.MTSlots, self:getMtSlot(self.cur_slot)) end if ev.code == ABS_MT_SLOT then - if self.cur_slot ~= ev.value then - table.insert(self.MTSlots, self:getMtSlot(ev.value)) - end - self.cur_slot = ev.value + switchSlotTo(ev.value) elseif ev.code == ABS_MT_TRACKING_ID then + if self.snow_protocol then + switchSlotTo(ev.value) + end self:setCurrentMtSlot("id", ev.value) elseif ev.code == ABS_MT_POSITION_X then self:setCurrentMtSlot("x", ev.value) @@ -411,10 +417,32 @@ function Input:handleTouchEv(ev) 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, set "used" + self:setMtSlot(MTSlot.slot, "used", true) + 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 not slot.used 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 clear used + for _, slot in pairs(self.ev_slots) do + slot.used = nil + end + end if touch_ges then self:gestureAdjustHook(touch_ges) return Event:new("Gesture", diff --git a/frontend/device/kobo/device.lua b/frontend/device/kobo/device.lua index ead7e3a38..9072f9291 100644 --- a/frontend/device/kobo/device.lua +++ b/frontend/device/kobo/device.lua @@ -104,7 +104,8 @@ local KoboPhoenix = Kobo:new{ 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: @@ -302,6 +303,10 @@ function Kobo:initEventAdjustHooks() 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)