mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
Introduce Device:useDPadAsActionKeys() (#11900)
1. Non-Kindle-specific `hasFiveWay` behavior is changed to `hasDPad and useDPadAsActionKeys`. For now they remain Kindle-specific in practice, unless one sets `useDPadAsActionKeys = yes` in a user patch. 2. With that disambiguation out of the way, `hasFiveWay` itself is further disambiguated into `hasScreenKB` and `hasSymKey`, as per the actual property being used, rather than something that tends to correlate with it. (It needn't be Kindle-specific per se, but non-Kindle devices have equivalent shortcuts with for example `Shift`.) Running the emulator with `DISABLE_TOUCH=1` will set `hasSymKey = yes`, which can be tested with right shift. Closes #11887.
This commit is contained in:
@@ -66,7 +66,7 @@ function ReaderBookmark:onGesture() end
|
||||
function ReaderBookmark:registerKeyEvents()
|
||||
if Device:hasKeyboard() then
|
||||
self.key_events.ShowBookmark = { { "B" } }
|
||||
elseif Device:hasFiveWay() then
|
||||
elseif Device:hasScreenKB() then
|
||||
self.key_events.ShowBookmark = { { "ScreenKB", "Left" } }
|
||||
self.key_events.ToggleBookmark = { { "ScreenKB", "Right" } }
|
||||
end
|
||||
|
||||
@@ -142,20 +142,20 @@ function ReaderFont:onGesture() end
|
||||
|
||||
function ReaderFont:registerKeyEvents()
|
||||
if Device:hasKeyboard() then
|
||||
-- add shortcut for keyboard
|
||||
self.key_events = {
|
||||
ShowFontMenu = { { "F" } },
|
||||
IncreaseSize = {
|
||||
self.key_events.ShowFontMenu = { { "F" } }
|
||||
if not (Device:hasScreenKB() or Device:hasSymKey()) then
|
||||
-- add shortcut for keyboard
|
||||
self.key_events.IncreaseSize = {
|
||||
{ "Shift", Input.group.PgFwd },
|
||||
event = "ChangeSize",
|
||||
args = 0.5
|
||||
},
|
||||
DecreaseSize = {
|
||||
}
|
||||
self.key_events.DecreaseSize = {
|
||||
{ "Shift", Input.group.PgBack },
|
||||
event = "ChangeSize",
|
||||
args = -0.5
|
||||
},
|
||||
}
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -246,16 +246,12 @@ function ReaderHighlight:registerKeyEvents()
|
||||
self.key_events.QuickLeftHighlightIndicator = { { "Shift", "Left" }, event = "MoveHighlightIndicator", args = {-1, 0, QUICK_INDICATOR_MOVE} }
|
||||
self.key_events.QuickRightHighlightIndicator = { { "Shift", "Right" }, event = "MoveHighlightIndicator", args = {1, 0, QUICK_INDICATOR_MOVE} }
|
||||
self.key_events.StartHighlightIndicator = { { "H" } }
|
||||
if Device:hasFiveWay() then
|
||||
self.key_events.KeyContentSelection = { { { "Up", "Down" } }, event = "StartHighlightIndicator" }
|
||||
end
|
||||
elseif Device:hasFiveWay() then
|
||||
elseif Device:hasScreenKB() then
|
||||
local QUICK_INDICATOR_MOVE = true
|
||||
self.key_events.QuickUpHighlightIndicator = { { "ScreenKB", "Up" }, event = "MoveHighlightIndicator", args = {0, -1, QUICK_INDICATOR_MOVE} }
|
||||
self.key_events.QuickDownHighlightIndicator = { { "ScreenKB", "Down" }, event = "MoveHighlightIndicator", args = {0, 1, QUICK_INDICATOR_MOVE} }
|
||||
self.key_events.QuickLeftHighlightIndicator = { { "ScreenKB", "Left" }, event = "MoveHighlightIndicator", args = {-1, 0, QUICK_INDICATOR_MOVE} }
|
||||
self.key_events.QuickRightHighlightIndicator = { { "ScreenKB", "Right" }, event = "MoveHighlightIndicator", args = {1, 0, QUICK_INDICATOR_MOVE} }
|
||||
self.key_events.KeyContentSelection = { { { "Up", "Down" } }, event = "StartHighlightIndicator" }
|
||||
end
|
||||
end
|
||||
|
||||
@@ -377,7 +373,7 @@ local highlight_dialog_position = {
|
||||
|
||||
function ReaderHighlight:addToMainMenu(menu_items)
|
||||
-- insert table to main reader menu
|
||||
if not Device:isTouchDevice() and Device:hasDPad() and not Device:hasFiveWay() then
|
||||
if not Device:isTouchDevice() and Device:hasDPad() and not Device:useDPadAsActionKeys() then
|
||||
menu_items.start_content_selection = {
|
||||
text = _("Start content selection"),
|
||||
callback = function()
|
||||
|
||||
@@ -233,26 +233,7 @@ end
|
||||
function ReaderLink:onGesture() end
|
||||
|
||||
function ReaderLink:registerKeyEvents()
|
||||
if Device:hasKeys() and not Device:hasFiveWay() then
|
||||
self.key_events = {
|
||||
SelectNextPageLink = {
|
||||
{ "Tab" },
|
||||
event = "SelectNextPageLink",
|
||||
},
|
||||
SelectPrevPageLink = {
|
||||
{ "Shift", "Tab" },
|
||||
{ "Sym", "Tab" }, -- Shift or Sym + Tab
|
||||
event = "SelectPrevPageLink",
|
||||
},
|
||||
GotoSelectedPageLink = {
|
||||
{ "Press" },
|
||||
event = "GotoSelectedPageLink",
|
||||
},
|
||||
-- "Back" is handled by ReaderBack, which will call our onGoBackLink()
|
||||
-- when G_reader_settings:readSetting("back_in_reader") == "previous_location"
|
||||
}
|
||||
end
|
||||
if Device:hasFiveWay() then
|
||||
if Device:hasScreenKB() or Device:hasSymKey() then
|
||||
self.key_events.GotoSelectedPageLink = { { "Press" }, event = "GotoSelectedPageLink" }
|
||||
if Device:hasKeyboard() then
|
||||
self.key_events.AddCurrentLocationToStack = { { "Shift", "Down" } }
|
||||
@@ -263,6 +244,23 @@ function ReaderLink:registerKeyEvents()
|
||||
self.key_events.SelectNextPageLink = { { "ScreenKB", "LPgFwd" }, event = "SelectNextPageLink" }
|
||||
self.key_events.SelectPrevPageLink = { { "ScreenKB", "LPgBack" }, event = "SelectPrevPageLink" }
|
||||
end
|
||||
elseif Device:hasKeys() then
|
||||
self.key_events = {
|
||||
SelectNextPageLink = {
|
||||
{ "Tab" },
|
||||
event = "SelectNextPageLink",
|
||||
},
|
||||
SelectPrevPageLink = {
|
||||
{ "Shift", "Tab" },
|
||||
event = "SelectPrevPageLink",
|
||||
},
|
||||
GotoSelectedPageLink = {
|
||||
{ "Press" },
|
||||
event = "GotoSelectedPageLink",
|
||||
},
|
||||
-- "Back" is handled by ReaderBack, which will call our onGoBackLink()
|
||||
-- when G_reader_settings:readSetting("back_in_reader") == "previous_location"
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -51,8 +51,7 @@ end
|
||||
function ReaderPaging:onGesture() end
|
||||
|
||||
function ReaderPaging:registerKeyEvents()
|
||||
if Device:hasFiveWay() then
|
||||
-- this targets all devices (kindles) non-touch with dPads (i.e dx, kk, k4 and others)
|
||||
if Device:hasDPad() and Device:useDPadAsActionKeys() then
|
||||
self.key_events.GotoNextPos = {
|
||||
{ { "RPgFwd", "LPgFwd" } },
|
||||
event = "GotoPosRel",
|
||||
|
||||
@@ -116,7 +116,7 @@ end
|
||||
function ReaderRolling:onGesture() end
|
||||
|
||||
function ReaderRolling:registerKeyEvents()
|
||||
if Device:hasFiveWay() then
|
||||
if Device:hasScreenKB() or Device:hasSymKey() then
|
||||
self.key_events.GotoNextView = {
|
||||
{ { "RPgFwd", "LPgFwd" } },
|
||||
event = "GotoViewRel",
|
||||
@@ -151,7 +151,7 @@ function ReaderRolling:registerKeyEvents()
|
||||
args = -1,
|
||||
}
|
||||
end
|
||||
if Device:hasFiveWay() then
|
||||
if Device:hasDPad() and Device:useDPadAsActionKeys() then
|
||||
self.key_events.GotoNextChapter = {
|
||||
{ "Right" },
|
||||
event = "GotoNextChapter",
|
||||
@@ -174,7 +174,7 @@ function ReaderRolling:registerKeyEvents()
|
||||
args = {0, 1},
|
||||
}
|
||||
end
|
||||
if Device:hasFiveWay() and not Device:hasKeyboard() then
|
||||
if Device:hasScreenKB() then
|
||||
self.key_events.MoveUp = {
|
||||
{ "ScreenKB", "RPgBack" },
|
||||
event = "Panning",
|
||||
|
||||
@@ -60,10 +60,10 @@ end
|
||||
function ReaderToc:onGesture() end
|
||||
|
||||
function ReaderToc:registerKeyEvents()
|
||||
if Device:hasKeyboard() then
|
||||
self.key_events.ShowToc = { { "T" } }
|
||||
elseif Device:hasFiveWay() then
|
||||
if Device:hasScreenKB() then
|
||||
self.key_events.ShowToc = { { "ScreenKB", "Up" } }
|
||||
elseif Device:hasKeyboard() then
|
||||
self.key_events.ShowToc = { { "T" } }
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user