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;
vrpn_3DConnexion_SpaceMouseWireless(const char *name, vrpn_Connection *c=0)
vrpn_3DConnexion_Navigator(const char *name, vrpn_Connection *c=0)
void server_mainloop(void)
Handles functions that all servers should provide in their mainloop() (ping/pong, for example) Should...
virtual void report_changes(vrpn_uint32 class_of_service=vrpn_CONNECTION_LOW_LATENCY, const struct timeval time=vrpn_ANALOG_NOW)
Send a report only if something has changed (for servers) Optionally, tell what time to stamp the val...
vrpn_3DConnexion_Navigator_for_Notebooks(const char *name, vrpn_Connection *c=0)
vrpn_3DConnexion_SpaceBall5000(const char *name, vrpn_Connection *c=0)
vrpn_3DConnexion_SpaceMouse(const char *name, vrpn_Connection *c=0)
vrpn_3DConnexion_Traveler(const char *name, vrpn_Connection *c=0)
struct timeval _timestamp
vrpn_float64 channel[vrpn_CHANNEL_MAX]
virtual int send_pending_reports(void)=0
send pending report, clear the buffer. This function was protected, now is public, so we can use it to send out intermediate results without calling mainloop
virtual void decodePacket(size_t bytes, vrpn_uint8 *buffer)
Accepts any device with the given vendor and product IDs.
virtual void mainloop()
Called once through each main loop iteration to handle updates. Remote object mainloop() should call ...
int vrpn_noint_select(int width, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout)
This routine will perform like a normal select() call, but it will restart if it quit because of an i...
Generic connection class not specific to the transport mechanism.
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 ...
All types of client/server/peer objects in VRPN should be derived from the vrpn_BaseClass type descri...
vrpn_Connection * d_connection
Connection that this object talks to.
void report(vrpn_uint32 class_of_service=vrpn_CONNECTION_LOW_LATENCY)
int send_text_message(const char *msg, struct timeval timestamp, vrpn_TEXT_SEVERITY type=vrpn_TEXT_NORMAL, vrpn_uint32 level=0)
Sends a NULL-terminated text message from the device d_sender_id.
virtual bool accept(const vrpn_HIDDEVINFO &device)=0
int vrpn_noint_block_read(int infile, char buffer[], size_t length)
This routine will read in a block from the file descriptor.
#define vrpn_gettimeofday
virtual void update()
Polls the device buffers and causes on_data_received callbacks if appropriate You NEED to call this f...
virtual ~vrpn_3DConnexion()
vrpn_3DConnexion_SpacePilot(const char *name, vrpn_Connection *c=0)
void on_data_received(size_t bytes, vrpn_uint8 *buffer)
Derived class reimplements this callback.
vrpn_3DConnexion_SpaceMousePro(const char *name, vrpn_Connection *c=0)
vrpn_3DConnexion_SpaceExplorer(const char *name, vrpn_Connection *c=0)
vrpn_3DConnexion(vrpn_HidAcceptor *filter, unsigned num_buttons, const char *name, vrpn_Connection *c=0)
vrpn_float64 last[vrpn_CHANNEL_MAX]
vrpn_HidAcceptor * _filter