mirror of
https://github.com/koreader/koreader.git
synced 2026-12-03 10:36:11 +00:00
ExternalKeyboard: reset modifier state during connection/disconnection
A dropped connection can leave a modifier stuck true if the timing is right, so we want to simply clear any potential discrepancies.
This commit is contained in:
1 parent
5294a37b38
commit
8bc88acde5
2 files changed
+16
No files matched your search
@@ -711,6 +711,15 @@ function Input:resetState()
|
||||
}
|
||||
end
|
||||
|
||||
-- A modifier release can get lost (e.g., a BT keyboard dropping connection mid-press
|
||||
-- while going to sleep), which would leave that modifier stuck as pressed.
|
||||
function Input:resetModifierKeys()
|
||||
for key in pairs(self.modifiers) do
|
||||
self.modifiers[key] = false
|
||||
end
|
||||
self.keyboard_toggle_tapped = nil
|
||||
end
|
||||
|
||||
function Input:handleKeyBoardEv(ev)
|
||||
-- Detect loss of contact for the "snow" protocol, as we *never* get EV_ABS:ABS_MT_TRACKING_ID:-1 on those...
|
||||
-- NOTE: The same logic *could* be used on *some* ST devices to detect contact states,
|
||||
|
||||
@@ -205,6 +205,10 @@ function ExternalKeyboard:_onEvdevInputRemove(event_path)
|
||||
-- Close our Input handle on it
|
||||
Device.input:close(event_path)
|
||||
|
||||
-- Modifier key_release may have been lost while the keyboard
|
||||
-- was disconnected, don't let them stay stuck true.
|
||||
Device.input:resetModifierKeys()
|
||||
|
||||
ExternalKeyboard.keyboard_fds[event_path] = nil
|
||||
ExternalKeyboard.connected_keyboards = ExternalKeyboard.connected_keyboards - 1
|
||||
logger.dbg("ExternalKeyboard: USB keyboard", event_path, "was disconnected; total:", ExternalKeyboard.connected_keyboards)
|
||||
@@ -353,6 +357,9 @@ function ExternalKeyboard:setupKeyboard(data)
|
||||
ExternalKeyboard.keyboard_fds[keyboard_info.event_path] = fd
|
||||
-- External keyboard arrows are keyboard-relative, not device-relative.
|
||||
Device.input.rotation_ignored_fds[fd] = true
|
||||
-- Modifier key_release may have been lost while the keyboard
|
||||
-- was disconnected, don't let them stay stuck true.
|
||||
Device.input:resetModifierKeys()
|
||||
ExternalKeyboard.connected_keyboards = ExternalKeyboard.connected_keyboards + 1
|
||||
logger.dbg("ExternalKeyboard: USB keyboard", keyboard_info.name, "@", keyboard_info.event_path, "was connected; total:", ExternalKeyboard.connected_keyboards)
|
||||
|
||||
|
||||
Reference in new issue
Block a user