Update Cryville.Input.

This commit is contained in:
2023-11-20 20:23:33 +08:00
parent 30e9f091d7
commit 4f12e4816f
8 changed files with 58 additions and 79 deletions

View File

@@ -1,3 +1,4 @@
using Cryville.Common.Interop;
using Cryville.Common.Logging;
using System;
@@ -5,7 +6,7 @@ namespace Cryville.Input.Unity.Android {
/// <summary>
/// An <see cref="InputHandler" /> that handles Android touch input.
/// </summary>
public class AndroidTouchHandler : AndroidInputHandler {
public class AndroidTouchHandler : AndroidInputHandler<AndroidTouchHandler> {
/// <summary>
/// Creates an instance of the <see cref="AndroidTouchHandler" /> class.
/// </summary>
@@ -39,16 +40,19 @@ namespace Cryville.Input.Unity.Android {
return JavaStaticMethods.SystemClock_uptimeMillis() / 1000.0;
}
internal override void OnFeed(int id, int action, long time, float x, float y, float z, float w) {
private protected override AndroidInputProxy_Callback Callback { get { return OnFeed; } }
[MonoPInvokeCallback]
static void OnFeed(int id, int action, long time, float x, float y, float z, float w) {
try {
double timeSecs = time / 1000.0;
if (action == -2) {
Batch(timeSecs);
Instance.Batch(timeSecs);
}
else {
Feed(0, id, new InputFrame(timeSecs, new InputVector(x, y)));
Instance.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));
Instance.Feed(0, id, new InputFrame(timeSecs));
}
}
catch (Exception ex) {