Skip to content

Commit

Permalink
Simplify non-static injectEvent() implementation
Browse files Browse the repository at this point in the history
Just call the static version (having a displayId) from the non-static
version (using the displayId field).
  • Loading branch information
rom1v committed Apr 30, 2021
1 parent d00ee64 commit 9a7d351
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions server/src/main/java/com/genymobile/scrcpy/Device.java
Original file line number Diff line number Diff line change
Expand Up @@ -188,18 +188,15 @@ public static boolean injectKeyEvent(int action, int keyCode, int repeat, int me
}

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) {
return injectKeyEvent(KeyEvent.ACTION_DOWN, keyCode, 0, 0, displayId) && injectKeyEvent(KeyEvent.ACTION_UP, keyCode, 0, 0, displayId);
}

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() {
Expand Down

0 comments on commit 9a7d351

Please sign in to comment.