Supports InputAvailable events with GameActivity

This makes a small change to the C glue code for GameActivity to send
looper wake ups when new input is received (only sending a single wake
up, until the application next handles input).

When a wake up is received and we recognise that new input is available
then an `InputAvailable` event is sent to the application - consistent
with how NativeActivity can deliver `InputAvailable` events.

This addresses a significant feature disparity between GameActivity and
NativeActivity that meant GameActivity was not practically usable for
GUI applications that wouldn't want to render continuously like a game.

Addresses #4
This commit is contained in:
Robert Bragg
2022-08-13 05:42:37 +01:00
parent 00b116bcfe
commit 3d1b1c5cb9
9 changed files with 182 additions and 5 deletions
-1
View File
@@ -13,7 +13,6 @@
<option value="$PROJECT_DIR$/app" />
</set>
</option>
<option name="resolveModulePerSourceSet" value="false" />
</GradleProjectSettings>
</option>
</component>
+4 -1
View File
@@ -11,7 +11,7 @@ fn android_main(app: AndroidApp) {
while !quit {
app.poll_events(
Some(std::time::Duration::from_millis(500)), /* timeout */
Some(std::time::Duration::from_secs(1)), /* timeout */
|event| {
match event {
PollEvent::Wake => {
@@ -49,6 +49,9 @@ fn android_main(app: AndroidApp) {
MainEvent::RedrawNeeded { .. } => {
redraw_pending = true;
}
MainEvent::InputAvailable { .. } => {
redraw_pending = true;
}
MainEvent::LowMemory => {}
MainEvent::Destroy => quit = true,