From 1adc84c2ac277a9935b77466f84fe13098696dae Mon Sep 17 00:00:00 2001 From: Qingping Hou Date: Sun, 14 Oct 2012 13:49:35 +0800 Subject: [PATCH 1/3] rename slider event to fake_events again --- input.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/input.c b/input.c index 06e1ce785..ca5a0a915 100644 --- a/input.c +++ b/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; From 2985d2756908cb761a5597f3469ffd6c17c47035 Mon Sep 17 00:00:00 2001 From: Qingping Hou Date: Sun, 14 Oct 2012 14:22:01 +0800 Subject: [PATCH 2/3] rewrite device detection --- frontend/ui/device.lua | 29 +++++++++++++++++++++++++++++ frontend/ui/inputevent.lua | 30 ++++++++++++++++++------------ 2 files changed, 47 insertions(+), 12 deletions(-) diff --git a/frontend/ui/device.lua b/frontend/ui/device.lua index f480ac46e..90295c98a 100644 --- a/frontend/ui/device.lua +++ b/frontend/ui/device.lua @@ -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 diff --git a/frontend/ui/inputevent.lua b/frontend/ui/inputevent.lua index 3f2674d69..3dad29fbe 100644 --- a/frontend/ui/inputevent.lua +++ b/frontend/ui/inputevent.lua @@ -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 From 54b33bd6a7853653f74d33e6cf3e22d5193bbb64 Mon Sep 17 00:00:00 2001 From: Qingping Hou Date: Sun, 14 Oct 2012 14:32:08 -0400 Subject: [PATCH 3/3] fix DXG detection --- frontend/ui/device.lua | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/frontend/ui/device.lua b/frontend/ui/device.lua index 90295c98a..813fc1520 100644 --- a/frontend/ui/device.lua +++ b/frontend/ui/device.lua @@ -7,9 +7,13 @@ 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 + 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 @@ -19,12 +23,7 @@ function Device:getModel() 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 + return "Kindle3" elseif cpu_mod == "MX3" then return "Kindle2" else