|
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.SpaceballPacket
Generates and decodes data packets for a Labtec's Spaceball device which formats are independant of the type.
NOTE: Some data packets will contain an additional "special character" ('^' - 0x5e) inserted within the data stream. This escape character notifies the system to modify the following byte. If the following byte is 'Q', (0x51), 'S' (0x53), or an 'M' (0x4d) the seventh bit should be cleared. (Which should result in 0x11, 0x13, 0x0d respectively.) If the following character is a second '^' (0x5e) then no modification should be made. (Do not forget to remove the '^' character from the packet buffer.). This is currently not implemented. Therefore certain data packets may be ignored, specially if buttons 3 and 4 are pressed at the same time.
NOTE: The Ignore Packet is not implemented.
Spaceball, Spaceball 2003, Spaceball 3003 and Spaceball 4000 are Trademarks of Labtec Inc.
| Field Summary | |
static byte |
BALL_DATA
|
static byte |
BUTTON_DATA
|
static int |
BUTTON_DATA_PACKET_LENGTH
|
static int[] |
BUTTON_MASK
|
static byte |
ECHO
|
static byte |
ERROR
|
static byte |
PACKET_TERMINATOR
|
static byte |
PATTERNED_BEEP
|
static int |
POSITION_DATA_PACKET_LENGTH
|
static byte |
RESET_DEVICE
This command causes the Spaceball to RESET. |
| Constructor Summary | |
SpaceballPacket()
|
|
| Method Summary | |
static int |
createEchoPacket(byte[] data,
int offset,
byte[] packetData)
Echo this packet. |
static int |
createPatternedBeepPacket(byte[] data,
int offset,
char[] pattern)
This command causes the firmware to emit a beep. |
static int |
createSimpleRequestPacket(byte[] data,
int offset,
byte request)
Creates a simple request packet (packet which consists only of a header). |
static void |
decodeBallData(byte[] readBuffer,
int[] ballData,
int packetStart)
|
protected static void |
decodeButtonData(int data,
int[] buttonData,
int[] buttonMask)
|
protected static int |
makeWord(byte firstByte,
byte secondByte)
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static final int POSITION_DATA_PACKET_LENGTH
public static final int BUTTON_DATA_PACKET_LENGTH
public static final byte BALL_DATA
public static final byte BUTTON_DATA
public static final byte PATTERNED_BEEP
public static final byte ERROR
public static final byte ECHO
public static final byte RESET_DEVICE
public static final int[] BUTTON_MASK
public static final byte PACKET_TERMINATOR
| Constructor Detail |
public SpaceballPacket()
| Method Detail |
public static int createPatternedBeepPacket(byte[] data,
int offset,
char[] pattern)
data - buffer into which the packet will be copied;
packet size = 2 byte + length of "pattern"offset - first byte of packet will be copied at
data[offset]pattern - Up to 16 upper and lower case letters. Letters that are
sooner in the alphabet stand for shorter beeps or pauses. Lower case
letters mean beep on, upper cae letters mean beep off. The last
character must be beep off.
public static int createSimpleRequestPacket(byte[] data,
int offset,
byte request)
data - buffer into which the packet will be copied;
Packet size = 2 bytes.offset - first byte of packet will be copied at
data[offset]request - header for the packet
public static int createEchoPacket(byte[] data,
int offset,
byte[] packetData)
data - buffer into which the packet will be copied;
packet size = 2 byte + length of packetData.offset - first byte of packet will be copied at
data[offset]packetData - Content of packet or null.
NOTE: The length of the array + 2 must be smaller than the length of
data - offset and the buffer used for receiving packets.
The value 0x0D must not be contained.
public static void decodeBallData(byte[] readBuffer,
int[] ballData,
int packetStart)
ballData - Current position Data; size of array = 7.
index 0: period of data (1/16th milliseconds),
index 1 xTranslationForce x-axis translation force,
index 2 yTranslationForce y-axis translation force,
index 3 zTranslationForce z-axis translation force,
index 4 xRotationalForce x-axis rotation force (positive values: counter
clockwise rotation),
index 5 yRotationalForce y-axis rotation force (positive values: counter
clockwise rotation),
index 6 zRotationalForce z-axis rotation force (positive values: counter
clockwise rotation)
protected static void decodeButtonData(int data,
int[] buttonData,
int[] buttonMask)
protected static int makeWord(byte firstByte,
byte secondByte)
|
j3d.org Code | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||