mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
The Wacom pen reports sane CLOCK_REALTIME timestamps, but the Touchscreen reports timestamps frozen at the boot time ts (in REALTIME) :s. So, make everyone use synthetic CLOCK_MONOTONIC timestamps in order to make gesture detection behave.
This commit is contained in:
@@ -1,5 +1,9 @@
|
||||
local Generic = require("device/generic/device") -- <= look at this file!
|
||||
local TimeVal = require("ui/timeval")
|
||||
local logger = require("logger")
|
||||
local ffi = require("ffi")
|
||||
local C = ffi.C
|
||||
require("ffi/linux_input_h")
|
||||
|
||||
local function yes() return true end
|
||||
local function no() return false end
|
||||
@@ -15,11 +19,6 @@ local function getModel()
|
||||
return model == "reMarkable 2.0", model
|
||||
end
|
||||
|
||||
local EV_ABS = 3
|
||||
local ABS_X = 00
|
||||
local ABS_Y = 01
|
||||
local ABS_MT_POSITION_X = 53
|
||||
local ABS_MT_POSITION_Y = 54
|
||||
-- Resolutions from libremarkable src/framebuffer/common.rs
|
||||
local screen_width = 1404 -- unscaled_size_check: ignore
|
||||
local screen_height = 1872 -- unscaled_size_check: ignore
|
||||
@@ -56,13 +55,13 @@ local Remarkable1 = Remarkable:new{
|
||||
}
|
||||
|
||||
function Remarkable1:adjustTouchEvent(ev, by)
|
||||
if ev.type == EV_ABS then
|
||||
if ev.type == C.EV_ABS then
|
||||
-- Mirror X and Y and scale up both X & Y as touch input is different res from
|
||||
-- display
|
||||
if ev.code == ABS_MT_POSITION_X then
|
||||
if ev.code == C.ABS_MT_POSITION_X then
|
||||
ev.value = (Remarkable1.mt_width - ev.value) * by.mt_scale_x
|
||||
end
|
||||
if ev.code == ABS_MT_POSITION_Y then
|
||||
if ev.code == C.ABS_MT_POSITION_Y then
|
||||
ev.value = (Remarkable1.mt_height - ev.value) * by.mt_scale_y
|
||||
end
|
||||
end
|
||||
@@ -79,25 +78,32 @@ local Remarkable2 = Remarkable:new{
|
||||
}
|
||||
|
||||
function Remarkable2:adjustTouchEvent(ev, by)
|
||||
if ev.type == EV_ABS then
|
||||
if ev.type == C.EV_ABS then
|
||||
-- Mirror Y and scale up both X & Y as touch input is different res from
|
||||
-- display
|
||||
if ev.code == ABS_MT_POSITION_X then
|
||||
if ev.code == C.ABS_MT_POSITION_X then
|
||||
ev.value = (ev.value) * by.mt_scale_x
|
||||
end
|
||||
if ev.code == ABS_MT_POSITION_Y then
|
||||
if ev.code == C.ABS_MT_POSITION_Y then
|
||||
ev.value = (Remarkable2.mt_height - ev.value) * by.mt_scale_y
|
||||
end
|
||||
end
|
||||
|
||||
-- Wacom uses CLOCK_REALTIME, but the Touchscreen spits out frozen timestamps.
|
||||
-- Inject CLOCK_MONOTONIC timestamps at the end of every input frame in order to have consistent gesture detection across input devices.
|
||||
-- c.f., #7536
|
||||
if ev.type == C.EV_SYN and ev.code == C.SYN_REPORT then
|
||||
ev.time = TimeVal:now()
|
||||
end
|
||||
end
|
||||
|
||||
local adjustAbsEvt = function(self, ev)
|
||||
if ev.type == EV_ABS then
|
||||
if ev.code == ABS_X then
|
||||
ev.code = ABS_Y
|
||||
if ev.type == C.EV_ABS then
|
||||
if ev.code == C.ABS_X then
|
||||
ev.code = C.ABS_Y
|
||||
ev.value = (wacom_height - ev.value) * wacom_scale_y
|
||||
elseif ev.code == ABS_Y then
|
||||
ev.code = ABS_X
|
||||
elseif ev.code == C.ABS_Y then
|
||||
ev.code = C.ABS_X
|
||||
ev.value = ev.value * wacom_scale_x
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user