Skip to main content

Joystick Class

Package: GHIElectronics.Endpoint.Devices.UsbHost
Namespace: GHIElectronics.Endpoint.Devices.UsbHost

Allows a usb device to be used as a joystick.

class Joystick : public 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​

TypeKindSummary
Joystick.ButtonChangedEventArgsClassThe events args for the ButtonPressed and ButtonReleased events.
Joystick.ButtonChangedEventHandlerDelegateThe delegate for when one of the joystick's button is pressed or released.
Joystick.CursorMovedEventArgsClassThe events args for the CursorMoved event.
Joystick.CursorMovedEventHandlerDelegateThe delegate for when one of the joystick's cursors moves.
Joystick.DeviceCapabilitiesEnumJoystick capabilities.
Joystick.HatSwitchPressedEventArgsClassThe events args for the HatSwitchPressed event.
Joystick.HatSwitchPressedEventHandlerDelegateThe delegate for when the joystick's hat switch is pressed.

Constructors​

Joystick(string deviceName)​

Joystick(const std::string& deviceName);

Opens the joystick that UsbHostController reported ("/dev/input/event3").

Properties​

Capabilities​

DeviceCapabilities Capabilities() const;

The capabilities of the joystick.

Returns DeviceCapabilities

CurrentHatSwitchDirection​

HatSwitchDirection CurrentHatSwitchDirection() const;

The current direction of the hat switch.

Returns HatSwitchDirection

Cursor2Position​

Position Cursor2Position() const;

The current position of the second cursor.

Returns Position

CursorPosition​

Position CursorPosition() const;

The current position of the first cursor.

Returns Position

Methods​

GetButtonState(int buttonNumber)​

ButtonState GetButtonState(int32_t buttonNumber);

Gets the current button state.

ParameterTypeDescription
buttonNumberintThe 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)​

void SetCursorBounds(Cursor cursor, int32_t minX, int32_t maxX, int32_t minY, int32_t maxY);

Sets the bounds for given cursor.

Events​

ButtonChanged​

Core::Event<...> ButtonChanged;

The event fired when one of the joystick's buttons is pressed or released.

CursorMoved​

Core::Event<...> CursorMoved;

The event fired when the joystick's cursor has moved.

HatSwitchPressed​

Core::Event<...> HatSwitchPressed;

The event fired when the joystick's hat switch has been pressed.