vrpn
07.33
Virtual Reality Peripheral Network
|
Go to the documentation of this file.
11 #if defined(VRPN_USE_HID)
16 static const vrpn_uint16 FUTABA_VENDOR = 0x1781;
17 static const vrpn_uint16 FUTABA_ELITE = 0x0e56;
19 static void normalize_axis(
const unsigned int value,
const short deadzone,
const vrpn_float64 scale, vrpn_float64& channel) {
20 channel = (
static_cast<float>(value) - 128.0f);
21 if (fabs(channel) < deadzone)
30 if (channel < -1.0) { channel = -1.0; }
31 if (channel > 1.0) { channel = 1.0; }
34 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) {
35 normalize_axis(x, deadzone, scale, channelX);
36 normalize_axis(y, deadzone, scale, channelY);
97 struct timeval current_time;
150 if (buffer[0] == 5) {
155 normalize_axes(buffer[5], buffer[3], 5, (1.0f / 0.70f),
channel[0],
channel[1]);
158 normalize_axes(buffer[1], buffer[2], 5, (1.0f / 0.70f),
channel[2],
channel[3]);
171 normalize_axis(buffer[4], 5, 1.0f,
channel[4]);
185 for (
int btn = 0; btn < 8; btn++) {
186 vrpn_uint8 mask =
static_cast<vrpn_uint8
>(1 << (btn % 8));
187 buttons[btn] = ((value & mask) != 0);
213 const vrpn_uint8 btnCount = 10;
214 const vrpn_uint8 btnValues[btnCount] = {0xa2, 0x51, 0x36, 0x1b, 0x12, 0x09, 0x06, 0x03, 0x02, 0x01};
215 for (
int i = 0; i < btnCount; i++) {
216 if ((value & btnValues[i]) == btnValues[i]) {
217 value ^= btnValues[i];
224 fprintf(stderr,
"vrpn_Futaba_InterLink_Elite: Unknown report = %u\n",
static_cast<unsigned>(buffer[0]));
227 fprintf(stderr,
"vrpn_Futaba_InterLink_Elite: Found a corrupted report; # total bytes = %u\n",
static_cast<unsigned>(bytes));
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)
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]
virtual void decodePacket(size_t bytes, vrpn_uint8 *buffer)=0
vrpn_Futaba_InterLink_Elite(const char *name, vrpn_Connection *c=0)
struct timeval _timestamp
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_Futaba(vrpn_HidAcceptor *filter, const char *name, vrpn_Connection *c=0)
vrpn_HidAcceptor * _filter
virtual void update()
Polls the device buffers and causes on_data_received callbacks if appropriate You NEED to call this f...
virtual ~vrpn_Futaba(void)
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.
virtual void mainloop(void)
Called once through each main loop iteration to handle updates. Remote object mainloop() should call ...
vrpn_float64 dials[vrpn_DIAL_MAX]
static int VRPN_CALLBACK on_last_disconnect(void *thisPtr, vrpn_HANDLERPARAM p)
static int VRPN_CALLBACK on_connect(void *thisPtr, vrpn_HANDLERPARAM p)
Generic connection class not specific to the transport mechanism.
void decodePacket(size_t bytes, vrpn_uint8 *buffer)
#define vrpn_gettimeofday
vrpn_float64 last[vrpn_CHANNEL_MAX]
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...
void on_data_received(size_t bytes, vrpn_uint8 *buffer)
Derived class reimplements this callback.