vrpn  07.33
Virtual Reality Peripheral Network
vrpn_Button Class Reference

This is the base class for both the client and server for a button device (a device with one or more boolean switches). More...

#include <vrpn_Button.h>

Inheritance diagram for vrpn_Button:
Collaboration diagram for vrpn_Button:

Public Member Functions

 vrpn_Button (const char *name, vrpn_Connection *c=NULL)
 
virtual ~vrpn_Button (void)
 
void print (void)
 
virtual void set_momentary (vrpn_int32 which_button)
 
virtual void set_toggle (vrpn_int32 which_button, vrpn_int32 current_state)
 
virtual void set_all_momentary (void)
 
virtual void set_all_toggle (vrpn_int32 default_state)
 
- 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. More...
 
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(). More...
 
- Public Member Functions inherited from vrpn_BaseClassUnique
 vrpn_BaseClassUnique ()
 
virtual ~vrpn_BaseClassUnique ()
 Unregister all of the message handlers that were to be autodeleted. More...
 
vrpn_ConnectionconnectionPtr ()
 Returns a pointer to the connection this object is using. More...
 

Protected Member Functions

virtual int register_types (void)
 Register the types of messages this device sends/receives. Return 0 on success, -1 on fail. More...
 
virtual void report_changes (void)
 
virtual void report_states (void)
 
virtual vrpn_int32 encode_to (char *buf, vrpn_int32 button, vrpn_int32 state)
 Encode a message describing the new state of a button. More...
 
virtual vrpn_int32 encode_states_to (char *buf)
 Encode a message describing the state of all buttons. More...
 
- 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. More...
 
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. More...
 
- 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. More...
 
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. More...
 
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. More...
 
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() More...
 
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() More...
 

Protected Attributes

unsigned char buttons [vrpn_BUTTON_MAX_BUTTONS]
 
unsigned char lastbuttons [vrpn_BUTTON_MAX_BUTTONS]
 
vrpn_int32 minrate [vrpn_BUTTON_MAX_BUTTONS]
 
vrpn_int32 num_buttons
 
struct timeval timestamp
 
vrpn_int32 change_message_id
 
vrpn_int32 states_message_id
 
vrpn_int32 admin_message_id
 
- Protected Attributes inherited from vrpn_BaseClassUnique
vrpn_Connectiond_connection
 Connection that this object talks to. More...
 
char * d_servicename
 Name of this device, not including the connection part. More...
 
vrpn_int32 d_sender_id
 Sender ID registered with the connection. More...
 
vrpn_int32 d_text_message_id
 ID for text messages. More...
 
vrpn_int32 d_ping_message_id
 Ask the server if they are there. More...
 
vrpn_int32 d_pong_message_id
 Server telling that it is there. More...
 

Additional Inherited Members

- Public Attributes inherited from vrpn_BaseClassUnique
bool shutup
 
vrpn_MESSAGEHANDLER handler
 
vrpn_int32 sender
 
vrpn_int32 type
 
void * userdata
 
- 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. More...
 
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. More...
 

Detailed Description

This is the base class for both the client and server for a button device (a device with one or more boolean switches).

Any server should actually derive from the vrpn_Button_Filter class, described next, which enables toggling any of the buttons.

Definition at line 30 of file vrpn_Button.h.

Constructor & Destructor Documentation

◆ vrpn_Button()

vrpn_Button::vrpn_Button ( const char *  name,
vrpn_Connection c = NULL 
)

Definition at line 90 of file vrpn_Button.C.

References buttons, vrpn_BaseClass::init(), lastbuttons, timestamp, and vrpn_BUTTON_MAX_BUTTONS.

Here is the call graph for this function:

◆ ~vrpn_Button()

vrpn_Button::~vrpn_Button ( void  )
virtual

Definition at line 122 of file vrpn_Button.C.

Member Function Documentation

◆ encode_states_to()

vrpn_int32 vrpn_Button::encode_states_to ( char *  buf)
protectedvirtual

Encode a message describing the state of all buttons.

Assumes that there is enough room in the buffer to hold the bytes from the message. Returns the number of bytes sent.

Reimplemented in vrpn_Button_Filter.

Definition at line 317 of file vrpn_Button.C.

References buttons, num_buttons, vrpn_buffer(), and vrpn_BUTTON_MAX_BUTTONS.

Referenced by report_states().

Here is the call graph for this function:

◆ encode_to()

vrpn_int32 vrpn_Button::encode_to ( char *  buf,
vrpn_int32  button,
vrpn_int32  state 
)
protectedvirtual

Encode a message describing the new state of a button.

