mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
handle Android app events in frontend/device code
Events have been passed to the frontend/device (or /input) code before. Some of them have been handled in the FFI/input code, however. That seems to be highly critical with regard to timing, though, so we just let it enqueue the event for our code to process later. That way, a mutex that locks the input event queue can be freed faster.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
local Generic = require("device/generic/device")
|
||||
local isAndroid, android = pcall(require, "android")
|
||||
local ffi = require("ffi")
|
||||
local DEBUG = require("dbg")
|
||||
|
||||
local function yes() return true end
|
||||
|
||||
@@ -18,8 +19,13 @@ function Device:init()
|
||||
device = self,
|
||||
event_map = require("device/android/event_map"),
|
||||
handleMiscEv = function(self, ev)
|
||||
DEBUG("Android application event", ev.code)
|
||||
if ev.code == ffi.C.APP_CMD_SAVE_STATE then
|
||||
return "SaveState"
|
||||
elseif ev.code == ffi.C.APP_CMD_GAINED_FOCUS then
|
||||
self.device.screen:refreshFull()
|
||||
elseif ev.code == ffi.C.APP_CMD_WINDOW_REDRAW_NEEDED then
|
||||
self.device.screen:refreshFull()
|
||||
end
|
||||
end,
|
||||
}
|
||||
|
||||
@@ -120,8 +120,6 @@ function Input:init()
|
||||
screen = self.device.screen,
|
||||
input = self,
|
||||
}
|
||||
-- allow access to device object in FFI API
|
||||
input.device = self.device
|
||||
|
||||
-- set up fake event map
|
||||
self.event_map[10000] = "IntoSS" -- go into screen saver
|
||||
|
||||
Reference in New Issue
Block a user