libretro.api.sensor¶
Types for providing sensor input to cores.
See also
SensorDriverThe
Protocolthat uses these types to implement sensor support in libretro.py.libretro.drivers.sensorlibretro.py’s included
SensorDriverimplementations.
Module Attributes
Corresponds to |
|
Adjust the state of a sensor on a controller. |
|
Return the current value reported by a sensor. |
Classes
Individual sensor axis or value identifiers. |
|
Action to enable or disable a sensor. |
|
Type of sensor hardware. |
|
Provides functions for managing sensor input. |
- retro_set_sensor_state_t¶
Adjust the state of a sensor on a controller.
Registered by the frontend and called by the core to enable or disable a particular sensor and request an update rate. Cores should only enable sensors while they are actively in use, since sensors can drain the host device’s battery.
- Parameters:
port – Index of the controller port whose sensor will be addressed.
action – A
SensorActiondescribing which sensor to enable or disable.rate – Desired sensor update rate, in Hz. Treated as a hint; the actual rate may differ depending on the device.
- Returns:
Trueif the sensor state was successfully adjusted,Falseotherwise (most commonly because the sensor is unavailable).
Corresponds to
retro_set_sensor_state_tinlibretro.h.
- retro_sensor_get_input_t¶
Return the current value reported by a sensor.
Registered by the frontend and called by the core.
- Parameters:
- Returns:
The current sensor value; semantics depend on
id, and0.0is returned for invalid arguments.
Corresponds to
retro_sensor_get_input_tinlibretro.h.
- class retro_sensor_interface[source]¶
Bases:
StructureProvides functions for managing sensor input.
Corresponds to
retro_sensor_interfaceinlibretro.h.>>> from libretro.api import retro_sensor_interface >>> s = retro_sensor_interface() >>> s.set_sensor_state is None True
- set_sensor_state¶
Enables or disables a sensor for a given port.
- get_sensor_input¶
Reads a sensor value for a given port and sensor ID.
- __deepcopy__(_)[source]¶
Return a copy of this object. Intended for use with
copy.deepcopy().>>> import copy >>> from libretro.api import retro_sensor_interface >>> copy.deepcopy(retro_sensor_interface()).set_sensor_state is None True
- __init__(*args, **kwargs)¶
- classmethod __new__(*args, **kwargs)¶
- class SensorAction[source]¶
Bases:
IntEnumAction to enable or disable a sensor.
>>> from libretro.api import SensorAction >>> SensorAction.GYROSCOPE_ENABLE.enabled True
- ACCELEROMETER_ENABLE = 0¶
- ACCELEROMETER_DISABLE = 1¶
- GYROSCOPE_ENABLE = 2¶
- GYROSCOPE_DISABLE = 3¶
- ILLUMINANCE_ENABLE = 4¶
- ILLUMINANCE_DISABLE = 5¶
- property sensor_type¶
Returns the
SensorTypethis action applies to.>>> from libretro.api import SensorAction, SensorType >>> SensorAction.ACCELEROMETER_ENABLE.sensor_type == SensorType.ACCELEROMETER True
- property enabled¶
Returns
Trueif this action enables the sensor.>>> from libretro.api import SensorAction >>> SensorAction.GYROSCOPE_DISABLE.enabled False
- __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)
- class SensorType[source]¶
Bases:
IntEnumType of sensor hardware.
>>> from libretro.api import SensorType >>> SensorType.ACCELEROMETER <SensorType.ACCELEROMETER: 0>
- ACCELEROMETER = 0¶
- GYROSCOPE = 3¶
- ILLUMINANCE = 6¶
- __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)
- class Sensor[source]¶
Bases:
IntEnumIndividual sensor axis or value identifiers.
>>> from libretro.api import Sensor, SensorType >>> Sensor.GYROSCOPE_X.type == SensorType.GYROSCOPE True
- ACCELEROMETER_X = 0¶
- ACCELEROMETER_Y = 1¶
- ACCELEROMETER_Z = 2¶
- GYROSCOPE_X = 3¶
- __new__(value)¶
- GYROSCOPE_Y = 4¶
- 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)
- GYROSCOPE_Z = 5¶
- ILLUMINANCE = 6¶
- property type¶
Returns the
SensorTypefor this sensor reading.>>> from libretro.api import Sensor, SensorType >>> Sensor.ILLUMINANCE.type == SensorType.ILLUMINANCE True
- retro_sensor_action¶
Corresponds to
retro_sensor_actioninlibretro.h.