libretro.drivers.input.driver¶
Protocol definition for input drivers.
See also
libretro.api.inputThe matching
ctypestypes, device identifiers, and callback definitions.
Classes
Protocol for drivers that provide input device state to a core. |
- class InputDriver[source]¶
Bases:
ProtocolProtocol for drivers that provide input device state to a core.
See also
libretro.api.inputThe matching
ctypestypes, device identifiers, and callback definitions.
- abstractmethod poll()[source]¶
Sample fresh input state for the upcoming frame.
Called by the session once per frame before the core’s
Core.run()so subsequentstate()queries see consistent input.See also
retro_input_poll_tThe C function pointer type whose signature this method implements.
- Return type:
- abstractmethod state(port, device, index, _id)[source]¶
Return the current state of a single input control.
- Parameters:
device (
InputDevice) – The input device class registered toport.index (
int) – Sub-device index (e.g. analog stick number)._id (
int) – Button or axis identifier within the device class.
- Return type:
- Returns:
The control’s current state, encoded per libretro’s input conventions.
See also
retro_input_state_tThe C function pointer type whose signature this method implements.
- abstract property descriptors¶
The input descriptors registered by the core, if any.
Set by the core via
RETRO_ENVIRONMENT_SET_INPUT_DESCRIPTORSto advertise the buttons and axes it actually consumes.- Parameters:
descriptors – The sequence of descriptors registered by the core.
- Raises:
UnsupportedEnvCall – If this driver does not accept input descriptors.
See also
retro_input_descriptorThe C struct that this attribute holds.
- abstract property keyboard_callback¶
The keyboard callback registered by the core, if any.
Set by the core via
RETRO_ENVIRONMENT_SET_KEYBOARD_CALLBACKto receive key-down/key-up events.Noneif the core has not registered a keyboard callback.- Parameters:
callback – The callback to register.
- Raises:
UnsupportedEnvCall – If this driver does not support keyboard input.
See also
retro_keyboard_callbackThe C struct registered by the core that contains this callback.
- keyboard_event(down, keycode, character, modifiers)[source]¶
Forward a keyboard event to the registered
keyboard_callback, if any.- Parameters:
keycode (
Key) – The libretro key identifier.character (
int|str|bytes) – The Unicode codepoint (or encoded form) produced by the key, for keys that produce text.modifiers (
KeyModifier) – Bitmask of active modifier keys at the time of the event.
- Return type:
- abstract property device_capabilities¶
Bitmask of input device classes supported by this driver.
Returned to the core in response to
RETRO_ENVIRONMENT_GET_INPUT_DEVICE_CAPABILITIES.Noneif the driver does not advertise device capabilities.- Parameters:
capabilities – The capability bitmask to advertise.
- Raises:
UnsupportedEnvCall – If this driver does not advertise device capabilities.
See also
InputDeviceFlagThe bit flags that compose this bitmask.
- __init__(*args, **kwargs)¶
- classmethod __new__(*args, **kwargs)¶
- abstract property controller_info¶
Per-port controller descriptions registered by the core, if any.
Set by the core via
RETRO_ENVIRONMENT_SET_CONTROLLER_INFOto advertise the controllers each port can be configured to emulate.- Parameters:
info – The controller descriptions registered by the core.
- Raises:
UnsupportedEnvCall – If this driver does not accept controller info.
See also
retro_controller_descriptionThe C struct that this attribute holds.
- abstract property bitmasks_supported¶
Whether the driver supports the joypad-bitmask state encoding.
Returned to the core in response to
RETRO_ENVIRONMENT_GET_INPUT_BITMASKS.Noneif the driver does not advertise bitmask support either way.- Parameters:
bitmask_supported –
Trueif the driver supports joypad bitmasks.- Raises:
UnsupportedEnvCall – If this driver does not advertise bitmask support.
- abstract property max_users¶
The maximum number of input ports this driver advertises to the core.
Returned to the core in response to
RETRO_ENVIRONMENT_GET_INPUT_MAX_USERS.Noneif the driver does not advertise a maximum.- Parameters:
max_users – The maximum number of input ports to advertise.
- Raises:
UnsupportedEnvCall – If this driver does not advertise a maximum.