rewrite device detection

pull/2/merge
Qingping Hou 12 years ago
parent 1adc84c2ac
commit 2985d27569

@ -3,6 +3,35 @@ Device = {
charging_mode = false,
}
function Device:getModel()
local std_out = io.popen("grep 'MX' /proc/cpuinfo | cut -d':' -f2 | awk {'print $2'}", "r")
local cpu_mod = std_out:read()
if not cpu_mod then
return nil
end
if cpu_mod == "MX50" then
local f = lfs.attributes("/sys/devices/system/fl_tps6116x/fl_tps6116x0/fl_intensity")
if f then
return "KindlePaperWhite"
else
return "Kindle4"
end
elseif cpu_mod == "MX35" then
-- check if we are running on Kindle 3 (additional volume input)
local f = lfs.attributes("/dev/input/event2")
if f then
return "Kindle3"
else
return "KindleDXG"
end
elseif cpu_mod == "MX3" then
return "Kindle2"
else
return nil
end
end
function Device:isKindle4()
re_val = os.execute("cat /proc/cpuinfo | grep MX50")
if re_val == 0 then

@ -230,21 +230,27 @@ function Input:init()
self.event_map = self.sdl_event_map
else
input.open("fake_events")
input.open("/dev/input/event0")
input.open("/dev/input/event1")
-- check if we are running on Kindle 3 (additional volume input)
local f=lfs.attributes("/dev/input/event2")
if f then
input.open("/dev/input/event2")
if Device:isKindle3() then
print("Auto-detected Kindle 3")
end
end
local dev_mod = Device:getModel()
if Device:isKindle4() then
input.open("/dev/input/event0")
if dev_mod ~= "KindlePaperWhite" then
-- we don't have event1 in KindlePaperWhite
input.open("/dev/input/event1")
elseif dev_mod == "KindlePaperWhite" then
print("Auto-detected Kindle PaperWhite")
elseif dev_mod == "Kindle4" then
print("Auto-detected Kindle 4")
self:adjustKindle4EventMap()
elseif dev_mod == "Kindle3" then
input.open("/dev/input/event2")
print("Auto-detected Kindle 3")
elseif dev_mod == "KindleDXG" then
print("Auto-detected Kindle DXG")
elseif dev_mod == "Kindle2" then
print("Auto-detected Kindle 2")
else
print("Not supported device model!")
os.exit(-1)
end
end
end

Loading…
Cancel
Save