libretro.drivers.sensor.iterable¶
SensorDriver implementation that replays sensor readings from an iterable.
See also
SensorDriverThe protocol this driver implements.
Classes
A |
|
A frozen snapshot of every sensor reading on a single input port. |
|
Represents the state of all possible sensors on a port. |
|
Per-sensor state: whether the core has enabled it and its requested update rate in Hz. |
|
An immutable triple of axis values used for accelerometer and gyroscope readings. |
- class Vector3[source]¶
Bases:
objectAn immutable triple of axis values used for accelerometer and gyroscope readings.
- x¶
- y¶
- z¶
- __init__(x=0.0, y=0.0, z=0.0)¶
- classmethod __new__(*args, **kwargs)¶
- class SensorState[source]¶
Bases:
objectPer-sensor state: whether the core has enabled it and its requested update rate in Hz.
- enabled¶
- rate¶
- __init__(enabled=False, rate=0)¶
- classmethod __new__(*args, **kwargs)¶
- class PortInput[source]¶
Bases:
objectA frozen snapshot of every sensor reading on a single input port.
- accelerometer = Vector3(x=0.0, y=0.0, z=0.0)¶
- gyroscope = Vector3(x=0.0, y=0.0, z=0.0)¶
- illuminance¶
- self[item][source]¶
Return the scalar reading for the axis or sensor identified by
item.- Return type:
- __init__(illuminance=0.0)¶
- classmethod __new__(*args, **kwargs)¶
- class PortState[source]¶
Bases:
objectRepresents the state of all possible sensors on a port.
- accelerometer¶
- gyroscope¶
- illuminance¶
- __init__(accelerometer=<factory>, gyroscope=<factory>, illuminance=<factory>)¶
- classmethod __new__(*args, **kwargs)¶
- class IterableSensorDriver[source]¶
Bases:
SensorDriverA
SensorDriverthat feeds input to the core from the output of an iterator.- __init__(source=None)[source]¶
Initialize this sensor driver. If a sensor is disabled, then it will always output 0.0.
- Parameters:
source (
Iterator[float|Vector3|PortInput|None|Sequence[float|Vector3|PortInput|None]] |Iterable[float|Vector3|PortInput|None|Sequence[float|Vector3|PortInput|None]] |Callable[[],Iterator[float|Vector3|PortInput|None|Sequence[float|Vector3|PortInput|None]]] |None) –An iterator or iterable whose elements are each one of the following:
NoneAll sensors on all ports will return 0.0.
int|float|bool|RealAll sensors on all ports will return the yielded value converted to a
float.Vector3Each value be used as the x, y, and z readings for every port’s accelerometer and gyroscope.
PortInputThe fields on the yielded object will be used as each port’s sensor readings.
Sequence[PortInput|Vector3|float|None]Each element in the sequence will be used for its corresponding port’s sensor readings based on the aforementioned rules.
- property sensor_state¶
A live mapping of input port to its per-sensor enable/rate state.
- set_sensor_state(port, action, rate)[source]¶
Configure a sensor on a port, possibly with a specific query rate.
Corresponds to
retro_set_sensor_state_t.Note
The
EnvironmentDrivershould validateportagainst the maximum number of players (if any), skipping this method and returningFalseif the port is invalid.
- classmethod __new__(*args, **kwargs)¶