BookMap on devices with useDPadAsActionKeys (#11916)

as first discussed here #11908. This PR brings the book map to non-touch devices that useDPadAsActionKeys().

Book map can be accessed from the menu or by using the following shortcut: ScreenKB + Down or Shift + Down depending on whether you use a K4 device or a kindle with keyboard respectively.

Inside the book map, a user can toggle the hamburger menu by pressing the Menu key and make any adjustment from there. ScreenKB (or Shift) + Up/Down allows it to scroll and Page turn buttons to move by whole full page turns. Back key allows user to exit the map.
This commit is contained in:
David
2024-06-05 21:50:22 +01:00
committed by GitHub
parent 21213f35af
commit 04eec52eee
4 changed files with 69 additions and 33 deletions

View File

@@ -21,10 +21,12 @@ local _ = require("gettext")
local ReaderThumbnail = WidgetContainer:extend{}
function ReaderThumbnail:init()
if not Device:isTouchDevice() then
self:registerKeyEvents()
if not Device:isTouchDevice() and not Device:useDPadAsActionKeys() then
-- The BookMap and PageBrowser widgets depend too much on gestures,
-- making them work with keys would be hard and very limited, so
-- making them work with not enough keys on Non-Touch would be hard and very limited, so
-- just don't make them available.
-- We will only let BookMap run on useDPadAsActionKeys devices.
return
end
@@ -62,6 +64,16 @@ function ReaderThumbnail:init()
end
end
function ReaderThumbnail:registerKeyEvents()
if Device:hasDPad() and Device:useDPadAsActionKeys() then
if Device:hasKeyboard() then
self.key_events.ShowBookMap = { { "Shift", "Down" } }
else
self.key_events.ShowBookMap = { { "ScreenKB", "Down" } }
end
end
end
function ReaderThumbnail:addToMainMenu(menu_items)
menu_items.book_map = {
text = _("Book map"),
@@ -75,6 +87,8 @@ function ReaderThumbnail:addToMainMenu(menu_items)
self:onShowBookMap(true)
end,
}
-- PageBrowser still needs some work before we can let it run on non-touch devices with useDPadAsActionKeys
if Device:hasDPad() and Device:useDPadAsActionKeys() then return end
menu_items.page_browser = {
text = _("Page browser"),
callback = function()