kobo(fix): make sure sleep cover is not interrupting sleeping when ignore_power_sleepcover is set

pull/2245/head
Qingping Hou 8 years ago
parent 22964a77a0
commit 93b3262db7

@ -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

Loading…
Cancel
Save