diff --git a/filechooser.lua b/filechooser.lua index 04f4db7dc..631ccf885 100644 --- a/filechooser.lua +++ b/filechooser.lua @@ -146,9 +146,13 @@ function FileChooser:choose(ypos, height) end local ev = input.waitForEvent() if ev.type == EV_KEY and ev.value == EVENT_VALUE_KEY_PRESS then - --print("key code:"..ev.code) + print("key code:"..ev.code) ev.code = adjustFWKey(ev.code) - if ev.code == KEY_FW_UP then + if ev.code == KEY_SHIFT then + Keys.shiftmode = true + elseif ev.code == KEY_ALT then + Keys.altmode = true + elseif ev.code == KEY_FW_UP then prevItem() elseif ev.code == KEY_FW_DOWN then nextItem() @@ -214,6 +218,12 @@ function FileChooser:choose(ypos, height) elseif ev.code == KEY_BACK then return nil end + elseif ev.type == EV_KEY and ev.value == EVENT_VALUE_KEY_RELEASE + and ev.code == KEY_SHIFT then + Keys.shiftmode = false + elseif ev.type == EV_KEY and ev.value == EVENT_VALUE_KEY_RELEASE + and ev.code == KEY_ALT then + Keys.altmode = false end end end diff --git a/filesearcher.lua b/filesearcher.lua index 6466b2098..9af4b2cbe 100644 --- a/filesearcher.lua +++ b/filesearcher.lua @@ -216,7 +216,11 @@ function FileSearcher:choose(ypos, height, keywords) local ev = input.waitForEvent() if ev.type == EV_KEY and ev.value == EVENT_VALUE_KEY_PRESS then ev.code = adjustFWKey(ev.code) - if ev.code == KEY_FW_UP then + if ev.code == KEY_SHIFT then + Keys.shiftmode = true + elseif ev.code == KEY_ALT then + Keys.altmode = true + elseif ev.code == KEY_FW_UP then prevItem() elseif ev.code == KEY_FW_DOWN then nextItem() @@ -272,6 +276,12 @@ function FileSearcher:choose(ypos, height, keywords) elseif ev.code == KEY_BACK then return nil end + elseif ev.type == EV_KEY and ev.value == EVENT_VALUE_KEY_RELEASE + and ev.code == KEY_SHIFT then + Keys.shiftmode = false + elseif ev.type == EV_KEY and ev.value == EVENT_VALUE_KEY_RELEASE + and ev.code == KEY_ALT then + Keys.altmode = false end end end diff --git a/inputbox.lua b/inputbox.lua index 3408567c7..4eab4f95e 100644 --- a/inputbox.lua +++ b/inputbox.lua @@ -102,9 +102,9 @@ function InputBox:input(ypos, height, title, d_text) ev.code = adjustFWKey(ev.code) --local secs, usecs = util.gettime() if ev.code == KEY_SHIFT then - self.shiftmode = true + Keys.shiftmode = true elseif ev.code == KEY_ALT then - self.altmode = true + Keys.altmode = true elseif ev.code == KEY_FW_UP then elseif ev.code == KEY_FW_DOWN then elseif ev.code == KEY_A then @@ -200,10 +200,10 @@ function InputBox:input(ypos, height, title, d_text) --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 - self.shiftmode = false + Keys.shiftmode = false elseif ev.type == EV_KEY and ev.value == EVENT_VALUE_KEY_RELEASE and ev.code == KEY_ALT then - self.altmode = false + Keys.altmode = false end end end diff --git a/keys.lua b/keys.lua index 7e3f5aec7..fb520c643 100644 --- a/keys.lua +++ b/keys.lua @@ -24,6 +24,11 @@ and was licensed under the GPLv2 ]]-- +Keys = { + altmode = false, + shiftmode = false, +} + KEY_1 = 2 KEY_2 = 3 KEY_3 = 4 @@ -120,6 +125,17 @@ function set_emu_keycodes() KEY_ENTER = 36 + KEY_1 = 10 + KEY_2 = 11 + KEY_3 = 12 + KEY_4 = 13 + KEY_5 = 14 + KEY_6 = 15 + KEY_7 = 16 + KEY_8 = 17 + KEY_9 = 18 + KEY_0 = 19 + KEY_Q = 24 KEY_W = 25 KEY_E = 26 @@ -163,17 +179,17 @@ function getRotationMode() 1 for landscape with bottom on the right side of screen, etc. 2 - ----------- - | ------- | + +-----------+ + | +-------+ | | | | | | | | | | | | | 3 | | | | 1 | | | | | | | | - | ------- | + | +-------+ | | | - ----------- + +-----------+ 0 --]] if KEY_FW_DOWN == 116 then -- in EMU mode always return 0 diff --git a/pdfreader.lua b/pdfreader.lua index ef9a7ab58..ec98dd1a9 100644 --- a/pdfreader.lua +++ b/pdfreader.lua @@ -356,27 +356,27 @@ function PDFReader:inputloop() if ev.type == EV_KEY and ev.value == EVENT_VALUE_KEY_PRESS then local secs, usecs = util.gettime() if ev.code == KEY_SHIFT then - self.shiftmode = true + Keys.shiftmode = true elseif ev.code == KEY_ALT then - self.altmode = true + Keys.altmode = true elseif ev.code == KEY_PGFWD or ev.code == KEY_LPGFWD then - if self.shiftmode then + if Keys.shiftmode then self:setglobalzoom(self.globalzoom*1.2) - elseif self.altmode then + elseif Keys.altmode then self:setglobalzoom(self.globalzoom*1.1) else self:goto(self.pageno + 1) end elseif ev.code == KEY_PGBCK or ev.code == KEY_LPGBCK then - if self.shiftmode then + if Keys.shiftmode then self:setglobalzoom(self.globalzoom*0.8) - elseif self.altmode then + elseif Keys.altmode then self:setglobalzoom(self.globalzoom*0.9) else self:goto(self.pageno - 1) end elseif ev.code == KEY_BACK then - if self.altmode then + if Keys.altmode then -- altmode, exit pdfreader self:clearcache() if self.doc ~= nil then @@ -399,19 +399,19 @@ function PDFReader:inputloop() elseif ev.code == KEY_VMINUS then self:modify_gamma( 0.8 ) elseif ev.code == KEY_A then - if self.shiftmode then + if Keys.shiftmode then self:setglobalzoommode(self.ZOOM_FIT_TO_CONTENT) else self:setglobalzoommode(self.ZOOM_FIT_TO_PAGE) end elseif ev.code == KEY_S then - if self.shiftmode then + if Keys.shiftmode then self:setglobalzoommode(self.ZOOM_FIT_TO_CONTENT_WIDTH) else self:setglobalzoommode(self.ZOOM_FIT_TO_PAGE_WIDTH) end elseif ev.code == KEY_D then - if self.shiftmode then + if Keys.shiftmode then self:setglobalzoommode(self.ZOOM_FIT_TO_CONTENT_HEIGHT) else self:setglobalzoommode(self.ZOOM_FIT_TO_PAGE_HEIGHT) @@ -430,10 +430,10 @@ function PDFReader:inputloop() local x local y - if self.shiftmode then -- shift always moves in small steps + if Keys.shiftmode then -- shift always moves in small steps x = self.shift_x / 2 y = self.shift_y / 2 - elseif self.altmode then + elseif Keys.altmode then x = self.shift_x / 5 y = self.shift_y / 5 elseif self.pan_by_page then @@ -469,7 +469,7 @@ function PDFReader:inputloop() self.offset_y = self.min_offset_y end elseif ev.code == KEY_FW_PRESS then - if self.shiftmode then + if Keys.shiftmode then self.offset_x = 0 self.offset_y = 0 else @@ -487,9 +487,9 @@ function PDFReader:inputloop() 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 print "shift haha" - self.shiftmode = false + Keys.shiftmode = false elseif ev.type == EV_KEY and ev.value == EVENT_VALUE_KEY_RELEASE and ev.code == KEY_ALT then - self.altmode = false + Keys.altmode = false end end end diff --git a/selectmenu.lua b/selectmenu.lua index 8c6219f60..9057ca9b1 100644 --- a/selectmenu.lua +++ b/selectmenu.lua @@ -169,7 +169,11 @@ function SelectMenu:choose(ypos, height) local ev = input.waitForEvent() if ev.type == EV_KEY and ev.value == EVENT_VALUE_KEY_PRESS then ev.code = adjustFWKey(ev.code) - if ev.code == KEY_FW_UP then + if ev.code == KEY_SHIFT then + Keys.shiftmode = true + elseif ev.code == KEY_ALT then + Keys.altmode = true + elseif ev.code == KEY_FW_UP then prevItem() elseif ev.code == KEY_FW_DOWN then nextItem() @@ -201,6 +205,12 @@ function SelectMenu:choose(ypos, height) elseif ev.code == KEY_BACK then return nil end + elseif ev.type == EV_KEY and ev.value == EVENT_VALUE_KEY_RELEASE + and ev.code == KEY_SHIFT then + Keys.shiftmode = false + elseif ev.type == EV_KEY and ev.value == EVENT_VALUE_KEY_RELEASE + and ev.code == KEY_ALT then + Keys.altmode = false end end end