-
Notifications
You must be signed in to change notification settings - Fork 6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Android] Fix a crash related to zeroed scanCode #35924
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -122,7 +122,7 @@ void updatePressingState(@NonNull Long physicalKey, @Nullable Long logicalKey) { | |
// the current event in consideration. | ||
// | ||
// Events that should be synthesized before the main event are synthesized | ||
// immediately, while events that should be syntehsized after the main event are appended to | ||
// immediately, while events that should be synthesized after the main event are appended to | ||
// `postSynchronize`. | ||
// | ||
// Although Android KeyEvent defined bitmasks for sided modifiers (SHIFT_LEFT_ON and | ||
|
@@ -133,6 +133,7 @@ void synchronizePressingKey( | |
PressingGoal goal, | ||
boolean truePressed, | ||
long eventLogicalKey, | ||
long eventPhysicalKey, | ||
KeyEvent event, | ||
ArrayList<Runnable> postSynchronize) { | ||
// During an incoming event, there might be a synthesized Flutter event for each key of each | ||
|
@@ -151,8 +152,8 @@ void synchronizePressingKey( | |
// 2. Derive the pre-event state of the event key (if applicable.) | ||
for (int keyIdx = 0; keyIdx < goal.keys.length; keyIdx += 1) { | ||
final KeyboardMap.KeyPair key = goal.keys[keyIdx]; | ||
nowStates[keyIdx] = pressingRecords.containsKey(goal.keys[keyIdx].physicalKey); | ||
if (goal.keys[keyIdx].logicalKey == eventLogicalKey) { | ||
nowStates[keyIdx] = pressingRecords.containsKey(key.physicalKey); | ||
if (key.logicalKey == eventLogicalKey) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just to confirm, are these two lines of change make any difference, or purely cosmetic? (I'm ok with either) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Purely cosmetic. The 'key' variable was already defined (before this PR) and It could be used on this two lines. |
||
switch (getEventType(event)) { | ||
case kDown: | ||
preEventStates[keyIdx] = false; | ||
|
@@ -161,7 +162,7 @@ void synchronizePressingKey( | |
postSynchronize.add( | ||
() -> | ||
synthesizeEvent( | ||
false, key.logicalKey, key.physicalKey, event.getEventTime())); | ||
false, key.logicalKey, eventPhysicalKey, event.getEventTime())); | ||
} | ||
break; | ||
case kUp: | ||
|
@@ -273,7 +274,12 @@ private boolean handleEventImpl( | |
final ArrayList<Runnable> postSynchronizeEvents = new ArrayList<>(); | ||
for (final PressingGoal goal : KeyboardMap.pressingGoals) { | ||
synchronizePressingKey( | ||
goal, (event.getMetaState() & goal.mask) != 0, logicalKey, event, postSynchronizeEvents); | ||
goal, | ||
(event.getMetaState() & goal.mask) != 0, | ||
logicalKey, | ||
physicalKey, | ||
event, | ||
postSynchronizeEvents); | ||
} | ||
|
||
for (final TogglingGoal goal : togglingGoals.values()) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for catching that! 😊