Panda3D
Loading...
Searching...
No Matches
buttonNode.I
Go to the documentation of this file.
1/**
2 * PANDA 3D SOFTWARE
3 * Copyright (c) Carnegie Mellon University. All rights reserved.
4 *
5 * All use of this software is subject to the terms of the revised BSD
6 * license. You should have received a copy of this license along
7 * with this source code in a file named "LICENSE."
8 *
9 * @file buttonNode.I
10 * @author drose
11 * @date 2002-03-12
12 */
13
14/**
15 * Returns true if the ButtonNode is valid and connected to a server, false
16 * otherwise.
17 */
18INLINE bool ButtonNode::
19is_valid() const {
20 return (_device != nullptr) && _device->is_connected();
21}
22
23/**
24 * Returns the number of buttons known to the ButtonNode. This includes those
25 * buttons whose state has been seen, as well as buttons that have been
26 * associated with a ButtonHandle even if their state is unknown. This number
27 * may change as more buttons are discovered.
28 */
29INLINE int ButtonNode::
30get_num_buttons() const {
31 return _device->get_num_buttons();
32}
33
34/**
35 * Associates the indicated ButtonHandle with the button of the indicated
36 * index number. When the given button index changes state, a corresponding
37 * ButtonEvent will be generated with the given ButtonHandle. Pass
38 * ButtonHandle::none() to turn off any association.
39 *
40 * It is not necessary to call this if you simply want to query the state of
41 * the various buttons by index number; this is only necessary in order to
42 * generate ButtonEvents when the buttons change state.
43 */
44INLINE void ButtonNode::
45set_button_map(int index, ButtonHandle button) {
46 _device->map_button(index, button);
47}
48
49/**
50 * Returns the ButtonHandle that was previously associated with the given
51 * index number by a call to set_button_map(), or ButtonHandle::none() if no
52 * button was associated.
53 */
55get_button_map(int index) const {
56 return _device->get_button_map(index);
57}
58
59/**
60 * Returns true if the indicated button (identified by its index number) is
61 * currently known to be down, or false if it is up or unknown.
62 */
63INLINE bool ButtonNode::
64get_button_state(int index) const {
65 return _device->is_button_pressed(index);
66}
67
68/**
69 * Returns true if the state of the indicated button is known, or false if we
70 * have never heard anything about this particular button.
71 */
72INLINE bool ButtonNode::
73is_button_known(int index) const {
74 return _device->is_button_known(index);
75}
A ButtonHandle represents a single button from any device, including keyboard buttons and mouse butto...
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 ...
Definition buttonNode.I:73
int get_num_buttons() const
Returns the number of buttons known to the ButtonNode.
Definition buttonNode.I:30
ButtonHandle get_button_map(int index) const
Returns the ButtonHandle that was previously associated with the given index number by a call to set_...
Definition buttonNode.I:55
bool get_button_state(int index) const
Returns true if the indicated button (identified by its index number) is currently known to be down,...
Definition buttonNode.I:64
bool is_valid() const
Returns true if the ButtonNode is valid and connected to a server, false otherwise.
Definition buttonNode.I:19
void set_button_map(int index, ButtonHandle button)
Associates the indicated ButtonHandle with the button of the indicated index number.
Definition buttonNode.I:45