vrpn  07.33
Virtual Reality Peripheral Network
vrpn_Mouse.h
Go to the documentation of this file.
1 #ifndef VRPN_MOUSE_H
2 #define VRPN_MOUSE_H
3 
5 // This file contains a distillation of the various Mouse classes that had
6 // been spread throughout VRPN. The interfaces have been rationalized, so
7 // that they are the same between operating systems and are factored into
8 // independent interfaces.
10 
11 /* file: vrpn_Mouse.h
12  * author: Mike Weiblen mew@mew.cx 2004-01-14
13  * copyright: (C) 2003,2004 Michael Weiblen
14  * license: Released to the Public Domain.
15  * depends: gpm 1.19.6, VRPN 06_04
16  * tested on: Linux w/ gcc 2.95.4
17  * references: http://mew.cx/ http://vrpn.org/
18  * http://linux.schottelius.org/gpm/
19 */
20 
22 // vrpn_Mouse is a VRPN server class to publish events from the PC's mouse.
23 // It provides a 2-channel vrpn_Analog for X & Y mouse motion, and a
24 // 3-channel vrpn_Button for the mouse buttons.
25 //
26 // vrpn_Mouse makes it easy to use the diverse array of commodity input
27 // devices that masquerade as a mouse, such as PS/2 trackballs, gyroscopic
28 // free-space pointers, and force-sensing touchpads.
29 //
30 // This version includes a Linux-specific implementation that leverages the Linux GPM
31 // (General Purpose Mouse) server to handle the low-level hardware interfaces
32 // and device protocols. GPM is commonly included in Linux distributions.
33 // The GPM homepage is http://linux.schottelius.org/gpm/
34 //
35 // It also includes a Windows interface to the mouse.
36 //
37 // The interface reports mouse position in fraction of the screen.
38 // The previous version of the Windows implementation had reported them
39 // in pixels, but this has been changed to match on both platforms.
40 //
41 // vrpn_Mouse must be run on a Linux console, not an xterm. Rationale:
42 // 1) Since the console environment doesn't presume the existence of a mouse,
43 // it avoids issues about mapping mouse events to window focus, etc.
44 // 2) With the mouse movement controlled by a different user, it's really
45 // not possible to also use a mouse-based user interface anyway.
46 // 3) My VRPN server machine is headless, and doesn't even have an X server.
48 
49 #include "vrpn_Analog.h" // for vrpn_Analog
50 #include "vrpn_Button.h" // for vrpn_Button_Filter
51 #include "vrpn_Configure.h" // for VRPN_API
52 #include "vrpn_Connection.h" // for vrpn_CONNECTION_LOW_LATENCY, etc
53 #include "vrpn_Shared.h" // for timeval
54 #include "vrpn_Types.h" // for vrpn_uint32
55 
57  public vrpn_Analog,
58  public vrpn_Button_Filter
59 {
60 public:
61  vrpn_Mouse( const char* name, vrpn_Connection* cxn );
62  virtual ~vrpn_Mouse();
63 
64  virtual void mainloop();
65 
66  class GpmOpenFailure {}; // thrown when can't open GPM server
67 
68 protected: // methods
71  virtual int get_report();
72 
74  virtual void report_changes( vrpn_uint32 class_of_service
76 
78  virtual void report( vrpn_uint32 class_of_service
80 
81 protected: // data
82  struct timeval timestamp;
83 
84 private: // disable unwanted default methods
85  vrpn_Mouse();
86  vrpn_Mouse(const vrpn_Mouse&);
87  const vrpn_Mouse& operator=(const vrpn_Mouse&);
88 };
89 
91 // (RDK) Button device that is connected to a serial port. This is a
92 // raw driver that can be used with any of the serial-enabled architectures,
93 // and does not go through the mouse driver -- it talks to the mouse
94 // directly as a serial device. This enables the user to use a mouse, or
95 // a rewired serial mouse, as a simple button device.
96 
98 
100 public:
101  // Open a serial mouse button device connected to the local machine
102 
103  vrpn_Button_SerialMouse(const char *name, vrpn_Connection *connection,
104  const char *port, int baud, vrpn_MOUSETYPE type);
105 
106  virtual void mainloop(void);
107 
108 protected:
109  char portname[512];
110  int baudrate;
112  int status;
113  int lastL, lastM, lastR; //used in 3 button emulator
116 
117  void read(void);
118 };
119 
120 #endif
const vrpn_uint32 vrpn_CONNECTION_LOW_LATENCY
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...
Definition: vrpn_Analog.C:71
vrpn_MOUSETYPE mousetype
Definition: vrpn_Mouse.h:114
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 ...
Definition: vrpn_Analog.C:94
#define VRPN_API
virtual void mainloop()=0
Called once through each main loop iteration to handle updates. Remote object mainloop() should call ...
All button servers should derive from this class, which provides the ability to turn any of the butto...
Definition: vrpn_Button.h:65
vrpn_MOUSETYPE
Definition: vrpn_Mouse.h:97