Enable Alt+Shift+G for screenshots on all devices with a keyboard (#11888)

This commit is contained in:
Frans de Jonge
2024-05-25 21:11:38 +02:00
committed by GitHub
parent 556e5bd6b4
commit b222900cb9

View File

@@ -15,22 +15,9 @@ local Screenshoter = InputContainer:extend{
}
function Screenshoter:init()
if not Device:isTouchDevice() then
if Device:hasKeyboard() then
self.key_events.KeyPressShoot = {
{ "Alt", "Shift", "G" }, -- same as stock firmware
event = "KeyPressShoot",
}
elseif Device:hasFiveWay() then
-- kindle 4 case: same as stock firmware.
self.key_events.KeyPressShoot = {
{ "ScreenKB", "Menu" },
event = "KeyPressShoot",
}
-- unable to add other non-touch devices as simultaneous key presses won't work without modifiers
end
return
end
self:registerKeyEvents()
if not Device:isTouchDevice() then return end
local diagonal = math.sqrt(Screen:getWidth()^2 + Screen:getHeight()^2)
self.ges_events = {
TapDiagonal = {
@@ -146,4 +133,22 @@ function Screenshoter:onSwipeDiagonal()
return self:onScreenshot()
end
function Screenshoter:registerKeyEvents()
if Device:hasKeyboard() then
self.key_events.KeyPressShoot = {
{ "Alt", "Shift", "G" }, -- same as stock Kindle firmware
event = "KeyPressShoot",
}
elseif Device:hasFiveWay() then
-- kindle 4 case: same as stock firmware.
self.key_events.KeyPressShoot = {
{ "ScreenKB", "Menu" },
event = "KeyPressShoot",
}
-- unable to add other non-touch devices as simultaneous key presses won't work without modifiers
end
end
Screenshoter.onPhysicalKeyboardConnected = Screenshoter.registerKeyEvents
return Screenshoter