Repository navigation
BGF: Minor code fixit on callbacks/controllers/command names - #127
Merged
Merged
Conversation
…names
Fix callback and controller bugs in base_game_framework's system event
and game controller managers, and the app command names used in the
lifecycle debug log:
- SystemEventManager::SetMemoryWarningEventCallback stored its
user_data into lifecycle_event_user_data_, so the memory callback got
a stale pointer and registering it clobbered the lifecycle
callback's user_data.
- GameControllerManager integrated (handset) motion:
- Report support from Paddleboat_getIntegratedMotionSensorFlags().
integrated_motion_data_ was never set, so
GetIntegratedMotionDataSupport() always returned false and
SetIntegratedMotionDataCallback() was a no-op.
- Integrated sensor reporting was enabled unconditionally at init, so
the accelerometer and gyroscope were sampled continuously in every
app (even agdktunnel idle on its menu). Reporting is now enabled
only while an integrated motion callback is registered and disabled
when it is cleared.
- GameControllerManager controller status:
- Map Paddleboat's JUST_CONNECTED / JUST_DISCONNECTED status callback
values. JUST_CONNECTED was treated as inactive, so a newly connected
controller was reported to the app as kInactive.
- Fire status_callback_ for status changes detected in Update(), and
only on real changes. If a different controller takes an already
active slot (device_id changed, e.g. swapped while stopped), report
a disconnect then a connect so its info is refreshed. Clear a
slot's data and info on disconnect so held buttons/sticks don't
stay stuck.
- Implement SetConsumeBackButton(), which was declared but never
defined (link error if called), via Paddleboat_setBackButtonConsumed.
- static_assert kMaxControllers <= PADDLEBOAT_MAX_CONTROLLERS, and
make GetIntegratedMotionDataSupport() const.
- PlatformEventAndroid: replace the kGlueCommandStrings array with a
switch on NativeAppGlueAppCmd. The array was missing
APP_CMD_SOFTWARE_KB_VIS_CHANGED, so every name for commands 6-16 was
off by one and command 17 read past the end of the array. The switch
names every command and has no default case, so -Wswitch fails the
build if a GameActivity update adds one. Out-of-range values log
UNKNOWN_APP_CMD.
Tested on a Pixel 10 Pro with agdktunnel and temporary test hooks:
- Lifecycle and memory callbacks receive their own user_data (memory
event from am send-trim-memory RUNNING_CRITICAL).
- dumpsys sensorservice: before this change the idle app held the
accelerometer and gyroscope; now it holds neither until an integrated
motion callback is registered. Integrated events arrive with their
user_data while registered, and stop (and the sensors are released)
when it is cleared.
- SetConsumeBackButton(false/true) round-trips via
Paddleboat_getBackButtonConsumed().
- Logcat shows correct names for all lifecycle commands. Removing a
case from the switch fails the build with -Wswitch.
Controller connect, disconnect and swap paths were not tested (no
physical controller available).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix event callback user data, controller status/motion, command names
Fix callback and controller bugs in base_game_framework's system event and game controller managers, and the app command names used in the lifecycle debug log: