Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions Packages/com.unity.inputsystem/InputSystem/IInputRuntime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<PlayModeStateChange> onPlayModeChanged { get; set; }
Action onProjectChange { get; set; }
Expand Down
4 changes: 4 additions & 0 deletions Packages/com.unity.inputsystem/InputSystem/InputManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Comment on lines +2534 to +2535

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see that logging the input action is bracketed by the new define UNITY_INPUT_SYSTEM_SUPPORTS_INSIGHTS. Should this also be conditional on it?

// Add it.
var markAsRemoved = false;
try
Expand Down Expand Up @@ -3597,6 +3599,8 @@ private unsafe void OnUpdate(InputUpdateType updateType, ref InputEventBuffer ev
{
RemoveDevice(device, keepOnListOfAvailableDevices: false);

m_Runtime.LogDeviceDisconnectedInsight(device.description);

Comment on lines +3602 to +3603

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar: should this be #if UNITY_INPUT_SYSTEM_SUPPORTS_INSIGHTS?

// If it's a native device with a description, put it on the list of disconnected
// devices.
if (device.native && !device.description.empty)
Expand Down
25 changes: 24 additions & 1 deletion Packages/com.unity.inputsystem/InputSystem/NativeInputRuntime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
using UnityEngine.Analytics;
using UnityEngine.InputSystem.Utilities;
using UnityEngineInternal.Input;
using UnityEngine.InputSystem.Layouts;


#if UNITY_EDITOR
using System.Reflection;
Expand Down Expand Up @@ -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());
Copy link

@rohit-moni rohit-moni Jan 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not too familiar with input actions, I'm worried that enabling this will add a string allocation to every input action, resulting in two potential issues: performance degradation of all inputs (allocation perf) and frequent / large garbage collection (after many disparate allocations). Can this be cached? Do we have the action type string already stored somewhere? Is there another reason that invalidates the concern?

#endif
}

#endif // UNITY_ANALYTICS || UNITY_EDITOR
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will have to be changed to whatever is the actual Unity version we happen to release Input insights in. We will know that once the native PR lands. Then we will change this for every backport

"define": "UNITY_INPUT_SYSTEM_SUPPORTS_INSIGHTS"
}
],
"noEngineReferences": false
}
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might want to store these in harness in case you want to test it in the package

{
}

public void LogDeviceDisconnectedInsight(InputDeviceDescription description)
{
}

public void LogInputActionInsight(InputAction action)
{
}

#endif // UNITY_ANALYTICS || UNITY_EDITOR
}
}
Loading