Skip to content

Commit

Permalink
game-activity: Integrate GameActivity 2.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
rib committed Jul 22, 2023
1 parent a8d5c37 commit 8067b0f
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 14 deletions.
9 changes: 6 additions & 3 deletions android-activity/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
<!-- markdownlint-disable MD022 MD024 MD032 -->

# Changelog
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

### Changed
- GameActivity updated to 2.0.2 (requires the corresponding 2.0.2 `.aar` release from Google) ([#88](https://github.com/rust-mobile/android-activity/pull/88))

## [0.4.2] - 2022-02-16
### Changed
Expand All @@ -19,7 +22,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed
- Removed some overly-verbose logging in the `native-activity` backend ([#49](https://github.com/rust-mobile/android-activity/pull/49))
### Removed
- Most of the examples were moved to https://github.com/rust-mobile/rust-android-examples ([#50](https://github.com/rust-mobile/android-activity/pull/50))
- Most of the examples were moved to <https://github.com/rust-mobile/rust-android-examples> ([#50](https://github.com/rust-mobile/android-activity/pull/50))

## [0.4] - 2022-11-10
### Changed
Expand Down Expand Up @@ -54,4 +57,4 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [0.1] - 2022-07-04
### Added
- Initial release
- Initial release
39 changes: 28 additions & 11 deletions android-activity/src/game_activity/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,17 @@ impl<'a> MotionEventsLendingIterator<'a> {
}
fn next(&mut self) -> Option<MotionEvent<'a>> {
if self.pos < self.count {
let ga_event = unsafe { &(*self.buffer.ptr.as_ptr()).motionEvents[self.pos] };
// Safety:
// - This iterator currently has exclusive access to the front buffer of events
// - We know the buffer is non-null
// - `pos` is less than the number of events stored in the buffer
let ga_event = unsafe {
(*self.buffer.ptr.as_ptr())
.motionEvents
.offset(self.pos as isize)
.as_ref()
.unwrap()
};
let event = MotionEvent::new(ga_event);
self.pos += 1;
Some(event)
Expand Down Expand Up @@ -496,7 +506,17 @@ impl<'a> KeyEventsLendingIterator<'a> {
}
fn next(&mut self) -> Option<KeyEvent<'a>> {
if self.pos < self.count {
let ga_event = unsafe { &(*self.buffer.ptr.as_ptr()).keyEvents[self.pos] };
// Safety:
// - This iterator currently has exclusive access to the front buffer of events
// - We know the buffer is non-null
// - `pos` is less than the number of events stored in the buffer
let ga_event = unsafe {
(*self.buffer.ptr.as_ptr())
.keyEvents
.offset(self.pos as isize)
.as_ref()
.unwrap()
};
let event = KeyEvent::new(ga_event);
self.pos += 1;
Some(event)
Expand Down Expand Up @@ -543,16 +563,15 @@ impl<'a> Drop for InputBuffer<'a> {
//
// https://github.com/rust-lang/rfcs/issues/2771
extern "C" {
pub fn Java_com_google_androidgamesdk_GameActivity_loadNativeCode_C(
pub fn Java_com_google_androidgamesdk_GameActivity_initializeNativeCode_C(
env: *mut JNIEnv,
javaGameActivity: jobject,
path: jstring,
funcName: jstring,
internalDataDir: jstring,
obbDir: jstring,
externalDataDir: jstring,
jAssetMgr: jobject,
savedState: jbyteArray,
javaConfig: jobject,
) -> jlong;

pub fn GameActivity_onCreate_C(
Expand All @@ -563,27 +582,25 @@ extern "C" {
}

#[no_mangle]
pub unsafe extern "C" fn Java_com_google_androidgamesdk_GameActivity_loadNativeCode(
pub unsafe extern "C" fn Java_com_google_androidgamesdk_GameActivity_initializeNativeCode(
env: *mut JNIEnv,
java_game_activity: jobject,
path: jstring,
func_name: jstring,
internal_data_dir: jstring,
obb_dir: jstring,
external_data_dir: jstring,
jasset_mgr: jobject,
saved_state: jbyteArray,
java_config: jobject,
) -> jni_sys::jlong {
Java_com_google_androidgamesdk_GameActivity_loadNativeCode_C(
Java_com_google_androidgamesdk_GameActivity_initializeNativeCode_C(
env,
java_game_activity,
path,
func_name,
internal_data_dir,
obb_dir,
external_data_dir,
jasset_mgr,
saved_state,
java_config,
)
}

Expand Down

0 comments on commit 8067b0f

Please # to comment.