vrpn 07.35
Virtual Reality Peripheral Network
|
#include <vrpn_HumanInterface.h>
Public Member Functions | |
vrpn_HidInterface (vrpn_HidAcceptor *acceptor, vrpn_uint16 vendor=0, vrpn_uint16 product=0, hid_device *device=NULL) | |
Constructor If we already have a HID device from some other source, it can be passed and we'll take ownership: still need the acceptor for reconnect, we just won't do it right away. | |
vrpn_HidInterface (vrpn_HidAcceptor *acceptor, hid_device *device) | |
Simplified constructor that just takes an acceptor and an underlying HID device (both non-optional). | |
vrpn_HidInterface (const char *device_path, vrpn_HidAcceptor *acceptor, vrpn_uint16 vendor=0, vrpn_uint16 product=0) | |
Constructor If we already know the path to the device we want, we can pass it in and open it directly: still need the acceptor for reconnect enumeration, we just won't do it right away. | |
virtual | ~vrpn_HidInterface () |
virtual bool | connected () const |
Returns true iff the last device I/O succeeded. | |
virtual void | update () |
Polls the device buffers and causes on_data_received callbacks if appropriate You NEED to call this frequently to ensure the OS doesn't drop data. | |
virtual bool | reconnect () |
Tries to reconnect to an acceptable device. Call this if you suspect a hotplug event has occurred. | |
vrpn_uint16 | vendor () const |
Returns USB vendor ID of connected device May not contain valid if an already-open device was provided to the constructor. | |
vrpn_uint16 | product () const |
Returns USB product ID of connected device May not contain valid if an already-open device was provided to the constructor. | |
int | interface_number () const |
Returns the USB interface number of connected device May not contain valid information on all platforms or if an already-open device was provided to the constructor. | |
Protected Member Functions | |
virtual void | on_data_received (size_t bytes, vrpn_uint8 *buffer)=0 |
Derived class reimplements this callback. | |
void | send_data (size_t bytes, const vrpn_uint8 *buffer) |
Call this to send data to the device. | |
void | send_feature_report (size_t bytes, const vrpn_uint8 *buffer) |
Call this to send a feature report to the device - first byte must be Report ID (or 0x0 for devices without numbered reports) | |
int | get_feature_report (size_t bytes, vrpn_uint8 *buffer) |
Call this to get a feature report from the device - first byte must be Report ID (or 0x0 for devices without numbered reports) | |
Protected Attributes | |
vrpn_HidAcceptor * | m_acceptor |
This is the HidAcceptor we use when reconnecting. | |
bool | m_working |
vrpn_uint16 | m_vendor |
vrpn_uint16 | m_product |
int | m_interface |
vrpn_uint16 | m_vendor_sought |
What vendor we want. | |
vrpn_uint16 | m_product_sought |
What product we want. | |
Definition at line 70 of file vrpn_HumanInterface.h.
vrpn_HidInterface::vrpn_HidInterface | ( | vrpn_HidAcceptor * | acceptor, |
vrpn_uint16 | vendor = 0, | ||
vrpn_uint16 | product = 0, | ||
hid_device * | device = NULL ) |
Constructor If we already have a HID device from some other source, it can be passed and we'll take ownership: still need the acceptor for reconnect, we just won't do it right away.
Not given an already-open device.
acceptor | Determines which device we want |
vendor | Default vendor is "any" |
product | Default product is "any" |
device | Optional underlying HID device to manage and take ownership of |
Definition at line 50 of file vrpn_HumanInterface.C.
References m_acceptor, reconnect(), and vrpn_HidAcceptor::reset().
vrpn_HidInterface::vrpn_HidInterface | ( | vrpn_HidAcceptor * | acceptor, |
hid_device * | device ) |
Simplified constructor that just takes an acceptor and an underlying HID device (both non-optional).
Designed for passing in a device (May look at you funny if you pass a NULL device, but will work just as if you had called the other constructor with a null device) but handles NULL devices just fine.
Not given an already-open device, hmm.
acceptor | Determines which device we want |
device | Underlying HID device to manage and take ownership of |
Definition at line 25 of file vrpn_HumanInterface.C.
References m_acceptor, reconnect(), and vrpn_HidAcceptor::reset().
vrpn_HidInterface::vrpn_HidInterface | ( | const char * | device_path, |
vrpn_HidAcceptor * | acceptor, | ||
vrpn_uint16 | vendor = 0, | ||
vrpn_uint16 | product = 0 ) |
Constructor If we already know the path to the device we want, we can pass it in and open it directly: still need the acceptor for reconnect enumeration, we just won't do it right away.
Given a null/empty path.
device_path | Platform-specific device path, suitable to be passed to HIDAPI's hid_open_path |
acceptor | Determines which device we want |
vendor | Default vendor is "any" |
product | Default product is "any" |
Definition at line 76 of file vrpn_HumanInterface.C.
References m_acceptor, reconnect(), and vrpn_HidAcceptor::reset().
|
virtual |
Definition at line 115 of file vrpn_HumanInterface.C.
|
virtual |
Returns true iff the last device I/O succeeded.
Definition at line 23 of file vrpn_HumanInterface.C.
References m_working.
Referenced by vrpn_Analog_5dtUSB::mainloop(), vrpn_Tracker_OSVRHackerDevKit::mainloop(), vrpn_Tracker_SpacePoint::mainloop(), and vrpn_Tracker_Wintracker::mainloop().
|
protected |
Call this to get a feature report from the device - first byte must be Report ID (or 0x0 for devices without numbered reports)
Definition at line 307 of file vrpn_HumanInterface.C.
References m_working.
int vrpn_HidInterface::interface_number | ( | ) | const |
Returns the USB interface number of connected device May not contain valid information on all platforms or if an already-open device was provided to the constructor.
Definition at line 20 of file vrpn_HumanInterface.C.
References m_interface.
|
protectedpure virtual |
Derived class reimplements this callback.
It is called whenever a read returns some data.
WARNING! The data returned by this function differs when the device sends multiple report types and when it only has one. When it can have more than one, the report type is sent as the first byte. When it only has one, the report type is NOT included. This is the behavior of the HIDAPI library we are using. It is surprising to me, but that's how it behaves.
Implemented in vrpn_3DConnexion, vrpn_Analog_5dtUSB, vrpn_CHProducts_Controller_Raw, vrpn_Contour, vrpn_DreamCheeky, vrpn_Futaba, vrpn_Griffin, vrpn_Logitech_Controller_Raw, vrpn_Microsoft_Controller_Raw, vrpn_nVidia_shield, vrpn_Retrolink, vrpn_Saitek_Controller_Raw, vrpn_Tracker_SpacePoint, vrpn_Tracker_Wintracker, vrpn_Vality, and vrpn_Xkeys.
Referenced by update().
vrpn_uint16 vrpn_HidInterface::product | ( | ) | const |
Returns USB product ID of connected device May not contain valid if an already-open device was provided to the constructor.
Definition at line 17 of file vrpn_HumanInterface.C.
References m_product.
Referenced by vrpn_Analog_5dtUSB::get_description().
|
virtual |
Tries to reconnect to an acceptable device. Call this if you suspect a hotplug event has occurred.
Definition at line 146 of file vrpn_HumanInterface.C.
References vrpn_HidAcceptor::accept(), vrpn_HIDDEVINFO::interface_number, m_acceptor, m_interface, m_product, m_product_sought, m_vendor, m_vendor_sought, vrpn_HIDDEVINFO::manufacturer_string, vrpn_HIDDEVINFO::path, vrpn_HIDDEVINFO::product, vrpn_HIDDEVINFO::product_string, vrpn_HIDDEVINFO::serial_number, and vrpn_HIDDEVINFO::vendor.
Referenced by vrpn_Tracker_OSVRHackerDevKit::mainloop(), vrpn_Tracker_SpacePoint::on_data_received(), vrpn_HidInterface(), vrpn_HidInterface(), and vrpn_HidInterface().
|
protected |
Call this to send data to the device.
Definition at line 275 of file vrpn_HumanInterface.C.
References m_working.
Referenced by vrpn_Xkeys_v1::setLEDs(), vrpn_Xkeys_v2::setLEDs(), and vrpn_Tracker_Wintracker::vrpn_Tracker_Wintracker().
|
protected |
Call this to send a feature report to the device - first byte must be Report ID (or 0x0 for devices without numbered reports)
Definition at line 288 of file vrpn_HumanInterface.C.
References m_working.
Referenced by vrpn_Oculus_DK1::writeKeepAlive(), and vrpn_Oculus_DK2::writeKeepAlive().
|
virtual |
Polls the device buffers and causes on_data_received callbacks if appropriate You NEED to call this frequently to ensure the OS doesn't drop data.
Definition at line 239 of file vrpn_HumanInterface.C.
References m_working, and on_data_received().
Referenced by vrpn_3DConnexion::mainloop(), vrpn_Analog_5dtUSB::mainloop(), vrpn_DreamCheeky_Drum_Kit::mainloop(), vrpn_Laputa::mainloop(), vrpn_Oculus::mainloop(), vrpn_Tracker_OSVRHackerDevKit::mainloop(), vrpn_Tracker_SpacePoint::mainloop(), vrpn_Tracker_Wintracker::mainloop(), vrpn_Xkeys_Desktop::mainloop(), vrpn_Xkeys_Pro::mainloop(), vrpn_Xkeys_Joystick::mainloop(), vrpn_Xkeys_Joystick12::mainloop(), vrpn_Xkeys_Jog_And_Shuttle::mainloop(), vrpn_Xkeys_Jog_And_Shuttle12::mainloop(), vrpn_Xkeys_Jog_And_Shuttle68::mainloop(), vrpn_Xkeys_XK3::mainloop(), vrpn_CHProducts_Fighterstick_USB::mainloop(), vrpn_Contour_ShuttleXpress::mainloop(), vrpn_Contour_ShuttlePROv2::mainloop(), vrpn_Futaba_InterLink_Elite::mainloop(), vrpn_Griffin_PowerMate::mainloop(), vrpn_Logitech_Extreme_3D_Pro::mainloop(), vrpn_Microsoft_SideWinder_Precision_2::mainloop(), vrpn_Microsoft_SideWinder::mainloop(), vrpn_Microsoft_Controller_Raw_Xbox_S::mainloop(), vrpn_Microsoft_Controller_Raw_Xbox_360_base::mainloop(), vrpn_nVidia_shield_USB::mainloop(), vrpn_nVidia_shield_stealth_USB::mainloop(), vrpn_Retrolink_GameCube::mainloop(), vrpn_Retrolink_Genesis::mainloop(), vrpn_Saitek_ST290_Pro::mainloop(), and vrpn_Vality_vGlass::mainloop().
vrpn_uint16 vrpn_HidInterface::vendor | ( | ) | const |
Returns USB vendor ID of connected device May not contain valid if an already-open device was provided to the constructor.
Definition at line 14 of file vrpn_HumanInterface.C.
References m_vendor.
|
protected |
This is the HidAcceptor we use when reconnecting.
We do not take ownership of the pointer; it is the user's responsibility. Using a stack-allocated acceptor is a really good way to get a segfault when calling reconnect()–there won't be an acceptor there any longer! Thus, always use "new" to make your acceptors.
Definition at line 175 of file vrpn_HumanInterface.h.
Referenced by vrpn_Tracker_OSVRHackerDevKit::mainloop(), reconnect(), vrpn_HidInterface(), vrpn_HidInterface(), vrpn_HidInterface(), vrpn_Analog_5dtUSB::~vrpn_Analog_5dtUSB(), vrpn_Laputa::~vrpn_Laputa(), vrpn_Oculus::~vrpn_Oculus(), and vrpn_Tracker_OSVRHackerDevKit::~vrpn_Tracker_OSVRHackerDevKit().
|
protected |
Definition at line 180 of file vrpn_HumanInterface.h.
Referenced by interface_number(), and reconnect().
|
protected |
Definition at line 179 of file vrpn_HumanInterface.h.
Referenced by product(), and reconnect().
|
protected |
What product we want.
Definition at line 191 of file vrpn_HumanInterface.h.
Referenced by reconnect().
|
protected |
Definition at line 178 of file vrpn_HumanInterface.h.
Referenced by reconnect(), and vendor().
|
protected |
What vendor we want.
Definition at line 190 of file vrpn_HumanInterface.h.
Referenced by reconnect().
|
protected |
Definition at line 177 of file vrpn_HumanInterface.h.
Referenced by connected(), get_feature_report(), send_data(), send_feature_report(), and update().