From 9a7d351d67396363f0d78473842d321f6c764877 Mon Sep 17 00:00:00 2001 From: Romain Vimont Date: Fri, 30 Apr 2021 23:01:58 +0200 Subject: [PATCH] Simplify non-static injectEvent() implementation Just call the static version (having a displayId) from the non-static version (using the displayId field). --- server/src/main/java/com/genymobile/scrcpy/Device.java | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/server/src/main/java/com/genymobile/scrcpy/Device.java b/server/src/main/java/com/genymobile/scrcpy/Device.java index 7d1d3aa8..4374ffc5 100644 --- a/server/src/main/java/com/genymobile/scrcpy/Device.java +++ b/server/src/main/java/com/genymobile/scrcpy/Device.java @@ -188,10 +188,7 @@ public final class Device { } public boolean injectKeyEvent(int action, int keyCode, int repeat, int metaState) { - long now = SystemClock.uptimeMillis(); - KeyEvent event = new KeyEvent(now, now, action, keyCode, repeat, metaState, KeyCharacterMap.VIRTUAL_KEYBOARD, 0, 0, - InputDevice.SOURCE_KEYBOARD); - return injectEvent(event); + return injectKeyEvent(action, keyCode, repeat, metaState, displayId); } public static boolean injectKeycode(int keyCode, int displayId) { @@ -199,7 +196,7 @@ public final class Device { } public boolean injectKeycode(int keyCode) { - return injectKeyEvent(KeyEvent.ACTION_DOWN, keyCode, 0, 0) && injectKeyEvent(KeyEvent.ACTION_UP, keyCode, 0, 0); + return injectKeycode(keyCode, displayId); } public static boolean isScreenOn() {