Ejemplo n.º 1
0
 void  dragStart(object sender, DragEventArgs e)
 {
     if (Frame.TC == 1 && bDragging == false)
     {
         SendPacket.sendDragStart((int)e.LocalPosition.X, (int)e.LocalPosition.Y);
         Console.WriteLine("DragStart1 at " + e.LocalPosition.ToString());
         bDragging = true;
     }
     if (Frame.TC == 2 && bDragging == false)
     {
         SendPacket.sendDragStart((int)e.LocalPosition.X, (int)e.LocalPosition.Y);
         Console.WriteLine("DragStart2 at " + e.LocalPosition.ToString());
         bDragging = true;
     }
 }
Ejemplo n.º 2
0
        public static void Initialize()
        {
            // Set up the graphics system
            graphics = new GraphicsContext();

            Draw.init(graphics);
            dgl_connection = new dialog.DLG_CONNECTION();

            UISystem.Initialize(graphics);

            sceneMain = new MainUI();
            UISystem.SetScene(sceneMain, null);

            stopWatch = new Stopwatch();
            texture1  = new Texture2D(940, 544, false, PixelFormat.Rgba);
            texture2  = new Texture2D(940, 544, false, PixelFormat.Rgba);

            // Set up Client
            client = new TCPConnection("192.168.1.110", 8080);
            SendPacket.Init(client);
        }
Ejemplo n.º 3
0
        /***
         * Connect
         */
        public void OnConnect(IAsyncResult AsyncResult)         //worker thread for receiving and processing packets
        {
            try
            {
                if (socket != null)
                {
                    socket.EndConnect(AsyncResult);
                    isConnected = true;
                    Console.WriteLine("Client connected...");
                    this.StatusType = Status.kConnected;
                    Thread.Sleep(2000);
                    SendPacket.sendReady();

                    //socket.BeginReceive(recvBuffer, 0, recvBuffer.Length, 0, new AsyncCallback(SocketEventCallback.ReceiveCallback), this);
                }
            }
            catch (SocketException e)
            {
                if (e.SocketErrorCode == SocketError.ConnectionReset || e.SocketErrorCode == SocketError.ConnectionAborted)
                {
                    Disconnect();
                }
            }
        }
Ejemplo n.º 4
0
 private static void drawDesktop()
 {
     try
     {
         /*
          * if(Frame.FrameReady)
          * {
          *      if(texture1.Width != Frame.Width || texture1.Height != Frame.Height)
          *      {
          *              texture1 = new Texture2D(Frame.Width ,Frame.Height,false,PixelFormat.Rgba);
          *              texture2 = new Texture2D(Frame.Width ,Frame.Height,false,PixelFormat.Rgba);
          *      }
          *
          *      texture1.SetPixels(0,Frame.FrameBuffer1);
          *      texture2.SetPixels(0,Frame.FrameBuffer2);
          *
          *      sceneMain.updateImage(texture1,texture2);
          *
          *      //SendPacket.sendReady();
          *      //GC.Collect();
          *
          * }
          * Draw.render(texture1, texture2);
          */
         Draw.render(Frame.ScreenTexture);
         if (Frame.FrameReady == true)
         {
             SendPacket.sendReady();
             Frame.FrameReady = false;
         }
     }
     catch (Exception e)
     {
         Console.WriteLine(e.ToString());
     }
 }
