mirror of
https://github.com/Genymobile/scrcpy.git
synced 2025-04-20 11:35:57 +00:00
Update EventController.java
add KeyCharacterMap.UnavailableException in charMap
This commit is contained in:
parent
e2ef39fae5
commit
5aa68dd172
1 changed files with 11 additions and 1 deletions
|
@ -19,7 +19,8 @@ public class EventController {
|
|||
private final Device device;
|
||||
private final DesktopConnection connection;
|
||||
|
||||
private final KeyCharacterMap charMap = KeyCharacterMap.load(KeyCharacterMap.VIRTUAL_KEYBOARD);
|
||||
// private final KeyCharacterMap charMap = KeyCharacterMap.load(KeyCharacterMap.VIRTUAL_KEYBOARD);
|
||||
private KeyCharacterMap charMap;
|
||||
|
||||
private long lastMouseDown;
|
||||
private final MotionEvent.PointerProperties[] pointerProperties = {new MotionEvent.PointerProperties()};
|
||||
|
@ -93,6 +94,15 @@ public class EventController {
|
|||
private boolean injectChar(char c) {
|
||||
String decomposed = KeyComposition.decompose(c);
|
||||
char[] chars = decomposed != null ? decomposed.toCharArray() : new char[] {c};
|
||||
|
||||
if (charMap == null) {
|
||||
try {
|
||||
charMap = KeyCharacterMap.load(KeyCharacterMap.VIRTUAL_KEYBOARD);
|
||||
} catch (KeyCharacterMap.UnavailableException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
KeyEvent[] events = charMap.getEvents(chars);
|
||||
if (events == null) {
|
||||
return false;
|
||||
|
|
Loading…
Add table
Reference in a new issue