Assumes that there is enough room in the buffer to hold the bytes from the message. Returns the number of bytes sent.

Definition at line 298 of file vrpn_Button.C.

References vrpn_buffer().

Here is the call graph for this function:

◆ print()

void vrpn_Button::print ( void  )

Definition at line 276 of file vrpn_Button.C.

References buttons, lastbuttons, and num_buttons.

◆ register_types()

int vrpn_Button::register_types ( void  )
protectedvirtual

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

Implements vrpn_BaseClass.

Definition at line 103 of file vrpn_Button.C.

References admin_message_id, change_message_id, vrpn_BaseClassUnique::d_connection, vrpn_Connection::register_message_type(), and states_message_id.

Here is the call graph for this function:

◆ report_changes()

void vrpn_Button::report_changes ( void  )
protectedvirtual

Reimplemented in vrpn_Xkeys_XK3, vrpn_Xkeys_Pro, vrpn_Button_Filter, vrpn_Xkeys_Desktop, and vrpn_DreamCheeky_Drum_Kit.

Definition at line 422 of file vrpn_Button.C.

References buttons, vrpn_BaseClassUnique::d_connection, lastbuttons, num_buttons, and PACK_MESSAGE.

Referenced by vrpn_Tracker_3DMouse::get_report(), vrpn_VPJoystick::mainloop(), vrpn_ADBox::mainloop(), vrpn_Event_Mouse::mainloop(), vrpn_Tracker_SpacePoint::on_data_received(), vrpn_Joystick::report(), vrpn_3DConnexion::report(), vrpn_CerealBox::report(), vrpn_Magellan::report(), vrpn_GlobalHapticsOrb::report(), vrpn_Tng3::report(), vrpn_Spaceball::report(), vrpn_ImmersionBox::report(), vrpn_3DMicroscribe::report(), vrpn_CHProducts_Fighterstick_USB::report(), vrpn_Saitek_ST290_Pro::report(), vrpn_Logitech_Extreme_3D_Pro::report(), vrpn_Futaba_InterLink_Elite::report(), vrpn_Griffin_PowerMate::report(), vrpn_Contour_ShuttleXpress::report(), vrpn_DreamCheeky_Drum_Kit::report(), vrpn_Xkeys_Desktop::report(), vrpn_Microsoft_SideWinder_Precision_2::report(), vrpn_Retrolink_GameCube::report(), vrpn_BiosciencesTools::report(), vrpn_Xkeys_Pro::report(), vrpn_Microsoft_SideWinder::report(), vrpn_Xkeys_Joystick::report(), vrpn_Microsoft_Controller_Raw_Xbox_S::report(), vrpn_IDEA::report(), vrpn_Xkeys_Jog_And_Shuttle::report(), vrpn_Microsoft_Controller_Raw_Xbox_360::report(), vrpn_Xkeys_XK3::report(), vrpn_inertiamouse::report(), vrpn_CerealBox::report_changes(), vrpn_3DConnexion::report_changes(), vrpn_Magellan::report_changes(), vrpn_GlobalHapticsOrb::report_changes(), vrpn_Spaceball::report_changes(), vrpn_Tng3::report_changes(), vrpn_ImmersionBox::report_changes(), vrpn_3DMicroscribe::report_changes(), vrpn_Logitech_Extreme_3D_Pro::report_changes(), vrpn_CHProducts_Fighterstick_USB::report_changes(), vrpn_Saitek_ST290_Pro::report_changes(), vrpn_Futaba_InterLink_Elite::report_changes(), vrpn_Contour_ShuttleXpress::report_changes(), vrpn_Griffin_PowerMate::report_changes(), vrpn_DreamCheeky_Drum_Kit::report_changes(), vrpn_Xkeys_Desktop::report_changes(), vrpn_Microsoft_SideWinder_Precision_2::report_changes(), vrpn_BiosciencesTools::report_changes(), vrpn_Retrolink_GameCube::report_changes(), vrpn_Xkeys_Pro::report_changes(), vrpn_Microsoft_SideWinder::report_changes(), vrpn_Xkeys_Joystick::report_changes(), vrpn_Microsoft_Controller_Raw_Xbox_S::report_changes(), vrpn_YEI_3Space::report_changes(), vrpn_IDEA::report_changes(), vrpn_Xkeys_Jog_And_Shuttle::report_changes(), vrpn_Microsoft_Controller_Raw_Xbox_360::report_changes(), vrpn_Xkeys_XK3::report_changes(), vrpn_inertiamouse::report_changes(), and vrpn_Wanda::report_new_button_info().

