private void RaiseInputsUpdatedEvent(InputUpdateEventArgs e) { EventHandler <InputUpdateEventArgs> handler; lock (UpdateInputsLock) { handler = InputUpdated; } if (handler != null) { handler(this, e); } }
private void RaiseInputsUpdatedEvent(InputUpdateEventArgs e) { EventHandler<InputUpdateEventArgs> handler; lock (UpdateInputsLock) { handler = InputUpdated; } if (handler != null) { handler(this, e); } }
private void OnInputsUpdateEventHandler(object sender, InputUpdateEventArgs e) { Profiler.BeginSample("---ClusterManager : Clusters Update Total"); String clusterHash; ResetClustersBuffers(); Profiler.BeginSample("------ClusterManager : Cancelled Buffer"); foreach (int touchId in InternalTouches.CancelledTouchBuffer) { clusterHash = GetClusterIdFromTouchPoint(touchId); if (clusterHash != null) { //Is a cluster with more than one point if (clusters[clusterHash].PointsIds.Count > 1) { Cluster updatedCluster = clusters[clusterHash].RemovePoint(touchId); //Update Current state Clusters clusters.Remove(clusterHash); clusters.Add(updatedCluster.Hash, updatedCluster); //If State is Cancelled update CancelledCluster Buffer if (updatedCluster.State == ClusterState.Cancelled) { IdentifiedClustersCancelled.Remove(updatedCluster.CancelledClusterHash); IdentifiedClustersCancelled.Add(updatedCluster.CancelledClusterHash, updatedCluster); } } //Is a cluster with only one point else { //Update CancelledClusterBuffer Cluster cluster = clusters[clusterHash].RemovePoint(touchId); if (cluster.State == ClusterState.Cancelled) { IdentifiedClustersCancelled.Remove(cluster.CancelledClusterHash); IdentifiedClustersCancelled.Add(cluster.CancelledClusterHash, cluster); } //Remove cluster from current Clusters clusters.Remove(clusterHash); } } //Remove touch from fingers touch list } Profiler.EndSample(); Profiler.BeginSample("------ClusterManager : Moved Buffer"); foreach (int touchId in InternalTouches.MovedTouchBuffer) { clusterHash = GetClusterIdFromTouchPoint(touchId); if (clusterHash != null) { Cluster[] updatedCluster = clusters[clusterHash].UpdatePoint(touchId); clusters.Remove(clusterHash); if (updatedCluster[0].Points.Count != 0) { clusters.Add(updatedCluster[0].Hash, updatedCluster[0]); if (updatedCluster[0].State == ClusterState.Cancelled) { IdentifiedClustersCancelled.Remove(updatedCluster[0].CancelledClusterHash); IdentifiedClustersCancelled.Add(updatedCluster[0].CancelledClusterHash, updatedCluster[0]); } } //Its the case where a previous cluster gets separeted into two if (updatedCluster[1] != null) clusters.Add(updatedCluster[1].Hash, updatedCluster[1]); } else { Cluster c = new Cluster(InternalTouches.List[touchId]); clusters.Add(c.Hash, c); } } Profiler.EndSample(); foreach (int touchId in InternalTouches.BaganTouhBuffer) { Cluster cl = new Cluster(InternalTouches.List[touchId]); clusters.Add(cl.Hash, cl); } if (InternalTouches.CancelledTouchBuffer.Count > 0 || InternalTouches.MovedTouchBuffer.Count > 0 || InternalTouches.BaganTouhBuffer.Count > 0) { Profiler.BeginSample("------ClusterManager : Clusters Update"); UpdateClusters(); Profiler.EndSample(); CheckClustersUpdated(); if (ClustersToIdentify.Count > 0 || IdentifiedClustersMoved.Count > 0 || IdentifiedClustersCancelled.Count > 0) RaiseClustersUpdateEvent(new ClustersUpdateEventArgs(ClustersToIdentify, IdentifiedClustersMoved, IdentifiedClustersCancelled.Values.ToList())); //Get points which are touches and not markers InputManager.SetFingersCancelled(InternalTouches.CancelledTouchBuffer.ToArray()); foreach (Cluster c in clusters.Values) { if (c.State == ClusterState.Invalid || c.State == ClusterState.Cancelled) { //This cluster is only made of finger touch points foreach (TouchInput touch in c.Points.Values) { InputManager.AddFingerTouch(touch); } } } } Profiler.EndSample(); }
private void OnInputsUpdateEventHandler(object sender, InputUpdateEventArgs e) { Profiler.BeginSample("---ClusterManager : Clusters Update Total"); String clusterHash; ResetClustersBuffers(); Profiler.BeginSample("------ClusterManager : Cancelled Buffer"); foreach (int touchId in InternalTouches.CancelledTouchBuffer) { clusterHash = GetClusterIdFromTouchPoint(touchId); if (clusterHash != null) { //Is a cluster with more than one point if (clusters[clusterHash].PointsIds.Count > 1) { Cluster updatedCluster = clusters[clusterHash].RemovePoint(touchId); //Update Current state Clusters clusters.Remove(clusterHash); clusters.Add(updatedCluster.Hash, updatedCluster); //If State is Cancelled update CancelledCluster Buffer if (updatedCluster.State == ClusterState.Cancelled) { IdentifiedClustersCancelled.Remove(updatedCluster.CancelledClusterHash); IdentifiedClustersCancelled.Add(updatedCluster.CancelledClusterHash, updatedCluster); } } //Is a cluster with only one point else { //Update CancelledClusterBuffer Cluster cluster = clusters[clusterHash].RemovePoint(touchId); if (cluster.State == ClusterState.Cancelled) { IdentifiedClustersCancelled.Remove(cluster.CancelledClusterHash); IdentifiedClustersCancelled.Add(cluster.CancelledClusterHash, cluster); } //Remove cluster from current Clusters clusters.Remove(clusterHash); } } //Remove touch from fingers touch list } Profiler.EndSample(); Profiler.BeginSample("------ClusterManager : Moved Buffer"); foreach (int touchId in InternalTouches.MovedTouchBuffer) { clusterHash = GetClusterIdFromTouchPoint(touchId); if (clusterHash != null) { Cluster[] updatedCluster = clusters[clusterHash].UpdatePoint(touchId); clusters.Remove(clusterHash); if (updatedCluster[0].Points.Count != 0) { clusters.Add(updatedCluster[0].Hash, updatedCluster[0]); if (updatedCluster[0].State == ClusterState.Cancelled) { IdentifiedClustersCancelled.Remove(updatedCluster[0].CancelledClusterHash); IdentifiedClustersCancelled.Add(updatedCluster[0].CancelledClusterHash, updatedCluster[0]); } } //Its the case where a previous cluster gets separeted into two if (updatedCluster[1] != null) { clusters.Add(updatedCluster[1].Hash, updatedCluster[1]); } } else { Cluster c = new Cluster(InternalTouches.List[touchId]); clusters.Add(c.Hash, c); } } Profiler.EndSample(); foreach (int touchId in InternalTouches.BaganTouhBuffer) { Cluster cl = new Cluster(InternalTouches.List[touchId]); clusters.Add(cl.Hash, cl); } if (InternalTouches.CancelledTouchBuffer.Count > 0 || InternalTouches.MovedTouchBuffer.Count > 0 || InternalTouches.BaganTouhBuffer.Count > 0) { Profiler.BeginSample("------ClusterManager : Clusters Update"); UpdateClusters(); Profiler.EndSample(); CheckClustersUpdated(); if (ClustersToIdentify.Count > 0 || IdentifiedClustersMoved.Count > 0 || IdentifiedClustersCancelled.Count > 0) { RaiseClustersUpdateEvent(new ClustersUpdateEventArgs(ClustersToIdentify, IdentifiedClustersMoved, IdentifiedClustersCancelled.Values.ToList())); } //Get points which are touches and not markers InputManager.SetFingersCancelled(InternalTouches.CancelledTouchBuffer.ToArray()); foreach (Cluster c in clusters.Values) { if (c.State == ClusterState.Invalid || c.State == ClusterState.Cancelled) { //This cluster is only made of finger touch points foreach (TouchInput touch in c.Points.Values) { InputManager.AddFingerTouch(touch); } } } } Profiler.EndSample(); }