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"]
path = koreader-base
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)
INSTALL_DIR=koreader-$(MACHINE)
ANDROID_LAUNCHER_DIR:=android/luajit-launcher
# files to link from main directory
INSTALL_FILES=reader.lua frontend resources defaults.lua l10n \
git-rev README.md COPYING
@ -97,7 +99,8 @@ kindleupdate: all
zip -9 -r \
../koreader-kindle-$(MACHINE)-$(VERSION).zip \
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)
koboupdate: all
@ -119,11 +122,17 @@ koboupdate: all
zip -9 -r \
../koreader-kobo-$(MACHINE)-$(VERSION).zip \
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:
cd $(INSTALL_DIR)/koreader && \
7z a -l -mx=5 ../koreader-g$(REVISION).7z *
androidupdate: all
mkdir -p $(ANDROID_LAUNCHER_DIR)/assets/module
-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:
$(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 isAndroid, android = pcall(require, "android")
local Dbg = {
is_on = false,
@ -16,7 +17,11 @@ local function LvDEBUG(lv, ...)
line = line .. " " .. tostring(v)
end
end
print("#"..line)
if isAndroid then
android.LOGI("#"..line)
else
print("#"..line)
end
end
function Dbg_mt.__call(dbg, ...)
@ -27,8 +32,10 @@ function Dbg:turnOn()
self.is_on = true
-- create or clear ev log file
os.execute("echo > ev.log")
self.ev_log = io.open("ev.log", "w")
if not isAndroid then
os.execute("echo > ev.log")
self.ev_log = io.open("ev.log", "w")
end
end
function Dbg:logEv(ev)

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

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

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