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),
|
||||
|
Reference in New Issue
Block a user