Skip to content

Commit 0a68b76

Browse files
committed
Trim API and changelog docs to what a caller needs
Review feedback: the docs had accumulated the reasoning behind the change rather than what a reader needs at the call site. - InputManager.ExecuteSystemCommand: drop the remarks block. Its first paragraph was history about the ExecuteGlobalCommand it replaced, and the second restated what the three call sites just below already show. - Query{Pen,Mouse,TouchPressure}SupportedCommand: drop the presence clause that duplicated the summary directly above it, and the platform-scope rationale that the engine's PlatformSystemCapabilities.h already owns. Kept the routing note, which is what stops these being sent through InputDevice.ExecuteCommand like every sibling in the folder, and the FourCC-must-match constraint, which is hand-mirrored across two repos. - InputCapabilitySupport: drop the TODO about the unpinned version expression. The merge gate is the open review thread on the asmdef, which is enforced; a comment is not. - Mouse/Pen/Touchscreen.isSupported: trim the remarks to what a caller needs. The legacy Input Manager comparison belongs in the migration documentation, which the remaining text now points at for the availability check. Kept what false means, the concrete undetermined case, and the main-thread contract. - InputManager.ExecuteSystemCommand: send through m_Runtime rather than InputRuntime.s_Instance, matching every other DeviceCommand call site and staying correct when a test installs its own runtime. - CHANGELOG: drop the feature explanation and the code snippet, reference the migration documentation instead, and cite ISX-2079 alongside ISX-2046 since Mouse.isSupported is that ticket's deliverable. - corresponding-old-new-api.md: qualify the property names in the migration table, link the legacy properties, and unpin a Unity 5.5 docs URL.
1 parent 95d60ca commit 0a68b76

10 files changed

Lines changed: 38 additions & 113 deletions

File tree

Packages/com.unity.inputsystem/CHANGELOG.md

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
99

1010
### Added
1111

