LemonInput
LemonInput
Section titled “LemonInput”LemonInput is a wrapper class for Xbox and PS5 controllers allowing automatic or manual detection and use in code.
Methods
Section titled “Methods”init()
Section titled “init()”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.
_find_port()
Section titled “_find_port()”Returns the first connected port matching the variant.
_auto_type()
Section titled “_auto_type()”_is_Xbox()
Section titled “_is_Xbox()”Checks if the controller at the specified port is an Xbox controller. Args: port (int): The port number to check.
_is_PS5()
Section titled “_is_PS5()”Checks if the controller at the specified port is a PS5 controller. Args: port (int): The port number to check.
getType()
Section titled “getType()”Returns the type of controller (Xbox or PS5).
uses_driverstation_maps()
Section titled “uses_driverstation_maps()”True if inputs are read using the Driver Station’s gamepad mapping.
getRawButton()
Section titled “getRawButton()”Returns the state of a raw (0-indexed) button.
getRawAxis()
Section titled “getRawAxis()”Returns the value of a raw (0-indexed) axis.
getPOV()
Section titled “getPOV()”Returns the POV angle in degrees (clockwise from up), or -1 if not pressed.
setRumble()
Section titled “setRumble()”Sets the rumble output of the controller.
_button()
Section titled “_button()”_axis()
Section titled “_axis()”getLeftBumper()
Section titled “getLeftBumper()”Returns the state of the left bumper button.
getRightBumper()
Section titled “getRightBumper()”Returns the state of the right bumper button.
Returns: bool: The state of the right bumper button (pressed or not).
getStartButton()
Section titled “getStartButton()”Returns the state of the start button.
Returns: bool: The state of the start button (pressed or not).
getBackButton()
Section titled “getBackButton()”Returns the state of the back button.
Returns: bool: The state of the back button (pressed or not).
getAButton()
Section titled “getAButton()”Returns the state of the ‘A’ button.
Returns: bool: The state of the ‘A’ button (pressed or not).
getBButton()
Section titled “getBButton()”Returns the state of the ‘B’ button.
Returns: bool: The state of the ‘B’ button (pressed or not).
getXButton()
Section titled “getXButton()”Returns the state of the ‘X’ button.
Returns: bool: The state of the ‘X’ button (pressed or not).
getYButton()
Section titled “getYButton()”Returns the state of the ‘Y’ button.
Returns: bool: The state of the ‘Y’ button (pressed or not).
getLeftStickButton()
Section titled “getLeftStickButton()”Returns the state of the left stick button.
Returns: bool: The state of the left stick button (pressed or not).
getRightStickButton()
Section titled “getRightStickButton()”Returns the state of the right stick button.
Returns: bool: The state of the right stick button (pressed or not).
getRightTriggerAxis()
Section titled “getRightTriggerAxis()”Returns the state of the right trigger button.
Returns: float: The state of the right trigger button ranging from 0.0 to 1.0.
getLeftTriggerAxis()
Section titled “getLeftTriggerAxis()”Returns the state of the left trigger button.
Returns: float: The state of the left trigger button ranging from 0.0 to 1.0.
getL1Button()
Section titled “getL1Button()”Returns the state of the L1 button.
getR1Button()
Section titled “getR1Button()”Returns the state of the R1 button.
getOptionsButton()
Section titled “getOptionsButton()”Returns the state of the Options button.
getCreateButton()
Section titled “getCreateButton()”Returns the state of the Create button.
getCrossButton()
Section titled “getCrossButton()”Returns the state of the Cross (X) button.
getCircleButton()
Section titled “getCircleButton()”Returns the state of the Circle (O) button.
getSquareButton()
Section titled “getSquareButton()”Returns the state of the Square button.
getTriangleButton()
Section titled “getTriangleButton()”Returns the state of the Triangle button.
getL3()
Section titled “getL3()”Returns the state of the L3 (left stick) button.
getR3()
Section titled “getR3()”Returns the state of the R3 (right stick) button.
getR2Axis()
Section titled “getR2Axis()”Returns the state of the R2 trigger.
getL2Axis()
Section titled “getL2Axis()”Returns the state of the L2 trigger.
setRumbleLeft()
Section titled “setRumbleLeft()”Sets the rumble of the controller.
Args: value (float): The value of the rumble to set.
setRumbleRight()
Section titled “setRumbleRight()”Sets the rumble of the controller.
Args: value (float): The value of the rumble to set.
getLeftX()
Section titled “getLeftX()”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.
getLeftY()
Section titled “getLeftY()”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.
getRightX()
Section titled “getRightX()”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.
getRightY()
Section titled “getRightY()”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.
_pov_xy()
Section titled “_pov_xy()”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.
getPovX()
Section titled “getPovX()”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.
getPovY()
Section titled “getPovY()”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.