◆ report_states()

void vrpn_Button::report_states ( void  )
protectedvirtual

◆ set_all_momentary()

void vrpn_Button::set_all_momentary ( void  )
virtual

Reimplemented in vrpn_Button_Filter.

Definition at line 254 of file vrpn_Button.C.

References PACK_ADMIN_MESSAGE, vrpn_ALL_ID, and vrpn_BUTTON_MOMENTARY.

◆ set_all_toggle()

void vrpn_Button::set_all_toggle ( vrpn_int32  default_state)
virtual

Reimplemented in vrpn_Button_Filter.

Definition at line 259 of file vrpn_Button.C.

References PACK_ADMIN_MESSAGE, and vrpn_ALL_ID.

◆ set_momentary()

void vrpn_Button::set_momentary ( vrpn_int32  which_button)
virtual

Reimplemented in vrpn_Button_Filter.

Definition at line 191 of file vrpn_Button.C.

References num_buttons, PACK_ADMIN_MESSAGE, vrpn_BaseClassUnique::send_text_message(), timestamp, vrpn_BUTTON_MOMENTARY, and vrpn_TEXT_ERROR.

Here is the call graph for this function:

◆ set_toggle()

void vrpn_Button::set_toggle ( vrpn_int32  which_button,
vrpn_int32  current_state 
)
virtual

Reimplemented in vrpn_Button_Filter.

Definition at line 226 of file vrpn_Button.C.

References num_buttons, PACK_ADMIN_MESSAGE, vrpn_BaseClassUnique::send_text_message(), timestamp, vrpn_BUTTON_TOGGLE_OFF, vrpn_BUTTON_TOGGLE_ON, and vrpn_TEXT_ERROR.

Here is the call graph for this function:

Member Data Documentation

◆ admin_message_id

vrpn_int32 vrpn_Button::admin_message_id
protected

Definition at line 51 of file vrpn_Button.h.

Referenced by register_types(), and vrpn_Button_Filter::vrpn_Button_Filter().

◆ buttons

unsigned char vrpn_Button::buttons[vrpn_BUTTON_MAX_BUTTONS]
protected

Definition at line 44 of file vrpn_Button.h.

Referenced by vrpn_raw_SGIBox::check_press_bank(), vrpn_raw_SGIBox::check_release_bank(), vrpn_Tracker_3DMouse::clear_values(), vrpn_Magellan::clear_values(), vrpn_CerealBox::clear_values(), vrpn_GlobalHapticsOrb::clear_values(), vrpn_Spaceball::clear_values(), vrpn_Tng3::clear_values(), vrpn_ImmersionBox::clear_values(), vrpn_inertiamouse::clear_values(), vrpn_IDEA::convert_report_to_buttons(), vrpn_3DConnexion::decodePacket(), vrpn_DreamCheeky_Drum_Kit::decodePacket(), vrpn_Xkeys_Desktop::decodePacket(), vrpn_Xkeys_XK3::decodePacket(), encode_states_to(), vrpn_Tracker_3DMouse::get_report(), vrpn_Keyboard::get_report(), vrpn_GlobalHapticsOrb::get_report(), vrpn_Magellan::get_report(), vrpn_Spaceball::get_report(), vrpn_Tng3::get_report(), vrpn_ImmersionBox::get_report(), vrpn_3DMicroscribe::get_report(), vrpn_Mouse::get_report(), vrpn_inertiamouse::get_report(), vrpn_YEI_3Space::handle_report(), vrpn_Wanda::mainloop(), vrpn_VPJoystick::mainloop(), vrpn_ADBox::mainloop(), vrpn_3DConnexion::mainloop(), vrpn_Button_NI_DIO24::mainloop(), vrpn_Button_Example_Server::mainloop(), vrpn_Tracker_SpacePoint::on_data_received(), vrpn_Joystick::parse(), print(), vrpn_Button_SerialMouse::read(), vrpn_Button_PinchGlove::read(), report_changes(), vrpn_Button_Filter::report_changes(), vrpn_Wanda::report_new_button_info(), vrpn_IDEA::reset(), vrpn_IDEA::send_move_request(), vrpn_Button_Server::set_button(), vrpn_BiosciencesTools::set_specified_channel(), vrpn_3DConnexion::vrpn_3DConnexion(), vrpn_BiosciencesTools::vrpn_BiosciencesTools(), vrpn_Button(), vrpn_Button_Parallel::vrpn_Button_Parallel(), vrpn_Button_PinchGlove::vrpn_Button_PinchGlove(), vrpn_Button_Remote::vrpn_Button_Remote(), vrpn_Button_SerialMouse::vrpn_Button_SerialMouse(), vrpn_IDEA::vrpn_IDEA(), vrpn_Keyboard::vrpn_Keyboard(), vrpn_Microsoft_Controller_Raw_Xbox_360::vrpn_Microsoft_Controller_Raw_Xbox_360(), vrpn_Mouse::vrpn_Mouse(), vrpn_Tracker_RazerHydra::vrpn_Tracker_RazerHydra(), vrpn_VPJoystick::vrpn_VPJoystick(), vrpn_Wanda::vrpn_Wanda(), vrpn_WiiMote::vrpn_WiiMote(), and vrpn_YEI_3Space::vrpn_YEI_3Space().

