Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
## [1.0.0-preview.1] - 2019-10-11

### Changed

- Generated action wrappers now won't `Destroy` the generated Asset in a finalizer, but instead implement `IDisposable`.
- Added back XR layouts (except for Magic Leap) that were removed for `1.0-preview`.
  * We removed these layouts under the assumption that they would almost concurrently become available in the respective device-specific XR packages. However, this did not work out as expected and the gap here turned out to be more than what we anticipated.
  * To deal with this gap, we have moved the bulk of the XR layouts back and will transition things gradually as support in device-specific packages becomes publicly available.

### Fixed

- Fixed a bug where the Input Settings Window might throw exceptions after assembly reload.
- Correctly implemented `IsPointerOverGameObject` method for `InputSystemUIInputModule`.
- Several bugs with layout overrides registered with (`InputSystem.RegisterLayoutOverrides`).
  * In `1.0-preview`, layout overrides could lead to corruption of the layout state and would also not be handled correctly by the various editor UIs.
- Selecting a layout in the input debugger no longer selects its first child item, too.
- Fixed XR devices reporting noise as valid user input (should fix problem of control schemes involving VR devices always activating when using `PlayerInput`).
- Fixed tap/swipe gesture detection in touch samples.

### Actions

- Fixed a bug where multiple composite bindings for the same controls but on different action maps would throw exceptions.
- Fixed `anyKey` not appearing in control picker for `Keyboard`.
- The text on the "Listen" button is no longer clipped off on 2019.3.
- Controls bound to actions through composites no longer show up as duplicates in the input debugger.
- Fixed "Create Actions..." on `PlayerInput` creating an asset with an incorrect binding for taps on Touchscreens. \
  __NOTE: If you have already created an .inputactions asset with this mechanism, update "tap [Touchscreen]" to "Primary Touch/Tap" to fix the problem manually.__
- Fixed `Invoke CSharp Events` when selected in `PlayerInput` not triggering `PlayerInput.onActionTriggered`.
- Fixed duplicating multiple items at the same time in the action editor duplicating them repeatedly.

### Added

- Will now recognize Xbox One and PS4 controllers connected to iOS devices correctly as Xbox One and PS4 controllers.
- Added a new sample called "Custom Device Usages" that shows how to use a layout override on `Gamepad` to allow distinguishing two gamepads in bindings based on which player the gamepad is assigned to.
- Added abstract `TrackedDevice` input device class as the basis for various kinds of tracked devices.
  • Loading branch information
Unity Technologies committed Oct 10, 2019
1 parent 576298c commit 447949e
Show file tree
Hide file tree
Showing 186 changed files with 1,699 additions and 91,270 deletions.
38 changes: 37 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,47 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
Due to package verification, the latest version below is the unpublished version and the date is meaningless.
however, it has to be formatted properly to pass verification tests.

## [1.0.0-preview.1] - 2019-10-11

### Changed

- Generated action wrappers now won't `Destroy` the generated Asset in a finalizer, but instead implement `IDisposable`.
- Added back XR layouts (except for Magic Leap) that were removed for `1.0-preview`.
* We removed these layouts under the assumption that they would almost concurrently become available in the respective device-specific XR packages. However, this did not work out as expected and the gap here turned out to be more than what we anticipated.
* To deal with this gap, we have moved the bulk of the XR layouts back and will transition things gradually as support in device-specific packages becomes publicly available.

### Fixed

- Fixed a bug where the Input Settings Window might throw exceptions after assembly reload.
- Correctly implemented `IsPointerOverGameObject` method for `InputSystemUIInputModule`.
- Several bugs with layout overrides registered with (`InputSystem.RegisterLayoutOverrides`).
* In `1.0-preview`, layout overrides could lead to corruption of the layout state and would also not be handled correctly by the various editor UIs.
- Selecting a layout in the input debugger no longer selects its first child item, too.
- Fixed XR devices reporting noise as valid user input (should fix problem of control schemes involving VR devices always activating when using `PlayerInput`).
- Fixed tap/swipe gesture detection in touch samples.

### Actions

