mirror of
https://github.com/Genymobile/scrcpy.git
synced 2026-04-21 01:33:36 +00:00
Handle repeating keycodes
Initialize "repeat" count on key events. PR #1519 <https://github.com/Genymobile/scrcpy/pull/1519> Refs #1013 <https://github.com/Genymobile/scrcpy/pull/1013> Signed-off-by: Romain Vimont <rom@rom1v.com>
This commit is contained in:
parent
0ba74fbd9a
commit
3c1ed5d86c
10 changed files with 45 additions and 11 deletions
|
|
@ -31,15 +31,17 @@ public final class ControlMessage {
|
|||
private int hScroll;
|
||||
private int vScroll;
|
||||
private int flags;
|
||||
private int repeat;
|
||||
|
||||
private ControlMessage() {
|
||||
}
|
||||
|
||||
public static ControlMessage createInjectKeycode(int action, int keycode, int metaState) {
|
||||
public static ControlMessage createInjectKeycode(int action, int keycode, int repeat, int metaState) {
|
||||
ControlMessage msg = new ControlMessage();
|
||||
msg.type = TYPE_INJECT_KEYCODE;
|
||||
msg.action = action;
|
||||
msg.keycode = keycode;
|
||||
msg.repeat = repeat;
|
||||
msg.metaState = metaState;
|
||||
return msg;
|
||||
}
|
||||
|
|
@ -144,4 +146,8 @@ public final class ControlMessage {
|
|||
public int getFlags() {
|
||||
return flags;
|
||||
}
|
||||
|
||||
public int getRepeat() {
|
||||
return repeat;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import java.nio.charset.StandardCharsets;
|
|||
|
||||
public class ControlMessageReader {
|
||||
|
||||
static final int INJECT_KEYCODE_PAYLOAD_LENGTH = 9;
|
||||
static final int INJECT_KEYCODE_PAYLOAD_LENGTH = 13;
|
||||
static final int INJECT_TOUCH_EVENT_PAYLOAD_LENGTH = 27;
|
||||
static final int INJECT_SCROLL_EVENT_PAYLOAD_LENGTH = 20;
|
||||
static final int SET_SCREEN_POWER_MODE_PAYLOAD_LENGTH = 1;
|
||||
|
|
@ -98,8 +98,9 @@ public class ControlMessageReader {
|
|||
}
|
||||
int action = toUnsigned(buffer.get());
|
||||
int keycode = buffer.getInt();
|
||||
int repeat = buffer.getInt();
|
||||
int metaState = buffer.getInt();
|
||||
return ControlMessage.createInjectKeycode(action, keycode, metaState);
|
||||
return ControlMessage.createInjectKeycode(action, keycode, repeat, metaState);
|
||||
}
|
||||
|
||||
private String parseString() {
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ public class Controller {
|
|||
switch (msg.getType()) {
|
||||
case ControlMessage.TYPE_INJECT_KEYCODE:
|
||||
if (device.supportsInputEvents()) {
|
||||
injectKeycode(msg.getAction(), msg.getKeycode(), msg.getMetaState());
|
||||
injectKeycode(msg.getAction(), msg.getKeycode(), msg.getRepeat(), msg.getMetaState());
|
||||
}
|
||||
break;
|
||||
case ControlMessage.TYPE_INJECT_TEXT:
|
||||
|
|
@ -130,8 +130,8 @@ public class Controller {
|
|||
}
|
||||
}
|
||||
|
||||
private boolean injectKeycode(int action, int keycode, int metaState) {
|
||||
return device.injectKeyEvent(action, keycode, 0, metaState);
|
||||
private boolean injectKeycode(int action, int keycode, int repeat, int metaState) {
|
||||
return device.injectKeyEvent(action, keycode, repeat, metaState);
|
||||
}
|
||||
|
||||
private boolean injectChar(char c) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue