diff --git a/frontend/device/input.lua b/frontend/device/input.lua index ccb781f46..f4091fbde 100644 --- a/frontend/device/input.lua +++ b/frontend/device/input.lua @@ -184,13 +184,8 @@ local Input = { UsbDevicePlugIn = true, UsbDevicePlugOut = true, }, - -- NOTE: When looking at the device in Portrait mode, that's assuming PgBack is on TOP, and PgFwd on the BOTTOM - rotation_map = { - [framebuffer.ORIENTATION_PORTRAIT] = {}, - [framebuffer.ORIENTATION_LANDSCAPE] = { Up = "Right", Right = "Down", Down = "Left", Left = "Up", LPgBack = "LPgFwd", LPgFwd = "LPgBack", RPgBack = "RPgFwd", RPgFwd = "RPgBack" }, - [framebuffer.ORIENTATION_PORTRAIT_ROTATED] = { Up = "Down", Right = "Left", Down = "Up", Left = "Right", LPgFwd = "LPgBack", LPgBack = "LPgFwd", RPgFwd = "RPgBack", RPgBack = "RPgFwd" }, - [framebuffer.ORIENTATION_LANDSCAPE_ROTATED] = { Up = "Left", Right = "Up", Down = "Right", Left = "Down" } - }, + -- This might be overloaded or even disabled (post-init) at instance-level, so we don't want any inheritance + rotation_map = nil, -- nil or a hash timer_callbacks = nil, -- instance-specific table, because the object may get destroyed & recreated at runtime disable_double_tap = true, @@ -256,6 +251,16 @@ function Input:init() input = self, } + -- NOTE: When looking at the device in Portrait mode, that's assuming PgBack is on TOP, and PgFwd on the BOTTOM + if not self.rotation_map then + self.rotation_map = { + [framebuffer.ORIENTATION_PORTRAIT] = {}, + [framebuffer.ORIENTATION_LANDSCAPE] = { Up = "Right", Right = "Down", Down = "Left", Left = "Up", LPgBack = "LPgFwd", LPgFwd = "LPgBack", RPgBack = "RPgFwd", RPgFwd = "RPgBack" }, + [framebuffer.ORIENTATION_PORTRAIT_ROTATED] = { Up = "Down", Right = "Left", Down = "Up", Left = "Right", LPgFwd = "LPgBack", LPgBack = "LPgFwd", RPgFwd = "RPgBack", RPgBack = "RPgFwd" }, + [framebuffer.ORIENTATION_LANDSCAPE_ROTATED] = { Up = "Left", Right = "Up", Down = "Right", Left = "Down" } + } + end + -- set up fake event map self.event_map[10000] = "IntoSS" -- go into screen saver self.event_map[10001] = "OutOfSS" -- go out of screen saver @@ -534,8 +539,11 @@ function Input:handleKeyBoardEv(ev) end -- take device rotation into account - if self.rotation_map[self.device.screen:getRotationMode()][keycode] then - keycode = self.rotation_map[self.device.screen:getRotationMode()][keycode] + if self.rotation_map then + local rota = self.device.screen:getRotationMode() + if self.rotation_map[rota][keycode] then + keycode = self.rotation_map[rota][keycode] + end end if self.fake_event_set[keycode] then diff --git a/frontend/device/pocketbook/device.lua b/frontend/device/pocketbook/device.lua index 951390a78..0b898a45d 100644 --- a/frontend/device/pocketbook/device.lua +++ b/frontend/device/pocketbook/device.lua @@ -62,6 +62,10 @@ local PocketBook = Generic:extend{ --- @fixme: Never actually set anywhere? is_using_raw_input = nil, + -- InkView may have started translating button codes based on rotation on newer devices... + -- That historically wasn't the case, hence this defaulting to false. + inkview_translates_buttons = false, + -- Will be set appropriately at init isB288SoC = no, @@ -216,6 +220,11 @@ function PocketBook:init() end, } + -- If InkView translates buttons for us, disable our own translation map + if self.inkview_translates_buttons then + self.input.rotation_map = nil + end + -- in contrast to kobo/kindle, pocketbook-devices do not use linux/input -- events directly. To be able to use input.lua nevertheless, we make -- inkview-events look like linux/input events or handle them directly @@ -593,6 +602,8 @@ local PocketBook700 = PocketBook:extend{ display_dpi = 300, isAlwaysPortrait = yes, hasNaturalLight = yes, + -- c.f., https://github.com/koreader/koreader/issues/9556 + inkview_translates_buttons = true, } -- PocketBook InkPad 3 (740)