mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
kobo(fix): make sure sleep cover is not interrupting sleeping when ignore_power_sleepcover is set
This commit is contained in:
@@ -275,12 +275,12 @@ function Input:handleKeyBoardEv(ev)
|
||||
return keycode
|
||||
end
|
||||
|
||||
-- Kobo sleep
|
||||
-- Kobo sleep cover
|
||||
if keycode == "Power_SleepCover" then
|
||||
if ev.value == EVENT_VALUE_KEY_PRESS then
|
||||
return "Suspend"
|
||||
return "SleepCoverClosed"
|
||||
else
|
||||
return "Resume"
|
||||
return "SleepCoverOpened"
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -118,16 +118,13 @@ function Kobo:init()
|
||||
self.input = require("device/input"):new{
|
||||
device = self,
|
||||
event_map = {
|
||||
[59] = "Power_SleepCover",
|
||||
[90] = "Light",
|
||||
[102] = "Home",
|
||||
[116] = "Power",
|
||||
}
|
||||
}
|
||||
|
||||
if not G_reader_settings:readSetting("ignore_power_sleepcover") then
|
||||
self.input.event_map[59] = "Power_SleepCover"
|
||||
end
|
||||
|
||||
Generic.init(self)
|
||||
|
||||
self.input.open("/dev/input/event0") -- Light button and sleep slider
|
||||
|
||||
@@ -86,6 +86,19 @@ function UIManager:init()
|
||||
self.event_handlers["Suspend"]()
|
||||
end
|
||||
end
|
||||
if not G_reader_settings:readSetting("ignore_power_sleepcover") then
|
||||
self.event_handlers["SleepCoverClosed"] = self.event_handlers["Suspend"]
|
||||
self.event_handlers["SleepCoverOpened"] = self.event_handlers["Resume"]
|
||||
else
|
||||
-- Closing/opening the cover will still wake up the device, so we
|
||||
-- need to put it back to sleep if we are in screen saver mode
|
||||
self.event_handlers["SleepCoverClosed"] = function()
|
||||
if Device.screen_saver_mode then
|
||||
self.event_handlers["Suspend"]()
|
||||
end
|
||||
end
|
||||
self.event_handlers["SleepCoverOpened"] = self.event_handlers["SleepCoverClosed"]
|
||||
end
|
||||
self.event_handlers["Light"] = function()
|
||||
Device:getPowerDevice():toggleFrontlight()
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user