oin/typings/sense_hat/stick.pyi

145 lines
4.7 KiB
Python
Raw Permalink Normal View History

2024-12-09 13:25:00 +01:00
"""
This type stub file was generated by pyright.
"""
from collections.abc import Callable
from typing import Any, NamedTuple
# native_str = str
# str = ...
DIRECTION_UP = ...
DIRECTION_DOWN = ...
DIRECTION_LEFT = ...
DIRECTION_RIGHT = ...
DIRECTION_MIDDLE = ...
ACTION_PRESSED = ...
ACTION_RELEASED = ...
ACTION_HELD = ...
class InputEvent(NamedTuple):
timestamp: int
direction: str
action: str
class SenseStick:
"""
Represents the joystick on the Sense HAT.
"""
SENSE_HAT_EVDEV_NAME = ...
EVENT_FORMAT = ...
EVENT_SIZE = ...
EV_KEY = ...
STATE_RELEASE = ...
STATE_PRESS = ...
STATE_HOLD = ...
KEY_UP = ...
KEY_LEFT = ...
KEY_RIGHT = ...
KEY_DOWN = ...
KEY_ENTER = ...
def __init__(self) -> None: ...
def close(self): ...
def __enter__(self): ...
def __exit__(self, exc_type, exc_value, exc_tb): ...
def wait_for_event(self, emptybuffer=...): # -> InputEvent | None:
"""
Waits until a joystick event becomes available. Returns the event, as
an `InputEvent` tuple.
If *emptybuffer* is `True` (it defaults to `False`), any pending
events will be thrown away first. This is most useful if you are only
interested in "pressed" events.
"""
...
def get_events(self): # -> list[Any]:
"""
Returns a list of all joystick events that have occurred since the last
call to `get_events`. The list contains events in the order that they
occurred. If no events have occurred in the intervening time, the
result is an empty list.
"""
...
@property
def direction_up(self): # -> None:
"""
The function to be called when the joystick is pushed up. The function
can either take a parameter which will be the `InputEvent` tuple that
has occurred, or the function can take no parameters at all.
"""
...
@direction_up.setter
def direction_up(
self, value: Callable[[InputEvent], Any] | Callable[[], Any]
) -> None: ...
2024-12-09 13:25:00 +01:00
@property
def direction_down(self): # -> None:
"""
The function to be called when the joystick is pushed down. The
function can either take a parameter which will be the `InputEvent`
tuple that has occurred, or the function can take no parameters at all.
Assign `None` to prevent this event from being fired.
"""
...
@direction_down.setter
def direction_down(
self, value: Callable[[InputEvent], Any] | Callable[[], Any]
) -> None: ...
2024-12-09 13:25:00 +01:00
@property
def direction_left(self): # -> None:
"""
The function to be called when the joystick is pushed left. The
function can either take a parameter which will be the `InputEvent`
tuple that has occurred, or the function can take no parameters at all.
Assign `None` to prevent this event from being fired.
"""
...
@direction_left.setter
def direction_left(
self, value: Callable[[InputEvent], Any] | Callable[[], Any]
) -> None: ...
2024-12-09 13:25:00 +01:00
@property
def direction_right(self): # -> None:
"""
The function to be called when the joystick is pushed right. The
function can either take a parameter which will be the `InputEvent`
tuple that has occurred, or the function can take no parameters at all.
Assign `None` to prevent this event from being fired.
"""
...
@direction_right.setter
def direction_right(
self, value: Callable[[InputEvent], Any] | Callable[[], Any]
) -> None: ...
2024-12-09 13:25:00 +01:00
@property
def direction_middle(self): # -> None:
"""
The function to be called when the joystick middle click is pressed. The
function can either take a parameter which will be the `InputEvent` tuple
that has occurred, or the function can take no parameters at all.
Assign `None` to prevent this event from being fired.
"""
...
@direction_middle.setter
def direction_middle(
self, value: Callable[[InputEvent], Any] | Callable[[], Any]
) -> None: ...
2024-12-09 13:25:00 +01:00
@property
def direction_any(self): # -> None:
"""
The function to be called when the joystick is used. The function
can either take a parameter which will be the `InputEvent` tuple that
has occurred, or the function can take no parameters at all.
This event will always be called *after* events associated with a
specific action. Assign `None` to prevent this event from being fired.
"""
...
@direction_any.setter
def direction_any(
self, value: Callable[[InputEvent], Any] | Callable[[], Any]
) -> None: ...