10 #if defined(VRPN_USE_HID)
13 static const vrpn_uint16 SAITEK_VENDOR = 0x06a3;
14 static const vrpn_uint16 ST290_PRO = 0x0d60;
18 #define GAMEPAD_TRIGGER_THRESHOLD 30
23 static vrpn_float64 normalize_dpad(
unsigned char up,
unsigned char right,
unsigned char down,
unsigned char left)
43 size_t index = ((x + 1) * 3) + (y + 1);
44 vrpn_float64 angles[] = {225, 270, 315, 180, -1, 0, 135, 90, 45};
45 return (angles[index]);
48 static void normalize_axis(
const unsigned int value,
const short deadzone,
const vrpn_float64 scale, vrpn_float64& channel,
int wordSize = 16)
50 channel = (static_cast<float>(value) - (float) (1 << (wordSize - 1)));
51 if (fabs(channel) < (deadzone * 3 / 4))
57 channel /= (float) (1 << (wordSize - 1));
60 if (channel < -1.0) { channel = -1.0; }
61 if (channel > 1.0) { channel = 1.0; }
64 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)
66 normalize_axis(x, deadzone, scale, channelX, wordSize);
67 normalize_axis(y, deadzone, scale, channelY, wordSize);
70 static vrpn_float64 normalize_trigger(
unsigned int trigger)
73 int value = trigger - 0x80;
137 struct timeval current_time;
205 normalize_axes(buffer[0], buffer[1], 0x08, 1.0f,
channel[0],
channel[1], 8);
206 normalize_axis(buffer[2], 0x08, 1.0f,
channel[2], 8);
207 normalize_axis(buffer[3], 0x08, 1.0f,
channel[3], 8);
209 vrpn_uint8 value, mask;
210 value = (buffer[4] >> 4);
211 for (
int btn = 0; btn < 4; btn++)
213 mask = static_cast<vrpn_uint8>(1 << (btn % 8));
214 buttons[btn] = ((value & mask) != 0);
216 value = (buffer[5] & 0x0f);
217 for (
int btn = 0; btn < 4; btn++)
219 mask = static_cast<vrpn_uint8>(1 << (btn % 8));
220 buttons[btn + 4] = ((value & mask) != 0);
225 switch (buffer[4] & 0x0f)
260 fprintf(stderr,
"vrpn_Saitek_ST290_Pro: Found a corrupted report; # total bytes = %u\n", static_cast<unsigned>(bytes));