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.
This commit is contained in:
parent
03c5f97e3f
commit
c6d01331ed
1 changed files with 4 additions and 6 deletions
|
@ -60,14 +60,13 @@ public class EventController {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void control() throws IOException {
|
public void control() throws IOException {
|
||||||
while (handleEvent()) ;
|
while (true) {
|
||||||
|
handleEvent();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean handleEvent() throws IOException {
|
private void handleEvent() throws IOException {
|
||||||
ControlEvent controlEvent = connection.receiveControlEvent();
|
ControlEvent controlEvent = connection.receiveControlEvent();
|
||||||
if (controlEvent == null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
switch (controlEvent.getType()) {
|
switch (controlEvent.getType()) {
|
||||||
case ControlEvent.TYPE_KEYCODE:
|
case ControlEvent.TYPE_KEYCODE:
|
||||||
injectKeycode(controlEvent.getAction(), controlEvent.getKeycode(), controlEvent.getMetaState());
|
injectKeycode(controlEvent.getAction(), controlEvent.getKeycode(), controlEvent.getMetaState());
|
||||||
|
@ -85,7 +84,6 @@ public class EventController {
|
||||||
executeCommand(controlEvent.getAction());
|
executeCommand(controlEvent.getAction());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean injectKeycode(int action, int keycode, int metaState) {
|
private boolean injectKeycode(int action, int keycode, int metaState) {
|
||||||
|
|
Loading…
Reference in a new issue