Source code for libretro.api.led

r"""
Types for allowing :class:`.Core`\s to control LED indicators on the host device.

.. seealso::

    :class:`.LedDriver`
        The protocol that uses these types to implement LED control support in libretro.py.

    :mod:`libretro.drivers.led`
        libretro.py's included :class:`.LedDriver` implementations.
"""

from ctypes import Structure, c_int
from dataclasses import dataclass

from libretro.ctypes import CIntArg, TypedFunctionPointer

retro_set_led_state_t = TypedFunctionPointer[None, [CIntArg[c_int], CIntArg[c_int]]]
"""
Set the state of an LED on the host device.

Registered by the :term:`frontend` and called by the :term:`core`
to enable or disable an indicator LED.

:param led: Index of the LED whose state will be changed.
:param state: New state of the LED;
    nonzero to enable, zero to disable.

Corresponds to :c:type:`retro_set_led_state_t` in ``libretro.h``.

.. seealso::
    :attr:`.LedDriver.set_led_state`
        The suggested entry point for this callback.
"""


[docs] @dataclass(init=False, slots=True) class retro_led_interface(Structure): r""" Defines a callback that :class:`.Core`\s can use to control LED indicators on the host device. Corresponds to :c:type:`retro_led_interface` in ``libretro.h``. """ set_led_state: retro_set_led_state_t | None """ Called by the :class:`.Core` to set the state of an LED. """ _fields_ = (("set_led_state", retro_set_led_state_t),)
[docs] def __deepcopy__(self, _): """ Return a copy of this object. Intended for use with :func:`copy.deepcopy`. >>> import copy >>> from libretro.api import retro_led_interface >>> copy.deepcopy(retro_led_interface()).set_led_state is None True """ return retro_led_interface(self.set_led_state)
__all__ = ["retro_led_interface", "retro_set_led_state_t"]