[][src]Module tetra::input

Functions and types relating to handling the player's input.

Gamepads

When accessing gamepad state, you specify which gamepad you're interested in via a 'gamepad ID'. The first gamepad connected to the system has ID 0, the second has ID 1, and so on.

If a controller is disconnected, the next controller to be connected will take its ID - otherwise, a new one will be allocated. This means that if you unplug a controller and then plug it back in, it should retain its existing ID. This behaviour might be made smarter in future versions.

Examples

The keyboard example demonstrates how to handle keyboard input.

The mouse example demonstrates how to handle mouse input.

The gamepad example demonstrates how to handle gamepad input.

The text_input example demonstrates how to handle text entry.

Enums

GamepadAxis

An axis of movement on a gamepad.

GamepadButton

A button on a gamepad.

GamepadStick

A control stick on a gamepad.

Key

A key on a keyboard.

KeyModifier

A key modifier on the keyboard.

MouseButton

A button on a mouse.

Functions

get_clipboard_text

Gets the text currently stored in the system's clipboard.

get_gamepad_axis_position

Returns the current position of the specified gamepad axis.

get_gamepad_buttons_down

Returns an iterator of the buttons that are currently down on the specified gamepad.

get_gamepad_buttons_pressed

Returns an iterator of the buttons that were pressed on the specified gamepad since the last update.

get_gamepad_buttons_released

Returns an iterator of the buttons that were released on the specified gamepad since the last update .

get_gamepad_name

Returns the name of the specified gamepad, or None if it is not connected.

get_gamepad_stick_position

Returns the current position of the specified gamepad control stick.

get_keys_down

Returns an iterator of the keys that are currently down.

get_keys_pressed

Returns an iterator of the keys that were pressed since the last update.

get_keys_released

Returns an iterator of the keys that were released since the last update.

get_mouse_position

Get the position of the mouse.

get_mouse_wheel_movement

Get the amount that the mouse wheel moved since the last update.

get_mouse_x

Get the X co-ordinate of the mouse.

get_mouse_y

Get the Y co-ordinate of the mouse.

get_text_input

Returns the text that the user entered since the last update. This will match the user's keyboard and OS settings.

is_gamepad_button_down

Returns true if the specified gamepad button is currently down.

is_gamepad_button_pressed

Returns true if the specified gamepad button was pressed since the last update.

is_gamepad_button_released

Returns true if the specified gamepad button was released since the last update.

is_gamepad_button_up

Returns true if the specified gamepad button is currently up.

is_gamepad_connected

Returns true if the specified gamepad is currently connected.

is_gamepad_vibration_supported

Returns true if the specified gamepad supports vibration.

is_key_down

Returns true if the specified key is currently down.

is_key_modifier_down

Returns true if the specified key modifier is currently down.

is_key_modifier_up

Returns true if the specified key modifier is currently up.

is_key_pressed

Returns true if the specified key was pressed since the last update.

is_key_released

Returns true if the specified key was released since the last update.

is_key_up

Returns true if the specified key is currently up.

is_mouse_button_down

Returns true if the specified mouse button is currently down.

is_mouse_button_pressed

Returns true if the specified mouse button was pressed since the last update.

is_mouse_button_released

Returns true if the specified mouse button was released since the last update.

is_mouse_button_up

Returns true if the specified mouse button is currently up.

is_mouse_scrolled_down

Returns true if the user scrolled down since the last update.

is_mouse_scrolled_up

Returns true if the user scrolled up since the last update.

set_clipboard_text

Sets the contents of the system's clipboard.

set_gamepad_vibration

Sets the specified gamepad's motors to vibrate indefinitely.

start_gamepad_vibration

Sets the specified gamepad's motors to vibrate for a set duration, specified in milliseconds. After this time has passed, the vibration will automatically stop.

stop_gamepad_vibration

Stops the specified gamepad's motors from vibrating.