mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
input(optimization): replace ev type reflection with table lookup
This commit is contained in:
committed by
Frans de Jonge
parent
597beab616
commit
06562fa582
@@ -62,6 +62,8 @@ an interface to get input events
|
||||
local Input = {
|
||||
-- this depends on keyboard layout and should be overridden:
|
||||
event_map = {},
|
||||
-- adapters are post processing functions that transform a given event to another event
|
||||
event_map_adapter = {},
|
||||
|
||||
group = {
|
||||
Cursor = { "Up", "Down", "Left", "Right" },
|
||||
@@ -266,8 +268,8 @@ function Input:handleKeyBoardEv(ev)
|
||||
return
|
||||
end
|
||||
|
||||
if type(keycode) == "function" then
|
||||
return keycode(ev)
|
||||
if self.event_map_adapter[keycode] then
|
||||
return self.event_map_adapter[keycode](ev)
|
||||
end
|
||||
|
||||
-- take device rotation into account
|
||||
|
||||
Reference in New Issue
Block a user