- Fixed a bug where multiple composite bindings for the same controls but on different action maps would throw exceptions.
- Fixed `anyKey` not appearing in control picker for `Keyboard`.
- The text on the "Listen" button is no longer clipped off on 2019.3.
- Controls bound to actions through composites no longer show up as duplicates in the input debugger.
- Fixed "Create Actions..." on `PlayerInput` creating an asset with an incorrect binding for taps on Touchscreens. \
__NOTE: If you have already created an .inputactions asset with this mechanism, update "tap [Touchscreen]" to "Primary Touch/Tap" to fix the problem manually.__
- Fixed `Invoke CSharp Events` when selected in `PlayerInput` not triggering `PlayerInput.onActionTriggered`.
- Fixed duplicating multiple items at the same time in the action editor duplicating them repeatedly.

### Added

- Will now recognize Xbox One and PS4 controllers connected to iOS devices correctly as Xbox One and PS4 controllers.
- Added a new sample called "Custom Device Usages" that shows how to use a layout override on `Gamepad` to allow distinguishing two gamepads in bindings based on which player the gamepad is assigned to.
- Added abstract `TrackedDevice` input device class as the basis for various kinds of tracked devices.

## [1.0.0-preview] - 2019-9-20

### Fixed

-Will now close Input Action Asset Editor windows from previous sessions when the corresponding action was deleted.
- Will now close Input Action Asset Editor windows from previous sessions when the corresponding action was deleted.
- Fixed an issue where Stick Controls could not be created in Players built with medium or high code stripping level enabled.
- Fixed incorrect default state for axes on some controllers.

Expand Down
6 changes: 6 additions & 0 deletions Documentation~/Gamepad.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ PlayStation controllers are well supported on different Devices. The Input Syste

* [`DualShock4GamepadHID`](../api/UnityEngine.InputSystem.DualShock.DualShock4GamepadHID.html): A DualShock 4 controller connected to a desktop computer using the HID interface. Supported on macOS, Windows, UWP, and Linux.

*
[`DualShock4GampadiOS`](../api/UnityEngine.InputSystem.iOS.DualShock4GampadiOS.html): A DualShock 4 controller connected to an iOS Device via Bluetooth. Requires iOS 13 or higher.

[`DualShock4GamepadHID`](../api/UnityEngine.InputSystem.DualShock.DualShock4GamepadHID.html) implements additional, DualShock-specific functionality on top the general support in the [`Gamepad`](../api/UnityEngine.InputSystem.Gamepad.html) class:

