add inactive touch zones around buttons on Kindle Voyage

This should fix #1801.
pull/2121/head
chrox 8 years ago
parent 30a9f73bb2
commit dee65a7999

@ -159,10 +159,22 @@ function Input:registerEventAdjustHook(hook, hook_params)
end
end
function Input:registerGestureAdjustHook(hook, hook_params)
local old = self.gestureAdjustHook
self.gestureAdjustHook = function(this, ges)
old(this, ges)
hook(this, ges, hook_params)
end
end
function Input:eventAdjustHook(ev)
-- do nothing by default
end
function Input:gestureAdjustHook(ges)
-- do nothing by default
end
-- catalogue of predefined hooks:
function Input:adjustTouchSwitchXY(ev)
if ev.type == EV_ABS then
@ -363,6 +375,7 @@ function Input:handleTouchEv(ev)
self.MTSlots = {}
if touch_ges then
--DEBUG("ges", touch_ges)
self:gestureAdjustHook(touch_ges)
return Event:new("Gesture",
self.gesture_detector:adjustGesCoordinate(touch_ges)
)
@ -427,6 +440,7 @@ function Input:handleTouchEvPhoenix(ev)
local touch_ges = self.gesture_detector:feedEvent(self.MTSlots)
self.MTSlots = {}
if touch_ges then
self:gestureAdjustHook(touch_ges)
return Event:new("Gesture",
self.gesture_detector:adjustGesCoordinate(touch_ges)
)
@ -495,6 +509,7 @@ function Input:waitEvent(timeout_us)
-- Do we really need to clear all setTimeout after
-- decided a gesture? FIXME
self.timer_callbacks = {}
self:gestureAdjustHook(touch_ges)
return Event:new("Gesture",
self.gesture_detector:adjustGesCoordinate(touch_ges)
)

@ -234,6 +234,35 @@ function KindleVoyage:init()
[109] = "LPgFwd",
},
}
-- touch gestures fall into these cold spots defined by (x, y, r)
-- will be rewritten to 'none' ges thus being ignored
-- x, y is the absolute position disregard of screen mode, r is spot radius
self.cold_spots = {
{
x = 1080 + 50, y = 485, r = 80
},
{
x = 1080 + 70, y = 910, r = 120
},
{
x = -50, y = 485, r = 80
},
{
x = -70, y = 910, r = 120
},
}
self.input:registerGestureAdjustHook(function(_, ges)
if ges then
local pos = ges.pos
for _, spot in ipairs(self.cold_spots) do
if (spot.x - pos.x) * (spot.x - pos.x) +
(spot.y - pos.y) * (spot.y - pos.y) < spot.r * spot.r then
ges.ges = "none"
end
end
end
end)
Kindle.init(self)

Loading…
Cancel
Save