Revamp manual rotation events (#6530)

Restore a Swap event like before #6309
Implement an Invert one
And keep the fairly useless +90° CW one, but under an accurate name.

Fix #6524
pull/6542/head
NiLuJe 4 years ago committed by GitHub
parent 85b498d76e
commit 1b904f0f0d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -239,8 +239,32 @@ if Device:canToggleGSensor() then
end
end
function DeviceListener:onToggleRotation()
local arg = bit.band((Screen:getRotationMode() + 1), 3)
function DeviceListener:onIterateRotation()
-- Simply rotate by 90° CW
local arg = bit.band(Screen:getRotationMode() + 1, 3)
self.ui:handleEvent(Event:new("SetRotationMode", arg))
return true
end
function DeviceListener:onInvertRotation()
-- Invert is always rota + 2, w/ wraparound
local arg = bit.band(Screen:getRotationMode() + 2, 3)
self.ui:handleEvent(Event:new("SetRotationMode", arg))
return true
end
function DeviceListener:onSwapRotation()
local rota = Screen:getRotationMode()
-- Portrait is always even, Landscape is always odd. For each of 'em, Landscape = Portrait + 1.
-- As such...
local arg
if bit.band(rota, 1) == 0 then
-- If Portrait, Landscape is +1
arg = bit.band(rota + 1, 3)
else
-- If Landscape, Portrait is -1
arg = bit.band(rota - 1, 3)
end
self.ui:handleEvent(Event:new("SetRotationMode", arg))
return true
end

@ -62,8 +62,10 @@ local settingsList = {
reboot = { category="none", event="Reboot", title=_("Reboot the device"), device=true, condition=Device:canReboot(),},
poweroff = { category="none", event="PowerOff", title=_("Power off"), device=true, condition=Device:canPowerOff(), separator=true,},
show_menu = { category="none", event="ShowMenu", title=_("Show menu"), device=true,},
toggle_hold_corners = { category="none", event="IgnoreHoldCorners", title=_("Toggle hold corners"), device=true,},
toggle_rotation = { category="none", event="ToggleRotation", title=_("Toggle rotation"), device=true, separator=true,},
toggle_hold_corners = { category="none", event="IgnoreHoldCorners", title=_("Toggle hold corners"), device=true, separator=true,},
toggle_rotation = { category="none", event="SwapRotation", title=_("Toggle orientation"), device=true,},
invert_rotation = { category="none", event="InvertRotation", title=_("Invert rotation"), device=true,},
iterate_rotation = { category="none", event="IterateRotation", title=_("Rotate by 90° CW"), device=true, separator=true,},
wallabag_download = { category="none", event="SynchronizeWallabag", title=_("Wallabag retrieval"), device=true,},
calibre_search = { category="none", event="CalibreSearch", title=_("Search in calibre metadata"), device=true,},
calibre_browse_tags = { category="none", event="CalibreBrowseTags", title=_("Browse all calibre tags"), device=true,},
@ -177,6 +179,8 @@ local dispatcher_menu_order = {
"toggle_hold_corners",
"toggle_gsensor",
"toggle_rotation",
"invert_rotation",
"iterate_rotation",
"wifi_on",
"wifi_off",

Loading…
Cancel
Save