feat: add set lock orientation in dispatcher (#13835)
Some checks failed
macos / macOS 13 x86-64 🔨15.2 🎯10.15 (push) Has been cancelled
macos / macOS 14 ARM64 🔨15.4 🎯11.0 (push) Has been cancelled

ATM you can only toggle G sensor lock in dispatcher, this commit adds
the ability to set the lock to on or off.

This can be useful in profiles that want to set an explicit mode
instead of toggling the setting.
This commit is contained in:
Kevin Hellemun
2025-05-22 00:21:41 +02:00
committed by GitHub
parent 2512f06eb0
commit 0eff9ede4d
2 changed files with 17 additions and 3 deletions

View File

@@ -224,7 +224,20 @@ if Device:hasGSensor() then
function DeviceListener:onLockGSensor()
G_reader_settings:flipNilOrFalse("input_lock_gsensor")
Device:lockGSensor(G_reader_settings:isTrue("input_lock_gsensor"))
self:setLockGsensor(G_reader_settings:isTrue("input_lock_gsensor"))
return true
end
-- @param flag bool on/off
function DeviceListener:onSetLockGSensor(flag)
self:setLockGsensor(flag)
return true
end
-- @param flag bool on/off
function DeviceListener:setLockGsensor(flag)
G_reader_settings:saveSetting("input_lock_gsensor", flag)
Device:lockGSensor(flag)
local new_text
if G_reader_settings:isTrue("input_lock_gsensor") then
new_text = _("Orientation locked.")
@@ -232,7 +245,6 @@ if Device:hasGSensor() then
new_text = _("Orientation unlocked.")
end
Notification:notify(new_text)
return true
end
end

View File

@@ -91,7 +91,8 @@ local settingsList = {
toggle_key_repeat = {category="none", event="ToggleKeyRepeat", title=_("Toggle key repeat"), device=true, condition=Device:hasKeys() and Device:canKeyRepeat(), separator=true},
toggle_gsensor = {category="none", event="ToggleGSensor", title=_("Toggle accelerometer"), device=true, condition=Device:hasGSensor()},
temp_gsensor_on = {category="none", event="TempGSensorOn", title=_("Enable accelerometer for 5 seconds"), device=true, condition=Device:hasGSensor()},
lock_gsensor = {category="none", event="LockGSensor", title=_("Lock auto rotation to current orientation"), device=true, condition=Device:hasGSensor()},
lock_gsensor = {category="none", event="LockGSensor", title=_("Toggle lock auto rotation to current orientation"), device=true, condition=Device:hasGSensor()},
set_lock_gsensor = {category="string", event="SetLockGSensor", title=_("Set lock auto rotation to current orientation"), device=true, condition=Device:hasGSensor(), args = {true, false}, toggle = { _("true"), _("false")}},
rotation_mode = {category="string", device=true}, -- title=_("Rotation"), parsed from CreOptions
toggle_rotation = {category="none", event="SwapRotation", title=_("Toggle orientation"), device=true},
invert_rotation = {category="none", event="InvertRotation", title=_("Invert rotation"), device=true},
@@ -329,6 +330,7 @@ local dispatcher_menu_order = {
"toggle_gsensor",
"temp_gsensor_on",
"lock_gsensor",
"set_lock_gsensor",
"rotation_mode",
"toggle_rotation",
"invert_rotation",