|
j3d.org Code | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectorg.j3d.device.input.spaceball.SpaceballDriver
Driver for Labtec's Spaceball device. Does not support multithreading. All methods must be called from a single thread.
Stores only the latest received position data, which can be obtained with
the getLastPositionValues(int[]) method. The event of pressing a button is
stored until getLastButtonValues(int[]) is called. Then all button states
are cleared, i. e. release events are ignored. It might happen that very fast
button press/release events will not be detected.
Use SpaceballTypeDetector.createSpaceballDriver(java.lang.String, int) to open a serial and
to obtain an appropriate SpaceballDriver object. After use
close() must be called to release the serial port.
Uses the javax.comm extension package, which must be installed.
Spaceball, Spaceball 2003, Spaceball 3003 and Spaceball 4000 are Trademarks of Labtec Inc.
| Field Summary | |
protected int[] |
itsButtonData
button pressed: value > 0, button not pressed: value = 0. |
protected int[] |
itsPositionData
Current position Data. |
protected byte[] |
itsWriteBuffer
use this buffer for packets send to the Spaceball device. |
| Constructor Summary | |
SpaceballDriver(SerialPort serialPort,
java.io.InputStream inputStream,
java.io.OutputStream outputStream,
int packetTerminator)
|
|
| Method Summary | |
void |
close()
Closes and frees serial port. |
abstract void |
disableDevice(int timeout)
Ceases postion data transfer from the Spaceball device. |
protected abstract void |
dispatch(byte[] readBuffer,
int dataStart,
int dataLength,
int header)
|
void |
emitPatternedBeep(char[] pattern)
Emits a patterend beep. |
abstract void |
enableDevice(int timeout)
Requests data from the Spaceball device. |
void |
getLastButtonValues(int[] buttonData)
|
void |
getLastPositionValues(int[] positionData)
|
int |
getNumOfButtons()
|
SerialPort |
getSerialPort()
Convenience method to enable an application to change port settings if necessary. |
static SerialPort |
openPort(java.lang.String portDescriptor)
|
static void |
pause(int timeInMillis)
|
protected static void |
printBuffer(byte[] buffer,
int length)
|
void |
processDeviceInfoResponse(int type,
int lineNumber,
java.lang.String content)
Overriding methods shall call processRequestResponse(int). |
void |
processEchoResponse(byte[] data)
Default action if an echo event from Spaceball device was received. |
void |
processError(int errorCode,
java.lang.String errorString)
|
void |
processRequestResponse(int type)
Notify driver that expected event from Spaceball device received for blocking requests. |
void |
read()
Reads data from serial port. |
void |
resetDevice(int timeout)
Resets device. |
protected void |
setNumOfButtons(int numOfButtons)
|
protected void |
waitForResponse(int timeout,
int request,
java.lang.String description)
Sends a request to the Spaceball device and wait until response is received or timeout period is over. |
protected void |
write(byte[] buffer,
int offset,
int length)
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
protected final int[] itsPositionData
protected final int[] itsButtonData
protected final byte[] itsWriteBuffer
| Constructor Detail |
public SpaceballDriver(SerialPort serialPort,
java.io.InputStream inputStream,
java.io.OutputStream outputStream,
int packetTerminator)
| Method Detail |
public void close()
throws java.io.IOException
java.io.IOException
public abstract void enableDevice(int timeout)
throws java.io.IOException
timeout - [ms] timeout for response from the Spaceball device
java.io.IOException - if timeout is reached without a response from the
Spaceball device or if an error occurs during reading the serial
port
public abstract void disableDevice(int timeout)
throws java.io.IOException
timeout - [ms] timeout for response from the Spaceball device
java.io.IOException - if timeout is reached without a response from the
Spaceball device or if an error occurs during reading the serial
port
public void read()
throws java.io.IOException
java.io.IOException - if an error occurs during reading the serial portpublic int getNumOfButtons()
public SerialPort getSerialPort()
#open was not
called before or was not successfull or after a call of close().public void getLastPositionValues(int[] positionData)
positionData - Max. size of array = 6.public void getLastButtonValues(int[] buttonData)
buttonData - button pressed: value > 0, button not pressed:
value = 0; Max. size of array = 12.
public void emitPatternedBeep(char[] pattern)
throws java.io.IOException
java.io.IOException - if timeout is reached without a response from the
Spaceball device or if an error occurs during reading the serial
portSpaceballPacket.createPatternedBeepPacket(byte[], int, char[])
public void resetDevice(int timeout)
throws java.io.IOException
timeout - for response from the Spaceball device.
java.io.IOException - if timeout is reached without a response from the
Spaceball device or if an error occurs during reading the serial
portSpaceballPacket.createSimpleRequestPacket(byte[], int, byte)
protected abstract void dispatch(byte[] readBuffer,
int dataStart,
int dataLength,
int header)
public void processRequestResponse(int type)
protected void setNumOfButtons(int numOfButtons)
public void processError(int errorCode,
java.lang.String errorString)
public void processDeviceInfoResponse(int type,
int lineNumber,
java.lang.String content)
processRequestResponse(int).
public void processEchoResponse(byte[] data)
public static SerialPort openPort(java.lang.String portDescriptor)
throws NoSuchPortException,
PortInUseException,
UnsupportedCommOperationException
NoSuchPortException
PortInUseException
UnsupportedCommOperationException
protected final void write(byte[] buffer,
int offset,
int length)
throws java.io.IOException
buffer - buffer containing the data to be written to the serial
interfaceoffset - start offset of "buffer"length - number of bytes to write
java.io.IOException
protected final void waitForResponse(int timeout,
int request,
java.lang.String description)
throws java.io.IOException
timeout - [ms] timeout for response from the Spaceball devicerequest - use constantsdescription - description of request
java.io.IOException
protected static void printBuffer(byte[] buffer,
int length)
public static void pause(int timeInMillis)
|
j3d.org Code | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||