initial commit for android port of koreader

This PR just shows how far we have went to
the android port. There is still a few steps before a running
android port.
pull/591/head
chrox 10 years ago
parent 6fba40cc77
commit 0a4a092d12

3
.gitmodules vendored

@ -1,3 +1,6 @@
[submodule "koreader-base"] [submodule "koreader-base"]
path = koreader-base path = koreader-base
url = git://github.com/koreader/koreader-base.git url = git://github.com/koreader/koreader-base.git
[submodule "android/luajit-launcher"]
path = android/luajit-launcher
url = https://github.com/hwhw/android-luajit-launcher.git

@ -14,6 +14,8 @@ export PATH:=$(CURDIR)/$(KOR_BASE)/toolchain/android-toolchain/bin:$(PATH)
MACHINE?=$(shell PATH=$(PATH) $(CC) -dumpmachine 2>/dev/null) MACHINE?=$(shell PATH=$(PATH) $(CC) -dumpmachine 2>/dev/null)
INSTALL_DIR=koreader-$(MACHINE) INSTALL_DIR=koreader-$(MACHINE)
ANDROID_LAUNCHER_DIR:=android/luajit-launcher
# files to link from main directory # files to link from main directory
INSTALL_FILES=reader.lua frontend resources defaults.lua l10n \ INSTALL_FILES=reader.lua frontend resources defaults.lua l10n \
git-rev README.md COPYING git-rev README.md COPYING
@ -97,7 +99,8 @@ kindleupdate: all
zip -9 -r \ zip -9 -r \
../koreader-kindle-$(MACHINE)-$(VERSION).zip \ ../koreader-kindle-$(MACHINE)-$(VERSION).zip \
extensions koreader launchpad \ extensions koreader launchpad \
-x "koreader/resources/fonts/*" "koreader/resources/icons/src/*" "koreader/spec/*" -x "koreader/resources/fonts/*" \
"koreader/resources/icons/src/*" "koreader/spec/*"
# @TODO write an installation script for KUAL (houqp) # @TODO write an installation script for KUAL (houqp)
koboupdate: all koboupdate: all
@ -119,11 +122,17 @@ koboupdate: all
zip -9 -r \ zip -9 -r \
../koreader-kobo-$(MACHINE)-$(VERSION).zip \ ../koreader-kobo-$(MACHINE)-$(VERSION).zip \
KoboRoot.tgz koreader koreader.png README_kobo.txt \ KoboRoot.tgz koreader koreader.png README_kobo.txt \
-x "koreader/resources/fonts/*" "koreader/resources/icons/src/*" "koreader/spec/*" -x "koreader/resources/fonts/*" \
"koreader/resources/icons/src/*" "koreader/spec/*"
androidupdate: androidupdate: all
cd $(INSTALL_DIR)/koreader && \ mkdir -p $(ANDROID_LAUNCHER_DIR)/assets/module
7z a -l -mx=5 ../koreader-g$(REVISION).7z * -rm $(ANDROID_LAUNCHER_DIR)/assets/module/koreader-*
cd $(INSTALL_DIR)/koreader && 7z a -l -mx=3 \
../../$(ANDROID_LAUNCHER_DIR)/assets/module/koreader-g$(REVISION).7z *
androiddev: androidupdate
$(MAKE) -C $(ANDROID_LAUNCHER_DIR) dev
pot: pot:
$(XGETTEXT_BIN) reader.lua `find frontend -iname "*.lua"` \ $(XGETTEXT_BIN) reader.lua `find frontend -iname "*.lua"` \

@ -0,0 +1 @@
Subproject commit 48e3a1aa4fbe6919e452f2bfee8d620eb79c71d3

