Better error messaging when input can't be used

This commit is contained in:
Iwan Timmer
2014-01-08 22:26:03 +01:00
parent d94f247134
commit 1cdb88c2a0
2 changed files with 21 additions and 8 deletions

View File

@@ -4,6 +4,7 @@ import com.limelight.nvstream.NvConnection;
import com.limelight.nvstream.input.KeyboardPacket;
import com.limelight.nvstream.input.MouseButtonPacket;
import java.awt.event.KeyEvent;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
@@ -167,9 +168,15 @@ public class EvdevHandler implements Runnable {
private FileChannel deviceInput;
private ByteBuffer inputBuffer;
public EvdevHandler(NvConnection conn, String device) throws FileNotFoundException {
public EvdevHandler(NvConnection conn, String device) throws FileNotFoundException, IOException {
this.conn = conn;
FileInputStream in = new FileInputStream(device);
File file = new File(device);
if (!file.exists())
throw new FileNotFoundException("File " + device + " not found");
if (!file.canRead())
throw new IOException("Can't read from " + device);
FileInputStream in = new FileInputStream(file);
deviceInput = in.getChannel();
inputBuffer = ByteBuffer.allocate(MAX_STRUCT_SIZE_BYTES);
inputBuffer.order(ByteOrder.nativeOrder());