Joystick Class
Package: GHIElectronics.Endpoint.Devices.UsbHost
Namespace: GHIElectronics.Endpoint.Devices.UsbHost
Allows a usb device to be used as a joystick.
public 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)
public Joystick(string deviceName)
Opens the joystick that UsbHostController reported ("/dev/input/event3").
Properties
Capabilities
public DeviceCapabilities Capabilities { get; }
The capabilities of the joystick.
Returns DeviceCapabilities
CurrentHatSwitchDirection
public HatSwitchDirection CurrentHatSwitchDirection { get; }
The current direction of the hat switch.
Returns HatSwitchDirection
Cursor2Position
public Position Cursor2Position { get; }
The current position of the second cursor.
Returns Position
CursorPosition
public Position CursorPosition { get; }
The current position of the first cursor.
Returns Position
Methods
GetButtonState(int buttonNumber)
public ButtonState GetButtonState(int buttonNumber)
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)
public void SetCursorBounds(Cursor cursor, int minX, int maxX, int minY, int maxY)
Sets the bounds for given cursor.
Events
ButtonChanged
public event ButtonChangedEventHandler ButtonChanged
The event fired when one of the joystick's buttons is pressed or released.
CursorMoved
public event CursorMovedEventHandler CursorMoved
The event fired when the joystick's cursor has moved.
HatSwitchPressed
public event HatSwitchPressedEventHandler HatSwitchPressed
The event fired when the joystick's hat switch has been pressed.