libretro.api.input.analog

Analog axis input state.

Classes

AnalogState

Snapshot of analog axis and button state.

DeviceIdAnalog

Analog stick axis.

DeviceIndexAnalog

The device that provides an analog axis.

class DeviceIndexAnalog[source]

Bases: IntEnum

The device that provides an analog axis.

LEFT = 0

The left analog stick.

RIGHT = 1

The right analog stick.

BUTTON = 2

Any analog button (e.g. shoulder triggers).

__new__(value)
classmethod value in self

Return True if value is in cls.

value is in cls if: 1) value is a member of cls, or 2) value is the value of one of the cls’s members. 3) value is a pseudo-member (flags)

classmethod self[name]

Return the member matching name.

__init__()
classmethod iter(self)

Return members in definition order.

classmethod len(self)

Return the number of members (no aliases)

class DeviceIdAnalog[source]

Bases: IntEnum

Analog stick axis.

>>> from libretro.api.input import DeviceIdAnalog
>>> DeviceIdAnalog.X
<DeviceIdAnalog.X: 0>
X = 0

An analog stick’s horizontal axis.

Y = 1

An analog stick’s vertical axis.

__new__(value)
classmethod value in self

Return True if value is in cls.

value is in cls if: 1) value is a member of cls, or 2) value is the value of one of the cls’s members. 3) value is a pseudo-member (flags)

classmethod self[name]

Return the member matching name.

__init__()
classmethod iter(self)

Return members in definition order.

classmethod len(self)

Return the number of members (no aliases)

class AnalogState[source]

Bases: InputDeviceState

Snapshot of analog axis and button state.

For the purpose of this snapshot, all buttons are considered “analog”.

b
y
select
start
up
down
left
right
a
x
l
r
l2
r2
l3
r3
lstick
rstick
property left_x

The horizontal axis of the left analog stick.

>>> from libretro.api.input import AnalogState
>>> state = AnalogState(lstick=(123, 0))
>>> state.left_x
123
__init__(b=0, y=0, select=0, start=0, up=0, down=0, left=0, right=0, a=0, x=0, l=0, r=0, l2=0, r2=0, l3=0, r3=0, lstick=(0, 0), rstick=(0, 0))
classmethod __new__(*args, **kwargs)
property left_y

The vertical axis of the left analog stick.

>>> from libretro.api.input import AnalogState
>>> state = AnalogState(lstick=(0, 123))
>>> state.left_y
123
property right_x

The horizontal axis of the right analog stick.

>>> from libretro.api.input import AnalogState
>>> state = AnalogState(rstick=(123, 0))
>>> state.right_x
123
property right_y

The vertical axis of the right analog stick.

>>> from libretro.api.input import AnalogState
>>> state = AnalogState(rstick=(0, 123))
>>> state.right_y
123
self[item][source]

Get the state of a button by its button ID or DeviceIdJoypad.

For example:

>>> from libretro.api.input import AnalogState, DeviceIdJoypad
>>> state = AnalogState(a=779)
>>> state[DeviceIdJoypad.A]
779
>>> state[DeviceIdJoypad.A] == state.a
True
>>> state[DeviceIdJoypad.A] == state[8]
True
Raises:
Return type:

int

Returns:

The analog state of the button, where 0 is not pressed and 32767 is fully pressed.