From 5b6d2ab66f56dde2266048eba2542569f724911f Mon Sep 17 00:00:00 2001 From: NiLuJe Date: Mon, 31 Oct 2022 02:09:37 +0100 Subject: [PATCH] ExternalKeyboard: Workaround bad interaction with coverbrowser when enabled on startup --- plugins/externalkeyboard.koplugin/main.lua | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/plugins/externalkeyboard.koplugin/main.lua b/plugins/externalkeyboard.koplugin/main.lua index eea9ca84c..842f4b458 100644 --- a/plugins/externalkeyboard.koplugin/main.lua +++ b/plugins/externalkeyboard.koplugin/main.lua @@ -90,6 +90,7 @@ local ExternalKeyboard = WidgetContainer:extend{ original_device_values = nil, keyboard_fds = {}, connected_keyboards = 0, + startup = true, } function ExternalKeyboard:init() @@ -112,7 +113,14 @@ function ExternalKeyboard:init() role = USB_ROLE_HOST end if role == USB_ROLE_HOST then - self:findAndSetupKeyboards() + -- NOTE: On startup, if the FM is not in classic mode, the coverbrowser plugin does a funky hostile takeover at runtime. + -- Delay our own stuff to make sure we affect the final widget. + if ExternalKeyboard.startup then + UIManager:nextTick(self.findAndSetupKeyboards, self) + ExternalKeyboard.startup = nil + else + self:findAndSetupKeyboards() + end end end @@ -333,9 +341,6 @@ function ExternalKeyboard:showHelp() UIManager:show(InfoMessage:new { text = _([[ Note that in the OTG mode the device would not be recognized as a USB drive by a computer. - -Troubleshooting: -- If the keyboard is not recognized after plugging it in, try switching the USB mode to regular and back to OTG again. ]]), }) end