diff --git a/frontend/device/input.lua b/frontend/device/input.lua index 0a46ceca0..fbf27b3cf 100644 --- a/frontend/device/input.lua +++ b/frontend/device/input.lua @@ -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) diff --git a/frontend/device/kobo/device.lua b/frontend/device/kobo/device.lua index 44ef60d1e..924ccb169 100644 --- a/frontend/device/kobo/device.lua +++ b/frontend/device/kobo/device.lua @@ -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)