Ejemplo n.º 5
0
        public static void UpdateGamepadState()
        {
            var gamepadData = GamePad.GetData(0);


            byte[] data = new byte[16];

            data[0]  = (byte)(((gamepadData.Buttons & GamePadButtons.Left) != 0)             ? 1:0);
            data[1]  = (byte)(((gamepadData.Buttons & GamePadButtons.Right) != 0)            ? 1:0);
            data[2]  = (byte)(((gamepadData.Buttons & GamePadButtons.Up) != 0)                       ? 1:0);
            data[3]  = (byte)(((gamepadData.Buttons & GamePadButtons.Down) != 0)             ? 1:0);
            data[4]  = (byte)(((gamepadData.Buttons & GamePadButtons.Square) != 0)           ? 1:0);
            data[5]  = (byte)(((gamepadData.Buttons & GamePadButtons.Cross) != 0)            ? 1:0);
            data[6]  = (byte)(((gamepadData.Buttons & GamePadButtons.Circle) != 0)           ? 1:0);
            data[7]  = (byte)(((gamepadData.Buttons & GamePadButtons.Triangle) != 0)         ? 1:0);
            data[8]  = (byte)(((gamepadData.Buttons & GamePadButtons.L) != 0)                        ? 1:0);
            data[9]  = (byte)(((gamepadData.Buttons & GamePadButtons.R) != 0)                        ? 1:0);
            data[10] = (byte)(((gamepadData.Buttons & GamePadButtons.Select) != 0)          ? 1:0);
            data[11] = (byte)(((gamepadData.Buttons & GamePadButtons.Start) != 0)           ? 1:0);

            if (inputType == 0)
            {
                //value 1 is positive value 2 is negative

                if (gamepadData.AnalogLeftX > 0.5f)
                {
                    data[12] = 1;
                }

                if (gamepadData.AnalogLeftX < -0.5f)
                {
                    data[12] = 2;
                }

                if (gamepadData.AnalogLeftX < 0.5f && gamepadData.AnalogLeftX > -0.5f)
                {
                    data[12] = 0;
                }

                if (gamepadData.AnalogLeftY > 0.5f)
                {
                    data[13] = 1;
                }

                if (gamepadData.AnalogLeftY < -0.5f)
                {
                    data[13] = 2;
                }

                if (gamepadData.AnalogLeftY < 0.5f && gamepadData.AnalogLeftY > -0.5f)
                {
                    data[13] = 0;
                }

                if (gamepadData.AnalogRightX > 0.5f)
                {
                    data[14] = 1;
                }

                if (gamepadData.AnalogRightX < -0.5f)
                {
                    data[14] = 2;
                }

                if (gamepadData.AnalogRightX < 0.5f && gamepadData.AnalogRightX > -0.5f)
                {
                    data[14] = 0;
                }

                if (gamepadData.AnalogRightY > 0.5f)
                {
                    data[15] = 1;
                }

                if (gamepadData.AnalogRightY < -0.5f)
                {
                    data[15] = 2;
                }

                if (gamepadData.AnalogRightY < 0.5f && gamepadData.AnalogRightY > -0.5f)
                {
                    data[15] = 0;
                }
            }
            else
            {
                //0 to 127 positive value  128 to 254 negative value
                if ((127 * gamepadData.AnalogLeftX) >= 0)
                {
                    data[12] = (byte)(127 * gamepadData.AnalogLeftX);
                }
                else
                {
                    data[12] = (byte)(((127 * gamepadData.AnalogLeftX) * -1f) + 127);
                }
            }

            if ((gamepadData.Buttons & GamePadButtons.L) != 0)
            {
                var     motionData = Motion.GetData(0);
                Vector3 vel        = motionData.AngularVelocity;
                Vector3 acc        = motionData.Acceleration;

                int avX, avY, avZ, aX, aY, aZ;

                avX = (int)(motionSensitivity * vel.X);
                avY = (int)(motionSensitivity * vel.Y);
                avZ = (int)(motionSensitivity * vel.Z);
                aX  = (int)(motionSensitivity * acc.X);
                aY  = (int)(motionSensitivity * acc.Y);
                aZ  = (int)(motionSensitivity * acc.Z);

                SendPacket.sendSensorData(avX, avY, avZ, aX, aY, aZ);
            }

            //data[12] = (byte)(gamepadData.AnalogLeftX);
            //data[13] = (byte)(gamepadData.AnalogLeftY);
            //data[14] = (byte)(gamepadData.AnalogRightX);
            //data[15] = (byte)(gamepadData.AnalogRightY);

            if (_prevData != null)
            {
                if (data.CompareBytes(_prevData))
                {
                    SendPacket.sendGamePadInput(data);
                }
            }
            else
            {
                SendPacket.sendGamePadInput(data);
            }

            _prevData = data;
//			int left = ((gamepadData.Buttons & GamePadButtons.Left) != 0)           ? 1:0;
//			int right = ((gamepadData.Buttons & GamePadButtons.Right) != 0)         ? 1:0;
//			int up = ((gamepadData.Buttons & GamePadButtons.Up) != 0)               ? 1:0;
//			int down = ((gamepadData.Buttons & GamePadButtons.Down) != 0)           ? 1:0;
//			int square = ((gamepadData.Buttons & GamePadButtons.Square) != 0)       ? 1:0;
//			int cross = ((gamepadData.Buttons & GamePadButtons.Cross) != 0)         ? 1:0;
//			int circle = ((gamepadData.Buttons & GamePadButtons.Circle) != 0)       ? 1:0;
//			int triangle = ((gamepadData.Buttons & GamePadButtons.Triangle) != 0)   ? 1:0;
//			int ltrigger = ((gamepadData.Buttons & GamePadButtons.L) != 0)          ? 1:0;
//			int rtrigger = ((gamepadData.Buttons & GamePadButtons.R) != 0)          ? 1:0;
//			int iselect = ((gamepadData.Buttons & GamePadButtons.Select) != 0)      ? 1:0;
//			int start = ((gamepadData.Buttons & GamePadButtons.Start) != 0)			? 1:0;
//
//			bool change = GamePadStateChange(left,
//			                                 right,
//			                                 up,
//			                                 down,
//			                                 square,
//			                                 cross,
//			                                 circle,
//			                                 triangle,
//			                                 ltrigger,
//			                                 rtrigger);
//
//			if(change)
//			{
//				byte[] data = new byte[10];
//				data[0] = (byte)PSV_BTN_LEFT;
//				data[1] = (byte)PSV_BTN_RIGHT;
//				data[2] = (byte)PSV_BTN_UP;
//				data[3] = (byte)PSV_BTN_DOWN;
//				data[4] = (byte)PSV_BTN_SQUARE;
//				data[5] = (byte)PSV_BTN_CROSS;
//				data[6] = (byte)PSV_BTN_CIRCLE;
//				data[7] = (byte)PSV_BTN_TRIANGLE;
//				data[8] = (byte)PSV_BTN_LTRIGGER;
//				data[9] = (byte)PSV_BTN_RTRIGGER;
//				data[10] = (byte)PSV_BTN_RTRIGGER;
//				data[11] = (byte)PSV_BTN_RTRIGGER;
//
//
//				SendPacket.sendGamePadInput(data);
//			}
//				//send keystate data only if keystate change
//			Console.WriteLine(change);
//			//Console.WriteLine(gamepadData.Buttons);
//			//Console.WriteLine(PSV_BTN_LEFT);
//			//joyState.digital[0] = (ctrl.Buttons & PSP_CTRL_TRIANGLE) ? 1 : 0;
        }
