From adfbbd9903223dc6386ebd8d8a90d97fc4e3fb54 Mon Sep 17 00:00:00 2001 From: hius07 <62179190+hius07@users.noreply.github.com> Date: Mon, 3 Jul 2023 07:58:51 +0300 Subject: [PATCH] Disabled touch input: always active gestures (#10624) --- frontend/dispatcher.lua | 29 +++++++++++++++++++++++++++++ plugins/gestures.koplugin/main.lua | 5 +++-- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/frontend/dispatcher.lua b/frontend/dispatcher.lua index 45523fb29..d75766ced 100644 --- a/frontend/dispatcher.lua +++ b/frontend/dispatcher.lua @@ -72,6 +72,8 @@ local settingsList = { poweroff = {category="none", event="RequestPowerOff", title=_("Power off"), device=true, condition=Device:canPowerOff(), separator=true}, toggle_hold_corners = {category="none", event="IgnoreHoldCorners", title=_("Toggle hold corners"), device=true}, + touch_input_on = {category="none", event="IgnoreTouchInput", arg=false, title=_("Enable touch input"), device=true}, + touch_input_off = {category="none", event="IgnoreTouchInput", arg=true, title=_("Disable touch input"), device=true}, toggle_touch_input = {category="none", event="IgnoreTouchInput", title=_("Toggle touch input"), device=true, separator=true}, toggle_gsensor = {category="none", event="ToggleGSensor", title=_("Toggle accelerometer"), device=true, condition=Device:hasGSensor()}, toggle_rotation = {category="none", event="SwapRotation", title=_("Toggle orientation"), device=true}, @@ -264,6 +266,8 @@ local dispatcher_menu_order = { "poweroff", "toggle_hold_corners", + "touch_input_on", + "touch_input_off", "toggle_touch_input", "toggle_gsensor", "rotation_mode", @@ -949,6 +953,31 @@ function Dispatcher:addSubMenu(caller, menu, location, settings) end end, }) + table.insert(menu, { + text = _("Always active"), + checked_func = function() + return location[settings] ~= nil + and location[settings].settings ~= nil + and location[settings].settings.always_active + end, + callback = function() + if location[settings] then + if location[settings].settings then + if location[settings].settings.always_active then + location[settings].settings.always_active = nil + if next(location[settings].settings) == nil then + location[settings].settings = nil + end + else + location[settings].settings.always_active = true + end + else + location[settings].settings = {["always_active"] = true} + end + caller.updated = true + end + end, + }) table.insert(menu, { text = _("Sort"), checked_func = function() diff --git a/plugins/gestures.koplugin/main.lua b/plugins/gestures.koplugin/main.lua index d36d966b1..a6b2b5675 100644 --- a/plugins/gestures.koplugin/main.lua +++ b/plugins/gestures.koplugin/main.lua @@ -121,7 +121,7 @@ Multiswipes allow you to perform complex gestures built up out of multiple swipe These advanced gestures consist of either straight swipes or diagonal swipes. To ensure accuracy, they can't be mixed.]]) --- If the gesture contains the "toggle_touch_input" action, +-- If the gesture contains "toggle_touch_input" or "touch_input_on" actions, or is set "Always active" manually, -- mark it "always active" to make sure that InputContainer won't block it after the IgnoreTouchInput Event. function Gestures:isGestureAlwaysActive(ges, multiswipe_directions) -- Handle multiswipes properly @@ -134,7 +134,8 @@ function Gestures:isGestureAlwaysActive(ges, multiswipe_directions) end end - return self.gestures[ges] and self.gestures[ges].toggle_touch_input + local gest = self.gestures[ges] + return gest and (gest.toggle_touch_input or gest.touch_input_on or (gest.settings and gest.settings.always_active)) end function Gestures:init()