From 95952f7b119aa32a657ef6cb16e20c32b82989c8 Mon Sep 17 00:00:00 2001 From: Dobrica Pavlinusic Date: Sat, 26 Nov 2011 15:07:04 +0100 Subject: [PATCH 1/4] enable panning over zoomed page This works only in ZOOM_BY_VALUE mode invoked by Shift+Page< or Shift+Page> Panning is modal: in normal mode, you move using fiveway but when you press fiveway you switch to move-by-screen mode (which is useful after you centered first column of article and you just want to move around) At any time you can press fiveway with shift to move in even smaller increments --- reader.lua | 53 +++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 49 insertions(+), 4 deletions(-) diff --git a/reader.lua b/reader.lua index 9131552cc..0c6f5984c 100755 --- a/reader.lua +++ b/reader.lua @@ -69,6 +69,10 @@ fullheight = 0 offset_x = 0 offset_y = 0 +shift_x = 100 +shift_y = 50 +shift_step = 1 -- using shift_[xy] or width/height + shiftmode = false if optarg["d"] == "k3" then @@ -156,9 +160,9 @@ end function show(no) local slot if globalzoommode ~= ZOOM_BY_VALUE then - slot = draworcache(no,globalzoommode,0,0,width,height,globalgamma) + slot = draworcache(no,globalzoommode,offset_x,offset_y,width,height,globalgamma) else - slot = draworcache(no,globalzoom,0,0,width,height,globalgamma) + slot = draworcache(no,globalzoom,offset_x,offset_y,width,height,globalgamma) end fb:blitFullFrom(cache[slot].bb) if rcount == rcountmax then @@ -182,9 +186,9 @@ function goto(no) if no < doc:getPages() then -- always pre-cache next page if globalzoommode ~= ZOOM_BY_VALUE then - draworcache(no,globalzoommode,0,0,width,height,globalgamma) + draworcache(no,globalzoommode,offset_x,offset_y,width,height,globalgamma) else - draworcache(no,globalzoom,0,0,width,height,globalgamma) + draworcache(no,globalzoom,offset_x,offset_y,width,height,globalgamma) end end end @@ -252,6 +256,47 @@ function mainloop() setglobalzoommode(ZOOM_FIT_TO_PAGE_HEIGHT) end end + + if globalzoommode == ZOOM_BY_VALUE then + local x + local y + + if shiftmode then -- shift always moves in small steps + x = shift_x / 3 + y = shift_y / 3 + elseif shift_step then + x = shift_x + y = shift_y + else + x = width - 5; -- small overlap when moving by page + y = height - 5; + end + + print("offset "..offset_x.."*"..offset_x.." shift "..x.."*"..y.." globalzoom="..globalzoom) + + if ev.code == KEY_FW_LEFT then + offset_x = offset_x + x + goto(pageno) + elseif ev.code == KEY_FW_RIGHT then + offset_x = offset_x - x + goto(pageno) + elseif ev.code == KEY_FW_UP then + offset_y = offset_y - y + goto(pageno) + elseif ev.code == KEY_FW_DOWN then + offset_y = offset_y + y + goto(pageno) + elseif ev.code == KEY_FW_PRESS then + if shiftmode then + offset_x = 0 + offset_y = 0 + goto(pageno) + else + shift_step = not shift_step + end + end + end + local nsecs, nusecs = util.gettime() local dur = (nsecs - secs) * 1000000 + nusecs - usecs print("E: T="..ev.type.." V="..ev.value.." C="..ev.code.." DUR="..dur) From 04087c072fd23652d52657ffd7c0f2252a58ea7d Mon Sep 17 00:00:00 2001 From: Dobrica Pavlinusic Date: Sat, 26 Nov 2011 15:52:20 +0100 Subject: [PATCH 2/4] added altmode for smaller pans and zooms --- keys.lua | 3 ++- reader.lua | 40 ++++++++++++++++++++++++++-------------- 2 files changed, 28 insertions(+), 15 deletions(-) diff --git a/keys.lua b/keys.lua index afb7dbd2f..c9504a25f 100755 --- a/keys.lua +++ b/keys.lua @@ -118,7 +118,8 @@ function set_emu_keycodes() KEY_A = 38 KEY_S = 39 KEY_D = 40 - KEY_SHIFT = 50 + KEY_SHIFT = 50 -- left shift + KEY_ALT = 64 -- left alt KEY_VPLUS = 95 -- F11 KEY_VMINUS = 96 -- F12 end diff --git a/reader.lua b/reader.lua index 0c6f5984c..e19fe4f94 100755 --- a/reader.lua +++ b/reader.lua @@ -71,9 +71,10 @@ offset_y = 0 shift_x = 100 shift_y = 50 -shift_step = 1 -- using shift_[xy] or width/height +pan_by_page = false -- using shift_[xy] or width/height shiftmode = false +altmode = false if optarg["d"] == "k3" then -- for now, the only difference is the additional input device @@ -219,17 +220,23 @@ function mainloop() local secs, usecs = util.gettime() if ev.code == KEY_SHIFT then shiftmode = true + elseif ev.code == KEY_ALT then + altmode = true elseif ev.code == KEY_PGFWD then - if not shiftmode then - goto(pageno + 1) + if shiftmode then + setglobalzoom(globalzoom*1.2) + elseif altmode then + setglobalzoom(globalzoom*1.1) else - setglobalzoom(globalzoom*1.25) + goto(pageno + 1) end elseif ev.code == KEY_PGBCK then - if not shiftmode then - goto(pageno - 1) - else + if shiftmode then setglobalzoom(globalzoom*0.8) + elseif altmode then + setglobalzoom(globalzoom*0.9) + else + goto(pageno - 1) end elseif ev.code == KEY_BACK then return @@ -262,14 +269,17 @@ function mainloop() local y if shiftmode then -- shift always moves in small steps - x = shift_x / 3 - y = shift_y / 3 - elseif shift_step then - x = shift_x - y = shift_y - else + x = shift_x / 2 + y = shift_y / 2 + elseif altmode then + x = shift_x / 5 + y = shift_y / 5 + elseif pan_by_page then x = width - 5; -- small overlap when moving by page y = height - 5; + else + x = shift_x + y = shift_y end print("offset "..offset_x.."*"..offset_x.." shift "..x.."*"..y.." globalzoom="..globalzoom) @@ -292,7 +302,7 @@ function mainloop() offset_y = 0 goto(pageno) else - shift_step = not shift_step + pan_by_page = not pan_by_page end end end @@ -302,6 +312,8 @@ function mainloop() print("E: T="..ev.type.." V="..ev.value.." C="..ev.code.." DUR="..dur) elseif ev.type == EV_KEY and ev.value == EVENT_VALUE_KEY_RELEASE and ev.code == KEY_SHIFT then shiftmode = false + elseif ev.type == EV_KEY and ev.value == EVENT_VALUE_KEY_RELEASE and ev.code == KEY_ALT then + altmode = false end end end From aa55dca6771a4e2df22a4b0ba5e58a035009329d Mon Sep 17 00:00:00 2001 From: Dobrica Pavlinusic Date: Sat, 26 Nov 2011 16:19:38 +0100 Subject: [PATCH 3/4] open reader using shift+P+P from Kindle's pdf viewer using launchpad lsof is used to find path of current opened pdf --- launchpad/kpdf.ini | 2 ++ launchpad/kpdf.sh | 8 ++++++++ 2 files changed, 10 insertions(+) create mode 100755 launchpad/kpdf.ini create mode 100755 launchpad/kpdf.sh diff --git a/launchpad/kpdf.ini b/launchpad/kpdf.ini new file mode 100755 index 000000000..5942666e0 --- /dev/null +++ b/launchpad/kpdf.ini @@ -0,0 +1,2 @@ +[Actions] +P P = !/mnt/us/launchpad/kpdf.sh diff --git a/launchpad/kpdf.sh b/launchpad/kpdf.sh new file mode 100755 index 000000000..d97a3e795 --- /dev/null +++ b/launchpad/kpdf.sh @@ -0,0 +1,8 @@ +echo unlock > /proc/keypad +echo unlock > /proc/fiveway +cd /mnt/us/test/ +cat /dev/fb0 > screen.fb0 & +pdf=`lsof | grep /mnt/us/documents | cut -c81- | sort -u` +./reader.lua "$pdf" +cat screen.fb0 > /dev/fb0 +echo 1 > /proc/eink_fb/update_display From 31a487e746acc205305c2e53ec418dd78e67f2b1 Mon Sep 17 00:00:00 2001 From: Dobrica Pavlinusic Date: Sat, 26 Nov 2011 16:32:24 +0100 Subject: [PATCH 4/4] fix direction of up/down pan --- reader.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/reader.lua b/reader.lua index e19fe4f94..dbe19d771 100755 --- a/reader.lua +++ b/reader.lua @@ -291,10 +291,10 @@ function mainloop() offset_x = offset_x - x goto(pageno) elseif ev.code == KEY_FW_UP then - offset_y = offset_y - y + offset_y = offset_y + y goto(pageno) elseif ev.code == KEY_FW_DOWN then - offset_y = offset_y + y + offset_y = offset_y - y goto(pageno) elseif ev.code == KEY_FW_PRESS then if shiftmode then