From 5c4651a3d9b50ac81c65ba5a0fc7a124469657c5 Mon Sep 17 00:00:00 2001 From: chrox Date: Sat, 17 Jan 2015 09:09:36 +0800 Subject: [PATCH] auto launch koreader when opening PDF/DJVU/EPUB/FB2 files in pocketbook --- Makefile | 26 +++++++++---- README.md | 12 +++++- base | 2 +- frontend/device/pocketbook/device.lua | 56 ++++++++++++++------------- platform/pocketbook/extensions.cfg | 10 +++++ platform/pocketbook/koreader.app | 10 ++++- 6 files changed, 79 insertions(+), 37 deletions(-) create mode 100644 platform/pocketbook/extensions.cfg diff --git a/Makefile b/Makefile index d41e9d94e..34f5687bb 100644 --- a/Makefile +++ b/Makefile @@ -9,8 +9,13 @@ KOR_BASE?=base VERSION=$(shell git describe HEAD) REVISION=$(shell git rev-parse --short HEAD) -# subdirectory we use to build the installation bundle -export PATH:=$(CURDIR)/$(KOR_BASE)/toolchain/android-toolchain/bin:$(PATH) +# set PATH to find CC in managed toolchains +ifeq ($(TARGET), android) + PATH:=$(CURDIR)/$(KOR_BASE)/$(ANDROID_TOOLCHAIN)/bin:$(PATH) +else ifeq ($(TARGET), pocketbook) + PATH:=$(CURDIR)/$(KOR_BASE)/$(POCKETBOOK_TOOLCHAIN)/bin:$(PATH) +endif + MACHINE?=$(shell PATH=$(PATH) $(CC) -dumpmachine 2>/dev/null) INSTALL_DIR=koreader-$(MACHINE) @@ -187,24 +192,31 @@ pbupdate: all rm -f koreader-pocketbook-$(MACHINE)-$(VERSION).zip # Pocketbook launching script mkdir -p $(INSTALL_DIR)/applications + mkdir -p $(INSTALL_DIR)/system/bin + mkdir -p $(INSTALL_DIR)/system/config + cp $(POCKETBOOK_DIR)/koreader.app $(INSTALL_DIR)/applications + cp $(POCKETBOOK_DIR)/koreader.app $(INSTALL_DIR)/system/bin + cp $(POCKETBOOK_DIR)/extensions.cfg $(INSTALL_DIR)/system/config + cp -rfL $(INSTALL_DIR)/koreader $(INSTALL_DIR)/applications # create new package cd $(INSTALL_DIR) && \ zip -9 -r \ ../koreader-pocketbook-$(MACHINE)-$(VERSION).zip \ - koreader applications -x "koreader/resources/fonts/*" \ + applications system -x "koreader/resources/fonts/*" \ "koreader/resources/icons/src/*" "koreader/spec/*" # generate koboupdate package index file zipinfo -1 koreader-pocketbook-$(MACHINE)-$(VERSION).zip > \ - $(INSTALL_DIR)/koreader/ota/package.index - echo "koreader/ota/package.index" >> $(INSTALL_DIR)/koreader/ota/package.index + $(INSTALL_DIR)/applications/koreader/ota/package.index + echo "applications/koreader/ota/package.index" >> \ + $(INSTALL_DIR)/applications/koreader/ota/package.index # update index file in zip package cd $(INSTALL_DIR) && zip -u ../koreader-pocketbook-$(MACHINE)-$(VERSION).zip \ - koreader/ota/package.index + applications/koreader/ota/package.index # make gzip pbupdate for zsync OTA update cd $(INSTALL_DIR) && \ tar czafh ../koreader-pocketbook-$(MACHINE)-$(VERSION).tar.gz \ - -T koreader/ota/package.index --no-recursion + -T applications/koreader/ota/package.index --no-recursion androidupdate: all mkdir -p $(ANDROID_LAUNCHER_DIR)/assets/module diff --git a/README.md b/README.md index 7b1c3c4f3..a5b7151d2 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ KOReader KOReader is a document viewer application, originally created for Kindle e-ink readers. It currently runs on Kindle 5 (Touch), Kindle Paperwhite, -Kobo and Android (2.3+) devices. Developers can also run Koreader emulator +Kobo, PocketBook 840 and Android (2.3+) devices. Developers can also run Koreader emulator for development purpose on desktop PC with Linux or Windows operating system. Main features for users @@ -120,6 +120,16 @@ To build installable package for Kobo: make TARGET=kobo clean koboupdate ``` +To build installable package for PocketBook you need first to obtain the SDK +from PocketBook: +``` +make pocketbook-toolchain +``` +then similarly with Kindle and Kobo building run this command: +``` +make TARGET=pocketbook clean pbupdate +``` + To run, you must call the script `reader.lua`. Run it without arguments to see usage notes. Note that the script and the `luajit` binary must be in the same directory. diff --git a/base b/base index 64ed78a30..877d3b55c 160000 --- a/base +++ b/base @@ -1 +1 @@ -Subproject commit 64ed78a30fd240216123543dd8267ec08c43b70f +Subproject commit 877d3b55cb3d687de2a2e4422395e6624c202c60 diff --git a/frontend/device/pocketbook/device.lua b/frontend/device/pocketbook/device.lua index 3d69ce409..e66f67f70 100644 --- a/frontend/device/pocketbook/device.lua +++ b/frontend/device/pocketbook/device.lua @@ -11,6 +11,8 @@ local EVT_KEYPRESS = 25 local EVT_KEYUP = 26 local EVT_KEYRELEASE = 26 local EVT_KEYREPEAT = 28 +local EVT_FOREGROUND = 151 +local EVT_BACKGROUND = 152 local KEY_POWER = 0x01 local KEY_DELETE = 0x08 @@ -34,50 +36,52 @@ local KEY_COVERCLOSE = 0x03 local function yes() return true end local PocketBook = Generic:new{ - -- both the following are just for testing similar behaviour - -- see ffi/framebuffer_mxcfb.lua model = "PocketBook", isPocketBook = yes, - - isTouchDevice = yes, - display_dpi = 212, - touch_dev = "/dev/input/event1", -- probably useless - emu_events_dev = "/var/dev/shm/emu_events", + isInBackGroud = false, } function PocketBook:init() - -- this example uses the mxcfb framebuffer driver: - self.screen = require("ffi/framebuffer_mxcfb"):new{device = self, debug = DEBUG} - - self.input = require("device/input"):new{ - device = self, - debug = DEBUG, - event_map = { - [25] = "LPgBack", - [24] = "LPgFwd", - [1002] = "Power", - } - } - -- we inject an input hook for debugging purposes. You probably don't want - -- it after everything is implemented. self.input:registerEventAdjustHook(function(_input, ev) DEBUG("ev", ev) if ev.type == EVT_KEYDOWN or ev.type == EVT_KEYUP then ev.code = ev.code ev.value = ev.type == EVT_KEYDOWN and 1 or 0 ev.type = 1 -- EV_KEY + elseif ev.type == EVT_BACKGROUND then + isInBackGroud = true + self:onPowerEvent("Power") + elseif isInBackGroud and ev.type == EVT_FOREGROUND then + isInBackGroud = false + self:onPowerEvent("Power") end end) - -- no backlight management yet - os.remove(self.emu_events_dev) os.execute("mkfifo " .. self.emu_events_dev) self.input.open(self.emu_events_dev, 1) Generic.init(self) end --- maybe additional implementations are needed for other models, --- testing on PocketBook Lux 2 for now. +local PocketBook840 = PocketBook:new{ + isTouchDevice = yes, + hasKeys = yes, + display_dpi = 250, + emu_events_dev = "/var/dev/shm/emu_events", +} + +function PocketBook840:init() + self.screen = require("ffi/framebuffer_mxcfb"):new{device = self, debug = DEBUG} + self.input = require("device/input"):new{ + device = self, + event_map = { + [25] = "LPgBack", + [24] = "LPgFwd", + [1002] = "Power", + } + } + PocketBook.init(self) +end -return PocketBook +-- should check device model before return to support other PocketBook models +return PocketBook840 diff --git a/platform/pocketbook/extensions.cfg b/platform/pocketbook/extensions.cfg new file mode 100644 index 000000000..5977d0ee0 --- /dev/null +++ b/platform/pocketbook/extensions.cfg @@ -0,0 +1,10 @@ +pdf:@PDF_file:1:koreader.app:ICON_PDF +djvu:@DJVU_file:1:koreader.app:ICON_DJVU +epub:@EPUB_file:1:koreader.app:ICON_EPUB +fb2:@FB2_file:1:koreader.app:ICON_FB2 +mobi:@MOBI_file:1:koreader.app:ICON_MOBI +zip:@ZIP_file:1:koreader.app:ICON_ZIP +cbz:@ZIP_file:1:koreader.app:ICON_ZIP + + + diff --git a/platform/pocketbook/koreader.app b/platform/pocketbook/koreader.app index 7ecea0c2b..60e09e8b1 100755 --- a/platform/pocketbook/koreader.app +++ b/platform/pocketbook/koreader.app @@ -2,7 +2,7 @@ export LC_ALL="en_US.UTF-8" # working directory of koreader -KOREADER_DIR=/mnt/ext1/koreader +KOREADER_DIR=/mnt/ext1/applications/koreader # update to new version from OTA directory NEWUPDATE="${KOREADER_DIR}/ota/koreader.updated.tar" @@ -21,7 +21,13 @@ export TESSDATA_PREFIX="data" # export dict directory export STARDICT_DATA_DIR="data/dict" -./reader.lua /mnt/ext1 2> crash.log +if [ `echo $@ | wc -c` -eq 1 ]; then + args="/mnt/ext1/" +else + args="$@" +fi + +./reader.lua "$args" 2> crash.log if pidof reader.lua > /dev/null 2>&1 ; then killall -TERM reader.lua