From c6d01331ed20dadfbf161b834d18bc0879fd9b8d Mon Sep 17 00:00:00 2001 From: Romain Vimont Date: Wed, 7 Feb 2018 17:48:21 +0100 Subject: [PATCH] Simplify EventController In handleEvent(), connection.receiveControlEvent() may never return null: either it returns a valid ControlEvent, either it throws an Exception. Therefore, there is no need to propagate a flag to indicate whether it returned a valid ControlEvent. --- .../java/com/genymobile/scrcpy/EventController.java | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/server/src/main/java/com/genymobile/scrcpy/EventController.java b/server/src/main/java/com/genymobile/scrcpy/EventController.java index ee0f0313..5b857dd7 100644 --- a/server/src/main/java/com/genymobile/scrcpy/EventController.java +++ b/server/src/main/java/com/genymobile/scrcpy/EventController.java @@ -60,14 +60,13 @@ public class EventController { } public void control() throws IOException { - while (handleEvent()) ; + while (true) { + handleEvent(); + } } - private boolean handleEvent() throws IOException { + private void handleEvent() throws IOException { ControlEvent controlEvent = connection.receiveControlEvent(); - if (controlEvent == null) { - return false; - } switch (controlEvent.getType()) { case ControlEvent.TYPE_KEYCODE: injectKeycode(controlEvent.getAction(), controlEvent.getKeycode(), controlEvent.getMetaState()); @@ -85,7 +84,6 @@ public class EventController { executeCommand(controlEvent.getAction()); break; } - return true; } private boolean injectKeycode(int action, int keycode, int metaState) {