Update Cryville.Input. Fix cleanup logic for input proxy.

This commit is contained in:
2023-05-07 21:30:00 +08:00
parent dad399facf
commit b4984c0b3a
10 changed files with 119 additions and 27 deletions

View File

@@ -42,6 +42,7 @@ namespace Cryville.Input.Unity.Android {
try {
double timeSecs = time / 1e9;
Feed(0, id, new InputFrame(timeSecs, new InputVector(x, y, z, w)));
Batch(timeSecs);
}
catch (Exception ex) {
Logger.Log("main", 4, "Input", "An error occurred while handling an Android sensor event: {0}", ex);

View File

@@ -42,9 +42,14 @@ namespace Cryville.Input.Unity.Android {
internal override void OnFeed(int id, int action, long time, float x, float y, float z, float w) {
try {
double timeSecs = time / 1000.0;
Feed(0, id, new InputFrame(timeSecs, new InputVector(x, y)));
if (action == 1 /*ACTION_UP*/ || action == 3 /*ACTION_CANCEL*/ || action == 6 /*ACTION_POINTER_UP*/)
Feed(0, id, new InputFrame(timeSecs));
if (action == -2) {
Batch(timeSecs);
}
else {
Feed(0, id, new InputFrame(timeSecs, new InputVector(x, y)));
if (action == 1 /*ACTION_UP*/ || action == 3 /*ACTION_CANCEL*/ || action == 6 /*ACTION_POINTER_UP*/)
Feed(0, id, new InputFrame(timeSecs));
}
}
catch (Exception ex) {
Logger.Log("main", 4, "Input", "An error occurred while handling an Android touch event: {0}", ex);

View File

@@ -44,6 +44,7 @@ public final class TouchProxy extends Proxy implements View.OnTouchListener {
feed(id, action, time, x, y);
}
}
feed(0, -2, time);
return false;
}
}