NOT WORKING initial kobo light support.

pull/174/head
Giorgio Micotti 11 years ago
parent ad4468aa4e
commit e4b8fc3266

@ -3,6 +3,7 @@ require "ui/device"
require "ui/time"
require "ui/gesturedetector"
require "ui/geometry"
require "ui/reader/readerfrontlight"
-- constants from <linux/input.h>
EV_SYN = 0
@ -318,6 +319,7 @@ function Input:init()
Device:setTouchInputDev("/dev/input/event1")
input.open("/dev/input/event0") -- Light button and sleep slider
print(_("Auto-detected Kobo"))
self:adjustKoboEventMap()
if dev_mod ~= 'Kobo_trilogy' then
function Input:eventAdjustHook(ev)
if ev.type == EV_ABS then
@ -368,6 +370,12 @@ function Input:adjustKindle4EventMap()
self.event_map[104] = "LPgFwd"
end
function Input:adjustKoboEventMap()
self.event_map[53] = "Power"
self.event_map[90] = "Light"
self.event_map[116] = "Power"
end
function Input:setTimeout(cb, tv_out)
local item = {
callback = cb,
@ -401,6 +409,10 @@ function Input:handleKeyBoardEv(ev)
return keycode
end
if keycode == "Light" then
ReaderFrontLight:toggle()
end
-- handle modifier keys
if self.modifiers[keycode] ~= nil then
if ev.value == EVENT_VALUE_KEY_PRESS then

@ -3,6 +3,7 @@ require "ui/device"
ReaderFrontLight = InputContainer:new{
steps = {0,1,2,3,4,5,6,7,8,9,10},
intensity = nil,
ld = nil,
}
function ReaderFrontLight:init()
@ -13,20 +14,23 @@ function ReaderFrontLight:init()
if self.lipc_handle then
self.intensity = self.lipc_handle:get_int_property("com.lab126.powerd", "flIntensity")
end
self.ges_events = {
Adjust = {
GestureRange:new{
ges = "two_finger_pan",
range = Geom:new{
x = 0, y = 0,
w = Screen:getWidth(),
h = Screen:getHeight(),
},
rate = 2.0,
}
},
}
end
if Device:isKobo() then
self.ld = kobolight.open()
end
self.ges_events = {
Adjust = {
GestureRange:new{
ges = "two_finger_pan",
range = Geom:new{
x = 0, y = 0,
w = Screen:getWidth(),
h = Screen:getHeight(),
},
rate = 2.0,
}
},
}
end
function ReaderFrontLight:onAdjust(arg, ges)
@ -57,5 +61,22 @@ function ReaderFrontLight:setIntensity(intensity, msg)
timeout = 1
})
end
if Device:isKobo() then
if self.ld == nil then
return true
end
self.intensity = intensity
self.ld:setBrightness(intensity)
end
return true
end
function ReaderFrontLight:toggle()
if Device:isKobo() then
if self.ld == nil then
return true
end
self.ld:toggle()
end
return true
end

@ -1 +1 @@
Subproject commit d45c0ac4b1f4801e193d0bc9a6c3759989dec7c2
Subproject commit 3c9f2c1fae326ffafcc82de1f021c9c0ea2391e9
Loading…
Cancel
Save