Ejemplo n.º 6
0
 void  LongPress(object sender, LongPressEventArgs e)
 {
     SendPacket.sendLongPress((int)e.LocalPosition.X, (int)e.LocalPosition.Y);
     Console.WriteLine("LongPress at " + e.LocalPosition.ToString());
 }
Ejemplo n.º 7
0
 void DoubleTap(object sender, DoubleTapEventArgs e)
 {
     SendPacket.sendDoubleTap((int)e.LocalPosition.X, (int)e.LocalPosition.Y);
     Console.WriteLine("DoubleTap at " + e.LocalPosition.ToString());
     //SendPacket.sendLeftMouseDoubleClick((int)e.LocalPosition.X,(int)e.LocalPosition.Y);//jonathan send touch cordinates so we can click those cordinates
 }
Ejemplo n.º 8
0
        public static void UpdateGamepadState()
        {
            var gamepadData = GamePad.GetData(0);

            GamepadPacketData padData = new GamepadPacketData();

            // turn on the bool bits
            uint unButtonState = 0;

            unButtonState      |= (uint)(gamepadData.Buttons & GamePadButtons.Left);
            unButtonState      |= (uint)(gamepadData.Buttons & GamePadButtons.Right);
            unButtonState      |= (uint)(gamepadData.Buttons & GamePadButtons.Up);
            unButtonState      |= (uint)(gamepadData.Buttons & GamePadButtons.Down);
            unButtonState      |= (uint)(gamepadData.Buttons & GamePadButtons.Square);
            unButtonState      |= (uint)(gamepadData.Buttons & GamePadButtons.Cross);
            unButtonState      |= (uint)(gamepadData.Buttons & GamePadButtons.Circle);
            unButtonState      |= (uint)(gamepadData.Buttons & GamePadButtons.Triangle);
            unButtonState      |= (uint)(gamepadData.Buttons & GamePadButtons.L);
            unButtonState      |= (uint)(gamepadData.Buttons & GamePadButtons.R);
            unButtonState      |= (uint)(gamepadData.Buttons & GamePadButtons.Select);
            unButtonState      |= (uint)(gamepadData.Buttons & GamePadButtons.Start);
            padData.ButtonState = unButtonState;

            // copy the analog values
            padData.LeftAnalogX  = gamepadData.AnalogLeftX;
            padData.LeftAnalogY  = gamepadData.AnalogLeftY;
            padData.RightAnalogX = gamepadData.AnalogRightX;
            padData.RightAnalogY = gamepadData.AnalogRightY;

            // send
            bool compResult = padData.Raw.CompareBytes(prevGamepadData.Raw);

            if (compResult == true)
            {
                SendPacket.sendGamePadInput(padData.Raw);
            }
            prevGamepadData.Raw = padData.Raw;

            /*
             * byte[] data = new byte[16];
             *
             * data[0] = (byte)(((gamepadData.Buttons & GamePadButtons.Left) != 0)      ? 1:0);
             * data[1] = (byte)(((gamepadData.Buttons & GamePadButtons.Right) != 0)         ? 1:0);
             * data[2] = (byte)(((gamepadData.Buttons & GamePadButtons.Up) != 0)            ? 1:0);
             * data[3] = (byte)(((gamepadData.Buttons & GamePadButtons.Down) != 0)      ? 1:0);
             * data[4] = (byte)(((gamepadData.Buttons & GamePadButtons.Square) != 0)        ? 1:0);
             * data[5] = (byte)(((gamepadData.Buttons & GamePadButtons.Cross) != 0)         ? 1:0);
             * data[6] = (byte)(((gamepadData.Buttons & GamePadButtons.Circle) != 0)        ? 1:0);
             * data[7] = (byte)(((gamepadData.Buttons & GamePadButtons.Triangle) != 0)  ? 1:0);
             * data[8] = (byte)(((gamepadData.Buttons & GamePadButtons.L) != 0)             ? 1:0);
             * data[9] = (byte)(((gamepadData.Buttons & GamePadButtons.R) != 0)             ? 1:0);
             * data[10] = (byte)(((gamepadData.Buttons & GamePadButtons.Select) != 0)       ? 1:0);
             * data[11] = (byte)(((gamepadData.Buttons & GamePadButtons.Start) != 0)		? 1:0);
             *
             * data[12] = (byte)(gamepadData.AnalogLeftX);
             * data[13] = (byte)(gamepadData.AnalogLeftY);
             * data[14] = (byte)(gamepadData.AnalogRightX);
             * data[15] = (byte)(gamepadData.AnalogRightY);
             *
             * if(inputType == 0)
             * {
             * //value 1 is positive value 2 is negative
             *
             *      if(gamepadData.AnalogLeftX > 0.5f)
             *              data[12] = 1;
             *
             *      if(gamepadData.AnalogLeftX < -0.5f)
             *              data[12] = 2;
             *
             *      if(gamepadData.AnalogLeftX < 0.5f && gamepadData.AnalogLeftX > -0.5f)
             *              data[12] = 0;
             *
             *      if(gamepadData.AnalogLeftY > 0.5f)
             *              data[13] = 1;
             *
             *      if(gamepadData.AnalogLeftY < -0.5f)
             *              data[13] = 2;
             *
             *      if(gamepadData.AnalogLeftY < 0.5f && gamepadData.AnalogLeftY > -0.5f)
             *              data[13] = 0;
             *
             *      if(gamepadData.AnalogRightX > 0.5f)
             *              data[14] = 1;
             *
             *      if(gamepadData.AnalogRightX < -0.5f)
             *              data[14] = 2;
             *
             *      if(gamepadData.AnalogRightX < 0.5f && gamepadData.AnalogRightX > -0.5f)
             *              data[14] = 0;
             *
             *      if(gamepadData.AnalogRightY > 0.5f)
             *              data[15] = 1;
             *
             *      if(gamepadData.AnalogRightY < -0.5f)
             *              data[15] = 2;
             *
             *      if(gamepadData.AnalogRightY < 0.5f && gamepadData.AnalogRightY > -0.5f)
             *              data[15] = 0;
             * }
             * else
             * {
             *      //0 to 127 positive value  128 to 254 negative value
             *      if((127 * gamepadData.AnalogLeftX) >= 0)
             *              data[12] = (byte)(127 * gamepadData.AnalogLeftX);
             *      else
             *              data[12] = (byte)(((127 * gamepadData.AnalogLeftX) *-1f) + 127);
             *
             * }
             */
            /*
             * if((gamepadData.Buttons & GamePadButtons.L) != 0 && false)
             * {
             *      var motionData = Motion.GetData(0);
             *      Vector3 vel = motionData.AngularVelocity;
             *      Vector3 acc = motionData.Acceleration;
             *
             *      int avX,avY,avZ,aX,aY,aZ;
             *
             *      avX = (int)(motionSensitivity * vel.X);
             *      avY = (int)(motionSensitivity * vel.Y);
             *      avZ = (int)(motionSensitivity * vel.Z);
             *      aX = (int)(motionSensitivity * acc.X);
             *      aY = (int)(motionSensitivity * acc.Y);
             *      aZ = (int)(motionSensitivity * acc.Z);
             *
             *      SendPacket.sendSensorData(avX,avY,avZ,aX,aY,aZ);
             * }
             */
            //data[12] = (byte)(gamepadData.AnalogLeftX);
            //data[13] = (byte)(gamepadData.AnalogLeftY);
            //data[14] = (byte)(gamepadData.AnalogRightX);
            //data[15] = (byte)(gamepadData.AnalogRightY);

            /*
             * if(_prevData != null)
             * {
             *      if(data.CompareBytes(_prevData))
             *         SendPacket.sendGamePadInput(data);
             * }
             * else
             * {
             *      SendPacket.sendGamePadInput(data);
             * }
             *
             * _prevData = data;
             */
//			int left = ((gamepadData.Buttons & GamePadButtons.Left) != 0)           ? 1:0;
//			int right = ((gamepadData.Buttons & GamePadButtons.Right) != 0)         ? 1:0;
//			int up = ((gamepadData.Buttons & GamePadButtons.Up) != 0)               ? 1:0;
//			int down = ((gamepadData.Buttons & GamePadButtons.Down) != 0)           ? 1:0;
//			int square = ((gamepadData.Buttons & GamePadButtons.Square) != 0)       ? 1:0;
//			int cross = ((gamepadData.Buttons & GamePadButtons.Cross) != 0)         ? 1:0;
//			int circle = ((gamepadData.Buttons & GamePadButtons.Circle) != 0)       ? 1:0;
//			int triangle = ((gamepadData.Buttons & GamePadButtons.Triangle) != 0)   ? 1:0;
//			int ltrigger = ((gamepadData.Buttons & GamePadButtons.L) != 0)          ? 1:0;
//			int rtrigger = ((gamepadData.Buttons & GamePadButtons.R) != 0)          ? 1:0;
//			int iselect = ((gamepadData.Buttons & GamePadButtons.Select) != 0)      ? 1:0;
//			int start = ((gamepadData.Buttons & GamePadButtons.Start) != 0)			? 1:0;
//
//			bool change = GamePadStateChange(left,
//			                                 right,
//			                                 up,
//			                                 down,
//			                                 square,
//			                                 cross,
//			                                 circle,
//			                                 triangle,
//			                                 ltrigger,
//			                                 rtrigger);
//
//			if(change)
//			{
//				byte[] data = new byte[10];
//				data[0] = (byte)PSV_BTN_LEFT;
//				data[1] = (byte)PSV_BTN_RIGHT;
//				data[2] = (byte)PSV_BTN_UP;
//				data[3] = (byte)PSV_BTN_DOWN;
//				data[4] = (byte)PSV_BTN_SQUARE;
//				data[5] = (byte)PSV_BTN_CROSS;
//				data[6] = (byte)PSV_BTN_CIRCLE;
//				data[7] = (byte)PSV_BTN_TRIANGLE;
//				data[8] = (byte)PSV_BTN_LTRIGGER;
//				data[9] = (byte)PSV_BTN_RTRIGGER;
//				data[10] = (byte)PSV_BTN_RTRIGGER;
//				data[11] = (byte)PSV_BTN_RTRIGGER;
//
//
//				SendPacket.sendGamePadInput(data);
//			}
//				//send keystate data only if keystate change
//			Console.WriteLine(change);
//			//Console.WriteLine(gamepadData.Buttons);
//			//Console.WriteLine(PSV_BTN_LEFT);
//			//joyState.digital[0] = (ctrl.Buttons & PSP_CTRL_TRIANGLE) ? 1 : 0;
        }
Ejemplo n.º 9
0
 void DoubleTap(object sender, DoubleTapEventArgs e)
 {
     SendPacket.sendDoubleTap((int)e.LocalPosition.X, (int)e.LocalPosition.Y);
     Console.WriteLine("DoubleTap at " + e.LocalPosition.ToString());
 }