vrpn
07.35
Virtual Reality Peripheral Network
Toggle main menu visibility
Loading...
Searching...
No Matches
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
23
class
VRPN_API
vrpn_Connection
;
24
25
26
/**************************************************************************************************/
27
/* constructor */
28
/**************************************************************************************************/
29
vrpn_Event_Analog::vrpn_Event_Analog
(
const
char
* name,
30
vrpn_Connection
* c,
31
const
char
* evdev_name) :
32
vrpn_Analog
( name, c),
33
fd
(-1),
34
max_num_events
( 16),
35
event_data
(
event_vector_t
( 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"
);
47
status
=
vrpn_ANALOG_FAIL
;
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
57
status
=
vrpn_ANALOG_FAIL
;
58
}
59
else
{
60
61
// Reset the tracker
62
status
=
vrpn_ANALOG_RESETTING
;
63
}
64
65
// set the time
66
vrpn_gettimeofday
(&
timestamp
, NULL);
67
68
#endif
// #if defined(LINUX)
69
}
70
71
/**************************************************************************************************/
72
/* destructor */
73
/**************************************************************************************************/
74
vrpn_Event_Analog::~vrpn_Event_Analog
() {
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
85
vrpn_Event::vrpn_close_event
(
fd
);
86
}
87
88
#endif
// #if defined(LINUX)
89
}
90
91
/***************************************************************************************************/
92
/* read the data */
93
/***************************************************************************************************/
94
int
95
vrpn_Event_Analog::read_available_data
() {
96
97
#if defined(_WIN32)
98
99
return
vrpn_Event::vrpn_read_event
(
fd
, &(
event_data
.front()),
max_num_events
);
100
101
#else
// not Windows
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
112
return
vrpn_Event::vrpn_read_event
(
fd
, &(
event_data
.front()),
max_num_events
);
113
114
#endif
// not Windows
115
}
vrpn_Analog::status
int status
Definition
vrpn_Analog.h:43
vrpn_Analog::vrpn_Analog
vrpn_Analog(const char *name, vrpn_Connection *c=NULL)
Definition
vrpn_Analog.C:14
vrpn_Analog::timestamp
struct timeval timestamp
Definition
vrpn_Analog.h:41
vrpn_Connection
Generic connection class not specific to the transport mechanism.
Definition
vrpn_Connection.h:561
vrpn_Event_Analog::vrpn_Event_Analog
vrpn_Event_Analog(const char *name, vrpn_Connection *connection, const char *evdev_name)
Definition
vrpn_Event_Analog.C:29
vrpn_Event_Analog::event_data
event_vector_t event_data
Definition
vrpn_Event_Analog.h:59
vrpn_Event_Analog::event_vector_t
std::vector< struct vrpn_Event::input_event > event_vector_t
Definition
vrpn_Event_Analog.h:49
vrpn_Event_Analog::~vrpn_Event_Analog
~vrpn_Event_Analog()
Definition
vrpn_Event_Analog.C:74
vrpn_Event_Analog::read_available_data
int read_available_data()
Definition
vrpn_Event_Analog.C:95
vrpn_Event_Analog::max_num_events
unsigned long max_num_events
Definition
vrpn_Event_Analog.h:56
vrpn_Event_Analog::fd
int fd
Definition
vrpn_Event_Analog.h:53
vrpn_Event::vrpn_close_event
void vrpn_close_event(const int fd)
Definition
vrpn_Event.C:51
vrpn_Event::vrpn_open_event
int vrpn_open_event(const char *file)
Definition
vrpn_Event.C:33
vrpn_Event::vrpn_read_event
int vrpn_read_event(int fd, input_event *data, int max_elements)
Definition
vrpn_Event.C:68
vrpn_ANALOG_FAIL
const int vrpn_ANALOG_FAIL
Definition
vrpn_Analog.h:23
vrpn_ANALOG_RESETTING
const int vrpn_ANALOG_RESETTING
Definition
vrpn_Analog.h:22
VRPN_API
#define VRPN_API
Definition
vrpn_Configure.h:648
vrpn_Event_Analog.h
vrpn_Connection
class VRPN_API vrpn_Connection
Definition
vrpn_Event_Analog.h:26
vrpn_Shared.h
vrpn_gettimeofday
#define vrpn_gettimeofday
Definition
vrpn_Shared.h:99
vrpn_Event_Analog.C
Generated by
1.17.0