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.
pull/2/merge
HW 13 years ago
commit 63445d3187

@ -127,8 +127,19 @@ $(LUALIB):
thirdparty: $(MUPDFLIBS) $(THIRDPARTYLIBS) $(LUALIBS) thirdparty: $(MUPDFLIBS) $(THIRDPARTYLIBS) $(LUALIBS)
INSTALL_DIR=kindlepdfviewer
install: install:
# install to kindle using USB networking # 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/ 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 slight differences between actual readers and the emulation. Run it like
this: this:
./reader.lua -d emu /PATH/TO/PDF.pdf ./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

@ -121,6 +121,10 @@ function set_emu_keycodes()
KEY_A = 38 KEY_A = 38
KEY_S = 39 KEY_S = 39
KEY_D = 40 KEY_D = 40
KEY_J = 44
KEY_K = 45
KEY_SHIFT = 50 -- left shift KEY_SHIFT = 50 -- left shift
KEY_ALT = 64 -- left alt KEY_ALT = 64 -- left alt
KEY_VPLUS = 95 -- F11 KEY_VPLUS = 95 -- F11

@ -1,14 +1,6 @@
#!/bin/sh #!/bin/sh
echo unlock > /proc/keypad echo unlock > /proc/keypad
echo unlock > /proc/fiveway echo unlock > /proc/fiveway
cd /mnt/us/test/ cd /mnt/us/kindlepdfviewer/
cat /dev/fb0 > /tmp/screen.fb0 & ./reader.lua /mnt/us/documents
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
echo 1 > /proc/eink_fb/update_display echo 1 > /proc/eink_fb/update_display

@ -21,6 +21,8 @@ PDFReader = {
globalzoom = 1.0, globalzoom = 1.0,
globalzoommode = -1, -- ZOOM_FIT_TO_PAGE globalzoommode = -1, -- ZOOM_FIT_TO_PAGE
globalrotate = 0,
-- gamma setting: -- gamma setting:
globalgamma = 1.0, -- GAMMA_NO_GAMMA globalgamma = 1.0, -- GAMMA_NO_GAMMA
@ -82,9 +84,9 @@ function PDFReader:cacheclaim(size)
return true return true
end 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 -- 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 if self.cache[hash] == nil then
-- not in cache, so prepare cache slot... -- not in cache, so prepare cache slot...
self:cacheclaim(width * height / 2); self:cacheclaim(width * height / 2);
@ -107,9 +109,9 @@ function PDFReader:draworcache(no, zoom, offset_x, offset_y, width, height, gamm
end end
-- calculate a hash for our current state -- 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... -- 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 end
-- blank the cache -- blank the cache
@ -186,6 +188,7 @@ function PDFReader:setzoom(page)
end end
end end
dc:setZoom(self.globalzoom) dc:setZoom(self.globalzoom)
dc:setRotate(self.globalrotate);
dc:setOffset(self.offset_x, self.offset_y) dc:setOffset(self.offset_x, self.offset_y)
self.fullwidth, self.fullheight = page:getSize(dc) self.fullwidth, self.fullheight = page:getSize(dc)
self.min_offset_x = fb.bb:getWidth() - self.fullwidth self.min_offset_x = fb.bb:getWidth() - self.fullwidth
@ -209,9 +212,9 @@ end
function PDFReader:show(no) function PDFReader:show(no)
local slot local slot
if self.globalzoommode ~= self.ZOOM_BY_VALUE then 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 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 end
fb.bb:blitFullFrom(self.cache[slot].bb) fb.bb:blitFullFrom(self.cache[slot].bb)
if self.rcount == self.rcountmax then if self.rcount == self.rcountmax then
@ -236,9 +239,9 @@ function PDFReader:goto(no)
if no < self.doc:getPages() then if no < self.doc:getPages() then
if self.globalzoommode ~= self.ZOOM_BY_VALUE then if self.globalzoommode ~= self.ZOOM_BY_VALUE then
-- pre-cache next page -- 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 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 end
end end
@ -267,6 +270,11 @@ function PDFReader:setglobalzoom(zoom)
end end
end end
function PDFReader:setrotate(rotate)
self.globalrotate = rotate
self:goto(self.pageno)
end
-- wait for input and handle it -- wait for input and handle it
function PDFReader:inputloop() function PDFReader:inputloop()
while 1 do while 1 do
@ -280,7 +288,7 @@ function PDFReader:inputloop()
elseif ev.code == KEY_PGFWD then elseif ev.code == KEY_PGFWD then
if self.shiftmode then if self.shiftmode then
self:setglobalzoom(self.globalzoom*1.2) self:setglobalzoom(self.globalzoom*1.2)
elseif altmode then elseif self.altmode then
self:setglobalzoom(self.globalzoom*1.1) self:setglobalzoom(self.globalzoom*1.1)
else else
self:goto(self.pageno + 1) self:goto(self.pageno + 1)
@ -288,7 +296,7 @@ function PDFReader:inputloop()
elseif ev.code == KEY_PGBCK then elseif ev.code == KEY_PGBCK then
if self.shiftmode then if self.shiftmode then
self:setglobalzoom(self.globalzoom*0.8) self:setglobalzoom(self.globalzoom*0.8)
elseif altmode then elseif self.altmode then
self:setglobalzoom(self.globalzoom*0.9) self:setglobalzoom(self.globalzoom*0.9)
else else
self:goto(self.pageno - 1) self:goto(self.pageno - 1)
@ -326,6 +334,11 @@ function PDFReader:inputloop()
else else
self:setglobalzoommode(self.ZOOM_FIT_TO_PAGE_HEIGHT) self:setglobalzoommode(self.ZOOM_FIT_TO_PAGE_HEIGHT)
end end
elseif ev.code == KEY_J then
self:setrotate( self.globalrotate + 10 )
elseif ev.code == KEY_K then
self:setrotate( self.globalrotate - 10 )
end end
if self.globalzoommode == self.ZOOM_BY_VALUE then if self.globalzoommode == self.ZOOM_BY_VALUE then

@ -40,6 +40,7 @@ if optarg["h"] or ARGV[optind] == nil then
print(" (floating point notation, e.g. \"1.5\")") print(" (floating point notation, e.g. \"1.5\")")
print("-d, --device=DEVICE set device specific configuration,") print("-d, --device=DEVICE set device specific configuration,")
print(" currently one of \"kdxg\" (default), \"k3\"") print(" currently one of \"kdxg\" (default), \"k3\"")
print(" \"emu\" (DXG emulation)")
print("-h, --help show this usage help") print("-h, --help show this usage help")
print("") print("")
print("If you give the name of a directory instead of a path, a file") 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 else
input.open("/dev/input/event0") input.open("/dev/input/event0")
input.open("/dev/input/event1") 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 end
if optarg["G"] ~= nil then if optarg["G"] ~= nil then

Loading…
Cancel
Save