◆ change_message_id

vrpn_int32 vrpn_Button::change_message_id
protected

Definition at line 49 of file vrpn_Button.h.

Referenced by register_types(), and vrpn_Button_Remote::vrpn_Button_Remote().

◆ lastbuttons

◆ minrate

vrpn_int32 vrpn_Button::minrate[vrpn_BUTTON_MAX_BUTTONS]
protected

Definition at line 46 of file vrpn_Button.h.

◆ num_buttons

vrpn_int32 vrpn_Button::num_buttons
protected

Definition at line 47 of file vrpn_Button.h.

Referenced by vrpn_GlobalHapticsOrb::clear_values(), vrpn_3DConnexion::decodePacket(), vrpn_DreamCheeky_Drum_Kit::decodePacket(), encode_states_to(), vrpn_Button_Filter::encode_states_to(), vrpn_Button_Remote::handle_states_message(), vrpn_VPJoystick::mainloop(), vrpn_ADBox::mainloop(), vrpn_Button_NI_DIO24::mainloop(), vrpn_Tracker_DTrack::mainloop(), vrpn_Button_Example_Server::mainloop(), vrpn_Button_Server::number_of_buttons(), print(), vrpn_Button_PinchGlove::read(), vrpn_Griffin_PowerMate::report(), vrpn_Contour_ShuttleXpress::report(), vrpn_Retrolink_GameCube::report(), report_changes(), vrpn_Griffin_PowerMate::report_changes(), vrpn_Contour_ShuttleXpress::report_changes(), vrpn_Retrolink_GameCube::report_changes(), vrpn_Button_Filter::report_changes(), vrpn_Button_Filter::set_all_momentary(), vrpn_Button_Filter::set_all_toggle(), vrpn_Button_Server::set_button(), set_momentary(), vrpn_Button_Filter::set_momentary(), set_toggle(), vrpn_Button_Filter::set_toggle(), vrpn_3DConnexion::vrpn_3DConnexion(), vrpn_3DMicroscribe::vrpn_3DMicroscribe(), vrpn_BiosciencesTools::vrpn_BiosciencesTools(), vrpn_Button_Example_Server::vrpn_Button_Example_Server(), vrpn_Button_NI_DIO24::vrpn_Button_NI_DIO24(), vrpn_Button_Parallel::vrpn_Button_Parallel(), vrpn_Button_PinchGlove::vrpn_Button_PinchGlove(), vrpn_Button_Remote::vrpn_Button_Remote(), vrpn_Button_SerialMouse::vrpn_Button_SerialMouse(), vrpn_Button_Server::vrpn_Button_Server(), vrpn_CerealBox::vrpn_CerealBox(), vrpn_Event_Mouse::vrpn_Event_Mouse(), vrpn_GlobalHapticsOrb::vrpn_GlobalHapticsOrb(), vrpn_IDEA::vrpn_IDEA(), vrpn_ImmersionBox::vrpn_ImmersionBox(), vrpn_inertiamouse::vrpn_inertiamouse(), vrpn_Joystick::vrpn_Joystick(), vrpn_Keyboard::vrpn_Keyboard(), vrpn_Magellan::vrpn_Magellan(), vrpn_Microsoft_Controller_Raw_Xbox_360::vrpn_Microsoft_Controller_Raw_Xbox_360(), vrpn_Mouse::vrpn_Mouse(), vrpn_raw_SGIBox::vrpn_raw_SGIBox(), vrpn_Spaceball::vrpn_Spaceball(), vrpn_Tng3::vrpn_Tng3(), vrpn_Tracker_3DMouse::vrpn_Tracker_3DMouse(), vrpn_Tracker_DTrack::vrpn_Tracker_DTrack(), vrpn_Tracker_RazerHydra::vrpn_Tracker_RazerHydra(), vrpn_Tracker_SpacePoint::vrpn_Tracker_SpacePoint(), vrpn_VPJoystick::vrpn_VPJoystick(), vrpn_Wanda::vrpn_Wanda(), vrpn_WiiMote::vrpn_WiiMote(), and vrpn_YEI_3Space::vrpn_YEI_3Space().

