InputDevice¶
-
class InputDevice¶
Bases:
TypedReferenceCountThis 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.
Added in version 1.10.0.
Inheritance diagram
digraph inheritance63d3b18b3c { bgcolor=transparent; rankdir=BT; size="8.0, 12.0"; "DTOOL_SUPER_BASE" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=11,height=0.25,shape=box,style=""]; "InputDevice" [URL="acron.core.InputDevice.html#acron.core.InputDevice",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=11,height=0.25,shape=box,style="",target="_top",tooltip="/**"]; "TypedReferenceCount" -> "InputDevice" [arrowsize=0.75,style=""]; "ReferenceCount" [URL="acron.core.ReferenceCount.html#acron.core.ReferenceCount",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=11,height=0.25,shape=box,style="",target="_top",tooltip="/**"]; "DTOOL_SUPER_BASE" -> "ReferenceCount" [arrowsize=0.75,style=""]; "TypedObject" [URL="acron.core.TypedObject.html#acron.core.TypedObject",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=11,height=0.25,shape=box,style="",target="_top",tooltip="/**"]; "DTOOL_SUPER_BASE" -> "TypedObject" [arrowsize=0.75,style=""]; "TypedReferenceCount" [URL="acron.core.TypedReferenceCount.html#acron.core.TypedReferenceCount",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=11,height=0.25,shape=box,style="",target="_top",tooltip="/**"]; "TypedObject" -> "TypedReferenceCount" [arrowsize=0.75,style=""]; "ReferenceCount" -> "TypedReferenceCount" [arrowsize=0.75,style=""]; }- class InputDevice.Axes¶
Bases:
alias of
pvector_AxisState
-
enum Axis¶
-
enumerator NONE = 0¶
-
enumerator X = 1¶
Generic translational axes
-
enumerator Y = 2¶
-
enumerator Z = 3¶
-
enumerator YAW = 4¶
Generic rotational axes, used by joysticks and 3D mice
-
enumerator PITCH = 5¶
-
enumerator ROLL = 6¶
-
enumerator LEFT_X = 7¶
Gamepad
-
enumerator LEFT_Y = 8¶
-
enumerator LEFT_TRIGGER = 9¶
-
enumerator RIGHT_X = 10¶
-
enumerator RIGHT_Y = 11¶
-
enumerator RIGHT_TRIGGER = 12¶
-
enumerator THROTTLE = 13¶
Flight stick specific
-
enumerator RUDDER = 14¶
When available separately from yaw
-
enumerator WHEEL = 15¶
Steering wheel / pedals
-
enumerator ACCELERATOR = 16¶
-
enumerator BRAKE = 17¶
-
enumerator PRESSURE = 18¶
Pen pressure
-
enumerator none = 0¶
Deprecated aliases
-
enumerator x = 1¶
-
enumerator y = 2¶
-
enumerator z = 3¶
-
enumerator yaw = 4¶
-
enumerator pitch = 5¶
-
enumerator roll = 6¶
-
enumerator left_x = 7¶
-
enumerator left_y = 8¶
-
enumerator left_trigger = 9¶
-
enumerator right_x = 10¶
-
enumerator right_y = 11¶
-
enumerator right_trigger = 12¶
-
enumerator throttle = 13¶
-
enumerator rudder = 14¶
-
enumerator wheel = 15¶
-
enumerator accelerator = 16¶
-
enumerator brake = 17¶
-
enumerator pressure = 18¶
-
enumerator NONE = 0¶
- class InputDevice.AxisState¶
Bases:
- __init__()¶
- property axis Axis¶
getter/setter for InputDevice::Axis InputDevice::AxisState::axis;
- class InputDevice.BatteryData¶
Bases:
- __init__()¶
- class InputDevice.ButtonState¶
Bases:
- __init__()¶
- property handle ButtonHandle¶
getter for ButtonHandle InputDevice::ButtonState::handle;
- class InputDevice.Buttons¶
Bases:
alias of
pvector_ButtonState
-
enum DeviceClass¶
This enum contains information that can be used to identify the type of input device.
-
enumerator UNKNOWN = 0¶
It is not known what type of device this is.
-
enumerator VIRTUAL = 1¶
This means that the device doesn’t correspond to a physical device, but rather to a dynamic source of input events.
-
enumerator KEYBOARD = 2¶
A physical, alphabetical keyboard.
-
enumerator MOUSE = 3¶
-
enumerator TOUCH = 4¶
-
enumerator GAMEPAD = 5¶
A gamepad with action buttons, a D-pad, and thumbsticks.
-
enumerator FLIGHT_STICK = 6¶
-
enumerator STEERING_WHEEL = 7¶
-
enumerator DANCE_PAD = 8¶
-
enumerator HMD = 9¶
Head-mounted display.
-
enumerator SPATIAL_MOUSE = 10¶
3D mouse, such as produced by 3Dconnexion.
-
enumerator DIGITIZER = 11¶
A graphics tablet with stylus/pen.
-
enumerator unknown = 0¶
Deprecated aliases.
-
enumerator virtual_device = 1¶
-
enumerator keyboard = 2¶
-
enumerator mouse = 3¶
-
enumerator touch = 4¶
-
enumerator gamepad = 5¶
-
enumerator flight_stick = 6¶
-
enumerator steering_wheel = 7¶
-
enumerator dance_pad = 8¶
-
enumerator hmd = 9¶
-
enumerator spatial_mouse = 10¶
-
enumerator digitizer = 11¶
-
enumerator UNKNOWN = 0¶
-
enum Feature¶
-
enumerator POINTER = 0¶
The device provides absolute screen coordinates.
-
enumerator KEYBOARD = 1¶
The device has an interface for providing text input.
-
enumerator TRACKER = 2¶
The device has a motion tracker, such as an HMD.
-
enumerator VIBRATION = 3¶
The device can produce force feedback.
-
enumerator BATTERY = 4¶
The device provides information about battery life.
-
enumerator pointer = 0¶
Deprecated aliases.
-
enumerator keyboard = 1¶
-
enumerator tracker = 2¶
-
enumerator vibration = 3¶
-
enumerator battery = 4¶
-
enumerator POINTER = 0¶
- InputDevice.disable_pointer_events()¶
Disables the generation of mouse-movement events.
- InputDevice.enable_pointer_events()¶
Enables the generation of mouse-movement events.
- InputDevice.find_axis()¶
Returns the first AnalogAxis found with the given axis, or throw an assert if the axis was not found in the list.
- InputDevice.find_button()¶
Returns the first
ButtonStatefound with the given axis, or throw an assert if the button handle was not found in the list.
- InputDevice.get_button_events()¶
Returns the list of recently-generated
ButtonEvents. The list is also cleared.
- static InputDevice.get_class_type()¶
- InputDevice.get_pointer_events()¶
Returns a
PointerEventListcontaining all the recent pointer events. Clears the list.
- InputDevice.has_button_event()¶
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().
- InputDevice.has_feature()¶
Determine supported features
Returns true if the device supports the indicated feature.
- InputDevice.has_pointer_event()¶
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().
- InputDevice.map_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.
- InputDevice.map_button()¶
Associate buttons/axes with symbolic handles.
Associates the indicated
ButtonHandlewith the button of the indicated index number. When the given button index changes state, a correspondingButtonEventwill be generated with the givenButtonHandle. PassButtonHandle::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
ButtonEventswhen the buttons change state.
- InputDevice.output()¶
Writes a one-line string describing the device.
- InputDevice.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.
- InputDevice.set_vibration()¶
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.