libretro.api.input.device¶
Input device definitions and state callbacks.
Module Attributes
A controller port index. |
|
Poll input devices for the current frame. |
|
Query the state of a specific input on a controller. |
Functions
|
Generate an ID for a libretro input device subclass. |
Classes
Enumeration of standard input device types. |
|
Bitmask flag equivalent of |
|
Empty marker class for identifying input device states. |
|
Description of a specific kind of controller emulated by a core. |
|
List of controller types usable by a controller port. |
|
Description of a single input action for a given device. |
- class InputDeviceFlag[source]¶
Bases:
IntFlagBitmask flag equivalent of
InputDevice.>>> from libretro.api.input import InputDeviceFlag >>> InputDeviceFlag.JOYPAD <InputDeviceFlag.JOYPAD: 2>
- NONE = 1¶
- JOYPAD = 2¶
- MOUSE = 4¶
- KEYBOARD = 8¶
- LIGHTGUN = 16¶
- ANALOG = 32¶
- POINTER = 64¶
- ALL = 126¶
- __new__(value)¶
- other in self¶
Returns True if self has at least the same flags set as other.
- iter(self)¶
Returns flags in definition order.
- len(self)¶
Return the number of members (no aliases)
- classmethod self[name]¶
Return the member matching name.
- __init__()¶
- class InputDevice[source]¶
Bases:
IntEnumEnumeration of standard input device types.
Corresponds to the
RETRO_DEVICE_*constants inlibretro.h.>>> from libretro.api.input import InputDevice >>> InputDevice.JOYPAD <InputDevice.JOYPAD: 1>
- NONE = 0¶
- JOYPAD = 1¶
- MOUSE = 2¶
- KEYBOARD = 3¶
- LIGHTGUN = 4¶
- ANALOG = 5¶
- POINTER = 6¶
- property flag¶
Returns the corresponding
InputDeviceFlagfor this device.
- __new__(value)¶
- classmethod value in self¶
Return True if value is in cls.
value is in cls if: 1) value is a member of cls, or 2) value is the value of one of the cls’s members. 3) value is a pseudo-member (flags)
- classmethod self[name]¶
Return the member matching name.
- __init__()¶
- classmethod iter(self)¶
Return members in definition order.
- classmethod len(self)¶
Return the number of members (no aliases)
- RETRO_DEVICE_SUBCLASS(base, id)[source]¶
Generate an ID for a libretro input device subclass.
- Return type:
- retro_input_poll_t¶
Poll input devices for the current frame.
Registered by the frontend and called by the core at least once per
retro_run()to refresh cached input state before any calls toretro_input_state_t.Corresponds to
retro_input_poll_tinlibretro.h.See also
InputDriver.pollThe
InputDrivermethod that implements this callback.Core.set_input_pollThe method that exposes this callback to a core.
- retro_input_state_t¶
Query the state of a specific input on a controller.
Registered by the frontend and called by the core to read the most recently polled input.
- Parameters:
port – Index of the controller port to query.
device – One of the
InputDeviceconstants identifying the abstract device type. The value is masked withRETRO_DEVICE_MASK.index – Sub-index whose meaning depends on
device(e.g. an analog stick index).id – Identifier of the specific input to read, such as one of the
RETRO_DEVICE_ID_*constants.
- Returns:
The current input value; semantics depend on
deviceandid, and0is returned for unsupported combinations.
Corresponds to
retro_input_state_tinlibretro.h.See also
InputDriver.stateThe suggested entry point for this callback in libretro.py.
Core.set_input_stateThe method that exposes this callback to a core.
- class retro_input_descriptor[source]¶
Bases:
StructureDescription of a single input action for a given device.
Corresponds to
retro_input_descriptorinlibretro.h.- port¶
Controller port index.
- device¶
Input device type.
- index¶
Sub-device index (e.g. analog stick index).
- id¶
Button or axis identifier.
- description¶
Human-readable label for this input.
- __deepcopy__(_)[source]¶
Return a deep copy of this object, including all strings.
Intended for use with
copy.deepcopy().
- __init__(*args, **kwargs)¶
- classmethod __new__(*args, **kwargs)¶
- class retro_controller_description[source]¶
Bases:
StructureDescription of a specific kind of controller emulated by a core.
Corresponds to
retro_controller_descriptioninlibretro.h.- desc¶
Human-readable name of the controller type.
- id¶
Device type identifier, used with
retro_set_controller_port_device().
- __deepcopy__(_)[source]¶
Create a deep copy of this object, including all strings. Intended for use with
copy.deepcopy().
- __init__(*args, **kwargs)¶
- classmethod __new__(*args, **kwargs)¶
- class retro_controller_info[source]¶
Bases:
StructureList of controller types usable by a controller port.
Can be indexed like a
Sequenceto access individualretro_controller_descriptions.Corresponds to
retro_controller_infoinlibretro.h.- __init__(*args, **kwargs)¶
- classmethod __new__(*args, **kwargs)¶
- types¶
Array of controller types supported by this port.
- __deepcopy__(memo)[source]¶
Return a deep copy of this object, including all strings and arrays. Intended for use with
copy.deepcopy().
- self[index][source]¶
- Overloads:
self, index (int) → retro_controller_description
self, index (slice[retro_controller_description]) → list[retro_controller_description]
Return the
retro_controller_descriptionat the given index or slice.- Parameters:
index – An integer index or slice object.
- Returns:
A single
retro_controller_descriptionifindexis anint, or alistof them if it’s aslice.- Raises:
ValueError – If there are no controller types available.
IndexError – If
indexis out of range.