vrpn
07.33
Virtual Reality Peripheral Network
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
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
56
class
VRPN_API
vrpn_Mouse
:
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
75
=
vrpn_CONNECTION_LOW_LATENCY
);
76
78
virtual
void
report( vrpn_uint32 class_of_service
79
=
vrpn_CONNECTION_LOW_LATENCY
);
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
97
enum
vrpn_MOUSETYPE
{
MOUSESYSTEMS
,
THREEBUTTON_EMULATION
,
MAX_MOUSE_TYPES
};
98
99
class
VRPN_API
vrpn_Button_SerialMouse
:
public
vrpn_Button_Filter
{
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
;
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_CONNECTION_LOW_LATENCY
const vrpn_uint32 vrpn_CONNECTION_LOW_LATENCY
Definition:
vrpn_Connection.h:122
vrpn_Types.h
vrpn_Analog
Definition:
vrpn_Analog.h:28
vrpn_Mouse::GpmOpenFailure
Definition:
vrpn_Mouse.h:66
vrpn_Configure.h
THREEBUTTON_EMULATION
Definition:
vrpn_Mouse.h:97
vrpn_Analog.h
MOUSESYSTEMS
Definition:
vrpn_Mouse.h:97
vrpn_Button_SerialMouse::mousetype
vrpn_MOUSETYPE mousetype
Definition:
vrpn_Mouse.h:114
vrpn_Connection
Generic connection class not specific to the transport mechanism.
Definition:
vrpn_Connection.h:510
vrpn_Connection.h
VRPN_API
#define VRPN_API
Definition:
vrpn_Configure.h:646
vrpn_BaseClass::mainloop
virtual void mainloop()=0
Called once through each main loop iteration to handle updates. Remote object mainloop() should call ...
vrpn_Mouse
Definition:
vrpn_Mouse.h:56
vrpn_Button_SerialMouse::serial_fd
int serial_fd
Definition:
vrpn_Mouse.h:111
vrpn_Button_SerialMouse::lastR
int lastR
Definition:
vrpn_Mouse.h:113
vrpn_Shared.h
vrpn_Button_SerialMouse::status
int status
Definition:
vrpn_Mouse.h:112
vrpn_Button_SerialMouse
Definition:
vrpn_Mouse.h:99
vrpn_Button_Filter
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
vrpn_MOUSETYPE
Definition:
vrpn_Mouse.h:97
vrpn_Button_SerialMouse::printed_error
bool printed_error
Definition:
vrpn_Mouse.h:115
vrpn_Button_SerialMouse::baudrate
int baudrate
Definition:
vrpn_Mouse.h:110
vrpn_Button.h
MAX_MOUSE_TYPES
Definition:
vrpn_Mouse.h:97
vrpn_Mouse.h
Generated by
1.8.11