diff --git a/Packages/com.unity.inputsystem/InputSystem/Actions/InputActionState.cs b/Packages/com.unity.inputsystem/InputSystem/Actions/InputActionState.cs index 82d6fe1082..094a177104 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Actions/InputActionState.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Actions/InputActionState.cs @@ -6,7 +6,6 @@ using Unity.Collections.LowLevel.Unsafe; using UnityEngine.InputSystem.Controls; using UnityEngine.InputSystem.LowLevel; -using Unity.Profiling; using UnityEngine.InputSystem.Utilities; using ProfilerMarker = Unity.Profiling.ProfilerMarker; @@ -957,6 +956,14 @@ public void EnableAllActions(InputActionMap map) NotifyListenersOfActionChange(InputActionChange.ActionEnabled, map.m_SingletonAction); else NotifyListenersOfActionChange(InputActionChange.ActionMapEnabled, map); + +#if UNITY_INPUT_SYSTEM_SUPPORTS_INSIGHTS + // also report all actions to insights + foreach (var inputAction in map.actions) + { + InputSystem.s_Manager.m_Runtime.LogInputActionInsight( inputAction ); + } +#endif } private void EnableControls(InputActionMap map) diff --git a/Packages/com.unity.inputsystem/InputSystem/IInputRuntime.cs b/Packages/com.unity.inputsystem/InputSystem/IInputRuntime.cs index f7851f12f0..12381093d5 100644 --- a/Packages/com.unity.inputsystem/InputSystem/IInputRuntime.cs +++ b/Packages/com.unity.inputsystem/InputSystem/IInputRuntime.cs @@ -187,6 +187,10 @@ internal unsafe interface IInputRuntime void SendAnalytic(InputAnalytics.IInputAnalytic analytic); #endif // UNITY_ANALYTICS || UNITY_EDITOR + void LogDeviceConnectedInsight(InputDeviceDescription description); + void LogDeviceDisconnectedInsight(InputDeviceDescription description); + void LogInputActionInsight(InputAction action); + #if UNITY_EDITOR Action onPlayModeChanged { get; set; } Action onProjectChange { get; set; } diff --git a/Packages/com.unity.inputsystem/InputSystem/InputManager.cs b/Packages/com.unity.inputsystem/InputSystem/InputManager.cs index 1edf9ad90f..96aaac69f9 100644 --- a/Packages/com.unity.inputsystem/InputSystem/InputManager.cs +++ b/Packages/com.unity.inputsystem/InputSystem/InputManager.cs @@ -2531,6 +2531,8 @@ private void OnNativeDeviceDiscovered(int deviceId, string deviceDescriptor) // Parse description, if need be. var description = device?.description ?? InputDeviceDescription.FromJson(deviceDescriptor); + m_Runtime.LogDeviceConnectedInsight(description); + // Add it. var markAsRemoved = false; try @@ -3597,6 +3599,8 @@ private unsafe void OnUpdate(InputUpdateType updateType, ref InputEventBuffer ev { RemoveDevice(device, keepOnListOfAvailableDevices: false); + m_Runtime.LogDeviceDisconnectedInsight(device.description); + // If it's a native device with a description, put it on the list of disconnected // devices. if (device.native && !device.description.empty) diff --git a/Packages/com.unity.inputsystem/InputSystem/NativeInputRuntime.cs b/Packages/com.unity.inputsystem/InputSystem/NativeInputRuntime.cs index 6ee7e59f1f..4070b22ef3 100644 --- a/Packages/com.unity.inputsystem/InputSystem/NativeInputRuntime.cs +++ b/Packages/com.unity.inputsystem/InputSystem/NativeInputRuntime.cs @@ -4,6 +4,8 @@ using UnityEngine.Analytics; using UnityEngine.InputSystem.Utilities; using UnityEngineInternal.Input; +using UnityEngine.InputSystem.Layouts; + #if UNITY_EDITOR using System.Reflection; @@ -423,6 +425,27 @@ public void SendAnalytic(InputAnalytics.IInputAnalytic analytic) #endif //ENABLE_CLOUD_SERVICES_ANALYTICS } - #endif // UNITY_ANALYTICS || UNITY_EDITOR + public void LogDeviceConnectedInsight(InputDeviceDescription description) + { +#if UNITY_INPUT_SYSTEM_SUPPORTS_INSIGHTS && !UNITY_EDITOR + NativeInputSystem.LogDeviceConnectedInsight(description.serial, description.product, description.interfaceName, description.version); +#endif + } + + public void LogDeviceDisconnectedInsight(InputDeviceDescription description) + { +#if UNITY_INPUT_SYSTEM_SUPPORTS_INSIGHTS && !UNITY_EDITOR + NativeInputSystem.LogDeviceDisconnectedInsight(description.serial); +#endif + } + + public void LogInputActionInsight(InputAction action) + { +#if UNITY_INPUT_SYSTEM_SUPPORTS_INSIGHTS && !UNITY_EDITOR + NativeInputSystem.LogInputActionInsight(action.name, action.type.ToString()); +#endif + } + +#endif // UNITY_ANALYTICS || UNITY_EDITOR } } diff --git a/Packages/com.unity.inputsystem/InputSystem/Unity.InputSystem.asmdef b/Packages/com.unity.inputsystem/InputSystem/Unity.InputSystem.asmdef index d551736cd1..3d9188f7f1 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Unity.InputSystem.asmdef +++ b/Packages/com.unity.inputsystem/InputSystem/Unity.InputSystem.asmdef @@ -92,11 +92,16 @@ "expression": "6000.3.0a6", "define": "UNITY_INPUT_SYSTEM_PLATFORM_POLLING_FREQUENCY" }, - { - "name": "Unity", + { + "name": "Unity", "expression": "6000.4.0a4", "define": "UNITY_INPUTSYSTEM_SUPPORTS_MOUSE_SCRIPT_EVENTS" - } + }, + { + "name": "Unity", + "expression": "6000.5.0a5", + "define": "UNITY_INPUT_SYSTEM_SUPPORTS_INSIGHTS" + } ], "noEngineReferences": false } diff --git a/Packages/com.unity.inputsystem/Tests/TestFixture/InputTestRuntime.cs b/Packages/com.unity.inputsystem/Tests/TestFixture/InputTestRuntime.cs index 0042954c86..bff1fc4d18 100644 --- a/Packages/com.unity.inputsystem/Tests/TestFixture/InputTestRuntime.cs +++ b/Packages/com.unity.inputsystem/Tests/TestFixture/InputTestRuntime.cs @@ -481,6 +481,19 @@ public void SendAnalytic(InputAnalytics.IInputAnalytic analytic) #endif // UNITY_2023_2_OR_NEWER } - #endif // UNITY_ANALYTICS || UNITY_EDITOR + // We don't want to populate Insights from within tests, even when running them in players + public void LogDeviceConnectedInsight(InputDeviceDescription description) + { + } + + public void LogDeviceDisconnectedInsight(InputDeviceDescription description) + { + } + + public void LogInputActionInsight(InputAction action) + { + } + +#endif // UNITY_ANALYTICS || UNITY_EDITOR } }