Only show error when no single input could be readed

This commit is contained in:
Iwan Timmer
2014-05-29 20:53:29 +02:00
parent b9a39a5d89
commit 74b8c287c0
2 changed files with 26 additions and 9 deletions

View File

@@ -87,8 +87,8 @@ public class Limelight implements NvConnectionListener {
displayError("Input", "Input could not be found"); displayError("Input", "Input could not be found");
return; return;
} catch (IOException ex) { } catch (IOException ex) {
displayError("Input", "Input could not be read"); displayError("Input", "No input could be readed");
displayError("Input", "Are you running as root?"); displayError("Input", "Try to run as root");
return; return;
} }

View File

@@ -43,21 +43,38 @@ public class EvdevLoader implements Runnable {
} }
public void start() throws FileNotFoundException, IOException { public void start() throws FileNotFoundException, IOException {
boolean watcher = false; boolean allInputs = inputs.isEmpty();
if (inputs.isEmpty()) {
watcher = true;
if (allInputs) {
String[] events = input.list(filter); String[] events = input.list(filter);
for (String event:events) for (String event:events)
inputs.add(new File(input, event).getAbsolutePath()); inputs.add(new File(input, event).getAbsolutePath());
} }
for (String input:inputs) boolean hasInput = false;
new EvdevHandler(conn, input, mapping).start(); IOException ex = null;
for (String input:inputs) {
try {
EvdevHandler handler = new EvdevHandler(conn, input, mapping);
handler.start();
hasInput = true;
} catch (FileNotFoundException e) {
throw e;
} catch (IOException e) {
//Throw always exception for explicitly loaded inputs
if (!allInputs)
throw e;
else
ex = e;
}
}
if (watcher) { //Only throw exception when no input get loaded
if (!hasInput && ex != null)
throw ex;
if (allInputs) {
Thread thread = new Thread(this); Thread thread = new Thread(this);
thread.setDaemon(true); thread.setDaemon(true);
thread.setName("Input - Search"); thread.setName("Input - Search");