mirror of
https://github.com/Genymobile/scrcpy
synced 2025-08-31 14:25:56 +00:00
Extract control event String parsing
Parsing a String from a serialized control event, encoded as length (2 bytes) + data, will be necessary in several events. Extract it to a separate method.
This commit is contained in:
@@ -92,7 +92,7 @@ public class ControlEventReader {
|
||||
return ControlEvent.createKeycodeControlEvent(action, keycode, metaState);
|
||||
}
|
||||
|
||||
private ControlEvent parseTextControlEvent() {
|
||||
private String parseString() {
|
||||
if (buffer.remaining() < 2) {
|
||||
return null;
|
||||
}
|
||||
@@ -101,7 +101,14 @@ public class ControlEventReader {
|
||||
return null;
|
||||
}
|
||||
buffer.get(textBuffer, 0, len);
|
||||
String text = new String(textBuffer, 0, len, StandardCharsets.UTF_8);
|
||||
return new String(textBuffer, 0, len, StandardCharsets.UTF_8);
|
||||
}
|
||||
|
||||
private ControlEvent parseTextControlEvent() {
|
||||
String text = parseString();
|
||||
if (text == null) {
|
||||
return null;
|
||||
}
|
||||
return ControlEvent.createTextControlEvent(text);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user