vrpn  07.33
Virtual Reality Peripheral Network
vrpn_Event_Analog.C
Go to the documentation of this file.
1 /**************************************************************************************************/
2 /* */
3 /* Copyright (C) 2004 Bauhaus University Weimar */
4 /* Released into the public domain on 6/23/2007 as part of the VRPN project */
5 /* by Jan P. Springer. */
6 /* */
7 /**************************************************************************************************/
8 /* */
9 /* module : vrpn_Event_Analog.h */
10 /* project : */
11 /* description: base class for devices using event interface */
12 /* */
13 /**************************************************************************************************/
14 
15 
16 // includes, system
17 #include <stdio.h> // for fprintf, stderr, NULL
18 #include "vrpn_Shared.h" // for vrpn_gettimeofday
19 
20 // includes, file
21 #include "vrpn_Event_Analog.h"
22 
24 
25 
26 /**************************************************************************************************/
27 /* constructor */
28 /**************************************************************************************************/
30  vrpn_Connection * c,
31  const char* evdev_name) :
32  vrpn_Analog( name, c),
33  fd(-1),
34  event_data( event_vector_t( 16)),
35  max_num_events( 16)
36 {
37  #if defined(_WIN32)
38 
39  fprintf( stderr, "vrpn_Event_Analog(): Not yet implemented on this architecture.");
40 
41  #else // #if defined(LINUX)
42 
43  // check if filename valid
44  if (0 == evdev_name) {
45 
46  fprintf(stderr,"vrpn_Event_Analog: No file name.\n");
48 
49  return;
50  }
51 
52  // open event interface
53  if ( -1 == (fd = vrpn_Event::vrpn_open_event( evdev_name))) {
54 
55  fprintf(stderr,"vrpn_Event_Analog: Failed to open event interface file.\n");
56 
58  }
59  else {
60 
61  // Reset the tracker
63  }
64 
65  // set the time
67 
68  #endif // #if defined(LINUX)
69 }
70 
71 /**************************************************************************************************/
72 /* destructor */
73 /**************************************************************************************************/
75 
76  #if defined(_WIN32)
77 
78  fprintf( stderr, "~vrpn_Event_Analog(): Not yet implemented on this architecture.");
79 
80  #else // #if defined(LINUX)
81 
82  // close handle if still valid
83  if ( -1 != fd) {
84 
86  }
87 
88  #endif // #if defined(LINUX)
89 }
90 
91 /***************************************************************************************************/
92 /* read the data */
93 /***************************************************************************************************/
94 int
96 
97  #if defined(_WIN32)
98 
100 
101  #else // if defined(LINUX)
102 
103  // check for updates at max_num_events
104  if (max_num_events != event_data.size()) {
105 
106  event_data.resize( max_num_events);
107 
108  max_num_events = event_data.size();
109  }
110 
111  // read data
113 
114  #endif // #if defined(LINUX)
115 }
vrpn_Event_Analog(const char *name, vrpn_Connection *connection, const char *evdev_name)
int vrpn_open_event(const char *file)
Definition: vrpn_Event.C:33
Generic connection class not specific to the transport mechanism.
#define VRPN_API
event_vector_t event_data
void vrpn_close_event(const int fd)
Definition: vrpn_Event.C:51
std::vector< struct vrpn_Event::input_event > event_vector_t
#define vrpn_gettimeofday
Definition: vrpn_Shared.h:89
const int vrpn_ANALOG_FAIL
Definition: vrpn_Analog.h:23
const int vrpn_ANALOG_RESETTING
Definition: vrpn_Analog.h:22
struct timeval timestamp
Definition: vrpn_Analog.h:41
int vrpn_read_event(int fd, input_event *data, int max_elements)
Definition: vrpn_Event.C:68