◆ states_message_id

vrpn_int32 vrpn_Button::states_message_id
protected

◆ timestamp

struct timeval vrpn_Button::timestamp
protected

Definition at line 48 of file vrpn_Button.h.

Referenced by vrpn_Keyboard::get_report(), vrpn_ADBox::mainloop(), vrpn_3DConnexion::mainloop(), vrpn_Button_SerialMouse::mainloop(), vrpn_Button_Example_Server::mainloop(), vrpn_Button_Python::mainloop(), vrpn_Tracker_SpacePoint::on_data_received(), vrpn_Button_PinchGlove::read(), vrpn_Joystick::report(), vrpn_3DConnexion::report(), vrpn_CerealBox::report(), vrpn_GlobalHapticsOrb::report(), vrpn_Magellan::report(), vrpn_Tng3::report(), vrpn_Spaceball::report(), vrpn_ImmersionBox::report(), vrpn_3DMicroscribe::report(), vrpn_Logitech_Extreme_3D_Pro::report(), vrpn_CHProducts_Fighterstick_USB::report(), vrpn_Saitek_ST290_Pro::report(), vrpn_Griffin_PowerMate::report(), vrpn_Contour_ShuttleXpress::report(), vrpn_Futaba_InterLink_Elite::report(), vrpn_DreamCheeky_Drum_Kit::report(), vrpn_Xkeys_Desktop::report(), vrpn_Microsoft_SideWinder_Precision_2::report(), vrpn_Retrolink_GameCube::report(), vrpn_Mouse::report(), vrpn_Xkeys_Pro::report(), vrpn_Microsoft_SideWinder::report(), vrpn_Xkeys_Joystick::report(), vrpn_Microsoft_Controller_Raw_Xbox_S::report(), vrpn_IDEA::report(), vrpn_Xkeys_Jog_And_Shuttle::report(), vrpn_Microsoft_Controller_Raw_Xbox_360::report(), vrpn_Xkeys_XK3::report(), vrpn_inertiamouse::report(), vrpn_CerealBox::report_changes(), vrpn_3DConnexion::report_changes(), vrpn_Magellan::report_changes(), vrpn_GlobalHapticsOrb::report_changes(), vrpn_Spaceball::report_changes(), vrpn_Tng3::report_changes(), vrpn_ImmersionBox::report_changes(), vrpn_3DMicroscribe::report_changes(), vrpn_Logitech_Extreme_3D_Pro::report_changes(), vrpn_CHProducts_Fighterstick_USB::report_changes(), vrpn_Saitek_ST290_Pro::report_changes(), vrpn_Griffin_PowerMate::report_changes(), vrpn_Futaba_InterLink_Elite::report_changes(), vrpn_Contour_ShuttleXpress::report_changes(), vrpn_DreamCheeky_Drum_Kit::report_changes(), vrpn_Xkeys_Desktop::report_changes(), vrpn_Microsoft_SideWinder_Precision_2::report_changes(), vrpn_Retrolink_GameCube::report_changes(), vrpn_Mouse::report_changes(), vrpn_Xkeys_Pro::report_changes(), vrpn_Microsoft_SideWinder::report_changes(), vrpn_Xkeys_Joystick::report_changes(), vrpn_Microsoft_Controller_Raw_Xbox_S::report_changes(), vrpn_YEI_3Space::report_changes(), vrpn_IDEA::report_changes(), vrpn_Xkeys_Jog_And_Shuttle::report_changes(), vrpn_Microsoft_Controller_Raw_Xbox_360::report_changes(), vrpn_Xkeys_XK3::report_changes(), vrpn_inertiamouse::report_changes(), report_states(), set_momentary(), vrpn_Button_Filter::set_momentary(), set_toggle(), vrpn_Button_Filter::set_toggle(), vrpn_ADBox::vrpn_ADBox(), vrpn_Button(), vrpn_Button_Parallel::vrpn_Button_Parallel(), vrpn_Button_PinchGlove::vrpn_Button_PinchGlove(), vrpn_Button_Remote::vrpn_Button_Remote(), vrpn_Button_Serial::vrpn_Button_Serial(), vrpn_Button_SerialMouse::vrpn_Button_SerialMouse(), vrpn_Event_Mouse::vrpn_Event_Mouse(), and vrpn_VPJoystick::vrpn_VPJoystick().


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