vrpn  07.33
Virtual Reality Peripheral Network
vrpn_Retrolink.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "vrpn_Analog.h" // for vrpn_Analog
4 #include "vrpn_Button.h" // for vrpn_Button_Filter
5 #include "vrpn_HumanInterface.h" // for vrpn_HidAcceptor (ptr only), etc
6 #include <stddef.h> // for size_t
7 
8 #if defined(VRPN_USE_HID)
9 
10 // Device drivers for the Retrolink Classic Controller USB line of products
11 // Currently supported: GameCube
12 //
13 // Exposes two major VRPN device classes: Button, Analog. See vrpn.cfg for
14 // a description of which buttons and control map where.
15 //
16 
18 public:
19  vrpn_Retrolink(vrpn_HidAcceptor *filter, const char *name, vrpn_Connection *c = 0);
20  virtual ~vrpn_Retrolink(void);
21 
22  virtual void mainloop(void) = 0;
23 
24 protected:
25  // Set up message handlers, etc.
26  void init_hid(void);
27  void on_data_received(size_t bytes, vrpn_uint8 *buffer);
28 
29  static int VRPN_CALLBACK on_connect(void *thisPtr, vrpn_HANDLERPARAM p);
30  static int VRPN_CALLBACK on_last_disconnect(void *thisPtr, vrpn_HANDLERPARAM p);
31 
32  virtual void decodePacket(size_t bytes, vrpn_uint8 *buffer) = 0;
33  struct timeval _timestamp;
35 
36  // No actual types to register, derived classes will be buttons, analogs
37  int register_types(void) { return 0; }
38 };
39 
40 //--------------------------------------------------------------------------------
41 // For GameCube :
42 // Analog channel assignments :
43 // 0 = Left joystick X axis; -1 = left, 1 = right
44 // 1 = Left joystick Y axis; -1 = up, 1 = down
45 // 2 = Right joystick X axis; -1 = left, 1 = right
46 // 3 = Right joystick Y axis; -1 = up, 1 = down
47 // 4 = Left rocker switch angle in degrees(-1 if nothing is pressed)
48 // Button number assignments :
49 // 0 = Y
50 // 1 = X
51 // 2 = A
52 // 3 = B
53 // 4 = left trigger
54 // 5 = right trigger
55 // 6 = Z
56 // 7 = Start / pause
57 // Buttons 8 - 11 are duplicate mappings for the rocker - switch; both
58 // these and the analog angle in degrees will change as they are pressed
59 // 8 = up
60 // 9 = right
61 // 10 = down
62 // 11 = left
63 
65 public:
66  vrpn_Retrolink_GameCube(const char *name, vrpn_Connection *c = 0);
67  virtual ~vrpn_Retrolink_GameCube(void) {};
68 
69  virtual void mainloop(void);
70 
71 protected:
72  // Send report iff changed
73  void report_changes (vrpn_uint32 class_of_service = vrpn_CONNECTION_LOW_LATENCY);
74  // Send report whether or not changed
75  void report (vrpn_uint32 class_of_service = vrpn_CONNECTION_LOW_LATENCY);
76 
77  void decodePacket(size_t bytes, vrpn_uint8 *buffer);
78 };
79 
80 // end of VRPN_USE_HID
81 #else
84 #endif
const vrpn_uint32 vrpn_CONNECTION_LOW_LATENCY
Generic connection class not specific to the transport mechanism.
#define VRPN_CALLBACK
#define VRPN_API
virtual void report_changes(void)
Definition: vrpn_Button.C:382
This structure is what is passed to a vrpn_Connection message callback.
Class from which all user-level (and other) classes that communicate with vrpn_Connections should der...
All button servers should derive from this class, which provides the ability to turn any of the butto...
Definition: vrpn_Button.h:65