j3d.org Code

org.j3d.device.input.spaceball
Class Spaceball4000Driver

java.lang.Object
  extended byorg.j3d.device.input.spaceball.SpaceballDriver
      extended byorg.j3d.device.input.spaceball.Spaceball4000Driver
All Implemented Interfaces:
Spaceball4000CallbackInterface

public class Spaceball4000Driver
extends SpaceballDriver
implements Spaceball4000CallbackInterface

Driver for Labtec's Spaceball 4000 device.

Spaceball and Spaceball 4000 are Trademarks of Labtec Inc.

Version:
29. Oct. 2001 Copyright (c) Dipl. Ing. Paul Szawlowski
Author:
Dipl. Ing. Paul Szawlowski - University of Vienna, Dept. of Medical Computer Sciences

Field Summary
 
Fields inherited from class org.j3d.device.input.spaceball.SpaceballDriver
itsButtonData, itsPositionData, itsWriteBuffer
 
Constructor Summary
Spaceball4000Driver(SerialPort serialPort, java.io.InputStream inputStream, java.io.OutputStream outputStream)
           
 
Method Summary
 void disableDevice(int timeout)
          Ceases postion data transfer from the Spaceball device.
protected  void dispatch(byte[] readBuffer, int dataStart, int dataLength, int header)
           
 void emitSingleBeep()
          Emits a single beep.
 void emitSingleBeep(int timeout)
          Emits a single beep.
 void enableAutoRezero(int timeout, boolean enable)
           
 void enableCubicSensitivity(int timeout, boolean enable)
           
 void enableDevice(int timeout)
          Requests data from the Spaceball 4000 device.
 void getDeviceDescriptor(int timeout)
           
 void getDeviceInfo(int timeout)
           
 void processAutoRezeroResponse(int autoZeroPeriod, int autoZeroWindow, boolean enabled)
          Overriding methods shall call this method.
 void processDeviceInfoResponse(int type, int lineNumber, java.lang.String content)
          Method for processing device info events.
 void processSensitivityResponse(byte value)
          Overriding methods shall call this method.
 void rezeroDevice(int timeout)
           
 void setHandedness(int handedness)
          Method to process the handedness response.
 void setNumOfButtons(int numOfButtons)
          Method to process the number of buttons of the device.
 
Methods inherited from class org.j3d.device.input.spaceball.SpaceballDriver
close, emitPatternedBeep, getLastButtonValues, getLastPositionValues, getNumOfButtons, getSerialPort, openPort, pause, printBuffer, processEchoResponse, processError, processRequestResponse, read, resetDevice, waitForResponse, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.j3d.device.input.spaceball.Spaceball4000CallbackInterface
processEchoResponse, processError, processRequestResponse
 

Constructor Detail

Spaceball4000Driver

public Spaceball4000Driver(SerialPort serialPort,
                           java.io.InputStream inputStream,
                           java.io.OutputStream outputStream)
                    throws java.io.IOException
Method Detail

dispatch

protected void dispatch(byte[] readBuffer,
                        int dataStart,
                        int dataLength,
                        int header)
Specified by:
dispatch in class SpaceballDriver

enableDevice

public void enableDevice(int timeout)
                  throws java.io.IOException
Requests data from the Spaceball 4000 device. Must be called once after SpaceballDriver#open in order to receive position data. The first data packet will be "null-data" packet (all position data is set to zero).

Blocking until response from device received or timeout is over.

Specified by:
enableDevice in class SpaceballDriver
Parameters:
timeout - [ms] timeout for response from the Spaceball device
Throws:
java.io.IOException - if timeout is reached without a response from the Spaceball device or if an error occurs during reading the serial port

disableDevice

public void disableDevice(int timeout)
                   throws java.io.IOException
Ceases postion data transfer from the Spaceball device. Blocking until response from the Spaceball device received or timeout is over.

Specified by:
disableDevice in class SpaceballDriver
Parameters:
timeout - [ms] timeout for response from the Spaceball device
Throws:
java.io.IOException - if timeout is reached without a response from the Spaceball device or if an error occurs during reading the serial port

emitSingleBeep

public void emitSingleBeep(int timeout)
                    throws java.io.IOException
Emits a single beep. Blocking until response from the Spaceball device received or timeout is over.

Parameters:
timeout - for response from the Spaceball device.
Throws:
java.io.IOException - if timeout is reached without a response from the Spaceball device or if an error occurs during reading the serial port
See Also:
SpaceballPacket.createSimpleRequestPacket(byte[], int, byte)

