Skip to content

Commit 694bb4a

Browse files
committed
Import android-games-sdk changes for 4.0.0
This imports the SDK from commit 6ab5146309e1ba7f3d670bba7a468434ae93203b, from: https://github.com/rust-mobile/android-games-sdk/commits/android-activity-4.0.0 This includes one "notify android_main of editor actions" patch which will make it possible to forward editor actions and support IME Commit events in Winit) # notify android_main of editor actions This adds a pendingEditorActions member to android_app that is set via onEditorAction and the android_main thread is notified via notifyInput instead of re-instating APP_CMD_EDITOR_ACTION. The idea is that the android_main thread should check for android_app->pendingEditorActions whenever input events are polled/iterated. # FFI bindings update Also updates the FFI bindings via generate-bindings.sh
1 parent e686e80 commit 694bb4a

File tree

6 files changed

+128
-90
lines changed

6 files changed

+128
-90
lines changed

android-activity/android-games-sdk/game-activity/prefab-src/modules/game-activity/include/game-activity/native_app_glue/android_native_app_glue.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,10 @@ struct android_app {
226226
* thread, so we can't say that this is only valid within the `APP_CMD_` handler.
227227
*/
228228
int editorAction;
229+
/**
230+
* true when editorAction has been set
231+
*/
232+
bool pendingEditorAction;
229233

230234
/**
231235
* Current state of the app's activity. May be either APP_CMD_START,

android-activity/android-games-sdk/game-activity/prefab-src/modules/game-activity/src/game-activity/native_app_glue/android_native_app_glue.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -726,9 +726,15 @@ static bool onEditorAction(GameActivity* activity, int action) {
726726
// XXX: this is a racy design that could lose InputConnection actions if the
727727
// application doesn't manage to look at app->editorAction before another
728728
// action is delivered.
729+
if (android_app->pendingEditorAction) {
730+
LOGW("Dropping editor action %d because previous action %d not yet "
731+
"handled",
732+
action, android_app->editorAction);
733+
}
729734
android_app->editorAction = action;
730-
// TODO: buffer these actions like other input events
731-
//notifyInput(android_app);
735+
android_app->pendingEditorAction = true;
736+
notifyInput(android_app);
737+
// TODO: buffer IME text events and editor actions like other input events
732738

733739
//android_app_write_cmd(android_app, APP_CMD_EDITOR_ACTION);
734740
pthread_mutex_unlock(&android_app->mutex);

android-activity/src/game_activity/ffi_aarch64.rs

Lines changed: 29 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6259,6 +6259,8 @@ pub struct android_app {
62596259
pub softwareKeyboardVisible: bool,
62606260
#[doc = " Last editor action. Valid within APP_CMD_SOFTWARE_KB_VIS_CHANGED handler.\n\n Note: the upstream comment above isn't accurate.\n - `APP_CMD_SOFTWARE_KB_VIS_CHANGED` is associated with `softwareKeyboardVisible`\n changes, not `editorAction`.\n - `APP_CMD_EDITOR_ACTION` is associated with this state but unlike for\n `window` state there's no synchonization that blocks the Java main\n thread, so we can't say that this is only valid within the `APP_CMD_` handler."]
62616261
pub editorAction: ::std::os::raw::c_int,
6262+
#[doc = " true when editorAction has been set"]
6263+
pub pendingEditorAction: bool,
62626264
#[doc = " Current state of the app's activity. May be either APP_CMD_START,\n APP_CMD_RESUME, APP_CMD_PAUSE, or APP_CMD_STOP."]
62636265
pub activityState: ::std::os::raw::c_int,
62646266
#[doc = " This is non-zero when the application's GameActivity is being\n destroyed and waiting for the app thread to complete."]
@@ -6292,7 +6294,7 @@ fn bindgen_test_layout_android_app() {
62926294
let ptr = UNINIT.as_ptr();
62936295
assert_eq!(
62946296
::std::mem::size_of::<android_app>(),
6295-
392usize,
6297+
400usize,
62966298
"Size of android_app"
62976299
);
62986300
assert_eq!(
@@ -6356,108 +6358,113 @@ fn bindgen_test_layout_android_app() {
63566358
"Offset of field: android_app::editorAction"
63576359
);
63586360
assert_eq!(
6359-
unsafe { ::std::ptr::addr_of!((*ptr).activityState) as usize - ptr as usize },
6361+
unsafe { ::std::ptr::addr_of!((*ptr).pendingEditorAction) as usize - ptr as usize },
63606362
88usize,
6363+
"Offset of field: android_app::pendingEditorAction"
6364+
);
6365+
assert_eq!(
6366+
unsafe { ::std::ptr::addr_of!((*ptr).activityState) as usize - ptr as usize },
6367+
92usize,
63616368
"Offset of field: android_app::activityState"
63626369
);
63636370
assert_eq!(
63646371
unsafe { ::std::ptr::addr_of!((*ptr).destroyRequested) as usize - ptr as usize },
6365-
92usize,
6372+
96usize,
63666373
"Offset of field: android_app::destroyRequested"
63676374
);
63686375
assert_eq!(
63696376
unsafe { ::std::ptr::addr_of!((*ptr).inputBuffers) as usize - ptr as usize },
6370-
96usize,
6377+
104usize,
63716378
"Offset of field: android_app::inputBuffers"
63726379
);
63736380
assert_eq!(
63746381
unsafe { ::std::ptr::addr_of!((*ptr).currentInputBuffer) as usize - ptr as usize },
6375-
192usize,
6382+
200usize,
63766383
"Offset of field: android_app::currentInputBuffer"
63776384
);
63786385
assert_eq!(
63796386
unsafe { ::std::ptr::addr_of!((*ptr).textInputState) as usize - ptr as usize },
6380-
196usize,
6387+
204usize,
63816388
"Offset of field: android_app::textInputState"
63826389
);
63836390
assert_eq!(
63846391
unsafe { ::std::ptr::addr_of!((*ptr).mutex) as usize - ptr as usize },
6385-
200usize,
6392+
208usize,
63866393
"Offset of field: android_app::mutex"
63876394
);
63886395
assert_eq!(
63896396
unsafe { ::std::ptr::addr_of!((*ptr).cond) as usize - ptr as usize },
6390-
240usize,
6397+
248usize,
63916398
"Offset of field: android_app::cond"
63926399
);
63936400
assert_eq!(
63946401
unsafe { ::std::ptr::addr_of!((*ptr).msgread) as usize - ptr as usize },
6395-
288usize,
6402+
296usize,
63966403
"Offset of field: android_app::msgread"
63976404
);
63986405
assert_eq!(
63996406
unsafe { ::std::ptr::addr_of!((*ptr).msgwrite) as usize - ptr as usize },
6400-
292usize,
6407+
300usize,
64016408
"Offset of field: android_app::msgwrite"
64026409
);
64036410
assert_eq!(
64046411
unsafe { ::std::ptr::addr_of!((*ptr).thread) as usize - ptr as usize },
6405-
296usize,
6412+
304usize,
64066413
"Offset of field: android_app::thread"
64076414
);
64086415
assert_eq!(
64096416
unsafe { ::std::ptr::addr_of!((*ptr).cmdPollSource) as usize - ptr as usize },
6410-
304usize,
6417+
312usize,
64116418
"Offset of field: android_app::cmdPollSource"
64126419
);
64136420
assert_eq!(
64146421
unsafe { ::std::ptr::addr_of!((*ptr).running) as usize - ptr as usize },
6415-
328usize,
6422+
336usize,
64166423
"Offset of field: android_app::running"
64176424
);
64186425
assert_eq!(
64196426
unsafe { ::std::ptr::addr_of!((*ptr).stateSaved) as usize - ptr as usize },
6420-
332usize,
6427+
340usize,
64216428
"Offset of field: android_app::stateSaved"
64226429
);
64236430
assert_eq!(
64246431
unsafe { ::std::ptr::addr_of!((*ptr).destroyed) as usize - ptr as usize },
6425-
336usize,
6432+
344usize,
64266433
"Offset of field: android_app::destroyed"
64276434
);
64286435
assert_eq!(
64296436
unsafe { ::std::ptr::addr_of!((*ptr).redrawNeeded) as usize - ptr as usize },
6430-
340usize,
6437+
348usize,
64316438
"Offset of field: android_app::redrawNeeded"
64326439
);
64336440
assert_eq!(
64346441
unsafe { ::std::ptr::addr_of!((*ptr).pendingWindow) as usize - ptr as usize },
6435-
344usize,
6442+
352usize,
64366443
"Offset of field: android_app::pendingWindow"
64376444
);
64386445
assert_eq!(
64396446
unsafe { ::std::ptr::addr_of!((*ptr).pendingContentRect) as usize - ptr as usize },
6440-
352usize,
6447+
360usize,
64416448
"Offset of field: android_app::pendingContentRect"
64426449
);
64436450
assert_eq!(
64446451
unsafe { ::std::ptr::addr_of!((*ptr).keyEventFilter) as usize - ptr as usize },
6445-
368usize,
6452+
376usize,
64466453
"Offset of field: android_app::keyEventFilter"
64476454
);
64486455
assert_eq!(
64496456
unsafe { ::std::ptr::addr_of!((*ptr).motionEventFilter) as usize - ptr as usize },
6450-
376usize,
6457+
384usize,
64516458
"Offset of field: android_app::motionEventFilter"
64526459
);
64536460
assert_eq!(
64546461
unsafe { ::std::ptr::addr_of!((*ptr).inputAvailableWakeUp) as usize - ptr as usize },
6455-
384usize,
6462+
392usize,
64566463
"Offset of field: android_app::inputAvailableWakeUp"
64576464
);
64586465
assert_eq!(
64596466
unsafe { ::std::ptr::addr_of!((*ptr).inputSwapPending) as usize - ptr as usize },
6460-
385usize,
6467+
393usize,
64616468
"Offset of field: android_app::inputSwapPending"
64626469
);
64636470
}

android-activity/src/game_activity/ffi_arm.rs

Lines changed: 29 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6724,6 +6724,8 @@ pub struct android_app {
67246724
pub softwareKeyboardVisible: bool,
67256725
#[doc = " Last editor action. Valid within APP_CMD_SOFTWARE_KB_VIS_CHANGED handler.\n\n Note: the upstream comment above isn't accurate.\n - `APP_CMD_SOFTWARE_KB_VIS_CHANGED` is associated with `softwareKeyboardVisible`\n changes, not `editorAction`.\n - `APP_CMD_EDITOR_ACTION` is associated with this state but unlike for\n `window` state there's no synchonization that blocks the Java main\n thread, so we can't say that this is only valid within the `APP_CMD_` handler."]
67266726
pub editorAction: ::std::os::raw::c_int,
6727+
#[doc = " true when editorAction has been set"]
6728+
pub pendingEditorAction: bool,
67276729
#[doc = " Current state of the app's activity. May be either APP_CMD_START,\n APP_CMD_RESUME, APP_CMD_PAUSE, or APP_CMD_STOP."]
67286730
pub activityState: ::std::os::raw::c_int,
67296731
#[doc = " This is non-zero when the application's GameActivity is being\n destroyed and waiting for the app thread to complete."]
@@ -6757,7 +6759,7 @@ fn bindgen_test_layout_android_app() {
67576759
let ptr = UNINIT.as_ptr();
67586760
assert_eq!(
67596761
::std::mem::size_of::<android_app>(),
6760-
248usize,
6762+
256usize,
67616763
"Size of android_app"
67626764
);
67636765
assert_eq!(
@@ -6821,108 +6823,113 @@ fn bindgen_test_layout_android_app() {
68216823
"Offset of field: android_app::editorAction"
68226824
);
68236825
assert_eq!(
6824-
unsafe { ::std::ptr::addr_of!((*ptr).activityState) as usize - ptr as usize },
6826+
unsafe { ::std::ptr::addr_of!((*ptr).pendingEditorAction) as usize - ptr as usize },
68256827
56usize,
6828+
"Offset of field: android_app::pendingEditorAction"
6829+
);
6830+
assert_eq!(
6831+
unsafe { ::std::ptr::addr_of!((*ptr).activityState) as usize - ptr as usize },
6832+
60usize,
68266833
"Offset of field: android_app::activityState"
68276834
);
68286835
assert_eq!(
68296836
unsafe { ::std::ptr::addr_of!((*ptr).destroyRequested) as usize - ptr as usize },
6830-
60usize,
6837+
64usize,
68316838
"Offset of field: android_app::destroyRequested"
68326839
);
68336840
assert_eq!(
68346841
unsafe { ::std::ptr::addr_of!((*ptr).inputBuffers) as usize - ptr as usize },
6835-
64usize,
6842+
72usize,
68366843
"Offset of field: android_app::inputBuffers"
68376844
);
68386845
assert_eq!(
68396846
unsafe { ::std::ptr::addr_of!((*ptr).currentInputBuffer) as usize - ptr as usize },
6840-
160usize,
6847+
168usize,
68416848
"Offset of field: android_app::currentInputBuffer"
68426849
);
68436850
assert_eq!(
68446851
unsafe { ::std::ptr::addr_of!((*ptr).textInputState) as usize - ptr as usize },
6845-
164usize,
6852+
172usize,
68466853
"Offset of field: android_app::textInputState"
68476854
);
68486855
assert_eq!(
68496856
unsafe { ::std::ptr::addr_of!((*ptr).mutex) as usize - ptr as usize },
6850-
168usize,
6857+
176usize,
68516858
"Offset of field: android_app::mutex"
68526859
);
68536860
assert_eq!(
68546861
unsafe { ::std::ptr::addr_of!((*ptr).cond) as usize - ptr as usize },
6855-
172usize,
6862+
180usize,
68566863
"Offset of field: android_app::cond"
68576864
);
68586865
assert_eq!(
68596866
unsafe { ::std::ptr::addr_of!((*ptr).msgread) as usize - ptr as usize },
6860-
176usize,
6867+
184usize,
68616868
"Offset of field: android_app::msgread"
68626869
);
68636870
assert_eq!(
68646871
unsafe { ::std::ptr::addr_of!((*ptr).msgwrite) as usize - ptr as usize },
6865-
180usize,
6872+
188usize,
68666873
"Offset of field: android_app::msgwrite"
68676874
);
68686875
assert_eq!(
68696876
unsafe { ::std::ptr::addr_of!((*ptr).thread) as usize - ptr as usize },
6870-
184usize,
6877+
192usize,
68716878
"Offset of field: android_app::thread"
68726879
);
68736880
assert_eq!(
68746881
unsafe { ::std::ptr::addr_of!((*ptr).cmdPollSource) as usize - ptr as usize },
6875-
188usize,
6882+
196usize,
68766883
"Offset of field: android_app::cmdPollSource"
68776884
);
68786885
assert_eq!(
68796886
unsafe { ::std::ptr::addr_of!((*ptr).running) as usize - ptr as usize },
6880-
200usize,
6887+
208usize,
68816888
"Offset of field: android_app::running"
68826889
);
68836890
assert_eq!(
68846891
unsafe { ::std::ptr::addr_of!((*ptr).stateSaved) as usize - ptr as usize },
6885-
204usize,
6892+
212usize,
68866893
"Offset of field: android_app::stateSaved"
68876894
);
68886895
assert_eq!(
68896896
unsafe { ::std::ptr::addr_of!((*ptr).destroyed) as usize - ptr as usize },
6890-
208usize,
6897+
216usize,
68916898
"Offset of field: android_app::destroyed"
68926899
);
68936900
assert_eq!(
68946901
unsafe { ::std::ptr::addr_of!((*ptr).redrawNeeded) as usize - ptr as usize },
6895-
212usize,
6902+
220usize,
68966903
"Offset of field: android_app::redrawNeeded"
68976904
);
68986905
assert_eq!(
68996906
unsafe { ::std::ptr::addr_of!((*ptr).pendingWindow) as usize - ptr as usize },
6900-
216usize,
6907+
224usize,
69016908
"Offset of field: android_app::pendingWindow"
69026909
);
69036910
assert_eq!(
69046911
unsafe { ::std::ptr::addr_of!((*ptr).pendingContentRect) as usize - ptr as usize },
6905-
220usize,
6912+
228usize,
69066913
"Offset of field: android_app::pendingContentRect"
69076914
);
69086915
assert_eq!(
69096916
unsafe { ::std::ptr::addr_of!((*ptr).keyEventFilter) as usize - ptr as usize },
6910-
236usize,
6917+
244usize,
69116918
"Offset of field: android_app::keyEventFilter"
69126919
);
69136920
assert_eq!(
69146921
unsafe { ::std::ptr::addr_of!((*ptr).motionEventFilter) as usize - ptr as usize },
6915-
240usize,
6922+
248usize,
69166923
"Offset of field: android_app::motionEventFilter"
69176924
);
69186925
assert_eq!(
69196926
unsafe { ::std::ptr::addr_of!((*ptr).inputAvailableWakeUp) as usize - ptr as usize },
6920-
244usize,
6927+
252usize,
69216928
"Offset of field: android_app::inputAvailableWakeUp"
69226929
);
69236930
assert_eq!(
69246931
unsafe { ::std::ptr::addr_of!((*ptr).inputSwapPending) as usize - ptr as usize },
6925-
245usize,
6932+
253usize,
69266933
"Offset of field: android_app::inputSwapPending"
69276934
);
69286935
}

0 commit comments

Comments
 (0)