@ -1,4 +1,5 @@
local DocSettings = require("docsettings") -- for dump method local DocSettings = require("docsettings") -- for dump method
local isAndroid, android = pcall(require, "android")
local Dbg = { local Dbg = {
is_on = false, is_on = false,
@ -16,7 +17,11 @@ local function LvDEBUG(lv, ...)
line = line .. " " .. tostring(v) line = line .. " " .. tostring(v)
end end
end end
print("#"..line) if isAndroid then
android.LOGI("#"..line)
else
print("#"..line)
end
end end
function Dbg_mt.__call(dbg, ...) function Dbg_mt.__call(dbg, ...)
@ -27,8 +32,10 @@ function Dbg:turnOn()
self.is_on = true self.is_on = true
-- create or clear ev log file -- create or clear ev log file
os.execute("echo > ev.log") if not isAndroid then
self.ev_log = io.open("ev.log", "w") os.execute("echo > ev.log")
self.ev_log = io.open("ev.log", "w")
end
end end
function Dbg:logEv(ev) function Dbg:logEv(ev)

@ -97,7 +97,7 @@ function Device:isKindle2()
end end
function Device:isKobo() function Device:isKobo()
return string.find(self:getModel(),"Kobo_") == 1 return string.find(self:getModel() or "", "Kobo_") == 1
end end
function Device:hasNoKeyboard() function Device:hasNoKeyboard()

@ -4,7 +4,6 @@ local Event = require("ui/event")
local TimeVal = require("ui/timeval") local TimeVal = require("ui/timeval")
local Screen = require("ui/screen") local Screen = require("ui/screen")
local Math = require("optmath") local Math = require("optmath")
local Dbg = require("dbg")
local DEBUG = require("dbg") local DEBUG = require("dbg")
local _ = require("gettext") local _ = require("gettext")
@ -286,11 +285,11 @@ function Input:init()
input.open("fake_events") input.open("fake_events")
end end
if dev_mod == "KindlePaperWhite" then if dev_mod == "KindlePaperWhite" then
print("Auto-detected Kindle PaperWhite") DEBUG("Auto-detected Kindle PaperWhite")
Device:setTouchInputDev("/dev/input/event0") Device:setTouchInputDev("/dev/input/event0")
input.open("/dev/input/event0") input.open("/dev/input/event0")
elseif dev_mod == "KindlePaperWhite2" then elseif dev_mod == "KindlePaperWhite2" then
print("Auto-detected Kindle PaperWhite") DEBUG("Auto-detected Kindle PaperWhite")
Device:setTouchInputDev("/dev/input/event1") Device:setTouchInputDev("/dev/input/event1")
input.open("/dev/input/event1") input.open("/dev/input/event1")
elseif dev_mod == "KindleTouch" then elseif dev_mod == "KindleTouch" then
@ -314,17 +313,11 @@ function Input:init()
end end
return ev return ev
end end
print("Auto-detected Kindle Touch") DEBUG("Auto-detected Kobo")
elseif Device:isKobo() then DEBUG("Device model=", dev_mod)
local firm_rev = Device:getFirmVer() DEBUG("Firmware revision", firm_rev)
input.open("/dev/input/event1") DEBUG("Screen width =", Screen:getWidth())
Device:setTouchInputDev("/dev/input/event1") DEBUG("Screen height =", Screen:getHeight())
input.open("/dev/input/event0") -- Light button and sleep slider
print("Auto-detected Kobo")
print("Device model=", dev_mod)
print("Firmware revision", firm_rev)
print("Screen width =", Screen:getWidth())
print("Screen height =", Screen:getHeight())
self:adjustKoboEventMap() self:adjustKoboEventMap()
if dev_mod ~= 'Kobo_trilogy' then if dev_mod ~= 'Kobo_trilogy' then
function Input:eventAdjustHook(ev) function Input:eventAdjustHook(ev)
@ -374,22 +367,23 @@ function Input:init()
end end
end end
elseif dev_mod == "Kindle4" then elseif dev_mod == "Kindle4" then
print("Auto-detected Kindle 4") DEBUG("Auto-detected Kindle 4")
input.open("/dev/input/event1") input.open("/dev/input/event1")
self:adjustKindle4EventMap() self:adjustKindle4EventMap()
elseif dev_mod == "Kindle3" then elseif dev_mod == "Kindle3" then
print("Auto-detected Kindle 3") DEBUG("Auto-detected Kindle 3")
input.open("/dev/input/event1") input.open("/dev/input/event1")
input.open("/dev/input/event2") input.open("/dev/input/event2")
elseif dev_mod == "KindleDXG" then elseif dev_mod == "KindleDXG" then
print("Auto-detected Kindle DXG") DEBUG("Auto-detected Kindle DXG")
input.open("/dev/input/event1") input.open("/dev/input/event1")
elseif dev_mod == "Kindle2" then elseif dev_mod == "Kindle2" then
print("Auto-detected Kindle 2") DEBUG("Auto-detected Kindle 2")
input.open("/dev/input/event1") input.open("/dev/input/event1")
elseif util.isAndroid() then
DEBUG("Auto-detected Android")
else else
print("Not supported device model!") DEBUG("Not supported device model!")
os.exit(-1)
end end
end end
@ -711,8 +705,8 @@ function Input:waitEvent(timeout_us, timeout_s)
end end
if ok and ev then if ok and ev then
if Dbg.is_on and ev then if DEBUG.is_on and ev then
Dbg:logEv(ev) DEBUG:logEv(ev)
end end
ev = self:eventAdjustHook(ev) ev = self:eventAdjustHook(ev)
if ev.type == EV_KEY then if ev.type == EV_KEY then

@ -1 +1 @@
Subproject commit 648148e3065a1019438f34c7c9b1b47653c0dab7 Subproject commit 0a3acc6bc64fbe42b7072d5100724992faca1514
Loading…
Cancel
Save