33#define STATE_SYNCHING (0)
34#define STATE_READING (1)
35#define STATE_RECEIVED (2)
37#define SYNC_BYTE (0xff)
39#define VP_BUTTON_1 4096
40#define VP_BUTTON_2 256
42#define VP_BUTTON_4 512
43#define VP_BUTTON_5 2048
45#define VP_BUTTON_7 1024
48#define VP_HAT_UP VP_BUTTON_5
49#define VP_HAT_DOWN VP_BUTTON_7
50#define VP_HAT_LEFT VP_BUTTON_8
51#define VP_HAT_RIGHT VP_BUTTON_6
53#define VP_TRIGGER VP_BUTTON_4
54#define VP_BUTTON_TOP VP_BUTTON_3
55#define VP_BUTTON_MIDDLE VP_BUTTON_2
56#define VP_BUTTON_BOTTOM VP_BUTTON_1
59#define VP_HAT_ALL ( VP_HAT_UP | VP_HAT_DOWN | VP_HAT_LEFT | VP_HAT_RIGHT )
60#define VP_BUTTON_ALL ( VP_TRIGGER | VP_BUTTON_TOP | VP_BUTTON_MIDDLE | VP_BUTTON_BOTTOM )
65 const char *port,
long baud)
73 fprintf(stderr,
"vrpn_VPJoystick: Cannot Open serial port\n");
108 struct timeval timeout = { 0,200000 };
110 if (serial_fd == -1) {
111 fprintf(stderr,
"vrpn_VPJOystick::mainloop(): Bad serial port descriptor\n");
120 message_buffer[0] = 0;
153 int flag = ((int) message_buffer[1])*256 + message_buffer[2];
void server_mainloop(void)
Handles functions that all servers should provide in their mainloop() (ping/pong, for example) Should...
Generic connection class not specific to the transport mechanism.
vrpn_VPJoystick(char *name, vrpn_Connection *c, const char *port="/dev/ttyS0", long baud=9600)
void mainloop()
Called once through each main loop iteration to handle updates. Remote object mainloop() should call ...
int vrpn_close_commport(int comm)
int vrpn_read_available_characters(int comm, unsigned char *buffer, size_t bytes)
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.
vrpn_Serial: Pulls all the serial port routines into one file to make porting to new operating system...
#define vrpn_gettimeofday
#define vrpn_VPJOY_MESSAGE_LENGTH
#define vrpn_VPJOY_NUM_BUTTONS