Panda3D
Public Member Functions | Static Public Member Functions | Protected Member Functions

ButtonNode Class Reference

This is the primary interface to on/off button devices associated with a ClientBase. More...

#include "buttonNode.h"

Inheritance diagram for ButtonNode:
DataNode PandaNode TypedWritable Namable LinkedListNode ReferenceCount TypedObject MemoryBase MemoryBase MemoryBase

List of all members.

Public Member Functions

 ButtonNode (ClientBase *client, const string &device_name)
virtual TypeHandle force_init_type ()
ButtonHandle get_button_map (int index) const
 Returns the ButtonHandle that was previously associated with the given index number by a call to set_button_map(), or ButtonHandle::none() if no button was associated.
bool get_button_state (int index) const
 Returns true if the indicated button (identified by its index number) is currently known to be down, or false if it is up or unknown.
int get_num_buttons () const
 Returns the number of buttons known to the ButtonNode.
virtual TypeHandle get_type () const
bool is_button_known (int index) const
 Returns true if the state of the indicated button is known, or false if we have never heard anything about this particular button.
bool is_valid () const
 Returns true if the ButtonNode is valid and connected to a server, false otherwise.
virtual void output (ostream &out) const
 Outputs the Namable.
void set_button_map (int index, ButtonHandle button)
 Associates the indicated ButtonHandle with the button of the indicated index number.
virtual void write (ostream &out, int indent_level=0) const

Static Public Member Functions

static TypeHandle get_class_type ()
static void init_type ()

Protected Member Functions

virtual void do_transmit_data (DataGraphTraverser *trav, const DataNodeTransmit &input, DataNodeTransmit &output)
 The virtual implementation of transmit_data().

Detailed Description

This is the primary interface to on/off button devices associated with a ClientBase.

This creates a node that connects to the named button device, if it exists, and provides hooks to the user to read the state of any of the sequentially numbered buttons associated with that device.

It also can associate an arbitrary ButtonHandle with each button; when buttons are associated with ButtonHandles, this node will put appropriate up and down events on the data graph for each button state change.

Definition at line 41 of file buttonNode.h.


Member Function Documentation

void ButtonNode::do_transmit_data ( DataGraphTraverser trav,
const DataNodeTransmit input,
DataNodeTransmit output 
) [protected, virtual]

The virtual implementation of transmit_data().

This function receives an array of input parameters and should generate an array of output parameters. The input parameters may be accessed with the index numbers returned by the define_input() calls that were made earlier (presumably in the constructor); likewise, the output parameters should be set with the index numbers returned by the define_output() calls.

Reimplemented from DataNode.

Definition at line 115 of file buttonNode.cxx.

References is_valid(), and DataNodeTransmit::set_data().

ButtonHandle ButtonNode::get_button_map ( int  index) const [inline]

Returns the ButtonHandle that was previously associated with the given index number by a call to set_button_map(), or ButtonHandle::none() if no button was associated.

Definition at line 75 of file buttonNode.I.

bool ButtonNode::get_button_state ( int  index) const [inline]

Returns true if the indicated button (identified by its index number) is currently known to be down, or false if it is up or unknown.

Definition at line 90 of file buttonNode.I.

int ButtonNode::get_num_buttons ( ) const [inline]

Returns the number of buttons known to the ButtonNode.

This includes those buttons whose state has been seen, as well as buttons that have been associated with a ButtonHandle even if their state is unknown. This number may change as more buttons are discovered.

Definition at line 38 of file buttonNode.I.

bool ButtonNode::is_button_known ( int  index) const [inline]

Returns true if the state of the indicated button is known, or false if we have never heard anything about this particular button.

Definition at line 105 of file buttonNode.I.

bool ButtonNode::is_valid ( ) const [inline]

Returns true if the ButtonNode is valid and connected to a server, false otherwise.

Definition at line 23 of file buttonNode.I.

Referenced by do_transmit_data().

void ButtonNode::output ( ostream &  out) const [virtual]

Outputs the Namable.

This function simply writes the name to the output stream; most Namable derivatives will probably redefine this.

Reimplemented from PandaNode.

Definition at line 73 of file buttonNode.cxx.

void ButtonNode::set_button_map ( int  index,
ButtonHandle  button 
) [inline]

Associates the indicated ButtonHandle with the button of the indicated index number.

When the given button index changes state, a corresponding ButtonEvent will be generated with the given ButtonHandle. Pass ButtonHandle::none() to turn off any association.

It is not necessary to call this if you simply want to query the state of the various buttons by index number; this is only necessary in order to generate ButtonEvents when the buttons change state.

Definition at line 60 of file buttonNode.I.


The documentation for this class was generated from the following files:
 All Classes Functions Variables Enumerations