vrpn 07.35
Virtual Reality Peripheral Network
Loading...
Searching...
No Matches
vrpn_Griffin Class Referenceabstract

#include <vrpn_Griffin.h>

Inheritance diagram for vrpn_Griffin:
Collaboration diagram for vrpn_Griffin:

Public Member Functions

 vrpn_Griffin (vrpn_HidAcceptor *filter, const char *name, vrpn_Connection *c=0, vrpn_uint16 vendor=0, vrpn_uint16 product=0)
 
virtual ~vrpn_Griffin (void)
 
virtual void mainloop (void)=0
 Called once through each main loop iteration to handle updates. Remote object mainloop() should call client_mainloop() and then call d_connection->mainloop(). Server object mainloop() should service the device and then call server_mainloop(), but should not normally call d_connection->mainloop().
 
- Public Member Functions inherited from vrpn_BaseClass
 vrpn_BaseClass (const char *name, vrpn_Connection *c=NULL)
 Names the device and assigns or opens connection, calls registration methods.
 
virtual ~vrpn_BaseClass ()
 
virtual void mainloop ()=0
 Called once through each main loop iteration to handle updates. Remote object mainloop() should call client_mainloop() and then call d_connection->mainloop(). Server object mainloop() should service the device and then call server_mainloop(), but should not normally call d_connection->mainloop().
 
- Public Member Functions inherited from vrpn_BaseClassUnique
 vrpn_BaseClassUnique ()
 
virtual ~vrpn_BaseClassUnique ()
 Unregister all of the message handlers that were to be autodeleted.
 
vrpn_ConnectionconnectionPtr ()
 Returns a pointer to the connection this object is using.
 

Protected Member Functions

void init_hid (void)
 
void on_data_received (size_t bytes, vrpn_uint8 *buffer)
 Derived class reimplements this callback.
 
virtual void decodePacket (size_t bytes, vrpn_uint8 *buffer)=0
 
int register_types (void)
 Register the types of messages this device sends/receives. Return 0 on success, -1 on fail.
 
- Protected Member Functions inherited from vrpn_BaseClass
virtual int init (void)
 Initialize things that the constructor can't. Returns 0 on success, -1 on failure.
 
virtual int register_senders (void)
 Register the sender for this device (by default, the name of the device). Return 0 on success, -1 on fail.
 
virtual int register_types (void)=0
 Register the types of messages this device sends/receives. Return 0 on success, -1 on fail.
 
- Protected Member Functions inherited from vrpn_BaseClassUnique
int register_autodeleted_handler (vrpn_int32 type, vrpn_MESSAGEHANDLER handler, void *userdata, vrpn_int32 sender=vrpn_ANY_SENDER)
 Registers a handler with the connection, and remembers to delete at destruction.
 
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.
 
SendTextMessageBoundCall send_text_message (vrpn_TEXT_SEVERITY type=vrpn_TEXT_NORMAL)
 Returns an object you can stream into to send a text message from the device like send_text_message(vrpn_TEXT_WARNING) << "Value of i is: " << i; This use requires including vrpn_SendTextMessageStreamProxy.h.
 
void server_mainloop (void)
 Handles functions that all servers should provide in their mainloop() (ping/pong, for example) Should be called by all servers in their mainloop()
 
void client_mainloop (void)
 Handles functions that all clients should provide in their mainloop() (warning of no server, for example) Should be called by all clients in their mainloop()
 
- Protected Member Functions inherited from vrpn_HidInterface
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)
 
 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.
 

Static Protected Member Functions

static int VRPN_CALLBACK on_connect (void *thisPtr, vrpn_HANDLERPARAM p)
 
static int VRPN_CALLBACK on_last_disconnect (void *thisPtr, vrpn_HANDLERPARAM p)
 
- Static Protected Member Functions inherited from vrpn_BaseClassUnique
static int encode_text_message_to_buffer (char *buf, vrpn_TEXT_SEVERITY severity, vrpn_uint32 level, const char *msg)
 Encodes the body of the text message into a buffer, preparing for sending.
 