* [`SetLightBarColor(Color)`](../api/UnityEngine.InputSystem.DualShock.DualShockGamepad.html#UnityEngine_InputSystem_DualShock_DualShockGamepad_SetLightBarColor_Color_): Lets you set the color of the light bar on the controller.
Expand All @@ -119,6 +122,9 @@ On other platforms Unity uses derived classes to represent Xbox controllers:

* [`XboxOneGampadMacOSWireless`](../api/UnityEngine.InputSystem.XInput.XboxOneGampadMacOSWireless.html): An Xbox One controller connected to a Mac via Bluetooth. Only the latest generation of Xbox One controllers supports Bluetooth. These controllers don't require any additional drivers in this scenario.

*
[`XboxOneGampadiOS`](../api/UnityEngine.InputSystem.iOS.XboxOneGampadiOS.html): An Xbox One controller connected to an iOS Device via Bluetooth. Requires iOS 13 or higher.

>__Note__:
>* XInput controllers on Mac currently require the installation of the [Xbox Controller Driver for macOS](https://github.com/360Controller/360Controller). Only USB connections are supported by this driver, no wireless dongles. However, the latest generation of Xbox One controllers natively supported Bluetooth. Macs natively support these controllers as HIDs without any additional drivers when connected via Bluetooth.
>* Unity supports Xbox controllers on WebGL in some browser and OS configurations, but treats them as basic [`Gamepad`](../api/UnityEngine.InputSystem.Gamepad.html) or [`Joystick`](../api/UnityEngine.InputSystem.Joystick.html) Devices, and doesn't support Rumble or any other Xbox-specific functionality.
Expand Down
2 changes: 1 addition & 1 deletion Documentation~/QuickStartGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ The quickest way to get started in script is to read the current state directly

```CSharp
using UnityEngine;
using UnityEngine.Experimental.Input;
using UnityEngine.InputSystem;

public class MyPlayerScript : MonoBehaviour
{
Expand Down
6 changes: 3 additions & 3 deletions Documentation~/SupportedDevices.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ The following Devices are supported in a way that doesn't require specialized su
|Device|Windows|Mac|Linux|UWP|Android|iOS(6)|Xbox(7)|PS4(7)|Switch(7)|WebGL|
|------|-------|---|-----|---|-------|---|----|---|------|-----|
|Xbox 360 (4)|Yes|Yes (3)|Yes|Yes|No|No|Yes|No|No|Sometimes (2)|
|Xbox One|Yes (1)|Yes (3)|Yes (1)|Yes|Yes (1)|No|Yes|No|No|Sometimes (2)|
|PS4|Yes (5)|Yes (5)|Yes (5)|Yes (5)|Yes (5)|No|No|Yes|No|Sometimes (2)|
|Xbox One|Yes (1)|Yes (3)|Yes (1)|Yes|Yes (1)|Yes (6)|Yes|No|No|Sometimes (2)|
|PS4|Yes (5)|Yes (5)|Yes (5)|Yes (5)|Yes (5)|Yes (5, 6)|No|Yes|No|Sometimes (2)|
|Switch|Yes|Yes|Yes|Yes|No|No|No|No|Yes|Sometimes (2)|

>__Notes__:
Expand All @@ -35,7 +35,7 @@ The following Devices are supported in a way that doesn't require specialized su
>3. XInput controllers on Mac currently require the installation of the [Xbox Controller Driver for macOS](https://github.com/360Controller/360Controller). Only USB connections are supported by that driver, no wireless dongles. However, the latest generation of Xbox One controllers natively support Bluetooth, and are natively supported on Macs as HIDs without any additional drivers when connected via Bluetooth.
>4. This includes any XInput-compatible Device.
>5. Unity doesn't support the gyro or accelerometer on PS4 controllers on platforms other than the PlayStation 4 console at the moment. Also, Unity doesn't support the *DualShock 4 USB Wireless Adaptor*.
>6. Unity supports Mfi certified controllers on iOS.
>6. Unity supports Mfi certified controllers on iOS. Xbox One and PS4 controllers are only supported on iOS 13 or higher.
>7. Consoles are supported using separate packages. You need to install these packages in your Project to enable console support.
### WebGL
Expand Down
2 changes: 2 additions & 0 deletions InputSystem/Actions/Composites/ButtonWithOneModifier.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using UnityEngine.InputSystem.Layouts;

////TODO: generalize the WithModifier composites so that they work with any kind of control, not just buttons

namespace UnityEngine.InputSystem.Composites
{
/// <summary>
Expand Down
1 change: 1 addition & 0 deletions InputSystem/Actions/InputActionMap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,7 @@ public InputAction this[string actionNameOrId]
}
}

////REVIEW: inconsistent naming; elsewhere we use "onActionTriggered" (which in turn is inconsistent with InputAction.started etc)
/// <summary>
/// Add or remove a callback that is triggered when an action in the map changes its <see cref="InputActionPhase">
/// phase</see>.
Expand Down
4 changes: 2 additions & 2 deletions InputSystem/Actions/InputBindingResolver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -497,8 +497,8 @@ public unsafe void AddActionMap(InputActionMap map)
}
Debug.Assert(bindingStartIndexForAction < ushort.MaxValue, "Binding start index on action exceeds limit");
Debug.Assert(bindingCountForAction < ushort.MaxValue, "Binding count on action exceeds limit");
newMemory.actionBindingIndicesAndCounts[i * 2] = (ushort)bindingStartIndexForAction;
newMemory.actionBindingIndicesAndCounts[i * 2 + 1] = (ushort)bindingCountForAction;
newMemory.actionBindingIndicesAndCounts[actionIndex * 2] = (ushort)bindingStartIndexForAction;
newMemory.actionBindingIndicesAndCounts[actionIndex * 2 + 1] = (ushort)bindingCountForAction;

// See if we may need conflict resolution on this action. Never needed for pass-through actions.
// Otherwise, if we have more than one bound control or have several bindings and one of them
Expand Down
2 changes: 2 additions & 0 deletions InputSystem/Controls/AnyKeyControl.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using UnityEngine.InputSystem.Layouts;
using UnityEngine.InputSystem.LowLevel;

////REVIEW: generalize this to AnyButton and add to more devices?

namespace UnityEngine.InputSystem.Controls
{
/// <summary>
Expand Down
59 changes: 49 additions & 10 deletions InputSystem/Controls/InputControlLayout.cs
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,24 @@ private enum Flags

public bool isControlLayout => !isDeviceLayout;

/// <summary>
/// Whether the layout is applies overrides to other layouts instead of
/// defining a layout by itself.
/// </summary>
/// <value>True if the layout acts as an override.</value>
/// <seealso cref="InputSystem.RegisterLayoutOverride"/>
public bool isOverride
{
get => (m_Flags & Flags.IsOverride) != 0;
internal set
{
if (value)
m_Flags |= Flags.IsOverride;
else
m_Flags &= ~Flags.IsOverride;
}
}

public bool isGenericTypeOfDevice
{
get => (m_Flags & Flags.IsGenericTypeOfDevice) != 0;
Expand Down Expand Up @@ -892,6 +910,7 @@ private enum Flags
{
IsGenericTypeOfDevice = 1 << 0,
HideInUI = 1 << 1,
IsOverride = 1 << 2,
}

private InputControlLayout(string name, Type type)
Expand Down Expand Up @@ -1736,6 +1755,7 @@ public struct LayoutMatcher
public Dictionary<InternedString, Func<InputControlLayout>> layoutBuilders;
public Dictionary<InternedString, InternedString> baseLayoutTable;
public Dictionary<InternedString, InternedString[]> layoutOverrides;
public HashSet<InternedString> layoutOverrideNames;
////TODO: find a smarter approach that doesn't require linearly scanning through all matchers
//// (also ideally shouldn't be a List but with Collection being a struct and given how it's
//// stored by InputManager.m_Layouts and in s_Layouts; we can't make it a plain array)
Expand All @@ -1748,6 +1768,7 @@ public void Allocate()
layoutBuilders = new Dictionary<InternedString, Func<InputControlLayout>>();
baseLayoutTable = new Dictionary<InternedString, InternedString>();
layoutOverrides = new Dictionary<InternedString, InternedString[]>();
layoutOverrideNames = new HashSet<InternedString>();
layoutMatchers = new List<LayoutMatcher>();
}

Expand Down Expand Up @@ -1819,20 +1840,25 @@ private InputControlLayout TryLoadLayoutInternal(InternedString name)

public InputControlLayout TryLoadLayout(InternedString name, Dictionary<InternedString, InputControlLayout> table = null)
{
var layout = TryLoadLayoutInternal(name);
// See if we have it cached.
if (table != null && table.TryGetValue(name, out var layout))
return layout;

layout = TryLoadLayoutInternal(name);
if (layout != null)
{
layout.m_Name = name;
if (table != null)
table[name] = layout;

if (layoutOverrideNames.Contains(name))
layout.isOverride = true;

// If the layout extends another layout, we need to merge the
// base layout into the final layout.
// NOTE: We go through the baseLayoutTable here instead of looking at
// the baseLayouts property so as to make this work for all types
// of layouts (FromType() does not set the property, for example).
var baseLayoutName = new InternedString();
if (baseLayoutTable.TryGetValue(name, out baseLayoutName))
if (!layout.isOverride && baseLayoutTable.TryGetValue(name, out baseLayoutName))
{
Debug.Assert(!baseLayoutName.IsEmpty());

Expand All @@ -1853,12 +1879,29 @@ public InputControlLayout TryLoadLayout(InternedString name, Dictionary<Interned
for (var i = 0; i < overrides.Length; ++i)
{
var overrideName = overrides[i];
var overrideLayout = TryLoadLayout(overrideName, table);
// NOTE: We do *NOT* pass `table` into TryLoadLayout here so that
// the override we load will not get cached. The reason is that
// we use MergeLayout which is destructive and thus should not
// end up in the table.
var overrideLayout = TryLoadLayout(overrideName);
overrideLayout.MergeLayout(layout);

// We're switching the layout we initially to the layout with
// the overrides applied. Make sure we get rid of information here
// from the override that we don't want to come through once the
// override is applied.
overrideLayout.m_BaseLayouts.Clear();
overrideLayout.isOverride = false;
overrideLayout.isGenericTypeOfDevice = layout.isGenericTypeOfDevice;
overrideLayout.m_Name = layout.name;

layout = overrideLayout;
layout.m_AppliedOverrides.Append(overrideName);
}
}

if (table != null)
table[name] = layout;
}

return layout;
Expand Down Expand Up @@ -2013,14 +2056,10 @@ public InputControlLayout FindOrLoadLayout(string name)
{
var internedName = new InternedString(name);

// See if we have it cached.
if (table != null && table.TryGetValue(internedName, out var layout))
return layout;

if (table == null)
table = new Dictionary<InternedString, InputControlLayout>();

layout = s_Layouts.TryLoadLayout(internedName, table);
var layout = s_Layouts.TryLoadLayout(internedName, table);
if (layout != null)
return layout;

Expand Down
19 changes: 10 additions & 9 deletions InputSystem/Controls/InputControlPath.cs
Original file line number Diff line number Diff line change
Expand Up @@ -322,16 +322,17 @@ public static string TryGetControlLayout(string path)

private static string FindControlLayoutRecursive(ref PathParser parser, string layoutName)
{
////TODO: add a static InputControlLayout.Cache instance that we look up layouts from and flush the cache every frame

// Load layout.
var layout = InputControlLayout.s_Layouts.TryLoadLayout(new InternedString(layoutName));
if (layout == null)
return null;
using (InputControlLayout.CacheRef())
{
// Load layout.
var layout = InputControlLayout.cache.FindOrLoadLayout(new InternedString(layoutName));
if (layout == null)
return null;

// Search for control layout. May have to jump to other layouts
// and search in them.
return FindControlLayoutRecursive(ref parser, layout);
// Search for control layout. May have to jump to other layouts
// and search in them.
return FindControlLayoutRecursive(ref parser, layout);
}
}

private static string FindControlLayoutRecursive(ref PathParser parser, InputControlLayout layout)
Expand Down
2 changes: 1 addition & 1 deletion InputSystem/Devices/Keyboard.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public unsafe struct KeyboardState : IInputStateTypeInfo
[InputControl(name = "leftAlt", displayName = "Left Alt", layout = "Key", usage = "Modifier", bit = (int)Key.LeftAlt)]
[InputControl(name = "rightAlt", displayName = "Right Alt", layout = "Key", usage = "Modifier", bit = (int)Key.RightAlt, alias = "AltGr")]
[InputControl(name = "leftCtrl", displayName = "Left Control", layout = "Key", usage = "Modifier", bit = (int)Key.LeftCtrl)]
[InputControl(name = "rightCtrl", displayName = "Rigth Control", layout = "Key", usage = "Modifier", bit = (int)Key.RightCtrl)]
[InputControl(name = "rightCtrl", displayName = "Right Control", layout = "Key", usage = "Modifier", bit = (int)Key.RightCtrl)]
[InputControl(name = "leftMeta", displayName = "Left System", layout = "Key", usage = "Modifier", bit = (int)Key.LeftMeta, aliases = new[] { "LeftWindows", "LeftApple", "LeftCommand" })]
[InputControl(name = "rightMeta", displayName = "Right System", layout = "Key", usage = "Modifier", bit = (int)Key.RightMeta, aliases = new[] { "RightWindows", "RightApple", "RightCommand" })]
[InputControl(name = "contextMenu", displayName = "Context Menu", layout = "Key", usage = "Modifier", bit = (int)Key.ContextMenu)]
Expand Down
37 changes: 37 additions & 0 deletions InputSystem/Devices/TrackedDevice.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
using UnityEngine.InputSystem.Controls;
using UnityEngine.InputSystem.Layouts;
using UnityEngine.Scripting;

namespace UnityEngine.InputSystem
{
/// <summary>
/// An input device that has its orientation and position in space tracked.
/// </summary>
[InputControlLayout(displayName = "Tracked Device", isGenericTypeOfDevice = true)]
[Preserve]
public class TrackedDevice : InputDevice
{
[InputControl(noisy = true)]
[Preserve]
public IntegerControl trackingState { get; private set; }
[InputControl(noisy = true)]
[Preserve]
public ButtonControl isTracked { get; private set; }
[InputControl(noisy = true)]
[Preserve]
public Vector3Control devicePosition { get; private set; }
[InputControl(noisy = true)]
[Preserve]
public QuaternionControl deviceRotation { get; private set; }

protected override void FinishSetup()
{
base.FinishSetup();

trackingState = GetChildControl<IntegerControl>("trackingState");
isTracked = GetChildControl<ButtonControl>("isTracked");
devicePosition = GetChildControl<Vector3Control>("devicePosition");
deviceRotation = GetChildControl<QuaternionControl>("deviceRotation");
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 447949e

Please sign in to comment.