Prune code.
This commit is contained in:
@@ -3,120 +3,6 @@ using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
|
||||
namespace Cryville.Common.Unity.Input {
|
||||
/*public class InputManager {
|
||||
int newId = 0;
|
||||
int GetNewId() {
|
||||
newId++;
|
||||
return newId;
|
||||
}
|
||||
PointerHandler ptrHandler;
|
||||
readonly Queue<PointerInfo> ptrEv = new Queue<PointerInfo>();
|
||||
readonly Dictionary<int, PointerInfo> ptr
|
||||
= new Dictionary<int, PointerInfo>();
|
||||
double originTime;
|
||||
void Callback(int id, PointerInfo info) {
|
||||
/*if (info.Phase != PointerPhase.Update)
|
||||
Logger.Log(
|
||||
"main", 0, "Input",
|
||||
"[{0}, p{1}] {2} {3} {4} at {5} (cs:{6}, ori:{7}, prs:{8})",
|
||||
info.EventTime, info.ProcessTime, info.Type,
|
||||
id, info.Phase, info.Position,
|
||||
info.ContactSize, info.Orientation, info.Pressure
|
||||
);*
|
||||
lock (ptrEv) {
|
||||
ptrEv.Enqueue(info);
|
||||
ptr[id] = info;
|
||||
}
|
||||
}
|
||||
public void Init() {
|
||||
try {
|
||||
if (Environment.OSVersion.Platform == PlatformID.Win32NT) {
|
||||
if (WindowsPointerHandler.IsSupported()) {
|
||||
ptrHandler = new WindowsPointerHandler(true, GetNewId, Callback);
|
||||
Logger.Log("main", 1, "Input", "Initialized windows pointer handler");
|
||||
}
|
||||
else if (UnityTouchHandler.IsSupported()) {
|
||||
ptrHandler = new UnityTouchHandler(GetNewId, Callback);
|
||||
Logger.Log("main", 1, "Input", "Initialized multi-platform pointer handler");
|
||||
}
|
||||
}
|
||||
else if (Application.platform == RuntimePlatform.Android) {
|
||||
/*if (AndroidTouchHandler.IsSupported()) {
|
||||
|
||||
}
|
||||
else*
|
||||
if (UnityTouchHandler.IsSupported()) {
|
||||
ptrHandler = new UnityTouchHandler(GetNewId, Callback);
|
||||
Logger.Log("main", 1, "Input", "Initialized multi-platform pointer handler");
|
||||
}
|
||||
}
|
||||
else {
|
||||
/*if (UnityPointerHandler.IsSupported()) {
|
||||
enableUnityTouch();
|
||||
}*
|
||||
}
|
||||
}
|
||||
catch (Exception ex) {
|
||||
Logger.Log("main", 4, "Input", "An error occured while initializing pointer handler:\n{0}", ex);
|
||||
}
|
||||
if (ptrHandler == null) Logger.Log("main", 3, "Input", "Pointer input is not supported on this device");
|
||||
}
|
||||
public void Activate() {
|
||||
if (ptrHandler != null) ptrHandler.Activate();
|
||||
}
|
||||
public void Deactivate() {
|
||||
if (ptrHandler != null) ptrHandler.Deactivate();
|
||||
ptr.Clear(); ptrEv.Clear();
|
||||
}
|
||||
public void Dispose() {
|
||||
ptrHandler.Dispose();
|
||||
}
|
||||
public void EnumeratePtrEvents(Action<PointerInfo> callback) {
|
||||
lock (ptrEv) {
|
||||
while (ptrEv.Count > 0) {
|
||||
var raw = ptrEv.Dequeue();
|
||||
raw.OffsetTime(originTime);
|
||||
callback(raw);
|
||||
}
|
||||
}
|
||||
}
|
||||
public void EnumeratePointers(Action<PointerInfo> callback) {
|
||||
lock (ptrEv) {
|
||||
var upid = new List<int>();
|
||||
var rmid = new List<int>();
|
||||
foreach (var p in ptr) {
|
||||
var raw = p.Value;
|
||||
if (raw.Phase == PointerPhase.Stationary)
|
||||
raw.EventTime = raw.ProcessTime = Time;
|
||||
else raw.OffsetTime(originTime);
|
||||
callback(raw);
|
||||
if (raw.Phase == PointerPhase.Begin || raw.Phase == PointerPhase.Update)
|
||||
upid.Add(p.Key);
|
||||
if (raw.Phase == PointerPhase.End || raw.Phase == PointerPhase.Cancel)
|
||||
rmid.Add(p.Key);
|
||||
}
|
||||
foreach (var i in upid) {
|
||||
var p = ptr[i];
|
||||
p.Phase = PointerPhase.Stationary;
|
||||
ptr[i] = p;
|
||||
}
|
||||
foreach (var i in rmid) ptr.Remove(i);
|
||||
// Logger.Log("main", 0, "Input", "Ptr count {0}", ptr.Count);
|
||||
}
|
||||
}
|
||||
public double Time {
|
||||
get {
|
||||
if (ptrHandler != null) return ptrHandler.GetCurrentTimestamp() - originTime;
|
||||
else return 0;
|
||||
}
|
||||
}
|
||||
public void SyncTime(double t) {
|
||||
if (ptrHandler != null) {
|
||||
originTime = ptrHandler.GetCurrentTimestamp() - t;
|
||||
Logger.Log("main", 0, "Input", "Sync time {0}", originTime);
|
||||
}
|
||||
}
|
||||
}*/
|
||||
public class InputManager {
|
||||
static readonly List<Type> HandlerRegistries = new List<Type> {
|
||||
typeof(WindowsPointerHandler),
|
||||
|
@@ -1,57 +0,0 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Cryville.Common.Unity.Input {
|
||||
#if false
|
||||
[Obsolete]
|
||||
public abstract class PointerHandler {
|
||||
protected Func<int> newIdCallback;
|
||||
protected Action<int, PointerInfo> callback;
|
||||
|
||||
public PointerHandler(Func<int> newIdCallback, Action<int, PointerInfo> callback) {
|
||||
this.newIdCallback = newIdCallback;
|
||||
this.callback = callback;
|
||||
}
|
||||
|
||||
public abstract void Activate();
|
||||
public abstract void Deactivate();
|
||||
|
||||
public abstract void Dispose();
|
||||
|
||||
public abstract double GetCurrentTimestamp();
|
||||
}
|
||||
|
||||
[Obsolete]
|
||||
public struct PointerInfo {
|
||||
public int Id;
|
||||
public double EventTime;
|
||||
public double ProcessTime;
|
||||
public PointerPhase Phase;
|
||||
public PointerType Type;
|
||||
public Vector2 Position;
|
||||
public Vector2? ContactSize;
|
||||
public uint? Orientation;
|
||||
public uint? Pressure;
|
||||
public double Time {
|
||||
// get { return EventTime == 0 ? ProcessTime : EventTime; }
|
||||
get { return ProcessTime; }
|
||||
}
|
||||
public void OffsetTime(double originTime) {
|
||||
if (EventTime != 0) EventTime -= originTime;
|
||||
if (ProcessTime != 0) ProcessTime -= originTime;
|
||||
}
|
||||
}
|
||||
|
||||
[Obsolete]
|
||||
public enum PointerPhase {
|
||||
Begin = 0,
|
||||
Update = 2, Stationary = 3,
|
||||
End = 4, Cancel = 5
|
||||
}
|
||||
|
||||
[Obsolete]
|
||||
public enum PointerType {
|
||||
Unknown, Mouse, Touch, Pen, TouchPad
|
||||
}
|
||||
#endif
|
||||
}
|
@@ -1,12 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6f0a4eae2ebff4d4d93e2f9fe31c1383
|
||||
timeCreated: 1611272693
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -4,8 +4,6 @@ using UnityEngine;
|
||||
#if UNITY_5_4_OR_NEWER
|
||||
using UnityEngine.Networking;
|
||||
using UnityEngine.Rendering;
|
||||
using static UnityEngine.Networking.UnityWebRequest;
|
||||
|
||||
#endif
|
||||
|
||||
namespace Cryville.Common.Unity {
|
||||
|
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.ComponentModel;
|
||||
using System.Reflection;
|
||||
using UnityEngine;
|
||||
|
Reference in New Issue
Block a user