static int decode_text_message_from_buffer (char *msg, vrpn_TEXT_SEVERITY *severity, vrpn_uint32 *level, const char *buf)
 Decodes the body of the text message from a buffer from the connection.
 

Protected Attributes

struct timeval _timestamp
 
vrpn_HidAcceptor_filter
 
- Protected Attributes inherited from vrpn_BaseClassUnique
vrpn_Connectiond_connection
 Connection that this object talks to.
 
char * d_servicename
 Name of this device, not including the connection part.
 
vrpn_int32 d_sender_id
 Sender ID registered with the connection.
 
vrpn_int32 d_text_message_id
 ID for text messages.
 
vrpn_int32 d_ping_message_id
 Ask the server if they are there.
 
vrpn_int32 d_pong_message_id
 Server telling that it is there.
 
- Protected Attributes inherited from vrpn_HidInterface
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.
 

Additional Inherited Members

- Public Attributes inherited from vrpn_BaseClassUnique
bool shutup
 

Detailed Description

Definition at line 25 of file vrpn_Griffin.h.

Constructor & Destructor Documentation

◆ vrpn_Griffin()

vrpn_Griffin::vrpn_Griffin ( vrpn_HidAcceptor filter,
const char *  name,
vrpn_Connection c = 0,
vrpn_uint16  vendor = 0,
vrpn_uint16  product = 0 
)

Definition at line 34 of file vrpn_Griffin.C.

References init_hid().

Here is the call graph for this function:

◆ ~vrpn_Griffin()

vrpn_Griffin::~vrpn_Griffin ( void  )
virtual

Definition at line 43 of file vrpn_Griffin.C.

References _filter.

Member Function Documentation

◆ decodePacket()

virtual void vrpn_Griffin::decodePacket ( size_t  bytes,
vrpn_uint8 *  buffer 
)
protectedpure virtual

Implemented in vrpn_Griffin_PowerMate.

Referenced by on_data_received().

◆ init_hid()

void vrpn_Griffin::init_hid ( void  )
protected

◆ mainloop()

virtual void vrpn_Griffin::mainloop ( void  )
pure virtual

Called once through each main loop iteration to handle updates. Remote object mainloop() should call client_mainloop() and then call d_connection->mainloop(). Server object mainloop() should service the device and then call server_mainloop(), but should not normally call d_connection->mainloop().

Implements vrpn_BaseClass.

Implemented in vrpn_Griffin_PowerMate.

◆ on_connect()

int vrpn_Griffin::on_connect ( void *  thisPtr,
vrpn_HANDLERPARAM  p 
)
staticprotected

Definition at line 69 of file vrpn_Griffin.C.

Referenced by init_hid().

◆ on_data_received()

void vrpn_Griffin::on_data_received ( size_t  bytes,
vrpn_uint8 *  buffer 
)
protectedvirtual

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.

Implements vrpn_HidInterface.

Definition at line 59 of file vrpn_Griffin.C.

References decodePacket().

Here is the call graph for this function:

◆ on_last_disconnect()

int vrpn_Griffin::on_last_disconnect ( void *  thisPtr,
vrpn_HANDLERPARAM  p 
)
staticprotected

Definition at line 64 of file vrpn_Griffin.C.

Referenced by init_hid().

◆ register_types()

int vrpn_Griffin::register_types ( void  )
inlineprotectedvirtual

Register the types of messages this device sends/receives. Return 0 on success, -1 on fail.

Implements vrpn_BaseClass.

Definition at line 46 of file vrpn_Griffin.h.

Member Data Documentation

◆ _filter

vrpn_HidAcceptor* vrpn_Griffin::_filter
protected

Definition at line 43 of file vrpn_Griffin.h.

Referenced by ~vrpn_Griffin().

◆ _timestamp

struct timeval vrpn_Griffin::_timestamp
protected

The documentation for this class was generated from the following files: