Skip to content

Commit

Permalink
Android: Process events from the JVM (#1326)
Browse files Browse the repository at this point in the history
Used to keep track of broadcast events on the main lua loop.

It is a generic mechanism able to execute chunks of lua code triggered by code running inside the JVM.
  • Loading branch information
zwim committed Apr 1, 2021
1 parent 514167d commit 528aa30
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions ffi/input_android.lua
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,14 @@ function input.waitForEvent(sec, usec)
android.lib.AInputQueue_finishEvent(android.app.inputQueue, event[0], handled)
end
end
elseif poll_state == C.LOOPER_ID_USER then
local message = ffi.new("unsigned char [4]")
C.read(fd[0], message, 4)
if message[0] == C.AEVENT_POWER_CONNECTED then
commandHandler(C.AEVENT_POWER_CONNECTED, 0)
elseif message[0] == C.AEVENT_POWER_DISCONNECTED then
commandHandler(C.AEVENT_POWER_DISCONNECTED, 0)
end
end
if android.app.destroyRequested ~= 0 then
android.LOGI("Engine thread destroy requested!")
Expand Down

0 comments on commit 528aa30

Please sign in to comment.