Instrument Android composition input for native diagnosis
This commit is contained in:
@@ -33,6 +33,8 @@ namespace MagnetismHeroes.UnityRuntime.Interaction
|
||||
private float _pinchDistance;
|
||||
private int _fingerId = -1;
|
||||
private bool _waitForAllTouchesReleased;
|
||||
private int _diagnosticEvents;
|
||||
private bool _diagnosticReady;
|
||||
private int _pinchFirstId = -1, _pinchSecondId = -1;
|
||||
private readonly struct TouchContact
|
||||
{
|
||||
@@ -162,6 +164,7 @@ namespace MagnetismHeroes.UnityRuntime.Interaction
|
||||
|
||||
private void RecordTouch(Finger finger)
|
||||
{
|
||||
if (AcceptInput && _diagnosticEvents++ < 16) Debug.Log($"[CompositionInput] callback {finger.lastTouch.phase} screen={finger.screen?.name} current={Touchscreen.current?.name} gesture={_gesture}");
|
||||
if (!AcceptInput || finger.screen != Touchscreen.current) return;
|
||||
// Copy each official history callback before later events overwrite the native touch slot.
|
||||
var touch = finger.lastTouch;
|
||||
@@ -228,6 +231,7 @@ namespace MagnetismHeroes.UnityRuntime.Interaction
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (AcceptInput && !_diagnosticReady) { _diagnosticReady = true; Debug.Log($"[CompositionInput] ready enabled={enabled} touchscreen={Touchscreen.current?.name} enhanced={EnhancedTouchSupport.enabled}"); }
|
||||
if (!AcceptInput) { _touchEvents.Clear(); _touches.Clear(); return; }
|
||||
bool hadTouches = _touchEvents.Count > 0, suppressRestOfFrame = false;
|
||||
while (_touchEvents.Count > 0)
|
||||
@@ -255,6 +259,7 @@ namespace MagnetismHeroes.UnityRuntime.Interaction
|
||||
}
|
||||
private void OnEnable()
|
||||
{
|
||||
Debug.Log("[CompositionInput] subscribing");
|
||||
EnhancedTouchSupport.Enable();
|
||||
UnityEngine.InputSystem.EnhancedTouch.Touch.onFingerDown += RecordTouch;
|
||||
UnityEngine.InputSystem.EnhancedTouch.Touch.onFingerMove += RecordTouch;
|
||||
|
||||
@@ -12,8 +12,10 @@ function Varint([int]$Value) {
|
||||
}
|
||||
$message=[Collections.Generic.List[byte]]::new()
|
||||
for ($offset=0; $offset -lt $Contacts.Count; $offset+=4) {
|
||||
# AVD touch injection uses portrait physical coordinates even when the app is landscape-left.
|
||||
$fields=@(1080-$Contacts[$offset+1],$Contacts[$offset],$Contacts[$offset+2],$Contacts[$offset+3])
|
||||
$touch=[Collections.Generic.List[byte]]::new()
|
||||
for ($field=0; $field -lt 4; $field++) { $touch.Add([byte](8*($field+1))); $touch.AddRange([byte[]](Varint $Contacts[$offset+$field])) }
|
||||
for ($field=0; $field -lt 4; $field++) { $touch.Add([byte](8*($field+1))); $touch.AddRange([byte[]](Varint $fields[$field])) }
|
||||
$message.Add(10); $message.AddRange([byte[]](Varint $touch.Count)); $message.AddRange($touch.ToArray())
|
||||
}
|
||||
$frame=[byte[]]::new($message.Count+5); $frame[1]=($message.Count -shr 24) -band 255; $frame[2]=($message.Count -shr 16) -band 255
|
||||
|
||||
Reference in New Issue
Block a user