vrpn
07.33
Virtual Reality Peripheral Network
|
Go to the documentation of this file.
10 #if defined(VRPN_USE_HID)
15 static const vrpn_uint16 CONTOUR_VENDOR = 0x0b33;
16 static const vrpn_uint16 CONTOUR_SHUTTLEXPRESS = 0x0020;
18 static void normalize_axis(
const unsigned int value,
const short deadzone,
const vrpn_float64 scale, vrpn_float64& channel) {
19 channel = (static_cast<float>(value) - 128.0f);
20 if (fabs(channel) < deadzone)
29 if (channel < -1.0) { channel = -1.0; }
30 if (channel > 1.0) { channel = 1.0; }
33 static void normalize_axes(
const unsigned int x,
const unsigned int y,
const short deadzone,
const vrpn_float64 scale, vrpn_float64& channelX, vrpn_float64& channelY) {
34 normalize_axis(x, deadzone, scale, channelX);
35 normalize_axis(y, deadzone, scale, channelY);
96 struct timeval current_time;
180 normalize_axis((
unsigned int) ((static_cast<float>(static_cast<vrpn_int8>(buffer[0])) * 128.0f / 7.0f) + 128.0f), 0, 1.0f,
channel[0]);
192 normalize_axis((
unsigned int) (static_cast<float>(static_cast<vrpn_int8>(buffer[1])) + 128.0f), 0, 1.0f,
channel[1]);
198 for (
int btn = 0; btn < 4; btn++) {
199 vrpn_uint8 mask = static_cast<vrpn_uint8>((1 << (btn % 8)) << 4);
200 buttons[btn] = ((value & mask) != 0);
204 for (
int btn = 0; btn < 1; btn++) {
205 vrpn_uint8 mask = static_cast<vrpn_uint8>(1 << (btn % 8));
206 buttons[btn + 4] = ((value & mask) != 0);
209 fprintf(stderr,
"vrpn_Contour_ShuttleXpress: Found a corrupted report; # total bytes = %u\n", static_cast<unsigned>(bytes));
virtual ~vrpn_Contour(void)
int register_autodeleted_handler(vrpn_int32 type, vrpn_MESSAGEHANDLER handler, void *userdata, vrpn_int32 sender=vrpn_ANY_SENDER)
Registers a handler with the connection, and remembers to delete at destruction.
virtual void report(void)
void decodePacket(size_t bytes, vrpn_uint8 *buffer)
const char * vrpn_got_connection
unsigned long vrpn_TimevalDuration(struct timeval endT, struct timeval startT)
Return number of microseconds between startT and endT.
vrpn_float64 channel[vrpn_CHANNEL_MAX]
const char * vrpn_dropped_last_connection
virtual void report(vrpn_uint32 class_of_service=vrpn_CONNECTION_LOW_LATENCY, const struct timeval time=vrpn_ANALOG_NOW)
Send a report whether something has changed or not (for servers) Optionally, tell what time to stamp ...
vrpn_Contour(vrpn_HidAcceptor *filter, const char *name, vrpn_Connection *c=0)
virtual void update()
Polls the device buffers and causes on_data_received callbacks if appropriate You NEED to call this f...
virtual void mainloop(void)
Called once through each main loop iteration to handle updates. Remote object mainloop() should call ...
virtual void decodePacket(size_t bytes, vrpn_uint8 *buffer)=0
vrpn_Connection * d_connection
Connection that this object talks to.
virtual vrpn_int32 register_message_type(const char *name)
This structure is what is passed to a vrpn_Connection message callback.
Accepts any device with the given vendor and product IDs.
struct timeval _timestamp
vrpn_float64 dials[vrpn_DIAL_MAX]
Generic connection class not specific to the transport mechanism.
#define vrpn_gettimeofday
void on_data_received(size_t bytes, vrpn_uint8 *buffer)
Derived class reimplements this callback.
static int VRPN_CALLBACK on_last_disconnect(void *thisPtr, vrpn_HANDLERPARAM p)
vrpn_float64 last[vrpn_CHANNEL_MAX]
vrpn_Contour_ShuttleXpress(const char *name, vrpn_Connection *c=0)
vrpn_HidAcceptor * _filter
static int VRPN_CALLBACK on_connect(void *thisPtr, vrpn_HANDLERPARAM p)
void server_mainloop(void)
Handles functions that all servers should provide in their mainloop() (ping/pong, for example) Should...
Class from which all user-level (and other) classes that communicate with vrpn_Connections should der...