class documentation

class Input:

Constructor: Input(back_button)

View In Hierarchy

Handles input from the keyboard.

Method __del__ Destructor to clean up resources.
Method __init__ Initialize the input manager for the current board.
Method button_to_char Convert a button code to its corresponding character.
Method is_held Return True if the last button was held for the specified duration.
Method is_pressed Returns True if any key is currently pressed.
Method on_key_callback Callback invoked when a key becomes available.
Method read Returns the key code as an integer (blocking call).
Method read_non_blocking Returns the key code as integer, or -1 if no key is pressed.
Method reset Resets the input state.
Method touch_to_button Convert touch coordinates to a corresponding button code.
Class Variable __slots__ Undocumented
Instance Variable pin Undocumented
Property button Returns the last button pressed.
Property gesture Returns the last touch gesture.
Property has_touch_support Returns True if touch input is supported on the current board.
Property point Returns the last touch point as (x, y).
Property was_capitalized Returns True if the last key pressed was a capital letter.
Method __touch_callback Handle a touch interrupt and map it to a button event.
Method _key_to_button Map a key to a button.
Method _poll_touch Poll the touch controller and map touch areas to button events.
Method _poll_touch_1_69 Poll the touch data and map it to a button event.
Instance Variable _button_map Undocumented
Instance Variable _character_map Undocumented
Instance Variable _current_board_id Undocumented
Instance Variable _delay_ms Undocumented
Instance Variable _elapsed_time Undocumented
Instance Variable _elapsed_touch_now Undocumented
Instance Variable _elapsed_touch_start Undocumented
Instance Variable _key_back Undocumented
Instance Variable _key_esc Undocumented
Instance Variable _last_button Undocumented
Instance Variable _last_gesture Undocumented
Instance Variable _last_point Undocumented
Instance Variable _screen_size Undocumented
Instance Variable _touch Undocumented
Instance Variable _touch_down_1_69 Undocumented
Instance Variable _touch_read_data_fast Undocumented
Instance Variable _was_capitalized Undocumented
Instance Variable _was_pressed Undocumented
def __del__(self):

Destructor to clean up resources.

def __init__(self, back_button=buttons.BUTTON_BACK):

Initialize the input manager for the current board.

Parameters
back_button:intThe button code used as back. Defaults to buttons.BUTTON_BACK.
def button_to_char(self, button: int) -> str:

Convert a button code to its corresponding character.

Parameters
button:intButton code.
Returns
strThe corresponding character or empty string if unmapped.
def is_held(self, duration: int = 3) -> bool:

Return True if the last button was held for the specified duration.

Parameters
duration:intNumber of polls the button must be held. Defaults to 3.
Returns
boolTrue if the button is held for the duration.
def is_pressed(self) -> bool:

Returns True if any key is currently pressed.

def on_key_callback(self, _=None):

Callback invoked when a key becomes available.

Parameters
_:NoneUnused argument required by mp_sched_schedule.
def read(self) -> int:

Returns the key code as an integer (blocking call).

Warning

This is a blocking call and should not be used in callback contexts.

Returns
intKey code (0-255)
def read_non_blocking(self) -> int:

Returns the key code as integer, or -1 if no key is pressed.

def reset(self):

Resets the input state.

def touch_to_button(self, x: int, y: int) -> int:

Convert touch coordinates to a corresponding button code.

Parameters
x:intX coordinate of the touch point.
y:intY coordinate of the touch point.
Returns
intThe button code corresponding to the touch area.
__slots__: tuple[str, ...] =

Undocumented

pin =

Undocumented

@property
button: int =

Returns the last button pressed.

@property
gesture =

Returns the last touch gesture.

@property
has_touch_support: bool =

Returns True if touch input is supported on the current board.

@property
point: tuple =

Returns the last touch point as (x, y).

@property
was_capitalized: bool =

Returns True if the last key pressed was a capital letter.

def __touch_callback(self, pin):

Handle a touch interrupt and map it to a button event.

Parameters
pin:PinThe pin that triggered the interrupt.
def _key_to_button(self, key) -> int:

Map a key to a button.

Parameters
key:int or strKey code from the C module or a string.
Returns
intThe mapped button code, or BUTTON_NONE if unmapped.
def _poll_touch(self):

Poll the touch controller and map touch areas to button events.

def _poll_touch_1_69(self):

Poll the touch data and map it to a button event.

_button_map =

Undocumented

_character_map =

Undocumented

_current_board_id =

Undocumented

_delay_ms: int =

Undocumented

_elapsed_time: int =

Undocumented

_elapsed_touch_now =

Undocumented

_elapsed_touch_start =

Undocumented

_key_back =

Undocumented

_key_esc =

Undocumented

_last_button =

Undocumented

_last_gesture =

Undocumented

_last_point =

Undocumented

_screen_size: tuple =

Undocumented

_touch =

Undocumented

_touch_down_1_69: bool =

Undocumented

_touch_read_data_fast =

Undocumented

_was_capitalized: bool =

Undocumented

_was_pressed: bool =

Undocumented