Kobo: Fix the input translation on the Elipsa 2E (#10802)

Apparently it mirrors on the Y axis. Or the panel vs. touch rotations are wonkier than expected or ...something.
reviewable/pr10803/r1
NiLuJe 10 months ago committed by GitHub
parent 0499b5109a
commit 0db7509fe2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -392,6 +392,20 @@ function Input:adjustABS_SwitchAxesAndMirrorX(ev, max_x)
end
end
function Input:adjustABS_SwitchAxesAndMirrorY(ev, max_y)
if ev.code == C.ABS_X then
ev.code = C.ABS_Y
ev.value = max_y - ev.value
elseif ev.code == C.ABS_Y then
ev.code = C.ABS_X
elseif ev.code == C.ABS_MT_POSITION_X then
ev.code = C.ABS_MT_POSITION_Y
ev.value = max_y - ev.value
elseif ev.code == C.ABS_MT_POSITION_Y then
ev.code = C.ABS_MT_POSITION_X
end
end
function Input:adjustABS_Translate(ev, by)
if ev.code == C.ABS_X or ev.code == C.ABS_MT_POSITION_X then
ev.value = by.x + ev.value

@ -108,6 +108,8 @@ local Kobo = Generic:extend{
touch_switch_xy = true,
-- most Kobos have also mirrored X coordinates
touch_mirrored_x = true,
-- but a few mirror on the Y axis instead
touch_mirrored_y = false,
-- enforce portrait mode on Kobos
--- @note: In practice, the check that is used for in ffi/framebuffer is no longer relevant,
--- since, in almost every case, we enforce a hardware Portrait rotation via fbdepth on startup by default ;).
@ -516,6 +518,7 @@ local KoboCondor = Kobo:extend{
display_dpi = 227,
pressure_event = C.ABS_MT_PRESSURE,
touch_mirrored_x = false,
touch_mirrored_y = true,
hasNaturalLight = yes,
frontlight_settings = {
frontlight_white = "/sys/class/backlight/mxc_msp430.0/brightness",
@ -975,7 +978,7 @@ end
function Kobo:initEventAdjustHooks()
-- Build a single composite hook, to avoid duplicated branches...
local koboInputMangling
-- NOTE: touch_switch_xy is *always* true, but not touch_mirrored_x...
-- NOTE: touch_switch_xy is *always* true, but not touch_mirrored_x or touch_mirrored_y...
if self.touch_switch_xy and self.touch_mirrored_x then
local max_x = self.screen:getWidth() - 1
koboInputMangling = function(this, ev)
@ -985,7 +988,16 @@ function Kobo:initEventAdjustHooks()
gyroTranslation(ev)
end
end
elseif self.touch_switch_xy and not self.touch_mirrored_x then
elseif self.touch_switch_xy and self.touch_mirrored_y then
local max_y = self.screen:getHeight() - 1
koboInputMangling = function(this, ev)
if ev.type == C.EV_ABS then
this:adjustABS_SwitchAxesAndMirrorY(ev, max_y)
elseif ev.type == C.EV_MSC and ev.code == C.MSC_RAW then
gyroTranslation(ev)
end
end
elseif self.touch_switch_xy and not self.touch_mirrored_x and not self.touch_mirrored_y then
koboInputMangling = function(this, ev)
if ev.type == C.EV_ABS then
this:adjustABS_SwitchXY(ev)

Loading…
Cancel
Save