Kobo: Unbreak touch input on fresh setups on Trilogy (#9473)

By making sure we setup the right evdev parser first ;).
reviewable/pr9474/r1
NiLuJe 2 years ago committed by GitHub
parent 8e1bb9bafc
commit 49e5200c8a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -9,7 +9,6 @@ globals = {
read_globals = { read_globals = {
"_ENV", "_ENV",
"KOBO_TOUCH_MIRRORED",
"KOBO_SYNC_BRIGHTNESS_WITH_NICKEL", "KOBO_SYNC_BRIGHTNESS_WITH_NICKEL",
"DHINTCOUNT", "DHINTCOUNT",
"DRENDER_MODE", "DRENDER_MODE",

@ -2,6 +2,7 @@ local Generic = require("device/generic/device")
local Geom = require("ui/geometry") local Geom = require("ui/geometry")
local WakeupMgr = require("device/wakeupmgr") local WakeupMgr = require("device/wakeupmgr")
local ffiUtil = require("ffi/util") local ffiUtil = require("ffi/util")
local lfs = require("libs/libkoreader-lfs")
local logger = require("logger") local logger = require("logger")
local util = require("util") local util = require("util")
local _ = require("gettext") local _ = require("gettext")
@ -642,24 +643,24 @@ function Kobo:init()
-- NOTE: usb hotplug event is also available in /tmp/nickel-hardware-status (... but only when Nickel is running ;p) -- NOTE: usb hotplug event is also available in /tmp/nickel-hardware-status (... but only when Nickel is running ;p)
self.input.open("fake_events") self.input.open("fake_events")
-- Input handling on Kobo is a thing of nightmares, start by setting up the actual evdev handler...
self:setTouchEventHandler()
-- And then handle the extra shenanigans if necessary.
if not self.needsTouchScreenProbe() then if not self.needsTouchScreenProbe() then
self:initEventAdjustHooks() self:initEventAdjustHooks()
else else
-- if touch probe is required, we postpone EventAdjustHook -- If touch probe is required, we postpone EventAdjustHook to *after* it has run,
-- initialization to when self:touchScreenProbe is called -- because some of it depends on its results...
self.touchScreenProbe = function() self.touchScreenProbe = function()
-- if user has not set KOBO_TOUCH_MIRRORED yet -- Only run the probe once ;).
if KOBO_TOUCH_MIRRORED == nil then if G_reader_settings:hasNot("kobo_touch_switch_xy") then
-- and has no probe before local TouchProbe = require("tools/kobo_touch_probe")
if G_reader_settings:hasNot("kobo_touch_switch_xy") then local UIManager = require("ui/uimanager")
local TouchProbe = require("tools/kobo_touch_probe") UIManager:show(TouchProbe:new{})
local UIManager = require("ui/uimanager") UIManager:run()
UIManager:show(TouchProbe:new{}) -- If all goes well, we should now have a kobo_touch_switch_xy setting.
UIManager:run()
-- assuming TouchProbe sets kobo_touch_switch_xy config
end
self.touch_switch_xy = G_reader_settings:readSetting("kobo_touch_switch_xy")
end end
self.touch_switch_xy = G_reader_settings:readSetting("kobo_touch_switch_xy")
self:initEventAdjustHooks() self:initEventAdjustHooks()
end end
end end
@ -770,25 +771,7 @@ end
function Kobo:supportsScreensaver() return true end function Kobo:supportsScreensaver() return true end
function Kobo:initEventAdjustHooks() function Kobo:setTouchEventHandler()
-- it's called KOBO_TOUCH_MIRRORED in defaults.lua, but what it
-- actually did in its original implementation was to switch X/Y.
-- NOTE: for kobo touch, adjustTouchSwitchXY needs to be called before
-- adjustTouchMirrorX
if (self.touch_switch_xy and not KOBO_TOUCH_MIRRORED)
or (not self.touch_switch_xy and KOBO_TOUCH_MIRRORED)
then
self.input:registerEventAdjustHook(self.input.adjustTouchSwitchXY)
end
if self.touch_mirrored_x then
self.input:registerEventAdjustHook(
self.input.adjustTouchMirrorX,
--- @fixme what if we change the screen portrait mode?
self.screen:getWidth()
)
end
if self.touch_snow_protocol then if self.touch_snow_protocol then
self.input.snow_protocol = true self.input.snow_protocol = true
elseif self.touch_phoenix_protocol then elseif self.touch_phoenix_protocol then
@ -797,7 +780,7 @@ function Kobo:initEventAdjustHooks()
self.input.handleTouchEv = self.input.handleTouchEvLegacy self.input.handleTouchEv = self.input.handleTouchEvLegacy
end end
-- Accelerometer on the Forma -- Accelerometer
if self.misc_ntx_gsensor_protocol then if self.misc_ntx_gsensor_protocol then
if G_reader_settings:isTrue("input_ignore_gsensor") then if G_reader_settings:isTrue("input_ignore_gsensor") then
self.input.isNTXAccelHooked = false self.input.isNTXAccelHooked = false
@ -808,14 +791,31 @@ function Kobo:initEventAdjustHooks()
end end
end end
function Kobo:initEventAdjustHooks()
-- NOTE: On trilogy, adjustTouchSwitchXY needs to be called before adjustTouchMirrorX
if self.touch_switch_xy then
self.input:registerEventAdjustHook(self.input.adjustTouchSwitchXY)
end
if self.touch_mirrored_x then
self.input:registerEventAdjustHook(
self.input.adjustTouchMirrorX,
--- NOTE: This is safe, we enforce the canonical portrait rotation on startup.
self.screen:getWidth()
)
end
end
local function getCodeName() local function getCodeName()
-- Try to get it from the env first -- Try to get it from the env first
local codename = os.getenv("PRODUCT") local codename = os.getenv("PRODUCT")
-- If that fails, run the script ourselves -- If that fails, run the script ourselves
if not codename then if not codename then
local std_out = io.popen("/bin/kobo_config.sh 2>/dev/null", "re") local std_out = io.popen("/bin/kobo_config.sh 2>/dev/null", "re")
codename = std_out:read("*line") if std_out then
std_out:close() codename = std_out:read("*line")
std_out:close()
end
end end
return codename return codename
end end
@ -824,6 +824,7 @@ function Kobo:getFirmwareVersion()
local version_file = io.open("/mnt/onboard/.kobo/version", "re") local version_file = io.open("/mnt/onboard/.kobo/version", "re")
if not version_file then if not version_file then
self.firmware_rev = "none" self.firmware_rev = "none"
return
end end
local version_str = version_file:read("*line") local version_str = version_file:read("*line")
version_file:close() version_file:close()

Loading…
Cancel
Save