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:
@@ -380,7 +380,7 @@ function FileManager:registerKeyEvents()
|
||||
self.key_events.Home = { { "Home" } }
|
||||
-- Override the menu.lua way of handling the back key
|
||||
self.file_chooser.key_events.Back = { { Device.input.group.Back } }
|
||||
if Device:hasFiveWay() and not Device:hasKeyboard() then
|
||||
if Device:hasScreenKB() then
|
||||
self.key_events.KeyToggleWifi = { { "ScreenKB", "Home" }, event = "ToggleWifi" }
|
||||
end
|
||||
if not Device:hasFewKeys() then
|
||||
|
||||
@@ -61,7 +61,7 @@ end
|
||||
function FileManagerMenu:registerKeyEvents()
|
||||
if Device:hasKeys() then
|
||||
self.key_events.ShowMenu = { { "Menu" } }
|
||||
if Device:hasFiveWay() and not Device:hasKeyboard() then
|
||||
if Device:hasScreenKB() then
|
||||
self.key_events.OpenLastDoc = { { "ScreenKB", "Back" } }
|
||||
end
|
||||
end
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -523,7 +523,10 @@ function ReaderUI:registerKeyEvents()
|
||||
if Device:hasKeys() then
|
||||
self.key_events.Home = { { "Home" } }
|
||||
self.key_events.Reload = { { "F5" } }
|
||||
if Device:hasFiveWay() then
|
||||
if Device:hasDPad() and Device:useDPadAsActionKeys() then
|
||||
self.key_events.KeyContentSelection = { { { "Up", "Down" } }, event = "StartHighlightIndicator" }
|
||||
end
|
||||
if Device:hasScreenKB() or Device:hasSymKey() then
|
||||
if Device:hasKeyboard() then
|
||||
self.key_events.KeyToggleWifi = { { "Shift", "Home" }, event = "ToggleWifi" }
|
||||
self.key_events.OpenLastDoc = { { "Shift", "Back" } }
|
||||
|
||||
@@ -41,9 +41,11 @@ local Device = {
|
||||
hasAuxBattery = no,
|
||||
hasKeyboard = no,
|
||||
hasKeys = no,
|
||||
hasFiveWay = no,
|
||||
hasScreenKB = no, -- in practice only some Kindles
|
||||
hasSymKey = no, -- in practice only some Kindles
|
||||
canKeyRepeat = no,
|
||||
hasDPad = no,
|
||||
useDPadAsActionKeys = no,
|
||||
hasExitOptions = yes,
|
||||
hasFewKeys = no,
|
||||
hasWifiToggle = yes,
|
||||
|
||||
@@ -518,8 +518,9 @@ local Kindle2 = Kindle:extend{
|
||||
isREAGL = no,
|
||||
hasKeyboard = yes,
|
||||
hasKeys = yes,
|
||||
hasFiveWay = yes,
|
||||
hasSymKey = yes,
|
||||
hasDPad = yes,
|
||||
useDPadAsActionKeys = yes,
|
||||
canHWInvert = no,
|
||||
canModifyFBInfo = no,
|
||||
canUseCBB = no, -- 4bpp
|
||||
@@ -532,8 +533,9 @@ local KindleDXG = Kindle:extend{
|
||||
isREAGL = no,
|
||||
hasKeyboard = yes,
|
||||
hasKeys = yes,
|
||||
hasFiveWay = yes,
|
||||
hasSymKey = yes,
|
||||
hasDPad = yes,
|
||||
useDPadAsActionKeys = yes,
|
||||
canHWInvert = no,
|
||||
canModifyFBInfo = no,
|
||||
canUseCBB = no, -- 4bpp
|
||||
@@ -546,8 +548,9 @@ local Kindle3 = Kindle:extend{
|
||||
isREAGL = no,
|
||||
hasKeyboard = yes,
|
||||
hasKeys = yes,
|
||||
hasFiveWay = yes,
|
||||
hasSymKey = yes,
|
||||
hasDPad = yes,
|
||||
useDPadAsActionKeys = yes,
|
||||
canHWInvert = no,
|
||||
canModifyFBInfo = no,
|
||||
canUseCBB = no, -- 4bpp
|
||||
@@ -558,8 +561,9 @@ local Kindle4 = Kindle:extend{
|
||||
model = "Kindle4",
|
||||
isREAGL = no,
|
||||
hasKeys = yes,
|
||||
hasFiveWay = yes,
|
||||
hasScreenKB = yes,
|
||||
hasDPad = yes,
|
||||
useDPadAsActionKeys = yes,
|
||||
canHWInvert = no,
|
||||
canModifyFBInfo = no,
|
||||
-- NOTE: It could *technically* use the C BB, as it's running @ 8bpp, but it's expecting an inverted palette...
|
||||
|
||||
@@ -68,6 +68,7 @@ local Device = Generic:extend{
|
||||
hasBattery = SDL.getPowerInfo,
|
||||
hasKeyboard = yes,
|
||||
hasKeys = yes,
|
||||
hasSymKey = os.getenv("DISABLE_TOUCH") == "1" and yes or no,
|
||||
hasDPad = yes,
|
||||
hasWifiToggle = no,
|
||||
hasSeamlessWifiToggle = no,
|
||||
|
||||
@@ -61,7 +61,7 @@ return {
|
||||
[1073741893] = "F12", -- F[12]
|
||||
|
||||
[1073742049] = "Shift", -- left shift
|
||||
[1073742053] = "Sym", -- right shift
|
||||
[1073742053] = os.getenv("DISABLE_TOUCH") == "1" and "Sym" or "Shift", -- right shift
|
||||
[1073742050] = "Alt", -- left alt
|
||||
[1073742054] = "AA", -- right alt key
|
||||
[1073741925] = "ContextMenu", -- Context menu key
|
||||
|
||||
@@ -139,7 +139,7 @@ function Screenshoter:registerKeyEvents()
|
||||
{ "Alt", "Shift", "G" }, -- same as stock Kindle firmware
|
||||
event = "KeyPressShoot",
|
||||
}
|
||||
elseif Device:hasFiveWay() then
|
||||
elseif Device:hasScreenKB() then
|
||||
-- kindle 4 case: same as stock firmware.
|
||||
self.key_events.KeyPressShoot = {
|
||||
{ "ScreenKB", "Menu" },
|
||||
|
||||
Reference in New Issue
Block a user