Joystick Class
Namespace: GHIElectronics.TinyCLR.Devices.UsbClient · Assembly: GHIElectronics.TinyCLR.Devices.UsbClient
This device emulates a joystick. You can set the x, y, and z axis values, the z axis rotation, the state of 32 buttons, and 8 hat swtich directions.
public class Joystick : RawDevice
Constructors
Joystick(UsbClientController usbClientController)
public Joystick(UsbClientController usbClientController) : this(usbClientController, new UsbClientSetting()
Creates a new joystick with default parameters.
| Parameter | Type | Description |
|---|---|---|
usbClientController | UsbClientController |
Joystick(UsbClientController usbClientController, UsbClientSetting usbClientSetting)
public Joystick(UsbClientController usbClientController, UsbClientSetting usbClientSetting) : base(usbClientController, usbClientSetting)
Creates a new joystick.
| Parameter | Type | Description |
|---|---|---|
usbClientController | UsbClientController | UsbClient controller. |
usbClientSetting | UsbClientSetting | UsbClient setting |
Properties
X
public int X { get; set; }
Sets the x axis position. It must be between –32,768 to +32,767.
Y
public int Y { get; set; }
Sets the y axis position. It must be between –32,768 to +32,767.
Z
public int Z { get; set; }
Sets the z axis position. It must be between –32,768 to +32,767.
ZRotation
public int ZRotation { get; set; }
Sets the z rotation. It must be between –32,768 to +32,767.
HatSwitch
public HatSwitchDirection HatSwitch { get; set; }
Sets the hat switch direction.
Methods
SendRawData(int x, int y, int z, int zRotation, uint buttons, HatSwitchDirection hatSwitch)
public void SendRawData(int x, int y, int z, int zRotation, uint buttons, HatSwitchDirection hatSwitch)
Sends the given raw data directly to the host..
| Parameter | Type | Description |
|---|---|---|
x | int | The new x position from -32,768 to 32,767. |
y | int | The new y position from -32,768 to 32,767. |
z | int | The new z position from -32,768 to 32,767. |
zRotation | int | The new z rotation from -32,768 to 32,767. |
buttons | uint | Sends the given uint as a bitfield where each 1 represents a button press for the button whose number is the bit number. |
hatSwitch | HatSwitchDirection | The new direction of the hat switch. |
IsButtonPressed(int index)
public bool IsButtonPressed(int index)
Whether or not the given button has been pressed.
| Parameter | Type | Description |
|---|---|---|
index | int | The button to query. |
Returns bool — The button state.
PressButton(int index)
public void PressButton(int index)
Presses the given button.
| Parameter | Type | Description |
|---|---|---|
index | int | The button to press. |
ReleaseButton(int index)
public void ReleaseButton(int index)
Releases the given button.
| Parameter | Type | Description |
|---|---|---|
index | int | The button to release. |
ClickButton(int index)
public void ClickButton(int index)
Presses then releases the given button.
| Parameter | Type | Description |
|---|---|---|
index | int | The button to click. |
ClickButton(int index, int delay)
public void ClickButton(int index, int delay)
Presses then releases the given button with the given delay between the actions.
| Parameter | Type | Description |
|---|---|---|
index | int | The button to click. |
delay | int | The delay between the actions. |