added altmode for smaller pans and zooms

pull/2/merge
Dobrica Pavlinusic 13 years ago
parent 95952f7b11
commit 04087c072f

@ -118,7 +118,8 @@ function set_emu_keycodes()
KEY_A = 38 KEY_A = 38
KEY_S = 39 KEY_S = 39
KEY_D = 40 KEY_D = 40
KEY_SHIFT = 50 KEY_SHIFT = 50 -- left shift
KEY_ALT = 64 -- left alt
KEY_VPLUS = 95 -- F11 KEY_VPLUS = 95 -- F11
KEY_VMINUS = 96 -- F12 KEY_VMINUS = 96 -- F12
end end

@ -71,9 +71,10 @@ offset_y = 0
shift_x = 100 shift_x = 100
shift_y = 50 shift_y = 50
shift_step = 1 -- using shift_[xy] or width/height pan_by_page = false -- using shift_[xy] or width/height
shiftmode = false shiftmode = false
altmode = false
if optarg["d"] == "k3" then if optarg["d"] == "k3" then
-- for now, the only difference is the additional input device -- for now, the only difference is the additional input device
@ -219,17 +220,23 @@ function mainloop()
local secs, usecs = util.gettime() local secs, usecs = util.gettime()
if ev.code == KEY_SHIFT then if ev.code == KEY_SHIFT then
shiftmode = true shiftmode = true
elseif ev.code == KEY_ALT then
altmode = true
elseif ev.code == KEY_PGFWD then elseif ev.code == KEY_PGFWD then
if not shiftmode then if shiftmode then
goto(pageno + 1) setglobalzoom(globalzoom*1.2)
elseif altmode then
setglobalzoom(globalzoom*1.1)
else else
setglobalzoom(globalzoom*1.25) goto(pageno + 1)
end end
elseif ev.code == KEY_PGBCK then elseif ev.code == KEY_PGBCK then
if not shiftmode then if shiftmode then
goto(pageno - 1)
else
setglobalzoom(globalzoom*0.8) setglobalzoom(globalzoom*0.8)
elseif altmode then
setglobalzoom(globalzoom*0.9)
else
goto(pageno - 1)
end end
elseif ev.code == KEY_BACK then elseif ev.code == KEY_BACK then
return return
@ -262,14 +269,17 @@ function mainloop()
local y local y
if shiftmode then -- shift always moves in small steps if shiftmode then -- shift always moves in small steps
x = shift_x / 3 x = shift_x / 2
y = shift_y / 3 y = shift_y / 2
elseif shift_step then elseif altmode then
x = shift_x x = shift_x / 5
y = shift_y y = shift_y / 5
else elseif pan_by_page then
x = width - 5; -- small overlap when moving by page x = width - 5; -- small overlap when moving by page
y = height - 5; y = height - 5;
else
x = shift_x
y = shift_y
end end
print("offset "..offset_x.."*"..offset_x.." shift "..x.."*"..y.." globalzoom="..globalzoom) print("offset "..offset_x.."*"..offset_x.." shift "..x.."*"..y.." globalzoom="..globalzoom)
@ -292,7 +302,7 @@ function mainloop()
offset_y = 0 offset_y = 0
goto(pageno) goto(pageno)
else else
shift_step = not shift_step pan_by_page = not pan_by_page
end end
end end
end end
@ -302,6 +312,8 @@ function mainloop()
print("E: T="..ev.type.." V="..ev.value.." C="..ev.code.." DUR="..dur) 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 elseif ev.type == EV_KEY and ev.value == EVENT_VALUE_KEY_RELEASE and ev.code == KEY_SHIFT then
shiftmode = false 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 end
end end

Loading…
Cancel
Save