This commit is contained in:
2026-04-30 20:58:59 +07:00
parent 8e524790d3
commit 30d914d3a5
604 changed files with 98040 additions and 531 deletions

View File

@@ -0,0 +1,44 @@
using UnityEngine;
using System.Collections.Generic;
namespace Hallucinate.UI
{
public static class MouseMetricsHelper
{
private static int _reportCount = 0;
private static float _timer = 0f;
private static int _lastPollingRate = 0;
private static float _lastLatency = 0f;
private static Vector2 _lastMousePos;
public static (int pollingRate, float latencyMs) GetMetrics()
{
Update();
return (_lastPollingRate, _lastLatency);
}
private static void Update()
{
_timer += Time.unscaledDeltaTime;
// Count "reports" based on position changes (simulated polling rate)
Vector2 currentPos = Input.mousePosition;
if (currentPos != _lastMousePos)
{
_reportCount++;
_lastMousePos = currentPos;
}
if (_timer >= 1f)
{
_lastPollingRate = (int)(_reportCount / _timer);
_reportCount = 0;
_timer = 0f;
}
// Dummy latency simulation (Input System doesn't expose raw hardware latency easily)
// In a real scenario, this would involve timestamping HID reports
_lastLatency = (1.0f / (Screen.currentResolution.refreshRateRatio.value > 0 ? (float)Screen.currentResolution.refreshRateRatio.value : 60f)) * 1000f;
}
}
}