Gamepad API
Preview noticeβ
The MatrixOS Python API is in preview and is subject to change; it may contain errors.
Overviewβ
The HID Gamepad interface allows the device to emulate a standard USB game controller, providing button controls, analog sticks, directional pad, and trigger functionality. This enables the device to work as a gamepad for gaming applications and other controller-aware software.
The Python HID Gamepad API is implemented in Applications/Python/PikaPython/MatrixOS_HID_Gamepad.py with type hints in Applications/Python/PikaPython/_MatrixOS_HID_Gamepad.pyi.
Button Functionsβ
MatrixOS.HID.Gamepad.Pressβ
def Press(button_id: int) -> None
Presses a gamepad button.
Parameters:
button_id(int): Button identifier (0-15 for standard gamepad buttons)
MatrixOS.HID.Gamepad.Releaseβ
def Release(button_id: int) -> None
Releases a gamepad button.
Parameters:
button_id(int): Button identifier to release
MatrixOS.HID.Gamepad.ReleaseAllβ
def ReleaseAll() -> None
Releases all currently pressed gamepad buttons.
MatrixOS.HID.Gamepad.Buttonβ
def Button(button_id: int, state: bool) -> None
Sets the state of a specific button.
Parameters:
button_id(int): Button identifierstate(bool): True to press, False to release
MatrixOS.HID.Gamepad.Buttonsβ
def Buttons(button_mask: int) -> None
Sets multiple button states using a bitmask.
Parameters:
button_mask(int): Bitmask where each bit represents a button state
Analog Stick Functionsβ
MatrixOS.HID.Gamepad.XAxisβ
def XAxis(value: int) -> None
Sets the left analog stick X-axis position.
Parameters:
value(int): Analog value (typically -32767 to 32767, 0 = center)
MatrixOS.HID.Gamepad.YAxisβ
def YAxis(value: int) -> None
Sets the left analog stick Y-axis position.
Parameters:
value(int): Analog value (typically -32767 to 32767, 0 = center)
MatrixOS.HID.Gamepad.ZAxisβ
def ZAxis(value: int) -> None
Sets the Z-axis (often used for left trigger).
Parameters:
value(int): Analog value
MatrixOS.HID.Gamepad.RXAxisβ
def RXAxis(value: int) -> None
Sets the right analog stick X-axis position.
Parameters:
value(int): Analog value (typically -32767 to 32767, 0 = center)
MatrixOS.HID.Gamepad.RYAxisβ
def RYAxis(value: int) -> None
Sets the right analog stick Y-axis position.
Parameters:
value(int): Analog value (typically -32767 to 32767, 0 = center)
MatrixOS.HID.Gamepad.RZAxisβ
def RZAxis(value: int) -> None
Sets the RZ-axis (often used for right trigger).
Parameters:
value(int): Analog value
Directional Pad Functionβ
MatrixOS.HID.Gamepad.DPadβ
def DPad(direction: GamepadDPadDirection) -> None
Sets the directional pad (D-pad) direction.
Parameters:
direction(GamepadDPadDirection): D-pad direction
Gamepad D-Pad Directionsβ
Available directions in GamepadDPadDirection:
NEUTRAL: No direction pressedUP: D-pad upDOWN: D-pad downLEFT: D-pad leftRIGHT: D-pad rightUP_LEFT: D-pad up-left diagonalUP_RIGHT: D-pad up-right diagonalDOWN_LEFT: D-pad down-left diagonalDOWN_RIGHT: D-pad down-right diagonal
Comments