libretro.api.timing

Types for managing the rate at which the Core runs.

Module Attributes

retro_usec_t

A timestamp or duration in microseconds.

retro_frame_time_callback_t

Notify the core of the time elapsed since the last retro_run().

Classes

ThrottleMode

The frontend's current throttle mode.

retro_fastforwarding_override

Allows the core to take control over fast-forwarding behavior.

retro_frame_time_callback

Corresponds to retro_frame_time_callback in libretro.h.

retro_throttle_state

Reports the frontend's current throttle mode and rate.

class ThrottleMode[source]

Bases: IntEnum

The frontend’s current throttle mode.

>>> from libretro.api import ThrottleMode
>>> ThrottleMode.FAST_FORWARD
<ThrottleMode.FAST_FORWARD: 2>
NONE = 0
FRAME_STEPPING = 1
FAST_FORWARD = 2
SLOW_MOTION = 3
REWINDING = 4
VSYNC = 5
UNBLOCKED = 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 retro_fastforwarding_override[source]

Bases: Structure

Allows the core to take control over fast-forwarding behavior.

Corresponds to retro_fastforwarding_override in libretro.h.

>>> from libretro.api import retro_fastforwarding_override
>>> ff = retro_fastforwarding_override()
>>> ff.fastforward
False
ratio

Maximum fast-forward ratio. 0.0 for no limit.

fastforward

Whether the frontend should fast-forward.

notification

Whether the frontend should display a fast-forward notification.

inhibit_toggle

Whether the player should be prevented from toggling fast-forward.

__init__(*args, **kwargs)
classmethod __new__(*args, **kwargs)
__deepcopy__(_)[source]

Return a copy of this object. Intended for use with copy.deepcopy().

>>> import copy
>>> from libretro.api import retro_fastforwarding_override
>>> copy.deepcopy(retro_fastforwarding_override()).fastforward
False
class retro_throttle_state[source]

Bases: Structure

Reports the frontend’s current throttle mode and rate.

Corresponds to retro_throttle_state in libretro.h.

>>> from libretro.api import retro_throttle_state
>>> ts = retro_throttle_state()
>>> ts.rate
0.0
__init__(*args, **kwargs)
classmethod __new__(*args, **kwargs)
mode

Current throttle mode.

rate

Rate at which the frontend is trying to run, as a multiple of normal speed.

__deepcopy__(_)[source]

Return a copy of this object. Intended for use with copy.deepcopy().

>>> import copy
>>> from libretro.api import retro_throttle_state
>>> copy.deepcopy(retro_throttle_state()).rate
0.0
class retro_frame_time_callback[source]

Bases: Structure

Corresponds to retro_frame_time_callback in libretro.h.

Wraps a callback that is invoked each frame with the elapsed time.

>>> from libretro.api import retro_frame_time_callback
>>> cb = retro_frame_time_callback()
>>> cb.reference
0
callback

Called each frame with the elapsed time in microseconds.

reference

Ideal duration of one frame in microseconds.

self(time=None)[source]

Invoke callback with the given time, or with reference if it’s None.

Does nothing if callback is unset.

__deepcopy__(_)[source]

Return a copy of this object. Intended for use with copy.deepcopy().

>>> import copy
>>> from libretro.api import retro_frame_time_callback
>>> copy.deepcopy(retro_frame_time_callback()).reference
0
__init__(*args, **kwargs)
classmethod __new__(*args, **kwargs)
retro_usec_t

A timestamp or duration in microseconds.

retro_frame_time_callback_t

Notify the core of the time elapsed since the last retro_run().

Registered by the core and called by the frontend right before each iteration of retro_run(). If the frontend is manipulating the frame time (e.g. via fast-forward or slow motion), the value passed in is the reference value from retro_frame_time_callback.reference.

Parameters:

usec – Time since the last retro_run(), in microseconds.

Corresponds to retro_frame_time_callback_t in libretro.h.