RflySimSDK v3.05
RflySimSDK说明文档
载入中...
搜索中...
未找到
vrpn_HidInterface类 参考abstract
+ 类 vrpn_HidInterface 继承关系图:
+ vrpn_HidInterface 的协作图:

Public 成员函数

 vrpn_HidInterface (vrpn_HidAcceptor *acceptor, vrpn_uint16 vendor=0, vrpn_uint16 product=0, hid_device *device=NULL)
 
 vrpn_HidInterface (vrpn_HidAcceptor *acceptor, hid_device *device)
 
 vrpn_HidInterface (const char *device_path, vrpn_HidAcceptor *acceptor, vrpn_uint16 vendor=0, vrpn_uint16 product=0)
 
virtual bool connected () const
 Returns true iff the last device I/O succeeded
 
virtual void update ()
 
virtual bool reconnect ()
 
vrpn_uint16 vendor () const
 
vrpn_uint16 product () const
 
int interface_number () const
 

Protected 成员函数

virtual void on_data_received (size_t bytes, vrpn_uint8 *buffer)=0
 Derived class reimplements this callback. It is called whenever a read returns some data.
 
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)
 
int get_feature_report (size_t bytes, vrpn_uint8 *buffer)
 

Protected 属性

vrpn_HidAcceptorm_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
 

构造及析构函数说明

◆ vrpn_HidInterface() [1/3]

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.

参数
acceptorDetermines which device we want
vendorDefault vendor is "any"
productDefault product is "any"
deviceOptional underlying HID device to manage and take ownership of

◆ vrpn_HidInterface() [2/3]

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.

参数
acceptorDetermines which device we want
deviceUnderlying HID device to manage and take ownership of

◆ vrpn_HidInterface() [3/3]

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.

参数
device_pathPlatform-specific device path, suitable to be passed to HIDAPI's hid_open_path
acceptorDetermines which device we want
vendorDefault vendor is "any"
productDefault product is "any"

成员函数说明

◆ connected()

virtual bool connected ( ) const
virtual

Returns true iff the last device I/O succeeded

◆ get_feature_report()

int get_feature_report ( size_t bytes,
vrpn_uint8 * buffer )
protected

Call this to get a feature report from the device - first byte must be Report ID (or 0x0 for devices without numbered reports)

返回
Number of bytes received, or -1 on error

◆ interface_number()

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.

◆ on_data_received()

virtual void on_data_received ( size_t bytes,
vrpn_uint8 * buffer )
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.

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 , 以及 vrpn_Xkeys 内被实现.

◆ product()

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.

◆ reconnect()

virtual bool reconnect ( )
virtual

Tries to reconnect to an acceptable device. Call this if you suspect a hotplug event has occurred.

◆ send_data()

void send_data ( size_t bytes,
const vrpn_uint8 * buffer )
protected

Call this to send data to the device

◆ send_feature_report()

void send_feature_report ( size_t bytes,
const vrpn_uint8 * buffer )
protected

Call this to send a feature report to the device - first byte must be Report ID (or 0x0 for devices without numbered reports)

◆ update()

virtual void update ( )
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

+ 这是这个函数的调用关系图:

◆ vendor()

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.

类成员变量说明

◆ m_acceptor

vrpn_HidAcceptor* m_acceptor
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.

◆ m_product_sought

vrpn_uint16 m_product_sought
protected

What product we want

◆ m_vendor_sought

vrpn_uint16 m_vendor_sought
protected

What vendor we want


该类的文档由以下文件生成: