InputDevice
from panda3d.core import InputDevice
- class InputDevice
Bases:
TypedReferenceCount
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.
New in version 1.10.0.
Inheritance diagram
- class Axis(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)
Bases:
Enum
- ACCELERATOR = 16
- BRAKE = 17
- LEFT_TRIGGER = 9
- LEFT_X = 7
- LEFT_Y = 8
- NONE = 0
- PITCH = 5
- PRESSURE = 18
- RIGHT_TRIGGER = 12
- RIGHT_X = 10
- RIGHT_Y = 11
- ROLL = 6
- RUDDER = 14
- THROTTLE = 13
- WHEEL = 15
- X = 1
- Y = 2
- YAW = 4
- Z = 3
- accelerator = 16
- brake = 17
- left_trigger = 9
- left_x = 7
- left_y = 8
- none = 0
- pitch = 5
- pressure = 18
- right_trigger = 12
- right_x = 10
- right_y = 11
- roll = 6
- rudder = 14
- throttle = 13
- wheel = 15
- x = 1
- y = 2
- yaw = 4
- z = 3
- class BatteryData
Bases:
DTOOL_SUPER_BASE
- __init__(*args, **kwargs)
- level
Ranges from 0 through max_level.
- max_level
Maximum value of ‘level’ field.
- class DeviceClass(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)
Bases:
Enum
- DANCE_PAD = 8
- DIGITIZER = 11
- FLIGHT_STICK = 6
- GAMEPAD = 5
- HMD = 9
- KEYBOARD = 2
- MOUSE = 3
- SPATIAL_MOUSE = 10
- STEERING_WHEEL = 7
- TOUCH = 4
- UNKNOWN = 0
- VIRTUAL = 1
- dance_pad = 8
- digitizer = 11
- flight_stick = 6
- gamepad = 5
- hmd = 9
- keyboard = 2
- mouse = 3
- spatial_mouse = 10
- steering_wheel = 7
- touch = 4
- unknown = 0
- virtual_device = 1
- class Feature(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)
Bases:
Enum
- BATTERY = 4
- KEYBOARD = 1
- POINTER = 0
- TRACKER = 2
- VIBRATION = 3
- battery = 4
- keyboard = 1
- pointer = 0
- tracker = 2
- vibration = 3
- SDown = 2
- SUnknown = 0
- SUp = 1
- S_down = 2
- S_unknown = 0
- S_up = 1
- __init__(*args, **kwargs)
- axes
- battery
- buttons
Make device buttons and axes iterable
- 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.
- device_class
This contains an identification of the general type of device. If this could not be determined, it is set to DC_unknown.
- disablePointerEvents()
C++ Interface: disable_pointer_events(const InputDevice self)
- /**
Disables the generation of mouse-movement events.
*/
- disable_pointer_events()
C++ Interface: disable_pointer_events(const InputDevice self)
- /**
Disables the generation of mouse-movement events.
*/
- enablePointerEvents()
C++ Interface: enable_pointer_events(const InputDevice self)
- /**
Enables the generation of mouse-movement events.
*/
- enable_pointer_events()
C++ Interface: enable_pointer_events(const InputDevice self)
- /**
Enables the generation of mouse-movement events.
*/
- findAxis()
C++ Interface: find_axis(InputDevice self, Axis axis)
- /**
Returns the first AnalogAxis found with the given axis, or throw an assert
if the axis was not found in the list.
*/
- findButton()
C++ Interface: find_button(InputDevice self, 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.
*/
- find_axis()
C++ Interface: find_axis(InputDevice self, Axis axis)
- /**
Returns the first AnalogAxis found with the given axis, or throw an assert
if the axis was not found in the list.
*/
- find_button()
C++ Interface: find_button(InputDevice self, 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.
*/
- getButtonEvents()
C++ Interface: get_button_events(const InputDevice self)
- /**
Returns the list of recently-generated ButtonEvents.
The list is also cleared.
*/
- getClassType()
C++ Interface: get_class_type()
- getPointerEvents()
C++ Interface: get_pointer_events(const InputDevice self)
- /**
Returns a PointerEventList containing all the recent pointer events.
Clears the list.
*/
- get_button_events()
C++ Interface: get_button_events(const InputDevice self)
- /**
Returns the list of recently-generated ButtonEvents.
The list is also cleared.
*/
- get_class_type()
C++ Interface: get_class_type()
- get_pointer_events()
C++ Interface: get_pointer_events(const InputDevice self)
- /**
Returns a PointerEventList containing all the recent pointer events.
Clears the list.
*/
- hasButtonEvent()
C++ Interface: has_button_event(InputDevice self)
- /**
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().
*/
- hasFeature()
C++ Interface: has_feature(InputDevice self, Feature feature)
// Determine supported features
- /**
Returns true if the device supports the indicated feature.
*/
- hasPointerEvent()
C++ Interface: has_pointer_event(InputDevice self)
- /**
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().
*/
- has_button_event()
C++ Interface: has_button_event(InputDevice self)
- /**
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().
*/
- has_feature()
C++ Interface: has_feature(InputDevice self, Feature feature)
// Determine supported features
- /**
Returns true if the device supports the indicated feature.
*/
- has_pointer_event()
C++ Interface: has_pointer_event(InputDevice self)
- /**
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().
*/
- manufacturer
The device’s manufacturer, or the empty string if not known.
- mapAxis()
C++ Interface: map_axis(const InputDevice self, int index, 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()
C++ Interface: map_button(const InputDevice self, int index, ButtonHandle handle)
// Associate buttons/axes with symbolic handles.
- /**
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.
*/
- map_axis()
C++ Interface: map_axis(const InputDevice self, int index, 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.
*/
- map_button()
C++ Interface: map_button(const InputDevice self, int index, ButtonHandle handle)
// Associate buttons/axes with symbolic handles.
- /**
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.
*/
- name
The human-readable name of this input device.
- output()
C++ Interface: output(InputDevice self, ostream out)
- /**
Writes a one-line string describing the device.
*/
- poll()
C++ Interface: poll(const InputDevice self)
- /**
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.
*/
- product_id
USB product ID of the device, or 0 if not known.
- serial_number
The device’s serial number, or the empty string if not known.
- setVibration()
C++ Interface: set_vibration(const InputDevice self, double strong, double weak)
// Enable rumble force-feedback effects
- /**
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.
*/
- set_vibration()
C++ Interface: set_vibration(const InputDevice self, double strong, double weak)
// Enable rumble force-feedback effects
- /**
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.
*/
- tracker
Getters for the various types of device data.
- vendor_id
USB vendor ID of the device, or 0 if not known.