Joystick Class
Package: GHIElectronics.Endpoint.Devices.UsbHost
Namespace: GHIElectronics.Endpoint.Devices.UsbHost
Allows a usb device to be used as a joystick.
class Joystick(BaseDevice): ...
Remarks
By default, the reported range for position is between -512 and 512, as on TinyCLR. Cursor1 is the left stick; Cursor2 is the right stick of a game pad. Buttons are numbered from 0. The events come on the joystick's own thread.
Nested Types
| Type | Kind | Summary |
|---|---|---|
| Joystick.ButtonChangedEventArgs | Class | The events args for the ButtonPressed and ButtonReleased events. |
| Joystick.ButtonChangedEventHandler | Delegate | The delegate for when one of the joystick's button is pressed or released. |
| Joystick.CursorMovedEventArgs | Class | The events args for the CursorMoved event. |
| Joystick.CursorMovedEventHandler | Delegate | The delegate for when one of the joystick's cursors moves. |
| Joystick.DeviceCapabilities | Enum | Joystick capabilities. |
| Joystick.HatSwitchPressedEventArgs | Class | The events args for the HatSwitchPressed event. |
| Joystick.HatSwitchPressedEventHandler | Delegate | The delegate for when the joystick's hat switch is pressed. |
Constructors
Joystick(string deviceName)
def __init__(self, deviceName: str):
Opens the joystick that UsbHostController reported ("/dev/input/event3").
Properties
Capabilities
Capabilities: DeviceCapabilities # @property
The capabilities of the joystick.
Returns DeviceCapabilities
CurrentHatSwitchDirection
CurrentHatSwitchDirection: HatSwitchDirection # @property
The current direction of the hat switch.
Returns HatSwitchDirection
Cursor2Position
Cursor2Position: Position # @property
The current position of the second cursor.
Returns Position
CursorPosition
CursorPosition: Position # @property
The current position of the first cursor.
Returns Position
Methods
GetButtonState(int buttonNumber)
def GetButtonState(self, buttonNumber: int) -> ButtonState:
Gets the current button state.
| Parameter | Type | Description |
|---|---|---|
buttonNumber | int | The button number to query (0 to 31). |
Returns ButtonState: The state of the button.
SetCursorBounds(Cursor cursor, int minX, int maxX, int minY, int maxY)
def SetCursorBounds(self, cursor: Cursor, minX: int, maxX: int, minY: int, maxY: int) -> None:
Sets the bounds for given cursor.
Events
ButtonChanged
ButtonChanged # += / -= handler
The event fired when one of the joystick's buttons is pressed or released.
CursorMoved
CursorMoved # += / -= handler
The event fired when the joystick's cursor has moved.
HatSwitchPressed
HatSwitchPressed # += / -= handler
The event fired when the joystick's hat switch has been pressed.