18 #if defined(linux) && defined(VRPN_USE_GPM_MOUSE) 23 #if !( defined(_WIN32) && defined(VRPN_USE_WINSOCK_SOCKETS) ) 24 # include <sys/select.h> 30 #pragma comment (lib, "user32.lib") 35 #ifndef SM_XVIRTUALSCREEN 36 #define COMPILE_MULTIMON_STUBS 62 #if defined(linux) && defined(VRPN_USE_GPM_MOUSE) 65 gpm_visiblepointer = 1;
69 gc.defaultMask = GPM_MOVE | GPM_HARD;
73 if( Gpm_Open( &gc, 0 ) < 0 )
85 fprintf(stderr,
"vrpn_Mouse::vrpn_Mouse() Not implement on this architecture\n");
93 #if defined(linux) && defined(VRPN_USE_GPM_MOUSE) 110 #if defined(linux) && defined(VRPN_USE_GPM_MOUSE) 114 FD_SET( gpm_fd, &readset );
115 struct timeval timeout = { 0, 0 };
116 select( gpm_fd+1, &readset, NULL, NULL, &timeout );
117 if( ! FD_ISSET( gpm_fd, &readset ) )
121 if( Gpm_GetEvent( &evt ) <= 0 )
124 if( evt.type & GPM_UP )
126 if( evt.buttons & GPM_B_LEFT )
buttons[0] = 0;
127 if( evt.buttons & GPM_B_MIDDLE )
buttons[1] = 0;
128 if( evt.buttons & GPM_B_RIGHT )
buttons[2] = 0;
132 buttons[0] = (evt.buttons & GPM_B_LEFT) ? 1 : 0;
133 buttons[1] = (evt.buttons & GPM_B_MIDDLE) ? 1 : 0;
134 buttons[2] = (evt.buttons & GPM_B_RIGHT) ? 1 : 0;
137 channel[0] = (vrpn_float64) evt.dx / gpm_mx;
138 channel[1] = (vrpn_float64) evt.dy / gpm_my;
140 #elif defined(_WIN32) 141 const unsigned LEFT_MOUSE_BUTTON = 0x01;
142 const unsigned RIGHT_MOUSE_BUTTON = 0x02;
143 const unsigned MIDDLE_MOUSE_BUTTON = 0x04;
146 if (0x80000 & GetKeyState(LEFT_MOUSE_BUTTON)) {
151 if (0x80000 & GetKeyState(MIDDLE_MOUSE_BUTTON)) {
156 if (0x80000 & GetKeyState(RIGHT_MOUSE_BUTTON)) {
164 GetCursorPos(&curPos);
165 vrpn_Analog::channel[0] = (vrpn_float64)(curPos.x - GetSystemMetrics(SM_XVIRTUALSCREEN)) / GetSystemMetrics(SM_CXVIRTUALSCREEN);
166 vrpn_Analog::channel[1] = (vrpn_float64)(curPos.y - GetSystemMetrics(SM_YVIRTUALSCREEN)) / GetSystemMetrics(SM_CYVIRTUALSCREEN);
199 #define BUTTON_READY (1) 200 #define BUTTON_FAIL (-1) 211 fprintf(stderr,
"vrpn_Button_SerialMouse: NULL port name\n");
222 fprintf(stderr,
"vrpn_Button_SerialMouse: Cannot open serial port\n");
271 unsigned char buffer;
283 fprintf (stderr,
"state: %d %d %d last: %d %d %d\n",
301 if ( (buffer != 0xc0) && (buffer != 0xd0) &&
302 (buffer != 0xe0) && (buffer != 0xf0) ) {
306 buttons[0] = (
unsigned char)( (buffer & 0x20)?1:0 );
307 buttons[2] = (
unsigned char)( (buffer & 0x10)?1:0 );
323 if ((buffer & 0xf8) != 0x80) {
327 buttons[0] = (
unsigned char)( (buffer & 4)?0:1 );
328 buttons[1] = (
unsigned char)( (buffer & 2)?0:1 );
329 buttons[2] = (
unsigned char)( (buffer & 1)?0:1 );
333 printf(
"vrpn_Button_SerialMouse::read(): Unknown mouse type\n");
void server_mainloop(void)
Handles functions that all servers should provide in their mainloop() (ping/pong, for example) Should...
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...
int vrpn_open_commport(const char *portname, long baud, int charsize, vrpn_SER_PARITY parity, bool rts_flow)
Open a serial port, given its name and baud rate.
virtual void mainloop()
Called once through each main loop iteration to handle updates. Remote object mainloop() should call ...
vrpn_Serial: Pulls all the serial port routines into one file to make porting to new operating system...
vrpn_float64 channel[vrpn_CHANNEL_MAX]
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 ...
struct timeval timestamp
time of last report from device
All types of client/server/peer objects in VRPN should be derived from the vrpn_BaseClass type descri...
virtual void report(vrpn_uint32 class_of_service=vrpn_CONNECTION_LOW_LATENCY)
send report whether or not changed
int vrpn_read_available_characters(int comm, unsigned char *buffer, size_t bytes)
int send_text_message(const char *msg, struct timeval timestamp, vrpn_TEXT_SEVERITY type=vrpn_TEXT_NORMAL, vrpn_uint32 level=0)
Sends a NULL-terminated text message from the device d_sender_id.
virtual int get_report()
Try to read reports from the device. Returns 1 if msg received, or 0 if none received.
#define vrpn_gettimeofday
vrpn_Mouse(const char *name, vrpn_Connection *cxn)
vrpn_float64 last[vrpn_CHANNEL_MAX]