11 #if defined(VRPN_USE_HID)
14 static const vrpn_uint16 LOGITECH_VENDOR = 0x046d;
15 static const vrpn_uint16 EXTREME_3D_PRO = 0xc215;
19 #define GAMEPAD_TRIGGER_THRESHOLD 30
24 static vrpn_float64 normalize_dpad(
unsigned char up,
unsigned char right,
unsigned char down,
unsigned char left)
44 size_t index = ((x + 1) * 3) + (y + 1);
45 vrpn_float64 angles[] = {225, 270, 315, 180, -1, 0, 135, 90, 45};
46 return (angles[index]);
49 static void normalize_axis(
const unsigned int value,
const short deadzone,
const vrpn_float64 scale, vrpn_float64& channel,
int wordSize = 16)
51 channel = (static_cast<float>(value) - (float) (1 << (wordSize - 1)));
52 if (fabs(channel) < (deadzone * 3 / 4))
58 channel /= (float) (1 << (wordSize - 1));
61 if (channel < -1.0) { channel = -1.0; }
62 if (channel > 1.0) { channel = 1.0; }
65 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,
int wordSize = 16)
67 normalize_axis(x, deadzone, scale, channelX, wordSize);
68 normalize_axis(y, deadzone, scale, channelY, wordSize);
71 static vrpn_float64 normalize_trigger(
unsigned int trigger)
74 int value = trigger - 0x80;
138 struct timeval current_time;
209 y = ((buffer[2] & 0x0f) << 8) + buffer[1];
211 normalize_axis(buffer[3], 0x12, 1.0f,
channel[2], 8);
212 normalize_axis(buffer[5], 0x0e, 1.0f,
channel[3], 8);
214 vrpn_uint8 value, mask;
216 for (
int btn = 0; btn < 8; btn++)
218 mask = static_cast<vrpn_uint8>(1 << (btn % 8));
219 buttons[btn] = ((value & mask) != 0);
224 switch (buffer[2] >> 4)
259 fprintf(stderr,
"vrpn_Logitech_Extreme_3D_Pro: Found a corrupted report; # total bytes = %u\n", static_cast<unsigned>(bytes));