tuxemon.platform.platform_pygame.events module

class tuxemon.platform.platform_pygame.events.DPadButtonInfo(*args, **kwargs)[source]

Bases: dict

position: Tuple[int, int]
rect: Rect
surface: Surface
class tuxemon.platform.platform_pygame.events.DPadInfo(*args, **kwargs)[source]

Bases: dict

position: Tuple[int, int]
rect: DPadRectsInfo
surface: Surface
class tuxemon.platform.platform_pygame.events.DPadRectsInfo(*args, **kwargs)[source]

Bases: dict

down: Rect
left: Rect
right: Rect
up: Rect
class tuxemon.platform.platform_pygame.events.PygameEventHandler(event_map=None)[source]

Bases: InputHandler[Event]

Input handler of Pygame events.

default_input_map: ClassVar[Mapping[int | None, int]]
class tuxemon.platform.platform_pygame.events.PygameEventQueueHandler[source]

Bases: EventQueueHandler

Handle all events from the pygame event queue.

add_input(player, handler)[source]

Add an input handler to process.

Parameters:
  • player (int) – Number of the player the handler belongs to.

  • handler (InputHandler[Any]) – Handler whose events will be processed from now on.

Return type:

None

process_events()[source]

Process all pygame events.

  • Should never return pygame-unique events

  • All events returned should be Tuxemon game specific

  • This must be the only function to get events from the pygame event queue

Yields:

Game events.

Return type:

Generator[PlayerInput, None, None]

set_input(player, element, handler)[source]

Sets an input handler to process.

Parameters:
  • player (int) – Number of the player the handler belongs to.

  • element (int) – Index to modify

  • handler (InputHandler[Any]) – Handler whose events will be processed from now on.

Return type:

None

class tuxemon.platform.platform_pygame.events.PygameGamepadInput(event_map=None, deadzone=0.25)[source]

Bases: PygameEventHandler

Gamepad event handler.

NOTE: Due to implementation, you may receive “released” inputs for buttons/directions/axis even if they are released already. Pressed or held inputs will never be duplicated and are always “correct”.

Parameters:
  • event_map – Mapping of original identifiers to button identifiers.

  • deadzone – Threshold used to detect when an analog stick should be considered not pressed, as obtaining an exact value of 0 is almost impossible.

check_axis(pg_event)[source]
Parameters:

pg_event (Event) –

Return type:

None

check_button(pg_event)[source]
Parameters:

pg_event (Event) –

Return type:

None

check_hat(pg_event)[source]
Parameters:

pg_event (Event) –

Return type:

None

default_input_map: ClassVar[Mapping[int | None, int]] = {0: 64, 1: 128, 6: 16384, 7: 32, 11: 4, 12: 8, 13: 1, 14: 2}
process_event(input_event)[source]

Process an input event, such as a Pygame event.

Parameters:

input_event (Event) – Input event to process.

Return type:

None

class tuxemon.platform.platform_pygame.events.PygameKeyboardInput(event_map=None)[source]

Bases: PygameEventHandler

Keyboard event handler.

Parameters:

event_map – Mapping of original identifiers to button identifiers.

default_input_map: ClassVar[Mapping[int | None, int]] = {1073741906: 1, 1073741905: 2, 1073741904: 4, 1073741903: 8, 13: 64, 1073742053: 128, 1073742049: 128, 27: 16384, 8: 20002, None: 20001}
process_event(input_event)[source]

Process an input event, such as a Pygame event.

Parameters:

input_event (Event) – Input event to process.

Return type:

None

class tuxemon.platform.platform_pygame.events.PygameMouseInput(event_map=None)[source]

Bases: PygameEventHandler

Mouse event handler.

Parameters:

event_map – Mapping of original identifiers to button identifiers.

default_input_map: ClassVar[Mapping[int | None, int]] = {1025: 32768, 1026: 32768}
process_event(pg_event)[source]

Process an input event, such as a Pygame event.

Parameters:
  • input_event – Input event to process.

  • pg_event (Event) –

Return type:

None

class tuxemon.platform.platform_pygame.events.PygameTouchOverlayInput(transparency)[source]

Bases: PygameEventHandler

Touch overlay event handler.

Parameters:

transparency – Transparency of the drawn overlay.

default_input_map: ClassVar[Mapping[int | None, int]] = {}
draw(screen)[source]

Draws the controller overlay to the screen.

Parameters:

screen (Surface) – Screen surface to draw onto.

Return type:

None

load()[source]

Load the touch overlay attributes.

Return type:

None

process_event(input_event)[source]

Process a Pygame event.

Process all events from the controller overlay and pass them down to current State. All controller overlay events are converted to keyboard events for compatibility. This is primarily used for the mobile version of Tuxemon.

Will probably be janky with multi touch.

Parameters:

input_event (Event) – Input event to process.

Return type:

None