2012-06-13 17:52:08 +00:00
|
|
|
Device = {
|
|
|
|
screen_saver_mode = false,
|
|
|
|
charging_mode = false,
|
2013-03-17 11:33:59 +00:00
|
|
|
survive_screen_saver = false,
|
|
|
|
touch_dev = nil,
|
2012-12-11 00:01:32 +00:00
|
|
|
model = nil,
|
2012-06-13 17:52:08 +00:00
|
|
|
}
|
|
|
|
|
2012-10-14 06:22:01 +00:00
|
|
|
function Device:getModel()
|
2013-04-30 05:47:30 +00:00
|
|
|
if self.model then return self.model end
|
2013-07-10 07:10:38 +00:00
|
|
|
if util.isEmulated()==1 then
|
|
|
|
self.model = "Emulator"
|
|
|
|
return self.model
|
|
|
|
end
|
2012-10-14 06:22:01 +00:00
|
|
|
local std_out = io.popen("grep 'MX' /proc/cpuinfo | cut -d':' -f2 | awk {'print $2'}", "r")
|
2013-04-07 08:33:58 +00:00
|
|
|
local cpu_mod = std_out:read()
|
2012-10-14 06:22:01 +00:00
|
|
|
if not cpu_mod then
|
2012-10-14 18:32:08 +00:00
|
|
|
local ret = os.execute("grep 'Hardware : Mario Platform' /proc/cpuinfo", "r")
|
|
|
|
if ret ~= 0 then
|
2013-04-30 05:47:30 +00:00
|
|
|
self.model = nil
|
2012-10-14 18:32:08 +00:00
|
|
|
else
|
2013-04-30 05:47:30 +00:00
|
|
|
self.model = "KindleDXG"
|
2012-10-14 18:32:08 +00:00
|
|
|
end
|
2012-10-14 06:22:01 +00:00
|
|
|
end
|
|
|
|
if cpu_mod == "MX50" then
|
2012-12-08 06:06:47 +00:00
|
|
|
-- for KPW
|
|
|
|
local pw_test_fd = lfs.attributes("/sys/devices/system/fl_tps6116x/fl_tps6116x0/fl_intensity")
|
2013-06-11 19:54:36 +00:00
|
|
|
-- for Kobo
|
|
|
|
local kg_test_fd = lfs.attributes("/bin/kobo_config.sh")
|
2012-12-08 06:06:47 +00:00
|
|
|
-- for KT
|
|
|
|
local kt_test_fd = lfs.attributes("/sys/devices/platform/whitney-button")
|
|
|
|
-- another special file for KT is Neonode zForce touchscreen:
|
|
|
|
-- /sys/devices/platform/zforce.0/
|
|
|
|
if pw_test_fd then
|
2013-04-30 05:47:30 +00:00
|
|
|
self.model = "KindlePaperWhite"
|
2013-06-11 19:54:36 +00:00
|
|
|
elseif kg_test_fd then
|
2013-07-10 07:10:38 +00:00
|
|
|
local std_out = io.popen("/bin/kobo_config.sh", "r")
|
|
|
|
local codename = std_out:read()
|
|
|
|
self.model = "Kobo_" .. codename
|
2012-12-08 06:06:47 +00:00
|
|
|
elseif kt_test_fd then
|
2013-04-30 05:47:30 +00:00
|
|
|
self.model = "KindleTouch"
|
2012-10-14 06:22:01 +00:00
|
|
|
else
|
2013-04-30 05:47:30 +00:00
|
|
|
self.model = "Kindle4"
|
2012-10-14 06:22:01 +00:00
|
|
|
end
|
|
|
|
elseif cpu_mod == "MX35" then
|
|
|
|
-- check if we are running on Kindle 3 (additional volume input)
|
2013-04-30 05:47:30 +00:00
|
|
|
self.model = "Kindle3"
|
2012-10-14 06:22:01 +00:00
|
|
|
elseif cpu_mod == "MX3" then
|
2013-04-30 05:47:30 +00:00
|
|
|
self.model = "Kindle2"
|
2012-10-14 06:22:01 +00:00
|
|
|
else
|
2013-04-30 05:47:30 +00:00
|
|
|
self.model = nil
|
2012-10-14 06:22:01 +00:00
|
|
|
end
|
2013-04-30 05:47:30 +00:00
|
|
|
return self.model
|
2012-10-14 06:22:01 +00:00
|
|
|
end
|
|
|
|
|
2012-06-13 17:52:08 +00:00
|
|
|
function Device:isKindle4()
|
2012-12-12 02:03:16 +00:00
|
|
|
return (self:getModel() == "Kindle4")
|
2012-06-13 13:27:38 +00:00
|
|
|
end
|
|
|
|
|
2012-06-13 17:52:08 +00:00
|
|
|
function Device:isKindle3()
|
2012-06-13 13:27:38 +00:00
|
|
|
re_val = os.execute("cat /proc/cpuinfo | grep MX35")
|
|
|
|
if re_val == 0 then
|
|
|
|
return true
|
|
|
|
else
|
|
|
|
return false
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-06-13 17:52:08 +00:00
|
|
|
function Device:isKindle2()
|
2012-06-13 13:27:38 +00:00
|
|
|
re_val = os.execute("cat /proc/cpuinfo | grep MX3")
|
|
|
|
if re_val == 0 then
|
|
|
|
return true
|
|
|
|
else
|
|
|
|
return false
|
|
|
|
end
|
|
|
|
end
|
2012-06-13 17:52:08 +00:00
|
|
|
|
2013-07-10 07:10:38 +00:00
|
|
|
function Device:isKobo()
|
|
|
|
if not self.model then
|
|
|
|
self.model = self:getModel()
|
|
|
|
end
|
|
|
|
re_val = string.find(self.model,"Kobo_")
|
|
|
|
if re_val == 1 then
|
|
|
|
return true
|
|
|
|
else
|
|
|
|
return false
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-12-11 00:01:32 +00:00
|
|
|
function Device:hasNoKeyboard()
|
|
|
|
if not self.model then
|
|
|
|
self.model = self:getModel()
|
|
|
|
end
|
|
|
|
return self:isTouchDevice() or (self.model == "Kindle4")
|
|
|
|
end
|
|
|
|
|
2013-01-01 01:44:52 +00:00
|
|
|
function Device:hasKeyboard()
|
|
|
|
return not self:hasNoKeyboard()
|
|
|
|
end
|
|
|
|
|
2012-11-11 07:24:11 +00:00
|
|
|
function Device:isTouchDevice()
|
2012-12-11 00:01:32 +00:00
|
|
|
if not self.model then
|
|
|
|
self.model = self:getModel()
|
|
|
|
end
|
2013-07-10 07:10:38 +00:00
|
|
|
return (self.model == "KindlePaperWhite") or (self.model == "KindleTouch") or self:isKobo() or util.isEmulated()
|
2012-11-11 07:24:11 +00:00
|
|
|
end
|
|
|
|
|
2013-03-17 11:33:59 +00:00
|
|
|
function Device:setTouchInputDev(dev)
|
|
|
|
self.touch_dev = dev
|
|
|
|
end
|
|
|
|
|
|
|
|
function Device:getTouchInputDev()
|
|
|
|
return self.touch_dev
|
|
|
|
end
|
|
|
|
|
2012-06-13 17:52:08 +00:00
|
|
|
function Device:intoScreenSaver()
|
|
|
|
--os.execute("echo 'screensaver in' >> /mnt/us/event_test.txt")
|
|
|
|
if self.charging_mode == false and self.screen_saver_mode == false then
|
|
|
|
Screen:saveCurrentBB()
|
2013-02-02 08:37:48 +00:00
|
|
|
--UIManager:show(InfoMessage:new{
|
|
|
|
--text = "Going into screensaver... ",
|
|
|
|
--timeout = 2,
|
|
|
|
--})
|
2013-01-10 06:23:11 +00:00
|
|
|
--util.sleep(1)
|
|
|
|
--os.execute("killall -cont cvm")
|
2012-06-13 17:52:08 +00:00
|
|
|
self.screen_saver_mode = true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
function Device:outofScreenSaver()
|
|
|
|
--os.execute("echo 'screensaver out' >> /mnt/us/event_test.txt")
|
|
|
|
if self.screen_saver_mode == true and self.charging_mode == false then
|
2013-02-02 08:37:48 +00:00
|
|
|
-- wait for native system update screen before we recover saved
|
|
|
|
-- Blitbuffer.
|
|
|
|
util.usleep(1500000)
|
2013-01-10 06:23:11 +00:00
|
|
|
--os.execute("killall -stop cvm")
|
2012-06-13 17:52:08 +00:00
|
|
|
Screen:restoreFromSavedBB()
|
2013-02-02 06:36:29 +00:00
|
|
|
Screen:refresh(0)
|
2013-03-17 11:33:59 +00:00
|
|
|
self.survive_screen_saver = true
|
2012-06-13 17:52:08 +00:00
|
|
|
end
|
|
|
|
self.screen_saver_mode = false
|
|
|
|
end
|
|
|
|
|
|
|
|
function Device:usbPlugIn()
|
|
|
|
--os.execute("echo 'usb in' >> /mnt/us/event_test.txt")
|
|
|
|
if self.charging_mode == false and self.screen_saver_mode == false then
|
|
|
|
Screen:saveCurrentBB()
|
2013-02-02 08:37:48 +00:00
|
|
|
--UIManager:show(InfoMessage:new{
|
2013-04-07 08:33:58 +00:00
|
|
|
--text = "Going into USB mode... ",
|
2013-02-02 08:37:48 +00:00
|
|
|
--timeout = 2,
|
|
|
|
--})
|
2013-02-02 06:36:29 +00:00
|
|
|
--util.sleep(1)
|
|
|
|
--os.execute("killall -cont cvm")
|
2012-06-13 17:52:08 +00:00
|
|
|
end
|
|
|
|
self.charging_mode = true
|
|
|
|
end
|
|
|
|
|
|
|
|
function Device:usbPlugOut()
|
|
|
|
--os.execute("echo 'usb out' >> /mnt/us/event_test.txt")
|
|
|
|
if self.charging_mode == true and self.screen_saver_mode == false then
|
2013-02-02 06:36:29 +00:00
|
|
|
--util.usleep(1500000)
|
|
|
|
--os.execute("killall -stop cvm")
|
2012-06-13 17:52:08 +00:00
|
|
|
Screen:restoreFromSavedBB()
|
2013-02-02 06:36:29 +00:00
|
|
|
Screen:refresh(0)
|
2012-06-13 17:52:08 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
--@TODO signal filemanager for file changes 13.06 2012 (houqp)
|
|
|
|
self.charging_mode = false
|
|
|
|
end
|