InputContainer/FocusManager: Simplify key_events clearing on unplug

Thanks to @poire-z for the idea, it's indeed much nicer this way ;).
This commit is contained in:
NiLuJe
2022-11-01 23:22:07 +01:00
parent d585cd5d86
commit 925fd647dc
19 changed files with 66 additions and 141 deletions

View File

@@ -13,14 +13,14 @@ local ReaderPanning = InputContainer:extend{
}
function ReaderPanning:init()
self:registerKeyEvents(true)
self:registerKeyEvents()
-- NOP our own gesture handling
self.ges_events = nil
end
function ReaderPanning:onGesture() end
function ReaderPanning:registerKeyEvents(init)
function ReaderPanning:registerKeyEvents()
if Device:hasKeyboard() then
self.key_events = {
-- these will all generate the same event, just with different arguments
@@ -45,13 +45,10 @@ function ReaderPanning:registerKeyEvents(init)
args = {1, 0}
},
}
elseif not init then
self.key_events = {}
end
end
ReaderPanning.onPhysicalKeyboardConnected = ReaderPanning.registerKeyEvents
ReaderPanning.onPhysicalKeyboardDisconnected = ReaderPanning.registerKeyEvents
function ReaderPanning:onPanning(args, _)
local dx, dy = unpack(args)