mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
Merge pull request #440 from houqp/new_ui_code
one bug fix and add paperwhite detection
This commit is contained in:
@@ -3,6 +3,34 @@ 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
|
||||
local ret = os.execute("grep 'Hardware : Mario Platform' /proc/cpuinfo", "r")
|
||||
if ret ~= 0 then
|
||||
return nil
|
||||
else
|
||||
return "KindleDXG"
|
||||
end
|
||||
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)
|
||||
return "Kindle3"
|
||||
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")
|
||||
local dev_mod = Device:getModel()
|
||||
|
||||
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
|
||||
|
||||
if Device:isKindle4() then
|
||||
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
|
||||
|
||||
2
input.c
2
input.c
@@ -77,7 +77,7 @@ static int openInputDevice(lua_State *L) {
|
||||
return luaL_error(L, "no free slot for new input device <%s>", inputdevice);
|
||||
}
|
||||
|
||||
if(!strcmp("slider",inputdevice)) {
|
||||
if(!strcmp("fake_events", inputdevice)) {
|
||||
/* special case: the power slider */
|
||||
int pipefd[2];
|
||||
int childpid;
|
||||
|
||||
Reference in New Issue
Block a user