Skip to content

Commit

Permalink
Revert "Inject WAKEUP instead of POWER"
Browse files Browse the repository at this point in the history
WAKEUP does not work on some devices.

Fixes #1655 <#1655>

This reverts commit 322f151.
  • Loading branch information
rom1v committed Aug 9, 2020
1 parent a59a157 commit 38940ff
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions server/src/main/java/com/genymobile/scrcpy/Controller.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ private void initPointers() {
public void control() throws IOException {
// on start, power on the device
if (!device.isScreenOn()) {
device.injectKeycode(KeyEvent.KEYCODE_WAKEUP);
device.injectKeycode(KeyEvent.KEYCODE_POWER);

// dirty hack
// After the keycode is injected, the device is powered on asynchronously.
// After POWER is injected, the device is powered on asynchronously.
// To turn the device screen off while mirroring, the client will send a message that
// would be handled before the device is actually powered on, so its effect would
// be "canceled" once the device is turned back on.
Expand Down Expand Up @@ -248,8 +248,8 @@ public void run() {
}

private boolean pressBackOrTurnScreenOn() {
int keycode = device.isScreenOn() ? KeyEvent.KEYCODE_BACK : KeyEvent.KEYCODE_WAKEUP;
if (keepPowerModeOff && keycode == KeyEvent.KEYCODE_WAKEUP) {
int keycode = device.isScreenOn() ? KeyEvent.KEYCODE_BACK : KeyEvent.KEYCODE_POWER;
if (keepPowerModeOff && keycode == KeyEvent.KEYCODE_POWER) {
schedulePowerModeOff();
}
return device.injectKeycode(keycode);
Expand Down

0 comments on commit 38940ff

Please sign in to comment.