Skip to content

Commit

Permalink
Merge pull request #106 from rust-mobile/rib/pr/game-activity-disable…
Browse files Browse the repository at this point in the history
…-get-unicode-char

GameActivity PATCH: Don't read unicode via getUnicodeChar
  • Loading branch information
rib authored Aug 7, 2023
2 parents b4cf0ee + 6b33074 commit 535994f
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 54 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ static struct {
jmethodID getRepeatCount;
jmethodID getKeyCode;
jmethodID getScanCode;
jmethodID getUnicodeChar;
//jmethodID getUnicodeChar;
} gKeyEventClassInfo;

extern "C" void GameActivityKeyEvent_fromJava(JNIEnv *env, jobject keyEvent,
Expand Down Expand Up @@ -379,8 +379,8 @@ extern "C" void GameActivityKeyEvent_fromJava(JNIEnv *env, jobject keyEvent,
env->GetMethodID(keyEventClass, "getKeyCode", "()I");
gKeyEventClassInfo.getScanCode =
env->GetMethodID(keyEventClass, "getScanCode", "()I");
gKeyEventClassInfo.getUnicodeChar =
env->GetMethodID(keyEventClass, "getUnicodeChar", "()I");
//gKeyEventClassInfo.getUnicodeChar =
// env->GetMethodID(keyEventClass, "getUnicodeChar", "()I");

gKeyEventClassInfoInitialized = true;
}
Expand All @@ -407,7 +407,8 @@ extern "C" void GameActivityKeyEvent_fromJava(JNIEnv *env, jobject keyEvent,
/*keyCode=*/
env->CallIntMethod(keyEvent, gKeyEventClassInfo.getKeyCode),
/*scanCode=*/
env->CallIntMethod(keyEvent, gKeyEventClassInfo.getScanCode),
env->CallIntMethod(keyEvent, gKeyEventClassInfo.getScanCode)
/*unicodeChar=*/
env->CallIntMethod(keyEvent, gKeyEventClassInfo.getUnicodeChar)};
//env->CallIntMethod(keyEvent, gKeyEventClassInfo.getUnicodeChar)
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ typedef struct GameActivityKeyEvent {
int32_t repeatCount;
int32_t keyCode;
int32_t scanCode;
int32_t unicodeChar;
//int32_t unicodeChar;
} GameActivityKeyEvent;

/**
Expand Down
13 changes: 1 addition & 12 deletions android-activity/src/game_activity/ffi_aarch64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2686,15 +2686,14 @@ pub struct GameActivityKeyEvent {
pub repeatCount: i32,
pub keyCode: i32,
pub scanCode: i32,
pub unicodeChar: i32,
}
#[test]
fn bindgen_test_layout_GameActivityKeyEvent() {
const UNINIT: ::std::mem::MaybeUninit<GameActivityKeyEvent> = ::std::mem::MaybeUninit::uninit();
let ptr = UNINIT.as_ptr();
assert_eq!(
::std::mem::size_of::<GameActivityKeyEvent>(),
64usize,
56usize,
concat!("Size of: ", stringify!(GameActivityKeyEvent))
);
assert_eq!(
Expand Down Expand Up @@ -2812,16 +2811,6 @@ fn bindgen_test_layout_GameActivityKeyEvent() {
stringify!(scanCode)
)
);
assert_eq!(
unsafe { ::std::ptr::addr_of!((*ptr).unicodeChar) as usize - ptr as usize },
56usize,
concat!(
"Offset of field: ",
stringify!(GameActivityKeyEvent),
"::",
stringify!(unicodeChar)
)
);
}
extern "C" {
#[doc = " \\brief Convert a Java `KeyEvent` to a `GameActivityKeyEvent`.\n\n This is done automatically by the GameActivity: see `onKeyUp` and `onKeyDown`\n to set a callback to consume the received events.\n This function can be used if you re-implement events handling in your own\n activity.\n Ownership of out_event is maintained by the caller."]
Expand Down
13 changes: 1 addition & 12 deletions android-activity/src/game_activity/ffi_arm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2716,15 +2716,14 @@ pub struct GameActivityKeyEvent {
pub repeatCount: i32,
pub keyCode: i32,
pub scanCode: i32,
pub unicodeChar: i32,
}
#[test]
fn bindgen_test_layout_GameActivityKeyEvent() {
const UNINIT: ::std::mem::MaybeUninit<GameActivityKeyEvent> = ::std::mem::MaybeUninit::uninit();
let ptr = UNINIT.as_ptr();
assert_eq!(
::std::mem::size_of::<GameActivityKeyEvent>(),
64usize,
56usize,
concat!("Size of: ", stringify!(GameActivityKeyEvent))
);
assert_eq!(
Expand Down Expand Up @@ -2842,16 +2841,6 @@ fn bindgen_test_layout_GameActivityKeyEvent() {
stringify!(scanCode)
)
);
assert_eq!(
unsafe { ::std::ptr::addr_of!((*ptr).unicodeChar) as usize - ptr as usize },
56usize,
concat!(
"Offset of field: ",
stringify!(GameActivityKeyEvent),
"::",
stringify!(unicodeChar)
)
);
}
extern "C" {
#[doc = " \\brief Convert a Java `KeyEvent` to a `GameActivityKeyEvent`.\n\n This is done automatically by the GameActivity: see `onKeyUp` and `onKeyDown`\n to set a callback to consume the received events.\n This function can be used if you re-implement events handling in your own\n activity.\n Ownership of out_event is maintained by the caller."]
Expand Down
13 changes: 1 addition & 12 deletions android-activity/src/game_activity/ffi_i686.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2637,15 +2637,14 @@ pub struct GameActivityKeyEvent {
pub repeatCount: i32,
pub keyCode: i32,
pub scanCode: i32,
pub unicodeChar: i32,
}
#[test]
fn bindgen_test_layout_GameActivityKeyEvent() {
const UNINIT: ::std::mem::MaybeUninit<GameActivityKeyEvent> = ::std::mem::MaybeUninit::uninit();
let ptr = UNINIT.as_ptr();
assert_eq!(
::std::mem::size_of::<GameActivityKeyEvent>(),
56usize,
52usize,
concat!("Size of: ", stringify!(GameActivityKeyEvent))
);
assert_eq!(
Expand Down Expand Up @@ -2763,16 +2762,6 @@ fn bindgen_test_layout_GameActivityKeyEvent() {
stringify!(scanCode)
)
);
assert_eq!(
unsafe { ::std::ptr::addr_of!((*ptr).unicodeChar) as usize - ptr as usize },
52usize,
concat!(
"Offset of field: ",
stringify!(GameActivityKeyEvent),
"::",
stringify!(unicodeChar)
)
);
}
extern "C" {
#[doc = " \\brief Convert a Java `KeyEvent` to a `GameActivityKeyEvent`.\n\n This is done automatically by the GameActivity: see `onKeyUp` and `onKeyDown`\n to set a callback to consume the received events.\n This function can be used if you re-implement events handling in your own\n activity.\n Ownership of out_event is maintained by the caller."]
Expand Down
13 changes: 1 addition & 12 deletions android-activity/src/game_activity/ffi_x86_64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2666,15 +2666,14 @@ pub struct GameActivityKeyEvent {
pub repeatCount: i32,
pub keyCode: i32,
pub scanCode: i32,
pub unicodeChar: i32,
}
#[test]
fn bindgen_test_layout_GameActivityKeyEvent() {
const UNINIT: ::std::mem::MaybeUninit<GameActivityKeyEvent> = ::std::mem::MaybeUninit::uninit();
let ptr = UNINIT.as_ptr();
assert_eq!(
::std::mem::size_of::<GameActivityKeyEvent>(),
64usize,
56usize,
concat!("Size of: ", stringify!(GameActivityKeyEvent))
);
assert_eq!(
Expand Down Expand Up @@ -2792,16 +2791,6 @@ fn bindgen_test_layout_GameActivityKeyEvent() {
stringify!(scanCode)
)
);
assert_eq!(
unsafe { ::std::ptr::addr_of!((*ptr).unicodeChar) as usize - ptr as usize },
56usize,
concat!(
"Offset of field: ",
stringify!(GameActivityKeyEvent),
"::",
stringify!(unicodeChar)
)
);
}
extern "C" {
#[doc = " \\brief Convert a Java `KeyEvent` to a `GameActivityKeyEvent`.\n\n This is done automatically by the GameActivity: see `onKeyUp` and `onKeyDown`\n to set a callback to consume the received events.\n This function can be used if you re-implement events handling in your own\n activity.\n Ownership of out_event is maintained by the caller."]
Expand Down

0 comments on commit 535994f

Please sign in to comment.