Skip to content

LemonInput

LemonInput is a wrapper class for Xbox and PS5 controllers allowing automatic or manual detection and use in code.

Initializes the control object with the specified port number and type. Args: port (int, optional): The port number of the controller. If unset, chooses first controller matching type not using driverstation maps. variant (str, optional): The type of the controller. Defaults to “DriverStation”. - “auto”: Automatically detects the controller type. - “DriverStation”: Uses the Driver Station’s standard gamepad mapping. - “Xbox”: Forces the controller type to Xbox not using driverstation maps. - “PS5”: Forces the controller type to PS5 not using driverstation maps.

Returns the first connected port matching the variant.

Checks if the controller at the specified port is an Xbox controller. Args: port (int): The port number to check.

Checks if the controller at the specified port is a PS5 controller. Args: port (int): The port number to check.

Returns the type of controller (Xbox or PS5).

True if inputs are read using the Driver Station’s gamepad mapping.

Returns the state of a raw (0-indexed) button.

Returns the value of a raw (0-indexed) axis.

Returns the POV angle in degrees (clockwise from up), or -1 if not pressed.

Sets the rumble output of the controller.

Returns the state of the left bumper button.

Returns the state of the right bumper button.

Returns: bool: The state of the right bumper button (pressed or not).

Returns the state of the start button.

Returns: bool: The state of the start button (pressed or not).

Returns the state of the back button.

Returns: bool: The state of the back button (pressed or not).

Returns the state of the ‘A’ button.

Returns: bool: The state of the ‘A’ button (pressed or not).

Returns the state of the ‘B’ button.

Returns: bool: The state of the ‘B’ button (pressed or not).

Returns the state of the ‘X’ button.

Returns: bool: The state of the ‘X’ button (pressed or not).

Returns the state of the ‘Y’ button.

Returns: bool: The state of the ‘Y’ button (pressed or not).

Returns the state of the left stick button.

Returns: bool: The state of the left stick button (pressed or not).

Returns the state of the right stick button.

Returns: bool: The state of the right stick button (pressed or not).

Returns the state of the right trigger button.

Returns: float: The state of the right trigger button ranging from 0.0 to 1.0.

Returns the state of the left trigger button.

Returns: float: The state of the left trigger button ranging from 0.0 to 1.0.

Returns the state of the L1 button.

Returns the state of the R1 button.

Returns the state of the Options button.

Returns the state of the Create button.

Returns the state of the Cross (X) button.

Returns the state of the Circle (O) button.

Returns the state of the Square button.

Returns the state of the Triangle button.

Returns the state of the L3 (left stick) button.

Returns the state of the R3 (right stick) button.

Returns the state of the R2 trigger.

Returns the state of the L2 trigger.

Sets the rumble of the controller.

Args: value (float): The value of the rumble to set.

Sets the rumble of the controller.

Args: value (float): The value of the rumble to set.

Returns the X-axis value of the left joystick.

Returns: float: The X-axis value of the left joystick, ranging from -1.0 to 1.0.

Returns the Y-axis value of the left joystick.

Returns: float: The Y-axis value of the left joystick, ranging from -1.0 to 1.0.

Returns the X-axis value of the right joystick.

Returns: float: The X-axis value of the right joystick, ranging from -1.0 to 1.0.

Returns the Y-axis value of the right joystick.

Returns: float: The Y-axis value of the right joystick, ranging from -1.0 to 1.0.

Returns the X and Y values of the POV as a tuple using sin and cos, or (0, 0) if the POV is not pressed (-1).

Returns: tuple: The X and Y values of the POV as a tuple.

Returns the X-axis value of the POV (Point of View) of a joystick.

Example:

controller = LemonInput(0)
if controller.getPOV() >= 0:
pov_x = controller.getPovX()
pov_y = controller.getPovY()

Returns: float: The X-axis value of the POV.

Returns the Y-axis value of the POV (Point of View) of a joystick.

Example:

controller = LemonInput(0)
if controller.getPOV() >= 0:
pov_x = controller.getPovX()
pov_y = controller.getPovY()

Returns: float: The Y-axis value of the POV.