10 #if defined(linux) && !defined(VRPN_USE_HID)
11 #define VRPN_USING_3DCONNEXION_EVENT_IFACE
12 #include <linux/input.h>
17 typedef struct input_devinfo {
22 } XXX_should_have_been_in_system_includes;
25 static const vrpn_uint16 vrpn_3DCONNEXION_VENDOR = 0x046d;
26 static const vrpn_uint16 vrpn_SPACEMOUSEWIRELESS_VENDOR = 9583;
27 static const vrpn_uint16 vrpn_3DCONNEXION_TRAVELER = 50723;
28 static const vrpn_uint16 vrpn_3DCONNEXION_NAVIGATOR = 50726;
29 static const vrpn_uint16 vrpn_3DCONNEXION_NAVIGATOR_FOR_NOTEBOOKS = 0xc628;
30 static const vrpn_uint16 vrpn_3DCONNEXION_SPACEEXPLORER = 0xc627;
31 static const vrpn_uint16 vrpn_3DCONNEXION_SPACEMOUSE = 50691;
32 static const vrpn_uint16 vrpn_3DCONNEXION_SPACEMOUSEPRO = 50731;
33 static const vrpn_uint16 vrpn_3DCONNEXION_SPACEMOUSEWIRELESS = 50735;
34 static const vrpn_uint16 vrpn_3DCONNEXION_SPACEBALL5000 = 0xc621;
35 static const vrpn_uint16 vrpn_3DCONNEXION_SPACEPILOT = 0xc625;
41 #if defined(VRPN_USE_HID)
58 #if defined(VRPN_USING_3DCONNEXION_EVENT_IFACE)
67 char *fname = (
char *)malloc(1000*
sizeof(
char));
69 sprintf(fname,
"/dev/input/event%d", i++);
70 f = fopen(fname,
"r+b");
74 struct input_devinfo ID;
75 ioctl(fileno(f), EVIOCGID, &ID);
91 perror(
"Could not open the device");
105 #if defined(VRPN_USING_3DCONNEXION_EVENT_IFACE)
111 #if defined(VRPN_USE_HID)
120 #if defined(VRPN_USE_HID)
125 #elif defined(VRPN_USING_3DCONNEXION_EVENT_IFACE)
126 struct timeval zerotime;
128 struct input_event ev;
132 zerotime.tv_usec = 0;
140 if (FD_ISSET(fd, &fdset)) {
142 if (
vrpn_noint_block_read(fd, reinterpret_cast<char*>(&ev),
sizeof(
struct input_event)) !=
sizeof(
struct input_event)) {
150 buttons[ev.code & 0x0ff] = ev.value;
159 channel[ev.code] = static_cast<double>(i)/400.0;
167 }
while (moreData == 1);
192 #if defined(linux) && !defined(VRPN_USE_HID)
193 int vrpn_3DConnexion::set_led(
int led_state)
195 struct input_event event;
199 event.code = LED_MISC;
200 event.value = led_state;
202 ret = write(fd, &event,
sizeof(
struct input_event));
204 perror (
"setting led state failed");
206 return ret < static_cast<int>(
sizeof(
struct input_event));
210 #if defined(VRPN_USE_HID)
220 fprintf(stderr,
"vrpn_3DConnexion::decodePacket(): Long packet (%d bytes), may mis-parse\n",
221 static_cast<int>(bytes));
227 for (
size_t i = 0; i < bytes / 7; i++) {
228 vrpn_uint8 *
report = buffer + (i * 7);
232 char report_type =
report[0];
233 vrpn_uint8 *bufptr = &
report[1];
234 const float scale = 1.0f/400.0f;
235 switch (report_type) {
246 channel[0] = vrpn_unbuffer_from_little_endian<vrpn_int16>(bufptr) * scale;
249 channel[1] = vrpn_unbuffer_from_little_endian<vrpn_int16>(bufptr) * scale;
252 channel[2] = vrpn_unbuffer_from_little_endian<vrpn_int16>(bufptr) * scale;
258 channel[3] = vrpn_unbuffer_from_little_endian<vrpn_int16>(bufptr) * scale;
261 channel[4] = vrpn_unbuffer_from_little_endian<vrpn_int16>(bufptr) * scale;
264 channel[5] = vrpn_unbuffer_from_little_endian<vrpn_int16>(bufptr) * scale;
295 vrpn_uint8 *location, mask;
296 location =
report + 1 + (btn / 8);
297 mask = 1 << (btn % 8);
298 buttons[btn] = ( (*location) & mask) != 0;