void ProcessTouchEvent(Touches touch) { int ID = touch.GetID(); if (touchList.ContainsKey(ID)) { touch.SetGesture(Touches.GESTURE_MOVE); touchList.Remove(ID); } else { touch.SetGesture(Touches.GESTURE_DOWN); } touchList.Add(ID, touch); SendTouchEvent(touch); }
// Update is called once per frame void Update() { lock(dgrams.SyncRoot) { foreach (String dgram in dgrams) { ParseDGram(dgram); } dgrams.Clear(); } if( ping ){ // Translate the passed message into ASCII and store it as a Byte array. client = new TcpClient(InputServer, msgPort); String message = "client_in,101,one ping only"; Byte[] data = System.Text.Encoding.ASCII.GetBytes(message); streamToServer = client.GetStream(); // Send the message to the server. streamToServer.Write(data, 0, data.Length); Debug.Log("Ping sent"); ping = false; } Hashtable tempList = new Hashtable(touchList); foreach( DictionaryEntry elem in tempList ) { //Console.WriteLine("Key = {0}, Value = {1}", elem.Key, elem.Value); Touches t = (Touches)elem.Value; long timeStamp = t.GetTimeStamp(); DateTime baseTime = new DateTime(1970, 1, 1, 0, 0, 0); long curTime = (DateTime.UtcNow - baseTime).Ticks / 10000; if( timeStamp + touchTimeOut < curTime ){ t.SetGesture(Touches.GESTURE_UP); SendTouchEvent( t ); touchList.Remove( t.GetID() ); } } // Emulates mouse input as touch events if( Input.GetMouseButtonDown(0) ) { MouseTouch = new Touches( Input.mousePosition, -1 ); MouseTouch.SetGesture(Touches.GESTURE_DOWN); SendTouchEvent(MouseTouch); } else if( Input.GetMouseButtonUp(0) ) { MouseTouch = new Touches( Input.mousePosition, -1 ); MouseTouch.SetGesture(Touches.GESTURE_UP); SendTouchEvent(MouseTouch); } else if( Input.GetMouseButton(0) ) { MouseTouch = new Touches( Input.mousePosition, -1 ); MouseTouch.SetGesture(Touches.GESTURE_MOVE); SendTouchEvent(MouseTouch); } else { MouseTouch = null; } }
void ProcessTouchEvent( Touches touch ) { int ID = touch.GetID(); if( touchList.ContainsKey( ID ) ){ touch.SetGesture(Touches.GESTURE_MOVE); touchList.Remove( ID ); } else { touch.SetGesture(Touches.GESTURE_DOWN); } touchList.Add( ID, touch ); SendTouchEvent( touch ); }
// Update is called once per frame void Update() { lock (dgrams.SyncRoot) { foreach (String dgram in dgrams) { ParseDGram(dgram); } dgrams.Clear(); } if (ping) { // Translate the passed message into ASCII and store it as a Byte array. client = new TcpClient(InputServer, msgPort); String message = "client_in,101,one ping only"; Byte[] data = System.Text.Encoding.ASCII.GetBytes(message); streamToServer = client.GetStream(); // Send the message to the server. streamToServer.Write(data, 0, data.Length); Debug.Log("Ping sent"); ping = false; } Hashtable tempList = new Hashtable(touchList); foreach (DictionaryEntry elem in tempList) { //Console.WriteLine("Key = {0}, Value = {1}", elem.Key, elem.Value); Touches t = (Touches)elem.Value; long timeStamp = t.GetTimeStamp(); DateTime baseTime = new DateTime(1970, 1, 1, 0, 0, 0); long curTime = (DateTime.UtcNow - baseTime).Ticks / 10000; if (timeStamp + touchTimeOut < curTime) { t.SetGesture(Touches.GESTURE_UP); SendTouchEvent(t); touchList.Remove(t.GetID()); } } // Emulates mouse input as touch events if (Input.GetMouseButtonDown(0)) { MouseTouch = new Touches(Input.mousePosition, -1); MouseTouch.SetGesture(Touches.GESTURE_DOWN); SendTouchEvent(MouseTouch); } else if (Input.GetMouseButtonUp(0)) { MouseTouch = new Touches(Input.mousePosition, -1); MouseTouch.SetGesture(Touches.GESTURE_UP); SendTouchEvent(MouseTouch); } else if (Input.GetMouseButton(0)) { MouseTouch = new Touches(Input.mousePosition, -1); MouseTouch.SetGesture(Touches.GESTURE_MOVE); SendTouchEvent(MouseTouch); } else { MouseTouch = null; } }