~hitmuri/vjpirate/trunk

« back to all changes in this revision

Viewing changes to os/mac/include/vrpn/vrpn_3DConnexion.h

  • Committer: Florent Berthaut
  • Date: 2014-07-26 18:53:16 UTC
  • mfrom: (5.1.12 mac)
  • Revision ID: flo@localhost.localdomain-20140726185316-c2ucnwmgm5kij4e2
Merged mac branch

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef VRPN_3DCONNEXION_H
 
2
#define VRPN_3DCONNEXION_H
 
3
 
 
4
#include "vrpn_HumanInterface.h"
 
5
#include "vrpn_Button.h"
 
6
#include "vrpn_Analog.h"
 
7
 
 
8
// Device drivers for the 3DConnexion SpaceNavigator and SpaceTraveler
 
9
// SpaceExplorer, SpaceMouse, Spaceball5000
 
10
// devices, connecting to them as HID devices (USB).
 
11
 
 
12
// Exposes two VRPN device classes: Button and Analog.
 
13
// Analogs are mapped to the six channels, each in the range (-1..1).
 
14
 
 
15
// This is the base driver for the devices.  The Navigator has
 
16
// only two buttons and has product ID 50726, the traveler has 8
 
17
// buttons and ID 50723.  The derived classes just construct with
 
18
// the appropriate number of buttons and an acceptor for the proper
 
19
// product ID; the baseclass does all the work.
 
20
 
 
21
#if defined(VRPN_USE_HID)
 
22
class VRPN_API vrpn_3DConnexion: public vrpn_Button, public vrpn_Analog, protected vrpn_HidInterface {
 
23
public:
 
24
  vrpn_3DConnexion(vrpn_HidAcceptor *filter, unsigned num_buttons,
 
25
                   const char *name, vrpn_Connection *c = 0);
 
26
  virtual ~vrpn_3DConnexion();
 
27
 
 
28
  virtual void mainloop();
 
29
 
 
30
  virtual void reconnect();
 
31
 
 
32
protected:
 
33
  // Set up message handlers, etc.
 
34
  void on_data_received(size_t bytes, vrpn_uint8 *buffer);
 
35
 
 
36
  virtual void decodePacket(size_t bytes, vrpn_uint8 *buffer);
 
37
  struct timeval _timestamp;
 
38
  vrpn_HidAcceptor *_filter;
 
39
 
 
40
  // Send report iff changed
 
41
  void report_changes (vrpn_uint32 class_of_service = vrpn_CONNECTION_LOW_LATENCY);
 
42
  // Send report whether or not changed
 
43
  void report (vrpn_uint32 class_of_service = vrpn_CONNECTION_LOW_LATENCY);
 
44
  // NOTE:  class_of_service is only applied to vrpn_Analog
 
45
  //  values, not vrpn_Button or vrpn_Dial
 
46
};
 
47
#else   // not _WIN32
 
48
class VRPN_API vrpn_3DConnexion: public vrpn_Button, public vrpn_Analog {
 
49
public:
 
50
  vrpn_3DConnexion(vrpn_HidAcceptor *filter, unsigned num_buttons,
 
51
                   const char *name, vrpn_Connection *c = 0);
 
52
  virtual ~vrpn_3DConnexion();
 
53
 
 
54
  virtual void mainloop();
 
55
 
 
56
protected:
 
57
  struct timeval _timestamp;
 
58
  vrpn_HidAcceptor *_filter;
 
59
  int fd;
 
60
 
 
61
  // Send report iff changed
 
62
  void report_changes(vrpn_uint32 class_of_service = vrpn_CONNECTION_LOW_LATENCY);
 
63
  // Send report whether or not changed
 
64
  void report(vrpn_uint32 class_of_service = vrpn_CONNECTION_LOW_LATENCY);
 
65
  // NOTE:  class_of_service is only applied to vrpn_Analog
 
66
  //  values, not vrpn_Button or vrpn_Dial
 
67
 
 
68
// There is a non-HID Linux-based driver for this device that has a capability
 
69
// not implemented in the HID interface.
 
70
#if defined(linux) && !defined(VRPN_USE_HID)
 
71
  int set_led(int led_state);
 
72
#endif
 
73
};
 
74
#endif  // not _WIN32
 
75
 
 
76
class VRPN_API vrpn_3DConnexion_Navigator: public vrpn_3DConnexion {
 
77
public:
 
78
  vrpn_3DConnexion_Navigator(const char *name, vrpn_Connection *c = 0);
 
79
  virtual ~vrpn_3DConnexion_Navigator() {};
 
80
 
 
81
protected:
 
82
};
 
83
 
 
84
class VRPN_API vrpn_3DConnexion_Traveler: public vrpn_3DConnexion {
 
85
public:
 
86
  vrpn_3DConnexion_Traveler(const char *name, vrpn_Connection *c = 0);
 
87
  virtual ~vrpn_3DConnexion_Traveler() {};
 
88
 
 
89
protected:
 
90
};
 
91
 
 
92
class VRPN_API vrpn_3DConnexion_SpaceMouse: public vrpn_3DConnexion {
 
93
public:
 
94
  vrpn_3DConnexion_SpaceMouse(const char *name, vrpn_Connection *c = 0);
 
95
  virtual ~vrpn_3DConnexion_SpaceMouse() {};
 
96
 
 
97
protected:
 
98
};
 
99
 
 
100
class VRPN_API vrpn_3DConnexion_SpaceExplorer: public vrpn_3DConnexion {
 
101
public:
 
102
  vrpn_3DConnexion_SpaceExplorer(const char *name, vrpn_Connection *c = 0);
 
103
  virtual ~vrpn_3DConnexion_SpaceExplorer() {};
 
104
 
 
105
protected:
 
106
};
 
107
 
 
108
class VRPN_API vrpn_3DConnexion_SpaceBall5000: public vrpn_3DConnexion {
 
109
public:
 
110
  vrpn_3DConnexion_SpaceBall5000(const char *name, vrpn_Connection *c = 0);
 
111
  virtual ~vrpn_3DConnexion_SpaceBall5000() {};
 
112
 
 
113
protected:
 
114
};
 
115
 
 
116
 
 
117
// end of VRPN_3DCONNEXION_H
 
118
#endif
 
119