mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
Input: Some more followups to the input device auto-detection stuff (#11855)
Switch to a new `input.fdopen` API & wrapper so we can keep the fds opened by `fbink_input_scan` instead of closing them to re-open them right after that... This should hopefully help on racy zForce devices that attempt to handle power management when opening/closing the device. We know this sometimes horribly fail to re-activate the IR grid (c.f., our manual activation on resume), but this apparently could also happen here (re: #11844) because of the quick succession of open->close->open.
This commit is contained in:
@@ -323,6 +323,29 @@ function Input.open(path, name)
|
||||
end
|
||||
end
|
||||
|
||||
--[[--
|
||||
Wrapper for our Lua/C input module's fdopen.
|
||||
|
||||
Note that we adhere to the "." syntax here for compatibility.
|
||||
|
||||
The `name` argument is optional, and used for logging purposes only.
|
||||
`path` is mandatory, though!
|
||||
--]]
|
||||
function Input.fdopen(fd, path, name)
|
||||
-- Make sure we don't open the same device twice.
|
||||
if not Input.opened_devices[path] then
|
||||
input.fdopen(fd)
|
||||
-- As with input.open, it will throw on error (closing the fd first)
|
||||
Input.opened_devices[path] = fd
|
||||
if name then
|
||||
logger.dbg("Kept fd", fd, "open for input device", name, "@", path)
|
||||
else
|
||||
logger.dbg("Kept fd", fd, "open for input device @", path)
|
||||
end
|
||||
return fd
|
||||
end
|
||||
end
|
||||
|
||||
--[[--
|
||||
Wrapper for our Lua/C input module's close.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user