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

[feat] Make touch work on the H2O2 #3715

Merged
merged 3 commits into from Mar 4, 2018
Merged
Changes from 2 commits
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.
+38 −5
Diff settings

Always

Just for now

Copy path View file
36 frontend/device/input.lua 100644 → 100755
@@ -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 switch_slot_to = function (value)

This comment has been minimized.

Copy link
@Frenzie

Frenzie Mar 4, 2018

Member

functions camelCase please

How about this?

local setCurSlot = function(value)

This comment has been minimized.

Copy link
@poire-z

poire-z Mar 4, 2018

Contributor

(I haven't looked much about the whole MTSlots code, just saying this after a quick look:)
why not make it a method of the Input object ? (so lua doesn't have to build a new function each time a touch event is processed)

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
switch_slot_to(ev.value)
elseif ev.code == ABS_MT_TRACKING_ID then
if self.snow_protocol then
switch_slot_to(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",
@@ -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)
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.