From 88c2307c142486389c020e68d4dc1a6f5bd257f6 Mon Sep 17 00:00:00 2001 From: chrox Date: Mon, 25 Nov 2013 23:30:44 +0800 Subject: [PATCH] fix kindle paperwhite2 support reported at http://www.mobileread.com/forums/showpost.php?p=2696481&postcount=316 tested at http://www.hi-pda.com/forum/redirect.php?goto=findpost&ptid=1078988&pid=23393929 --- frontend/ui/device.lua | 24 +++++++++++++++---- frontend/ui/input.lua | 24 ++++++++++--------- .../ui/reader/readeractivityindicator.lua | 2 +- 3 files changed, 33 insertions(+), 17 deletions(-) diff --git a/frontend/ui/device.lua b/frontend/ui/device.lua index 99bccbfc9..8b5536ca9 100644 --- a/frontend/ui/device.lua +++ b/frontend/ui/device.lua @@ -13,6 +13,9 @@ local Device = { model = nil, firmware_rev = nil, frontlight = nil, + has_no_keyboard = nil, + is_touch_device = nil, + has_front_light = nil, screen = Screen } @@ -60,7 +63,7 @@ function Device:getModel() elseif pw_set[kindle_devcode] then self.model = "KindlePaperWhite" elseif pw2_set[kindle_devcode] then - self.model = "KindlePaperWhite" + self.model = "KindlePaperWhite2" end else local kg_test_fd = lfs.attributes("/bin/kobo_config.sh") @@ -98,8 +101,11 @@ function Device:isKobo() end function Device:hasNoKeyboard() + if self.has_no_keyboard ~= nil then return self.has_no_keyboard end local model = self:getModel() - return (model == "KindlePaperWhite") or (model == "KindleTouch") or self:isKobo() + self.has_no_keyboard = (model == "KindlePaperWhite") or (model == "KindlePaperWhite2") + or (model == "KindleTouch") or self:isKobo() + return self.has_no_keyboard end function Device:hasKeyboard() @@ -107,13 +113,20 @@ function Device:hasKeyboard() end function Device:isTouchDevice() + if self.is_touch_device ~= nil then return self.is_touch_device end local model = self:getModel() - return (model == "KindlePaperWhite") or (model == "KindleTouch") or self:isKobo() or util.isEmulated() + self.is_touch_device = (model == "KindlePaperWhite") or (model == "KindlePaperWhite2") + or (model == "KindleTouch") or self:isKobo() or util.isEmulated() + return self.is_touch_device end function Device:hasFrontlight() + if self.has_front_light ~= nil then return self.has_front_light end local model = self:getModel() - return (model == "KindlePaperWhite") or (model == "Kobo_dragon") or (model == "Kobo_kraken") or (model == "Kobo_phoenix") or util.isEmulated() + self.has_front_light = (model == "KindlePaperWhite") or (model == "KindlePaperWhite2") + or (model == "Kobo_dragon") or (model == "Kobo_kraken") or (model == "Kobo_phoenix") + or util.isEmulated() + return self.has_front_light end function Device:setTouchInputDev(dev) @@ -206,7 +219,8 @@ function Device:getFrontlight() if self.frontlight ~= nil then return self.frontlight elseif self:hasFrontlight() then - if self:getModel() == "KindlePaperWhite" then + local model = self:getModel() + if model == "KindlePaperWhite" or model == "KindlePaperWhite2" then self.frontlight = KindleFrontLight elseif self:isKobo() then self.frontlight = KoboFrontLight diff --git a/frontend/ui/input.lua b/frontend/ui/input.lua index 0c9955523..018569e9a 100644 --- a/frontend/ui/input.lua +++ b/frontend/ui/input.lua @@ -282,19 +282,17 @@ function Input:init() if not Device:isKobo() then input.open("fake_events") end - if dev_mod ~= "KindleTouch" and not Device:isKobo() then - -- event0 in KindleTouch is "WM8962 Beep Generator" (useless) - Device:setTouchInputDev("/dev/input/event0") - input.open("/dev/input/event0") - end - if dev_mod ~= "KindleTouch" and dev_mod ~= "KindlePaperWhite" then - -- event1 in KindleTouch is "imx-yoshi Headset" (useless) - -- and we don't have event1 in KindlePaperWhite - input.open("/dev/input/event1") - end if dev_mod == "KindlePaperWhite" then print(_("Auto-detected Kindle PaperWhite")) + Device:setTouchInputDev("/dev/input/event0") + input.open("/dev/input/event0") + elseif dev_mod == "KindlePaperWhite2" then + print(_("Auto-detected Kindle PaperWhite")) + Device:setTouchInputDev("/dev/input/event1") + input.open("/dev/input/event1") elseif dev_mod == "KindleTouch" then + -- event0 in KindleTouch is "WM8962 Beep Generator" (useless) + -- event1 in KindleTouch is "imx-yoshi Headset" (useless) Device:setTouchInputDev("/dev/input/event3") input.open("/dev/input/event2") -- Home button input.open("/dev/input/event3") -- touchscreen @@ -370,14 +368,18 @@ function Input:init() end elseif dev_mod == "Kindle4" then print(_("Auto-detected Kindle 4")) + input.open("/dev/input/event1") self:adjustKindle4EventMap() elseif dev_mod == "Kindle3" then - input.open("/dev/input/event2") print(_("Auto-detected Kindle 3")) + input.open("/dev/input/event1") + input.open("/dev/input/event2") elseif dev_mod == "KindleDXG" then print(_("Auto-detected Kindle DXG")) + input.open("/dev/input/event1") elseif dev_mod == "Kindle2" then print(_("Auto-detected Kindle 2")) + input.open("/dev/input/event1") else print(_("Not supported device model!")) os.exit(-1) diff --git a/frontend/ui/reader/readeractivityindicator.lua b/frontend/ui/reader/readeractivityindicator.lua index 64a44c7b0..14ca25b33 100644 --- a/frontend/ui/reader/readeractivityindicator.lua +++ b/frontend/ui/reader/readeractivityindicator.lua @@ -6,7 +6,7 @@ local ReaderActivityIndicator = EventListener:new{} function ReaderActivityIndicator:init() local dev_mod = Device:getModel() - if dev_mod == "KindlePaperWhite" or dev_mod == "KindleTouch" then + if dev_mod == "KindlePaperWhite" or dev_mod == "KindlePaperWhite2" or dev_mod == "KindleTouch" then require "liblipclua" self.lipc_handle = lipc.init("com.github.koreader.activityindicator") end