12-
- Added `Pen.isSupported`, `Mouse.isSupported` and `Touchscreen.isPressureSupported`, reporting what the current platform is capable of rather than what is connected right now. Use them to decide whether to offer device-specific functionality at all. These are not drop-in replacements for the legacy `UnityEngine.Input.stylusTouchSupported` and `Input.mousePresent`: those conflated capability with presence, and on platforms where legacy did real hardware detection the new properties report capability instead, so they can be `true` where legacy was `false`. To act on input, check `Device.current != null && Device.current.enabled` rather than `Device.current != null` alone; a non-null `current` means a device object is registered, which several platforms do unconditionally, and `enabled` is what tells you it is active. The properties require an Editor version that can answer the query and are not compiled in on older versions. `Pen.isSupported` and `Touchscreen.isPressureSupported` come from [ISX-2046](https://jira.unity3d.com/browse/ISX-2046); `Mouse.isSupported` is the short-term scope of [ISX-2079](https://jira.unity3d.com/browse/ISX-2079), whose remaining half is a real presence primitive rather than a capability one
13-
14-
```csharp
15-
// Before, legacy input. Reported true on any iPad new enough to pair a Pencil, whether or
16-
// not one was paired, so the two questions could not be told apart.
17-
if (Input.stylusTouchSupported) { }
18-
if (Input.mousePresent) { }
19-
20-
// After. Capability is its own question with its own answer.
21-
if (Pen.isSupported) { } // could a pen ever work on this platform
22-
if (Mouse.isSupported) { } // could a mouse ever work on this platform
23-
24-
// Acting on input is a different question, and needs both parts. A non-null current means a
25-
// device object is registered, not that hardware is attached; enabled is what says it is active.
26-
if (Pen.current != null && Pen.current.enabled) { }
27-
```
12+
- Added `Pen.isSupported`, `Mouse.isSupported` and `Touchscreen.isPressureSupported`, reporting what the current platform is capable of rather than what is connected right now. These are not drop-in replacements for the legacy `UnityEngine.Input` equivalents; see the "Device capability and device availability" section of the migration documentation for how they differ, and for how to check whether a device is available to read from. [ISX-2046] [ISX-2079]
2813

2914
### Fixed
3015

Packages/com.unity.inputsystem/Documentation~/corresponding-old-new-api.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,14 +69,15 @@ Directly reading hardware controls bypasses the new Input System's action-based
6969

7070
## Device capability and device availability
7171

72-
Several old Input Manager properties, such as `Input.mousePresent` and `Input.stylusTouchSupported`, answered
72+
Several Input Manager properties, such as [`Input.mousePresent`](https://docs.unity3d.com/ScriptReference/Input-mousePresent.html) and
73+
[`Input.stylusTouchSupported`](https://docs.unity3d.com/ScriptReference/Input-stylusTouchSupported.html), answered
7374
two questions at once, and answered them differently depending on the platform. On some platforms they were a
7475
hardcoded constant meaning roughly "this platform has this kind of device", and on others they performed real
7576
hardware detection.
7677

7778
The new Input System separates the two:
78-
79-
- **Can this platform do it at all?** Use the capability properties: [`Mouse.isSupported`](xref:UnityEngine.InputSystem.Mouse),
79+
- **Does this platform even support this input interface?**
80+
Use the capability properties: [`Mouse.isSupported`](xref:UnityEngine.InputSystem.Mouse),
8081
[`Pen.isSupported`](xref:UnityEngine.InputSystem.Pen) and [`Touchscreen.isPressureSupported`](xref:UnityEngine.InputSystem.Touchscreen).
8182
These never change while the application runs, so read them once and decide whether to offer device-specific
8283
functionality.
@@ -100,7 +101,7 @@ instead, so it can be `true` where the old one was `false`. The tables below not
100101
[`Input.GetMouseButtonDown`](https://docs.unity3d.com/ScriptReference/Input.GetMouseButtonDown.html)<br/>Example: `Input.GetMouseButtonDown(0)`|Use [`wasPressedThisFrame`](xref:UnityEngine.InputSystem.Controls.ButtonControl) on the corresponding mouse button.<br/>Example: `InputSystem.Mouse.current.leftButton.wasPressedThisFrame`
101102
[`Input.GetMouseButtonUp`](https://docs.unity3d.com/ScriptReference/Input.GetMouseButtonUp.html)<br/>Example: `Input.GetMouseButtonUp(0)`|Use [`wasReleasedThisFrame`](xref:UnityEngine.InputSystem.Controls.ButtonControl) on the corresponding mouse button.<br/>Example: `InputSystem.Mouse.current.leftButton.wasReleasedThisFrame`
102103
[`Input.mousePosition`](https://docs.unity3d.com/ScriptReference/Input-mousePosition.html)|Use [`Mouse.current.position.ReadValue()`](xref:UnityEngine.InputSystem.Mouse)<br/>Example: `Vector2 position = Mouse.current.position.ReadValue();`<br/> **Note:** Mouse simulation from touch isn't implemented yet.
103-
[`Input.mousePresent`](https://docs.unity3d.com/ScriptReference/Input-mousePresent.html)|Use [`isSupported`](xref:UnityEngine.InputSystem.Mouse) to check whether the platform supports mouse input at all.<br/>Example: `if (Mouse.isSupported) ShowMouseSettings();`<br/>**Note:** Not a drop-in replacement; see [Device capability and device availability](#device-capability-and-device-availability) above. Input System does not currently deliver mouse input on iOS, iPadOS or visionOS, so `Mouse.isSupported` is `false` there even though the platform itself supports indirect mice. Requires a recent Editor version.
104+
[`Input.mousePresent`](https://docs.unity3d.com/ScriptReference/Input-mousePresent.html)|Use [`Mouse.isSupported`](xref:UnityEngine.InputSystem.Mouse) to check whether the platform supports mouse input at all.<br/>Example: `if (Mouse.isSupported) ShowMouseSettings();`<br/>**Note:** Not a drop-in replacement; see [Device capability and device availability](#device-capability-and-device-availability) above. Input System does not currently deliver mouse input on iOS, iPadOS or visionOS, so `Mouse.isSupported` is `false` there even though the platform itself supports indirect mice. Requires a recent Editor version.
104105

105106
## Touch and Pen
106107

@@ -109,10 +110,10 @@ instead, so it can be `true` where the old one was `false`. The tables below not
109110
[`Input.GetTouch`](https://docs.unity3d.com/ScriptReference/Input.GetTouch.html)<br/>For example:<br/>`Touch touch = Input.GetTouch(0);`<br/>`Vector2 touchPos = touch.position;`|Use [`EnhancedTouch.Touch.activeTouches[i]`](xref:UnityEngine.InputSystem.EnhancedTouch.Touch)<br/>Example: `Vector2 touchPos = EnhancedTouch.Touch.activeTouches[0].position;`<br/> **Note:** Enable enhanced touch support first by calling [`EnhancedTouch.Enable()`](xref:UnityEngine.InputSystem.EnhancedTouch.EnhancedTouchSupport).
110111
[`Input.multiTouchEnabled`](https://docs.unity3d.com/ScriptReference/Input-multiTouchEnabled.html)|There is no direct equivalent, because this is a setting rather than a hardware capability. To get the same first-touch-wins behaviour, read [`primaryTouch`](xref:UnityEngine.InputSystem.Touchscreen) instead of iterating all touches, or bind to `<Touchscreen>/primaryTouch`.<br/>Example: `if (Touchscreen.current != null && Touchscreen.current.primaryTouch.press.isPressed)`<br/>**Note:** Two differences from setting `Input.multiTouchEnabled = false`. First, `primaryTouch` filters only itself: [`touches`](xref:UnityEngine.InputSystem.Touchscreen), the `<Touchscreen>/touch*` bindings and [`EnhancedTouch`](xref:UnityEngine.InputSystem.EnhancedTouch.Touch) still report every finger, whereas the legacy setting suppressed additional touches globally. Second, when the finger that started the primary touch lifts while other fingers are still down, the primary touch is retained rather than ended until the last finger is released, so a control bound to it stays actuated in the meantime.
111112
[`Input.simulateMouseWithTouches`](https://docs.unity3d.com/ScriptReference/Input-multiTouchEnabled.html)|No corresponding API yet.
112-
[`Input.stylusTouchSupported`](https://docs.unity3d.com/ScriptReference/Input-stylusTouchSupported.html)|Use [`isSupported`](xref:UnityEngine.InputSystem.Pen) to check whether the platform supports pen input at all.<br/>Example: `if (Pen.isSupported) ShowPenSettings();`<br/>**Note:** Not a drop-in replacement; see [Device capability and device availability](#device-capability-and-device-availability) above. Requires a recent Editor version.
113+
[`Input.stylusTouchSupported`](https://docs.unity3d.com/ScriptReference/Input-stylusTouchSupported.html)|Use [`Pen.isSupported`](xref:UnityEngine.InputSystem.Pen) to check whether the platform supports pen input at all.<br/>Example: `if (Pen.isSupported) ShowPenSettings();`<br/>**Note:** Not a drop-in replacement; see [Device capability and device availability](#device-capability-and-device-availability) above. Requires a recent Editor version.
113114
[`Input.touchCount`](https://docs.unity3d.com/ScriptReference/Input-touchCount.html)|[`EnhancedTouch.Touch.activeTouches.Count`](xref:UnityEngine.InputSystem.EnhancedTouch.Touch)<br/> **Note:** Enable enhanced touch support first by calling [`EnhancedTouchSupport.Enable()`](xref:UnityEngine.InputSystem.EnhancedTouch.EnhancedTouchSupport)
114115
[`Input.touches`](https://docs.unity3d.com/scriptreference/input-touches.html)|[`EnhancedTouch.Touch.activeTouches`](xref:UnityEngine.InputSystem.EnhancedTouch.Touch)<br/> **Note:** Enable enhanced touch support first by calling [`EnhancedTouch.Enable()`](xref:UnityEngine.InputSystem.EnhancedTouch.EnhancedTouchSupport)
115-
[`Input.touchPressureSupported`](https://docs.unity3d.com/ScriptReference/Input-touchPressureSupported.html)|Use [`isPressureSupported`](xref:UnityEngine.InputSystem.Touchscreen) to check whether the platform delivers a real pressure value with touch input.<br/>Example: `if (Touchscreen.isPressureSupported) UsePressureForBrushWidth();`<br/>**Note:** When this is `false`, [`pressure`](xref:UnityEngine.InputSystem.Controls.TouchControl) reports a constant `1` while a finger is down rather than a measured value. This is a platform-wide answer rather than a per-device one. Requires a recent Editor version.
116+
[`Input.touchPressureSupported`](https://docs.unity3d.com/ScriptReference/Input-touchPressureSupported.html)|Use [`Touchscreen.isPressureSupported`](xref:UnityEngine.InputSystem.Touchscreen) to check whether the platform delivers a real pressure value with touch input.<br/>Example: `if (Touchscreen.isPressureSupported) UsePressureForBrushWidth();`<br/>**Note:** When this is `false`, [`pressure`](xref:UnityEngine.InputSystem.Controls.TouchControl) reports a constant `1` while a finger is down rather than a measured value. This is a platform-wide answer rather than a per-device one. Requires a recent Editor version.
116117
[`Input.touchSupported`](https://docs.unity3d.com/ScriptReference/Input-touchSupported.html)|[`Touchscreen.current != null`](xref:UnityEngine.InputSystem.Touchscreen)
117118
[`Input.backButtonLeavesApp`](https://docs.unity3d.com/ScriptReference/Input-backButtonLeavesApp.html)|No corresponding API yet.
118119
[`GetPenEvent`](https://docs.unity3d.com/ScriptReference/Input.GetPenEvent.html)<br/>[`GetLastPenContactEvent`](https://docs.unity3d.com/ScriptReference/Input.GetLastPenContactEvent.html)<br/>[`ResetPenEvents`](https://docs.unity3d.com/ScriptReference/Input.ResetPenEvents.html)<br/>[`ClearLastPenContactEvent`](https://docs.unity3d.com/ScriptReference/Input.ClearLastPenContactEvent.html)|Use: [`Pen.current`](xref:UnityEngine.InputSystem.Pen)<br/>See the [Pen, tablet and stylus support](devices-pen.md) docs for more information.

Packages/com.unity.inputsystem/InputSystem/Runtime/Devices/Commands/InputCapabilitySupport.cs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,3 @@
1-
////TODO: the UNITY_INPUTSYSTEM_SUPPORTS_CAPABILITY_QUERIES version expression in
2-
//// Unity.InputSystem.asmdef and Unity.InputSystem.Tests.asmdef is still a local development
3-
//// Editor version. It must be set to the version that actually ships the engine side of
4-
//// ISX-2046 before this merges, or the gate will enable code referencing engine symbols that
5-
//// standard builds of that version do not have. Recorded here because asmdef files are JSON
6-
//// and cannot carry a comment of their own.
7-
81
#if UNITY_INPUTSYSTEM_SUPPORTS_CAPABILITY_QUERIES
92
namespace UnityEngine.InputSystem.LowLevel
103
{

Packages/com.unity.inputsystem/InputSystem/Runtime/Devices/Commands/QueryMouseSupportedCommand.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace UnityEngine.InputSystem.LowLevel
1111
/// <remarks>
1212
/// Addressed to the engine's system endpoint rather than to a device, so it is sent through
1313
/// <see cref="InputManager.ExecuteSystemCommand{TCommand}"/> rather than
14-
/// <see cref="InputDevice.ExecuteCommand{TCommand}"/>. Presence is answered by the device list.
14+
/// <see cref="InputDevice.ExecuteCommand{TCommand}"/>.
1515
///
1616
/// The FourCC must match <c>kInputFourCCIOCTLQueryMouseSupported</c> in the engine's
1717
/// <c>Modules/Input/InputFourCC.h</c>.

Packages/com.unity.inputsystem/InputSystem/Runtime/Devices/Commands/QueryPenSupportedCommand.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace UnityEngine.InputSystem.LowLevel
1111
/// <remarks>
1212
/// Addressed to the engine's system endpoint rather than to a device, so it is sent through
1313
/// <see cref="InputManager.ExecuteSystemCommand{TCommand}"/> rather than
14-
/// <see cref="InputDevice.ExecuteCommand{TCommand}"/>. Presence is answered by the device list.
14+
/// <see cref="InputDevice.ExecuteCommand{TCommand}"/>.
1515
///
1616
/// The FourCC must match <c>kInputFourCCIOCTLQueryPenSupported</c> in the engine's
1717
/// <c>Modules/Input/InputFourCC.h</c>.

Packages/com.unity.inputsystem/InputSystem/Runtime/Devices/Commands/QueryTouchPressureSupportedCommand.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,6 @@ namespace UnityEngine.InputSystem.LowLevel
1313
/// <see cref="InputManager.ExecuteSystemCommand{TCommand}"/> rather than
1414
/// <see cref="InputDevice.ExecuteCommand{TCommand}"/>.
1515
///
16-
/// This is answered at platform scope rather than per touchscreen, because that is the scope at
17-
/// which the answer exists: every platform sources it from a device-model or OS-API property
18-
/// rather than by enumerating digitizers.
19-
///
2016
/// The FourCC must match <c>kInputFourCCIOCTLQueryTouchPressureSupported</c> in the engine's
2117
/// <c>Modules/Input/InputFourCC.h</c>.
2218
/// </remarks>

Packages/com.unity.inputsystem/InputSystem/Runtime/Devices/Mouse.cs

Lines changed: 8 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -265,36 +265,19 @@ public class Mouse : Pointer, IInputStateCallbackReceiver
265265
/// <value>True if the platform supports mouse input.</value>
266266
/// <remarks>
267267
/// This answers "could a mouse work here", which is the question to ask when deciding
268-
/// whether to offer mouse-specific functionality in a UI. To ask whether a mouse is
269-
/// available to read from right now, check both <see cref="current"/> and
270-
/// <see cref="InputDevice.enabled"/>, as described below.
271-
///
272-
/// Legacy <c>UnityEngine.Input</c> conflated the two under <c>Input.mousePresent</c>, which is
273-
/// a hardcoded true on Windows, macOS, Linux and WebGL, and genuine detection only on iOS,
274-
/// Android, UWP and the consoles.
268+
/// whether to offer mouse-specific functionality in a UI. The answer cannot change while the
269+
/// application runs.
275270
///
276271
/// A false value means either that the platform does not support mouse input or that it could
277272
/// not determine the answer. The two are deliberately not distinguished, because a caller
278-
/// deciding whether to offer functionality wants the same behaviour in both cases. It does not
279-
/// mean the Editor was unable to ask, since this property only exists on Editor versions that
280-
/// can.
281-
///
282-
/// The answer cannot change while the application runs, so it is queried once and cached.
283-
///
284-
/// Three checks are easy to confuse, in increasing strictness. This property asks whether the
285-
/// platform could ever deliver mouse input. <c>Mouse.current != null</c> asks only whether a device
286-
/// object is registered, which is not the same as hardware being attached, since several
287-
/// platforms register unconditionally. <c>Mouse.current != null &amp;&amp; Mouse.current.enabled</c>
288-
/// adds whether it is currently active, and that is the check to make before acting on input.
273+
/// deciding whether to offer functionality wants the same behaviour in both cases. It never
274+
/// means the Editor was unable to ask, since the property only exists where it can.
289275
///
290-
/// The two clauses catch different things. <c>current != null</c> is what catches a disconnect,
291-
/// since removal nulls <c>current</c>, though that relies on the platform reporting removal at all.
292-
/// <c>enabled</c> does not become false on unplug: it tracks whether the device is enabled for
293-
/// input, through <see cref="InputSystem.EnableDevice"/> and <see cref="InputSystem.DisableDevice"/>.
276+
/// Whether a mouse is available to read from right now is a separate question, and needs both
277+
/// <see cref="current"/> and <see cref="InputDevice.enabled"/>. See the "Device capability and
278+
/// device availability" section of the Input Manager migration documentation.
294279
///
295-
/// The Device Simulator makes that visible: while simulating a touch device it disables the native
296-
/// Mouse without removing it, so <c>current</c> stays non-null while <c>enabled</c> is false.
297-
/// Read it from the main thread: resolving mouse support can require a platform API that is
280+
/// Read this from the main thread: resolving the answer can require a platform API that is
298281
/// main-thread only, and the first read is the one that resolves it.
299282
/// </remarks>
300283
/// <example>

0 commit comments

Comments
 (0)