diff --git a/frontend/ui/device.lua b/frontend/ui/device.lua index 2c81231e3..208d1c2b7 100644 --- a/frontend/ui/device.lua +++ b/frontend/ui/device.lua @@ -8,7 +8,10 @@ Device = { frontlight = nil, } -BaseFrontLight = {} +BaseFrontLight = { + min = 1, max = 10, + intensity = nil, +} KindleFrontLight = { min = 0, max = 24, @@ -26,7 +29,7 @@ KoboFrontLight = { function Device:getModel() if self.model then return self.model end - if util.isEmulated()==1 then + if util.isEmulated() then self.model = "Emulator" return self.model end @@ -184,18 +187,23 @@ function Device:getFrontlight() self.frontlight = KindleFrontLight elseif self:isKobo() then self.frontlight = KoboFrontLight + else -- emulated FrontLight + self.frontlight = BaseFrontLight end - if self.frontlight ~= nil then - self.frontlight:init() - end + self.frontlight:init() end return self.frontlight end -function BaseFrontLight:intensityCheckBounds(intensity) +function BaseFrontLight:init() end +function BaseFrontLight:toggle() end +function BaseFrontLight:setIntensityHW() end + +function BaseFrontLight:setIntensity(intensity) intensity = intensity < self.min and self.min or intensity intensity = intensity > self.max and self.max or intensity self.intensity = intensity + self:setIntensityHW() end function KindleFrontLight:init() @@ -217,11 +225,10 @@ function KindleFrontLight:toggle() end end -KindleFrontLight.intensityCheckBounds = BaseFrontLight.intensityCheckBounds +KindleFrontLight.setIntensity = BaseFrontLight.setIntensity -function KindleFrontLight:setIntensity(intensity) +function KindleFrontLight:setIntensityHW() if self.lipc_handle ~= nil then - self:intensityCheckBounds(intensity) self.lipc_handle:set_int_property("com.lab126.powerd", "flIntensity", self.intensity) end end @@ -236,11 +243,10 @@ function KoboFrontLight:toggle() end end -KoboFrontLight.intensityCheckBounds = BaseFrontLight.intensityCheckBounds +KoboFrontLight.setIntensity = BaseFrontLight.setIntensity -function KoboFrontLight:setIntensity(intensity) +function KoboFrontLight:setIntensityHW() if self.fl ~= nil then - self:intensityCheckBounds(intensity) self.fl:setBrightness(self.intensity) end end diff --git a/frontend/ui/inputevent.lua b/frontend/ui/inputevent.lua index eb003e594..5ffb56269 100644 --- a/frontend/ui/inputevent.lua +++ b/frontend/ui/inputevent.lua @@ -270,7 +270,7 @@ function Input:init() self.event_map[10020] = "Charging" self.event_map[10021] = "NotCharging" - if util.isEmulated() == 1 then + if util.isEmulated() then self:initKeyMap() os.remove("/tmp/emu_event") os.execute("mkfifo /tmp/emu_event") diff --git a/koreader-base b/koreader-base index cc5b399fb..bc556f656 160000 --- a/koreader-base +++ b/koreader-base @@ -1 +1 @@ -Subproject commit cc5b399fb29e2a08105dcad38c5e6833225fcf9c +Subproject commit bc556f656b0a0f3ca211d7000ea99ec04d947494 diff --git a/reader.lua b/reader.lua index 88817a98a..f430e7cb2 100755 --- a/reader.lua +++ b/reader.lua @@ -24,7 +24,7 @@ function exitReader() input.closeAll() - if util.isEmulated() == 0 then + if not util.isEmulated() then if Device:isKindle3() or (Device:getModel() == "KindleDXG") then -- send double menu key press events to trigger screen refresh os.execute("echo 'send 139' > /proc/keypad;echo 'send 139' > /proc/keypad")