emitSingleBeep

public void emitSingleBeep()
                    throws java.io.IOException
Emits a single beep. Does not wait for response from the Spaceball device. Note: non blocking

Throws:
java.io.IOException - if an error occurs during reading the serial port
See Also:
SpaceballPacket.createSimpleRequestPacket(byte[], int, byte)

rezeroDevice

public void rezeroDevice(int timeout)
                  throws java.io.IOException
Throws:
java.io.IOException

enableAutoRezero

public void enableAutoRezero(int timeout,
                             boolean enable)
                      throws java.io.IOException
Parameters:
timeout - for response from the Spaceball device.
enable - true = auto rezero enabled, false = auto rezero disabled
Throws:
java.io.IOException - if timeout is reached without a response from the Spaceball device or if an error occurs during reading the serial port
See Also:
Spaceball4000Packet.createEnableDisableAutoRezeroPacket(byte[], int, boolean)

enableCubicSensitivity

public void enableCubicSensitivity(int timeout,
                                   boolean enable)
                            throws java.io.IOException
Parameters:
timeout - for response from the Spaceball device.
enable - true = cubic sensitivity, false = standard sensitivity
Throws:
java.io.IOException - if timeout is reached without a response from the Spaceball device or if an error occurs during reading the serial port
See Also:
Spaceball4000Packet.createCubicSensitivityEnableDisablePacket(byte[], int, boolean)

getDeviceDescriptor

public void getDeviceDescriptor(int timeout)
                         throws java.io.IOException
Parameters:
timeout - for response from the Spaceball device.
Throws:
java.io.IOException - if timeout is reached without a response from the Spaceball device or if an error occurs during reading the serial port
See Also:
SpaceballPacket.createSimpleRequestPacket(byte[], int, byte)

getDeviceInfo

public void getDeviceInfo(int timeout)
                   throws java.io.IOException
Parameters:
timeout - for response from the Spaceball device.
Throws:
java.io.IOException - if timeout is reached without a response from the Spaceball device or if an error occurs during reading the serial port
See Also:
SpaceballPacket.createSimpleRequestPacket(byte[], int, byte)

processDeviceInfoResponse

public void processDeviceInfoResponse(int type,
                                      int lineNumber,
                                      java.lang.String content)
Description copied from interface: Spaceball4000CallbackInterface
Method for processing device info events. A device info may consist of up to 4 packets containing a string. This method is called for each packet separately.

Specified by:
processDeviceInfoResponse in interface Spaceball4000CallbackInterface
Overrides:
processDeviceInfoResponse in class SpaceballDriver

processSensitivityResponse

public void processSensitivityResponse(byte value)
Overriding methods shall call this method. param value use constants Spaceball4000Packet#CUBIC_SENSITIVITY_ENABLED, Spaceball4000Packet#STANDARD_SENSITIVITY_ENABLED; other values indicate an error during decoding

Specified by:
processSensitivityResponse in interface Spaceball4000CallbackInterface
Parameters:
value - use constants
  • Spaceball4000Packet.CUBIC_SENSITIVITY_ENABLED
  • Spaceball4000Packet.STANDARD_SENSITIVITY_ENABLED
other values indicate an error during decoding

processAutoRezeroResponse

public void processAutoRezeroResponse(int autoZeroPeriod,
                                      int autoZeroWindow,
                                      boolean enabled)
Overriding methods shall call this method.

Specified by:
processAutoRezeroResponse in interface Spaceball4000CallbackInterface
Parameters:
autoZeroPeriod - [ms] 0 <= autoZeroPeriod <= 0xFFFF
autoZeroWindow - [raw reading units] 0 <= autoZeroWindow < 0xFF
enabled - true if auto-rezero is enabled

setHandedness

public void setHandedness(int handedness)
Description copied from interface: Spaceball4000CallbackInterface
Method to process the handedness response.

Specified by:
setHandedness in interface Spaceball4000CallbackInterface
Parameters:
handedness - use constants Spaceball4000DeviceDescriptor#LEFT, Spaceball4000DeviceDescriptor#RIGHT

setNumOfButtons

public void setNumOfButtons(int numOfButtons)
Description copied from interface: Spaceball4000CallbackInterface
Method to process the number of buttons of the device.

Specified by:
setNumOfButtons in interface Spaceball4000CallbackInterface
Overrides:
setNumOfButtons in class SpaceballDriver

j3d.org Code

Latest Info from http://code.j3d.org/
Copyright © 2001 - j3d.org