mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
Merge pull request #10 from dpavlin/master
Rotate page to better represent comics and other horisontal pdfs & lots of cleaning up and bringing out of Beta.
This commit is contained in:
13
Makefile
13
Makefile
@@ -127,8 +127,19 @@ $(LUALIB):
|
||||
|
||||
thirdparty: $(MUPDFLIBS) $(THIRDPARTYLIBS) $(LUALIBS)
|
||||
|
||||
INSTALL_DIR=kindlepdfviewer
|
||||
|
||||
install:
|
||||
# install to kindle using USB networking
|
||||
scp kpdfview *.lua root@192.168.2.2:/mnt/us/test/
|
||||
scp kpdfview *.lua root@192.168.2.2:/mnt/us/$(INSTALL_DIR)/
|
||||
scp launchpad/* root@192.168.2.2:/mnt/us/launchpad/
|
||||
|
||||
VERSION?=$(shell git rev-parse --short HEAD)
|
||||
customupdate: kpdfview
|
||||
# ensure that build binary is for ARM
|
||||
file kpdfview | grep ARM || exit 1
|
||||
mkdir $(INSTALL_DIR)
|
||||
cp -p README.TXT COPYING kpdfview *.lua $(INSTALL_DIR)
|
||||
zip -r kindlepdfviewer-$(VERSION).zip $(INSTALL_DIR) launchpad/
|
||||
rm -Rf $(INSTALL_DIR)
|
||||
@echo "copy kindlepdfviewer-$(VERSION).zip to /mnt/us/customupdates and install with shift+shift+I"
|
||||
|
||||
@@ -61,3 +61,9 @@ The reader.lua script needs a device argument in order to cope with some
|
||||
slight differences between actual readers and the emulation. Run it like
|
||||
this:
|
||||
./reader.lua -d emu /PATH/TO/PDF.pdf
|
||||
|
||||
By default emulation will provide DXG resolution of 824*1200. It can be
|
||||
specified at compile time, this is example for Kindle 3:
|
||||
|
||||
EMULATE_READER_W=600 EMULATE_READER_H=800 EMULATE_READER=1 make kpdfview
|
||||
|
||||
|
||||
4
keys.lua
4
keys.lua
@@ -121,6 +121,10 @@ function set_emu_keycodes()
|
||||
KEY_A = 38
|
||||
KEY_S = 39
|
||||
KEY_D = 40
|
||||
|
||||
KEY_J = 44
|
||||
KEY_K = 45
|
||||
|
||||
KEY_SHIFT = 50 -- left shift
|
||||
KEY_ALT = 64 -- left alt
|
||||
KEY_VPLUS = 95 -- F11
|
||||
|
||||
@@ -1,14 +1,6 @@
|
||||
#!/bin/sh
|
||||
echo unlock > /proc/keypad
|
||||
echo unlock > /proc/fiveway
|
||||
cd /mnt/us/test/
|
||||
cat /dev/fb0 > /tmp/screen.fb0 &
|
||||
if [ "x$1" == "x" ] ; then
|
||||
pdf=`lsof | grep /mnt/us/documents | cut -c81- | sort -u`
|
||||
else
|
||||
pdf="$1"
|
||||
fi
|
||||
./reader.lua "$pdf"
|
||||
cat /tmp/screen.fb0 > /dev/fb0
|
||||
rm /tmp/screen.fb0
|
||||
cd /mnt/us/kindlepdfviewer/
|
||||
./reader.lua /mnt/us/documents
|
||||
echo 1 > /proc/eink_fb/update_display
|
||||
|
||||
@@ -21,6 +21,8 @@ PDFReader = {
|
||||
globalzoom = 1.0,
|
||||
globalzoommode = -1, -- ZOOM_FIT_TO_PAGE
|
||||
|
||||
globalrotate = 0,
|
||||
|
||||
-- gamma setting:
|
||||
globalgamma = 1.0, -- GAMMA_NO_GAMMA
|
||||
|
||||
@@ -82,9 +84,9 @@ function PDFReader:cacheclaim(size)
|
||||
return true
|
||||
end
|
||||
|
||||
function PDFReader:draworcache(no, zoom, offset_x, offset_y, width, height, gamma)
|
||||
function PDFReader:draworcache(no, zoom, offset_x, offset_y, width, height, gamma, rotate)
|
||||
-- hash draw state
|
||||
local hash = self:cachehash(no, zoom, offset_x, offset_y, width, height, gamma)
|
||||
local hash = self:cachehash(no, zoom, offset_x, offset_y, width, height, gamma, rotate)
|
||||
if self.cache[hash] == nil then
|
||||
-- not in cache, so prepare cache slot...
|
||||
self:cacheclaim(width * height / 2);
|
||||
@@ -107,9 +109,9 @@ function PDFReader:draworcache(no, zoom, offset_x, offset_y, width, height, gamm
|
||||
end
|
||||
|
||||
-- calculate a hash for our current state
|
||||
function PDFReader:cachehash(no, zoom, offset_x, offset_y, width, height, gamma)
|
||||
function PDFReader:cachehash(no, zoom, offset_x, offset_y, width, height, gamma, rotate)
|
||||
-- TODO (?): make this a "real" hash...
|
||||
return no..'_'..zoom..'_'..offset_x..','..offset_y..'-'..width..'x'..height..'_'..gamma;
|
||||
return no..'_'..zoom..'_'..offset_x..','..offset_y..'-'..width..'x'..height..'_'..gamma..'_'..rotate
|
||||
end
|
||||
|
||||
-- blank the cache
|
||||
@@ -186,6 +188,7 @@ function PDFReader:setzoom(page)
|
||||
end
|
||||
end
|
||||
dc:setZoom(self.globalzoom)
|
||||
dc:setRotate(self.globalrotate);
|
||||
dc:setOffset(self.offset_x, self.offset_y)
|
||||
self.fullwidth, self.fullheight = page:getSize(dc)
|
||||
self.min_offset_x = fb.bb:getWidth() - self.fullwidth
|
||||
@@ -209,9 +212,9 @@ end
|
||||
function PDFReader:show(no)
|
||||
local slot
|
||||
if self.globalzoommode ~= self.ZOOM_BY_VALUE then
|
||||
slot = self:draworcache(no,self.globalzoommode,self.offset_x,self.offset_y,width,height,self.globalgamma)
|
||||
slot = self:draworcache(no,self.globalzoommode,self.offset_x,self.offset_y,width,height,self.globalgamma,self.globalrotate)
|
||||
else
|
||||
slot = self:draworcache(no,self.globalzoom,self.offset_x,self.offset_y,width,height,self.globalgamma)
|
||||
slot = self:draworcache(no,self.globalzoom,self.offset_x,self.offset_y,width,height,self.globalgamma,self.globalrotate)
|
||||
end
|
||||
fb.bb:blitFullFrom(self.cache[slot].bb)
|
||||
if self.rcount == self.rcountmax then
|
||||
@@ -236,9 +239,9 @@ function PDFReader:goto(no)
|
||||
if no < self.doc:getPages() then
|
||||
if self.globalzoommode ~= self.ZOOM_BY_VALUE then
|
||||
-- pre-cache next page
|
||||
self:draworcache(no+1,self.globalzoommode,self.offset_x,self.offset_y,width,height,self.globalgamma)
|
||||
self:draworcache(no+1,self.globalzoommode,self.offset_x,self.offset_y,width,height,self.globalgamma,self.globalrotate)
|
||||
else
|
||||
self:draworcache(no,self.globalzoom,self.offset_x,self.offset_y,width,height,self.globalgamma)
|
||||
self:draworcache(no,self.globalzoom,self.offset_x,self.offset_y,width,height,self.globalgamma,self.globalrotate)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -267,6 +270,11 @@ function PDFReader:setglobalzoom(zoom)
|
||||
end
|
||||
end
|
||||
|
||||
function PDFReader:setrotate(rotate)
|
||||
self.globalrotate = rotate
|
||||
self:goto(self.pageno)
|
||||
end
|
||||
|
||||
-- wait for input and handle it
|
||||
function PDFReader:inputloop()
|
||||
while 1 do
|
||||
@@ -280,7 +288,7 @@ function PDFReader:inputloop()
|
||||
elseif ev.code == KEY_PGFWD then
|
||||
if self.shiftmode then
|
||||
self:setglobalzoom(self.globalzoom*1.2)
|
||||
elseif altmode then
|
||||
elseif self.altmode then
|
||||
self:setglobalzoom(self.globalzoom*1.1)
|
||||
else
|
||||
self:goto(self.pageno + 1)
|
||||
@@ -288,7 +296,7 @@ function PDFReader:inputloop()
|
||||
elseif ev.code == KEY_PGBCK then
|
||||
if self.shiftmode then
|
||||
self:setglobalzoom(self.globalzoom*0.8)
|
||||
elseif altmode then
|
||||
elseif self.altmode then
|
||||
self:setglobalzoom(self.globalzoom*0.9)
|
||||
else
|
||||
self:goto(self.pageno - 1)
|
||||
@@ -326,6 +334,11 @@ function PDFReader:inputloop()
|
||||
else
|
||||
self:setglobalzoommode(self.ZOOM_FIT_TO_PAGE_HEIGHT)
|
||||
end
|
||||
|
||||
elseif ev.code == KEY_J then
|
||||
self:setrotate( self.globalrotate + 10 )
|
||||
elseif ev.code == KEY_K then
|
||||
self:setrotate( self.globalrotate - 10 )
|
||||
end
|
||||
|
||||
if self.globalzoommode == self.ZOOM_BY_VALUE then
|
||||
|
||||
10
reader.lua
10
reader.lua
@@ -40,6 +40,7 @@ if optarg["h"] or ARGV[optind] == nil then
|
||||
print(" (floating point notation, e.g. \"1.5\")")
|
||||
print("-d, --device=DEVICE set device specific configuration,")
|
||||
print(" currently one of \"kdxg\" (default), \"k3\"")
|
||||
print(" \"emu\" (DXG emulation)")
|
||||
print("-h, --help show this usage help")
|
||||
print("")
|
||||
print("If you give the name of a directory instead of a path, a file")
|
||||
@@ -63,6 +64,15 @@ elseif optarg["d"] == "emu" then
|
||||
else
|
||||
input.open("/dev/input/event0")
|
||||
input.open("/dev/input/event1")
|
||||
|
||||
-- check if we are running on Kindle 3 (additional volume input)
|
||||
local f=lfs.attributes("/dev/input/event2")
|
||||
print(f)
|
||||
if f then
|
||||
print("Auto-detected Kindle 3")
|
||||
set_k3_keycodes()
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
if optarg["G"] ~= nil then
|
||||
|
||||
Reference in New Issue
Block a user