Panda3D
|
This is a structure representing a single input device. More...
Classes | |
class | AxisState |
class | BatteryData |
class | ButtonState |
Public Types | |
enum | Axis { none = 0, x = 1, y = 2, z = 3, yaw = 4, pitch = 5, roll = 6, left_x = 7, left_y = 8, left_trigger = 9, right_x = 10, right_y = 11, right_trigger = 12, throttle = 13, rudder = 14, wheel = 15, accelerator = 16, brake = 17 } |
enum | DeviceClass { unknown = 0, virtual_device = 1, keyboard = 2, mouse = 3, touch = 4, gamepad = 5, flight_stick = 6, steering_wheel = 7, dance_pad = 8, hmd = 9, spatial_mouse = 10 } |
enum | Feature { pointer = 0, keyboard = 2, tracker = 2, vibration = 3, battery = 4 } |
enum | State { S_unknown = 0, S_up = 1, S_down = 2 } |
Public Member Functions | |
disablePointerEvents () | |
Disables the generation of mouse-movement events. More... | |
enablePointerEvents () | |
Enables the generation of mouse-movement events. More... | |
InputDevice::AxisState | findAxis (InputDevice::Axis axis) |
Returns the first AnalogAxis found with the given axis, or throw an assert if the axis was not found in the list. More... | |
InputDevice::ButtonState | findButton (ButtonHandle handle) |
Returns the first ButtonState found with the given axis, or throw an assert if the button handle was not found in the list. More... | |
ButtonEventList | getButtonEvents () |
Returns the list of recently-generated ButtonEvents. More... | |
PointerEventList | getPointerEvents () |
Returns a PointerEventList containing all the recent pointer events. More... | |
bool | hasButtonEvent () |
Returns true if this device has a pending button event (a mouse button or keyboard button down/up), false otherwise. More... | |
bool | hasFeature (InputDevice::Feature feature) |
Returns true if the device supports the indicated feature. More... | |
bool | hasPointerEvent () |
Returns true if this device has a pending pointer event (a mouse movement), or false otherwise. More... | |
mapAxis (int index, InputDevice::Axis axis) | |
Associates the indicated Axis with the axis of the indicated index number. More... | |
mapButton (int index, ButtonHandle handle) | |
Associates the indicated ButtonHandle with the button of the indicated index number. More... | |
output (Ostream out) | |
Writes a one-line string describing the device. More... | |
poll () | |
Polls the input device for new activity, to ensure it contains the latest events. More... | |
setVibration (double strong, double weak) | |
Sets the strength of the vibration effect, if supported. More... | |
![]() | |
TypeHandle | getType () |
int | getTypeIndex () |
Returns the internal index number associated with this object's TypeHandle, a unique number for each different type. More... | |
bool | isExactType (TypeHandle handle) |
Returns true if the current object is the indicated type exactly. More... | |
bool | isOfType (TypeHandle handle) |
Returns true if the current object is or derives from the indicated type. More... | |
![]() | |
int | getRefCount () |
Returns the current reference count. More... | |
ref () | |
Explicitly increments the reference count. More... | |
bool | testRefCountIntegrity () |
Does some easy checks to make sure that the reference count isn't completely bogus. More... | |
bool | testRefCountNonzero () |
Does some easy checks to make sure that the reference count isn't zero, or completely bogus. More... | |
bool | unref () |
Explicitly decrements the reference count. More... | |
Static Public Member Functions | |
static TypeHandle | getClassType () |
![]() | |
static TypeHandle | getClassType () |
![]() | |
static TypeHandle | getClassType () |
![]() | |
static TypeHandle | getClassType () |
Public Attributes | |
InputDevice::Axes | _axes |
InputDevice::BatteryData | _battery_data |
InputDevice::Buttons | _buttons |
PointerData | _pointer_data |
TrackerData | _tracker_data |
InputDevice::AxisState | axes [] |
InputDevice::BatteryData | battery |
Returns a rough indication of the battery level, ranging from 0 (completely empty battery) to the indicated max_level value. More... | |
InputDevice::ButtonState | buttons [] |
Make device buttons and axes iterable. More... | |
bool | connected |
This is false if we know that the device is not currently connected. May report false positives if we can't know this with certainty. More... | |
InputDevice::DeviceClass | device_class |
This contains an identification of the general type of device. If this could not be determined, it is set to DC_unknown. More... | |
String | manufacturer |
The device's manufacturer, or the empty string if not known. More... | |
String | name |
The human-readable name of this input device. More... | |
unsigned short int | product_id |
USB product ID of the device, or 0 if not known. More... | |
String | serial_number |
The device's serial number, or the empty string if not known. More... | |
TrackerData | tracker |
Getters for the various types of device data. More... | |
unsigned short int | vendor_id |
USB vendor ID of the device, or 0 if not known. More... | |
![]() | |
TypeHandle | type |
Returns the TypeHandle representing this object's type. More... | |
![]() | |
int | ref_count |
The current reference count. More... | |
This is a structure representing a single input device.
Input devices may have zero or more buttons, pointers, or axes associated with them, and optionally a motion tracker.
These devices are brought under a common interface because there is such a large range of devices out there that may support any number of these types of axes, we couldn't even begin to cover them with type-specific subclasses.
Use the various has_() and get_num_() methods to determine information about the device capabilities. For instance, has_keyboard() will give an indication that you can receive keystroke events from this device, and get_num_buttons() will tell you that the device may send button events.
There is the DeviceType enumeration, however, which will (if known) contain identification of the general category of devices this fits in, such as keyboard, mouse, gamepad, or flight stick.
enum Axis |
enum DeviceClass |
enum Feature |
enum State |
disablePointerEvents | ( | ) |
Disables the generation of mouse-movement events.
enablePointerEvents | ( | ) |
Enables the generation of mouse-movement events.
InputDevice::AxisState findAxis | ( | InputDevice::Axis | axis | ) |
Returns the first AnalogAxis found with the given axis, or throw an assert if the axis was not found in the list.
InputDevice::ButtonState findButton | ( | ButtonHandle | handle | ) |
Returns the first ButtonState found with the given axis, or throw an assert if the button handle was not found in the list.
ButtonEventList getButtonEvents | ( | ) |
Returns the list of recently-generated ButtonEvents.
The list is also cleared.
|
static |
PointerEventList getPointerEvents | ( | ) |
Returns a PointerEventList containing all the recent pointer events.
Clears the list.
bool hasButtonEvent | ( | ) |
Returns true if this device has a pending button event (a mouse button or keyboard button down/up), false otherwise.
If this returns true, the particular event may be extracted via get_button_event().
bool hasFeature | ( | InputDevice::Feature | feature | ) |
Returns true if the device supports the indicated feature.
bool hasPointerEvent | ( | ) |
Returns true if this device has a pending pointer event (a mouse movement), or false otherwise.
If this returns true, the particular event may be extracted via get_pointer_event().
mapAxis | ( | int | index, |
InputDevice::Axis | axis | ||
) |
Associates the indicated Axis with the axis of the indicated index number.
Pass Axis::none to turn off any association.
It is not necessary to call this if you simply want to query the state of the various axes by index number.
mapButton | ( | int | index, |
ButtonHandle | handle | ||
) |
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.
output | ( | Ostream | out | ) |
Writes a one-line string describing the device.
poll | ( | ) |
Polls the input device for new activity, to ensure it contains the latest events.
This will only have any effect for some types of input devices; others may be updated automatically, and this method will be a no-op.
setVibration | ( | double | strong, |
double | weak | ||
) |
Sets the strength of the vibration effect, if supported.
The values are clamped to 0-1 range. The first value axes the low-frequency rumble motor, whereas the second axes the high-frequency motor, if present.
InputDevice::Axes _axes |
InputDevice::BatteryData _battery_data |
InputDevice::Buttons _buttons |
PointerData _pointer_data |
TrackerData _tracker_data |
InputDevice::AxisState axes[] |
InputDevice::BatteryData battery |
Returns a rough indication of the battery level, ranging from 0 (completely empty battery) to the indicated max_level value.
InputDevice::ButtonState buttons[] |
Make device buttons and axes iterable.
bool connected |
This is false if we know that the device is not currently connected. May report false positives if we can't know this with certainty.
InputDevice::DeviceClass device_class |
This contains an identification of the general type of device. If this could not be determined, it is set to DC_unknown.
String manufacturer |
The device's manufacturer, or the empty string if not known.
String name |
The human-readable name of this input device.
unsigned short int product_id |
USB product ID of the device, or 0 if not known.
String serial_number |
The device's serial number, or the empty string if not known.
TrackerData tracker |
Getters for the various types of device data.
unsigned short int vendor_id |
USB vendor ID of the device, or 0 if not known.