RflySimSDK v3.05
RflySimSDK说明文档
载入中...
搜索中...
未找到
vrpn_Mouse.h
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
56class VRPN_API vrpn_Mouse :
57 public vrpn_Analog,
59{
60public:
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
68protected: // methods
71 virtual int get_report();
72
74 virtual void report_changes( vrpn_uint32 class_of_service
75 = vrpn_CONNECTION_LOW_LATENCY );
76
78 virtual void report( vrpn_uint32 class_of_service
79 = vrpn_CONNECTION_LOW_LATENCY );
80
81protected: // data
82 struct timeval timestamp;
83
84private: // 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
97enum vrpn_MOUSETYPE {MOUSESYSTEMS, THREEBUTTON_EMULATION, MAX_MOUSE_TYPES};
98
100public:
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
108protected:
109 char portname[512];
110 int baudrate;
111 int serial_fd;
112 int status;
113 int lastL, lastM, lastR; //used in 3 button emulator
114 vrpn_MOUSETYPE mousetype;
115 bool printed_error;
116
117 void read(void);
118};
119
120#endif
定义 vrpn_Analog.h:28
定义 vrpn_Button.h:66
定义 vrpn_Mouse.h:99
virtual void mainloop(void)
Generic connection class not specific to the transport mechanism.
定义 vrpn_Connection.h:562
定义 vrpn_Mouse.h:66
定义 vrpn_Mouse.h:59
virtual void mainloop()
virtual int get_report()
virtual void report(vrpn_uint32 class_of_service=vrpn_CONNECTION_LOW_LATENCY)
send report whether or not changed
virtual void report_changes(vrpn_uint32 class_of_service=vrpn_CONNECTION_LOW_LATENCY)
send report iff changed