fix(input): use elseif conditional logic in adjustTouchSwitchXY

pull/1080/head
Qingping Hou 10 years ago
parent 6eca26f610
commit 8927f901da

@ -155,10 +155,15 @@ end
-- catalogue of predefined hooks:
function Input:adjustTouchSwitchXY(ev)
if ev.type == EV_ABS then
if ev.code == ABS_X then ev.code = ABS_Y end
if ev.code == ABS_Y then ev.code = ABS_X end
if ev.code == ABS_MT_POSITION_X then ev.code = ABS_MT_POSITION_Y end
if ev.code == ABS_MT_POSITION_Y then ev.code = ABS_MT_POSITION_X end
if ev.code == ABS_X then
ev.code = ABS_Y
elseif ev.code == ABS_Y then
ev.code = ABS_X
elseif ev.code == ABS_MT_POSITION_X then
ev.code = ABS_MT_POSITION_Y
elseif ev.code == ABS_MT_POSITION_Y then
ev.code = ABS_MT_POSITION_X
end
end
end
function Input:adjustTouchScale(ev, by)
@ -172,17 +177,15 @@ function Input:adjustTouchScale(ev, by)
end
end
function Input:adjustTouchMirrorX(ev, width)
if ev.type == EV_ABS then
if ev.code == ABS_X or ev.code == ABS_MT_POSITION_X then
ev.value = width - ev.value
end
if ev.type == EV_ABS
and (ev.code == ABS_X or ev.code == ABS_MT_POSITION_X) then
ev.value = width - ev.value
end
end
function Input:adjustTouchMirrorY(ev, height)
if ev.type == EV_ABS then
if ev.code == ABS_Y or ev.code == ABS_MT_POSITION_Y then
ev.value = height - ev.value
end
if ev.type == EV_ABS
and (ev.code == ABS_Y or ev.code == ABS_MT_POSITION_Y) then
ev.value = height - ev.value
end
end
function Input:adjustTouchTranslate(ev, by)

@ -76,7 +76,7 @@ function Kobo:init()
-- it's called KOBO_TOUCH_MIRRORED in defaults.lua, but what it
-- actually did in its original implementation was to switch X/Y.
if self.touch_switch_xy and not KOBO_TOUCH_MIRRORED
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)

Loading…
Cancel
Save