GameActivity PATCH: Don't read unicode via getUnicodeChar

The `unicodeChar` in `GameActivityKeyEvent` wasn't being exposed by
`android-activity` because we couldn't expose the unicode character in
the same way with the native-activity backend - due to how events are
received via an `InputQueue` that doesn't expose the underlying Java
references for the key events.

Now that we have a consistent way of supporting unicode character
mapping via `KeyCharacterMap` bindings it's redundant for the
`GameActivity` backend to call `getUnicodeChar` automatically for
each key press.
This commit is contained in:
Robert Bragg
2023-08-03 10:02:13 +01:00
parent b4cf0eeabf
commit 6b3307410e
6 changed files with 11 additions and 54 deletions
@@ -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,
@@ -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;
}
@@ -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)
};
}
@@ -312,7 +312,7 @@ typedef struct GameActivityKeyEvent {
int32_t repeatCount;
int32_t keyCode;
int32_t scanCode;
int32_t unicodeChar;
//int32_t unicodeChar;
} GameActivityKeyEvent;
/**
@@ -2686,7 +2686,6 @@ pub struct GameActivityKeyEvent {
pub repeatCount: i32,
pub keyCode: i32,
pub scanCode: i32,
pub unicodeChar: i32,
}
#[test]
fn bindgen_test_layout_GameActivityKeyEvent() {
@@ -2694,7 +2693,7 @@ fn bindgen_test_layout_GameActivityKeyEvent() {
let ptr = UNINIT.as_ptr();
assert_eq!(
::std::mem::size_of::<GameActivityKeyEvent>(),
64usize,
56usize,
concat!("Size of: ", stringify!(GameActivityKeyEvent))
);
assert_eq!(
@@ -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."]
+1 -12
View File
@@ -2716,7 +2716,6 @@ pub struct GameActivityKeyEvent {
pub repeatCount: i32,
pub keyCode: i32,
pub scanCode: i32,
pub unicodeChar: i32,
}
#[test]
fn bindgen_test_layout_GameActivityKeyEvent() {
@@ -2724,7 +2723,7 @@ fn bindgen_test_layout_GameActivityKeyEvent() {
let ptr = UNINIT.as_ptr();
assert_eq!(
::std::mem::size_of::<GameActivityKeyEvent>(),
64usize,
56usize,
concat!("Size of: ", stringify!(GameActivityKeyEvent))
);
assert_eq!(
@@ -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."]
+1 -12
View File
@@ -2637,7 +2637,6 @@ pub struct GameActivityKeyEvent {
pub repeatCount: i32,
pub keyCode: i32,
pub scanCode: i32,
pub unicodeChar: i32,
}
#[test]
fn bindgen_test_layout_GameActivityKeyEvent() {
@@ -2645,7 +2644,7 @@ fn bindgen_test_layout_GameActivityKeyEvent() {
let ptr = UNINIT.as_ptr();
assert_eq!(
::std::mem::size_of::<GameActivityKeyEvent>(),
56usize,
52usize,
concat!("Size of: ", stringify!(GameActivityKeyEvent))
);
assert_eq!(
@@ -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."]
@@ -2666,7 +2666,6 @@ pub struct GameActivityKeyEvent {
pub repeatCount: i32,
pub keyCode: i32,
pub scanCode: i32,
pub unicodeChar: i32,
}
#[test]
fn bindgen_test_layout_GameActivityKeyEvent() {
@@ -2674,7 +2673,7 @@ fn bindgen_test_layout_GameActivityKeyEvent() {
let ptr = UNINIT.as_ptr();
assert_eq!(
::std::mem::size_of::<GameActivityKeyEvent>(),
64usize,
56usize,
concat!("Size of: ", stringify!(GameActivityKeyEvent))
);
assert_eq!(
@@ -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."]