mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
Merge pull request #1390 from chrox/master
auto launch koreader when opening PDF/DJVU/EPUB/FB2 files in pocketbook
This commit is contained in:
31
Makefile
31
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/*" \
|
||||
"koreader/resources/icons/src/*" "koreader/spec/*"
|
||||
applications system -x "applications/koreader/resources/fonts/*" \
|
||||
"applications/koreader/resources/icons/src/*" "applications/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
|
||||
@@ -222,6 +234,9 @@ androiddev: androidupdate
|
||||
android-toolchain:
|
||||
$(MAKE) -C $(KOR_BASE) android-toolchain
|
||||
|
||||
pocketbook-toolchain:
|
||||
$(MAKE) -C $(KOR_BASE) pocketbook-toolchain
|
||||
|
||||
pot:
|
||||
mkdir -p $(TEMPLATE_DIR)
|
||||
$(XGETTEXT_BIN) reader.lua `find frontend -iname "*.lua"` \
|
||||
|
||||
12
README.md
12
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.
|
||||
|
||||
2
base
2
base
Submodule base updated: 64ed78a30f...3991f10184
@@ -29,10 +29,10 @@ function ReaderPaging:init()
|
||||
self.key_events = {
|
||||
GotoNextPage = {
|
||||
{Input.group.PgFwd}, doc = "go to next page",
|
||||
event = "GotoPageRel", args = 1 },
|
||||
event = "PagingRel", args = 1 },
|
||||
GotoPrevPage = {
|
||||
{Input.group.PgBack}, doc = "go to previous page",
|
||||
event = "GotoPageRel", args = -1 },
|
||||
event = "PagingRel", args = -1 },
|
||||
|
||||
GotoFirst = {
|
||||
{"1"}, doc = "go to start", event = "GotoPercent", args = 0},
|
||||
|
||||
@@ -7,7 +7,6 @@ local GestureRange = require("ui/gesturerange")
|
||||
local _ = require("gettext")
|
||||
|
||||
local ReaderRotation = InputContainer:new{
|
||||
ROTATE_ANGLE_THRESHOLD = 15,
|
||||
current_rotation = 0
|
||||
}
|
||||
|
||||
@@ -25,21 +24,6 @@ function ReaderRotation:init()
|
||||
event = "Rotate", args = 90 },
|
||||
}
|
||||
end
|
||||
if Device:isTouchDevice() then
|
||||
self.ges_events = {
|
||||
RotateGes = {
|
||||
GestureRange:new{
|
||||
ges = "rotate",
|
||||
range = Geom:new{
|
||||
x = 0, y = 0,
|
||||
w = Screen:getWidth(),
|
||||
h = Screen:getHeight(),
|
||||
},
|
||||
rate = 0.3,
|
||||
}
|
||||
},
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
-- TODO: reset rotation on new document, maybe on new page?
|
||||
@@ -50,15 +34,4 @@ function ReaderRotation:onRotate(rotate_by)
|
||||
return true
|
||||
end
|
||||
|
||||
function ReaderRotation:onRotateGes(arg, ges)
|
||||
if ges.angle and ges.angle > self.ROTATE_ANGLE_THRESHOLD then
|
||||
if Screen:getScreenMode() == "portrait" then
|
||||
self.ui:handleEvent(Event:new("SetScreenMode", "landscape"))
|
||||
else
|
||||
self.ui:handleEvent(Event:new("SetScreenMode", "portrait"))
|
||||
end
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
return ReaderRotation
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
local Event = require("ui/event")
|
||||
local util = require("ffi/util")
|
||||
local DEBUG = require("dbg")
|
||||
|
||||
@@ -69,10 +70,12 @@ function Device:getPowerDevice()
|
||||
end
|
||||
|
||||
function Device:intoScreenSaver()
|
||||
local UIManager = require("ui/uimanager")
|
||||
if self.charging_mode == false and self.screen_saver_mode == false then
|
||||
self.screen:saveCurrentBB()
|
||||
self.screen_saver_mode = true
|
||||
end
|
||||
UIManager:sendEvent(Event:new("FlushSettings"))
|
||||
end
|
||||
|
||||
function Device:outofScreenSaver()
|
||||
@@ -97,6 +100,7 @@ function Device:onPowerEvent(ev)
|
||||
self.screen:setRotationMode(0)
|
||||
Screensaver:show()
|
||||
self:prepareSuspend()
|
||||
UIManager:sendEvent(Event:new("FlushSettings"))
|
||||
UIManager:scheduleIn(10, self.Suspend)
|
||||
elseif (ev == "Power" or ev == "Resume") and self.screen_saver_mode then
|
||||
DEBUG("Resuming...")
|
||||
|
||||
@@ -37,6 +37,17 @@ function BasePowerD:read_int_file(file)
|
||||
end
|
||||
end
|
||||
|
||||
function BasePowerD:read_str_file(file)
|
||||
local fd = io.open(file, "r")
|
||||
if fd then
|
||||
local str = fd:read("*all")
|
||||
fd:close()
|
||||
return str
|
||||
else
|
||||
return ""
|
||||
end
|
||||
end
|
||||
|
||||
function BasePowerD:setIntensity(intensity)
|
||||
intensity = intensity < self.fl_min and self.fl_min or intensity
|
||||
intensity = intensity > self.fl_max and self.fl_max or intensity
|
||||
|
||||
@@ -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,55 @@ 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",
|
||||
isInBackGround = 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)
|
||||
--DEBUG("ev", ev.type, ev.code, ev.value)
|
||||
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
|
||||
isInBackGround = true
|
||||
self:onPowerEvent("Power")
|
||||
elseif isInBackGround and ev.type == EVT_FOREGROUND then
|
||||
isInBackGround = false
|
||||
self:onPowerEvent("Power")
|
||||
elseif not isInBackGround and ev.type == EVT_FOREGROUND then
|
||||
self.screen:refreshPartial()
|
||||
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",
|
||||
}
|
||||
|
||||
return PocketBook
|
||||
function PocketBook840:init()
|
||||
self.screen = require("ffi/framebuffer_mxcfb"):new{device = self, debug = DEBUG}
|
||||
self.powerd = require("device/pocketbook/powerd"):new{device = self}
|
||||
self.input = require("device/input"):new{
|
||||
device = self,
|
||||
event_map = {
|
||||
[24] = "LPgBack",
|
||||
[25] = "LPgFwd",
|
||||
[1002] = "Power",
|
||||
}
|
||||
}
|
||||
PocketBook.init(self)
|
||||
end
|
||||
|
||||
-- should check device model before return to support other PocketBook models
|
||||
return PocketBook840
|
||||
|
||||
31
frontend/device/pocketbook/powerd.lua
Normal file
31
frontend/device/pocketbook/powerd.lua
Normal file
@@ -0,0 +1,31 @@
|
||||
local BasePowerD = require("device/generic/powerd")
|
||||
local ffi = require("ffi")
|
||||
local inkview = ffi.load("inkview")
|
||||
|
||||
ffi.cdef[[
|
||||
int IsCharging();
|
||||
]]
|
||||
|
||||
local PocketBookPowerD = BasePowerD:new{
|
||||
battCapacity = nil,
|
||||
is_charging = nil,
|
||||
batt_capacity_file = "/sys/devices/platform/sun5i-i2c.0/i2c-0/0-0034/axp20-supplyer.28/power_supply/battery/capacity",
|
||||
is_charging_file = "/sys/devices/platform/sun5i-i2c.0/i2c-0/0-0034/axp20-supplyer.28/power_supply/battery/status",
|
||||
}
|
||||
|
||||
function PocketBookPowerD:init()
|
||||
end
|
||||
|
||||
function PocketBookPowerD:getCapacityHW()
|
||||
self.battCapacity = self:read_int_file(self.batt_capacity_file)
|
||||
return self.battCapacity
|
||||
end
|
||||
|
||||
function PocketBookPowerD:isChargingHW()
|
||||
self.is_charging = self:read_str_file(self.is_charging_file)
|
||||
return self.is_charging == "Charging"
|
||||
-- or we can query using SDK method `IsCharging`
|
||||
--return inkview.IsCharging() == 1
|
||||
end
|
||||
|
||||
return PocketBookPowerD
|
||||
@@ -39,7 +39,6 @@ function UIManager:init()
|
||||
}
|
||||
if Device:isKobo() then
|
||||
self.event_handlers["Suspend"] = function(input_event)
|
||||
self:sendEvent(Event:new("FlushSettings"))
|
||||
Device:onPowerEvent(input_event)
|
||||
end
|
||||
self.event_handlers["Resume"] = function(input_event)
|
||||
@@ -64,7 +63,6 @@ function UIManager:init()
|
||||
end
|
||||
elseif Device:isKindle() then
|
||||
self.event_handlers["IntoSS"] = function()
|
||||
self:sendEvent(Event:new("FlushSettings"))
|
||||
Device:intoScreenSaver()
|
||||
end
|
||||
self.event_handlers["OutOfSS"] = function()
|
||||
|
||||
10
platform/pocketbook/extensions.cfg
Normal file
10
platform/pocketbook/extensions.cfg
Normal file
@@ -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
|
||||
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user