You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* DOCF-1072 restructured most of How Do I? page.
* minor docs link fixes
* DOCF-3072 - add solution for how to wait for any button or key press
* DOCF-3073 - How to create custom devices
* xr device sample code fix and howdoi anchor link fixes
* Fixed bug relating to link in H3 header
* Another anchor link fix
* Moved sample code for HMD extra update
* whitespace formatting fixes
---------
Co-authored-by: James McGill <jamesmcgill@users.noreply.github.com>
When something isn't working as expected, the quickest way to troubleshoot what's wrong is the Input Debugger in the Unity Editor. The Input Debugger provides access to the activity of the Input System in both the Editor and the connected Players.
13
18
@@ -58,7 +63,7 @@ When there are [`InputUser`](UserManagement.md) instances (if you use `PlayerInp
58
63
59
64
### Debugging layouts
60
65
61
-
The [__Layouts__](Layouts.md) list in the Input Debugger window displays a breakdown of all registered [Control and Device layouts](Layouts.md). This is the database of supported hardware and the knowledge of how to represent a given piece of input hardware. It's useful when you want to [create a new Device mapping](HowDoI.md#create-my-own-custom-devices) and see how the Input System represents it.
66
+
The [__Layouts__](Layouts.md) list in the Input Debugger window displays a breakdown of all registered [Control and Device layouts](Layouts.md). This is the database of supported hardware and the knowledge of how to represent a given piece of input hardware. It's useful when you want to [create a new Device mapping](HID.md#creating-a-custom-device-layout) and see how the Input System represents it.
62
67
63
68

64
69
@@ -96,16 +101,16 @@ When Device Simulator window is in use, mouse and pen inputs on the simulated de
96
101
97
102
To prevent conflicts between simulated touchscreen inputs and native mouse and pen inputs, Device Simulator disables all native mouse and pen devices.
>__Note__: Joysticks/gamepads are not yet supported over the Unity Remote. No joystick/gamepad input from the mobile device will come through in the editor.
102
-
103
-
>__Note__: This requires Unity 2021.2.18 or later.
104
+
## Unity Remote
104
105
105
106
The Unity Remote is an app available for iOS and Android which allows using a mobile device for input while running in the Unity Editor. You can find details about the app and how to install it in the [Unity manual](https://docs.unity3d.com/Manual/UnityRemote5.html).
106
107
107
108
If you would like to try out the Unity Remote app, you can [install](Installation.md#installing-samples) the "Unity Remote" sample that is provided with the Input System package.
108
109
110
+
>__Note__: Joysticks/gamepads are not yet supported over the Unity Remote. No joystick/gamepad input from the mobile device will come through in the editor.
111
+
112
+
>__Note__: This requires Unity 2021.2.18 or later.
113
+
109
114
When in play mode in the Editor and connected to the Unity Remote app, you will see a number of Devices have been added with the [`InputDevice.remote`](../api/UnityEngine.InputSystem.InputDevice.html#UnityEngine_InputSystem_InputDevice_remote) flag set to true:
@@ -125,3 +130,44 @@ The [`Accelerometer`](../api/UnityEngine.InputSystem.Accelerometer.html) device
125
130
The remaining sensors listed above will need to be explicitly enabled via [`InputSystem.EnableDevice`](../api/UnityEngine.InputSystem.InputSystem.html#UnityEngine_InputSystem_InputSystem_EnableDevice_UnityEngine_InputSystem_InputDevice_) just like local sensors. Setting the sampling frequency on these sensors from the Unity Remote using [`Sensor.samplingFrequency`](../api/UnityEngine.InputSystem.Sensor.html#UnityEngine_InputSystem_Sensor_samplingFrequency) will be relayed to the device but note that setting the frequency on one of them will set it for all of them.
126
131
127
132
Touch coordinates from the device will be translated to the screen coordinates of the Game View inside the Editor.
133
+
134
+
## Other tips:
135
+
136
+
To record events flowing through the system, use this code:
137
+
138
+
```C#
139
+
140
+
// You can also provide a device ID to only
141
+
// trace events for a specific device.
142
+
vartrace=newInputEventTrace();
143
+
144
+
trace.Enable();
145
+
146
+
varcurrent=newInputEventPtr();
147
+
while (trace.GetNextEvent(refcurrent))
148
+
{
149
+
Debug.Log("Got some event: "+current);
150
+
}
151
+
152
+
// Also supports IEnumerable.
153
+
foreach (vareventPtrintrace)
154
+
Debug.Log("Got some event: "+eventPtr);
155
+
156
+
// Trace consumes unmanaged resources. Make sure you dispose it correctly to avoid memory leaks.
157
+
trace.Dispose();
158
+
159
+
```
160
+
161
+
To see events as they're processed, use this code:
162
+
163
+
```C#
164
+
165
+
InputSystem.onEvent+=
166
+
(eventPtr, device) =>
167
+
{
168
+
// Can handle events yourself, for example, and then stop them
169
+
// from further processing by marking them as handled.
Physically, Input Devices represent devices attached to the computer, which a user can use to control the app. Logically, Input Devices are the top-level container for [Controls](Controls.md). The [`InputDevice`](../api/UnityEngine.InputSystem.InputDevice.html) class is itself a specialization of [`InputControl`](../api/UnityEngine.InputSystem.InputControl.html). See [supported Devices](SupportedDevices.md) to see what kind of Devices the Input System currently supports.
26
39
@@ -187,6 +200,23 @@ Devices that the [native backend](Architecture.md#native-backend) reports are co
// All strings in here are regexs and case-insensitive.
211
+
"product":"MyController",
212
+
"manufacturer":"MyCompany"
213
+
}
214
+
}
215
+
```
216
+
217
+
Note:Youdon't have to restart Unity in order for changes in your layout to take effect on native Devices. The Input System applies changes automatically on every domain reload, so you can just keep refining a layout and your Device is recreated with the most up-to-date version every time scripts are recompiled.
A [`Gamepad`](../api/UnityEngine.InputSystem.Gamepad.html) is narrowly defined as a Device with two thumbsticks, a D-pad, and four face buttons. Additionally, gamepads usually have two shoulder and two trigger buttons. Most gamepads also have two buttons in the middle.
13
15
14
16
A gamepad can have additional Controls, such as a gyro, which the Device can expose. However, all gamepads are guaranteed to have at least the minimum set of Controls described above.
15
17
16
18
Gamepad support guarantees the correct location and functioning of Controls across platforms and hardware. For example, a PS4 DualShock controller layout should look identical regardless of which platform it is supported on. A gamepad's south face button should always be the lowermost face button.
17
19
18
-
>NOTE: Generic [HID](./HID.md) gamepads will __not__ be surfaced as [`Gamepad`](../api/UnityEngine.InputSystem.Gamepad.html) devices but rather be created as generic [joysticks](./Joystick.md). This is because the Input System cannot guarantee correct mapping of buttons and axes on the controller (the information is simply not available at the HID level). Only HID gamepads that are explicitly supported by the Input System (like the PS4 controller) will come out as gamepads. Note that you can set up the same kind of support for specific HID gamepads yourself (see ["Overriding the HID Fallback"](./HID.md#overriding-the-hid-fallback)).
20
+
>NOTE: Generic [HID](./HID.md) gamepads will __not__ be surfaced as [`Gamepad`](../api/UnityEngine.InputSystem.Gamepad.html) devices but rather be created as generic [joysticks](./Joystick.md). This is because the Input System cannot guarantee correct mapping of buttons and axes on the controller (the information is simply not available at the HID level). Only HID gamepads that are explicitly supported by the Input System (like the PS4 controller) will come out as gamepads. Note that you can set up the same kind of support for specific HID gamepads yourself (see ["Overriding the HID Fallback"](./HID.md#creating-a-custom-device-layout)).
19
21
20
22
>NOTE: In case you want to use the gamepad for driving mouse input, there is a sample called `Gamepad Mouse Cursor` you can install from the package manager UI when selecting the Input System package. The sample demonstrates how to set up gamepad input to drive a virtual mouse cursor.
Deadzones prevent accidental input due to slight variations in where gamepad sticks come to rest at their centre point. They allow a certain small inner area where the input is considered to be zero even if it is slightly off from the zero position.
66
+
67
+
To add a deadzone to gamepad stick, put a [stick deadzone Processor](Processors.md#stick-deadzone) on the sticks, like this:
Thegamepadlayoutalreadyaddsstickdeadzoneprocessorswhichtaketheirminandmaxvaluesfrom [`InputSettings.defaultDeadzoneMin`](../api/UnityEngine.InputSystem.InputSettings.html#UnityEngine_InputSystem_InputSettings_defaultDeadzoneMin) and [`InputSettings.defaultDeadzoneMax`](../api/UnityEngine.InputSystem.InputSettings.html#UnityEngine_InputSystem_InputSettings_defaultDeadzoneMax).
0 commit comments