Skip to content

Commit cee9ffd

Browse files
committed
docs
1 parent 632b112 commit cee9ffd

File tree

3 files changed

+39
-1
lines changed

3 files changed

+39
-1
lines changed

Packages/com.unity.inputsystem/Documentation~/HID.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ HIDs are handled in one of two ways:
1515

1616
## Auto-generated layouts
1717

18-
By default, the input system will create layouts and device representations for any HID which reports it's usage as `GenericDesktop/Joystick`, `GenericDesktop/Gamepad` or `GenericDesktop/MultiAxisController` (see the [HID usage table specifications](https://www.usb.org/document-library/hid-usage-tables-112) for more info). You can override that behavior to support any other device by adding a handler to the [`HIDSupport.shouldCreateHID`](../api/UnityEngine.InputSystem.HID.HIDSupport.html#UnityEngine_InputSystem_HID_HIDSupport_shouldCreateHID) event.
18+
By default, the input system will create layouts and device representations for any HID which reports it's usage as `GenericDesktop/Joystick`, `GenericDesktop/Gamepad` or `GenericDesktop/MultiAxisController` (see the [HID usage table specifications](https://www.usb.org/document-library/hid-usage-tables-112) for more info). You can change the list of supported usages by setting [`HIDSupport.supportedHIDUsages`](../api/UnityEngine.InputSystem.HID.HIDSupport.html#UnityEngine_InputSystem_HID_HIDSupport_supportedHIDUsages).
1919

2020
Nor when the input system automatically create a layouts for a HID, these devices are currently always reported as [`Joysticks`](Joystick.md), represented by the [`Joystick` device class]((../api/UnityEngine.InputSystem.Joystick.html). The first elements with a reported HID usage of `GenericDesktop/X` and `GenericDesktop/Y` together form the joystick's [`stick`](../api/UnityEngine.InputSystem.Joystick.html#UnityEngine_InputSystem_Joystick_stick) control. Then controls are added for all further HID axis or button elements, using the control names reported by the HID specification (which tend to be rather generic). The first control with a HID usage of `Button/Button 1` will be assigned to the joystick's [`trigger`](../api/UnityEngine.InputSystem.Joystick.html#UnityEngine_InputSystem_Joystick_trigger) control.
2121

Packages/com.unity.inputsystem/InputSystem/Plugins/HID/HID.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1151,6 +1151,7 @@ public enum GenericDesktop
11511151
Keypad = 0x07,
11521152
MultiAxisController = 0x08,
11531153
TabletPCControls = 0x09,
1154+
AssistiveControl = 0x0A,
11541155
X = 0x30,
11551156
Y = 0x31,
11561157
Z = 0x32,

Packages/com.unity.inputsystem/InputSystem/Plugins/HID/HIDSupport.cs

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,36 @@ namespace UnityEngine.InputSystem.HID
2828
/// </remarks>
2929
public static class HIDSupport
3030
{
31+
/// <summary>
32+
/// A pair of HID usage page and HID usage number.
33+
/// </summary>
34+
/// <remarks>
35+
/// Used to describe a HID usage for the <see cref="supportedHIDUsages"/> property.
36+
/// </remarks>
3137
public struct HIDPageUsage
3238
{
39+
/// <summary>
40+
/// The usage page.
41+
/// </summary>
3342
public HID.UsagePage page;
43+
44+
/// <summary>
45+
/// A number specifying the usage on the usage page.
46+
/// </summary>
3447
public int usage;
3548

49+
/// <summary>
50+
/// Create a HIDPageUsage struct by specifying a page and usage.
51+
/// </summary>
3652
public HIDPageUsage(HID.UsagePage page, int usage)
3753
{
3854
this.page = page;
3955
this.usage = usage;
4056
}
4157

58+
/// <summary>
59+
/// Create a HIDPageUsage struct from the GenericDesktop usage page by specifying the usage.
60+
/// </summary>
4261
public HIDPageUsage(HID.GenericDesktop usage)
4362
{
4463
this.page = HID.UsagePage.GenericDesktop;
@@ -47,6 +66,24 @@ public HIDPageUsage(HID.GenericDesktop usage)
4766
}
4867

4968

69+
/// <summary>
70+
/// An array of HID usages the input is configured to support.
71+
/// </summary>
72+
/// <remarks>
73+
/// The input system will only create <see cref="InputDevice"/>s for HIDs with usages
74+
/// listed in this array. Any other HID will be ignored. This saves the input system from
75+
/// spending resources on creating layouts and devices for HIDs which are not supported or
76+
/// not usable for game input.
77+
///
78+
/// By default, this includes only <see cref="HID.GenericDesktop.Joystick"/>,
79+
/// <see cref="HID.GenericDesktop.Gamepad"/> and <see cref="HID.GenericDesktop.MultiAxisController"/>,
80+
/// but you can set this property to include any other HID usages.
81+
///
82+
/// Note that currently on macOS, the only HID usages which can be enabled are
83+
/// <see cref="HID.GenericDesktop.Joystick"/>, <see cref="HID.GenericDesktop.Gamepad"/>,
84+
/// <see cref="HID.GenericDesktop.MultiAxisController"/>, <see cref="HID.GenericDesktop.TabletPCControls"/>,
85+
/// and <see cref="HID.GenericDesktop.AssistiveControl"/>.
86+
/// </remarks>
5087
public static ReadOnlyArray<HIDPageUsage> supportedHIDUsages { get; set; }
5188

5289
/// <summary>

0 commit comments

Comments
 (0)