Update() public method

public Update ( float elapsed ) : void
elapsed float
return void
        private void updateControllerState(object o, EventArgs e)
        {
            if (controller != null)
            {
                controller.Update();

                leftStickXTextBox.Text = " " + Convert.ToByte(controller.LeftStick.Position.X * 100 + 100).ToString();
                leftStickYTextBox.Text = " " + Convert.ToByte(controller.LeftStick.Position.Y * 100 + 100).ToString();

                rightStickXTextBox.Text = " " + Convert.ToByte(controller.RightStick.Position.X * 100 + 100).ToString();
                rightStickYTextBox.Text = " " + Convert.ToByte(controller.RightStick.Position.Y * 100 + 100).ToString();

                rightBumperTextBox.Text = " " + controller.RightShoulder.ToString();
                leftBumperTextBox.Text  = " " + controller.LeftShoulder.ToString();

                leftTriggerTextBox.Text  = " " + Convert.ToByte(controller.LeftTrigger * 100).ToString();
                rightTriggerTextBox.Text = " " + Convert.ToByte(controller.RightTrigger * 100).ToString();

                upDpadTextBox.Text    = " " + controller.DPad.Up.ToString();
                downDpadTextBox.Text  = " " + controller.DPad.Down.ToString();
                rightDpadTextBox.Text = " " + controller.DPad.Right.ToString();
                leftDpadTextBox.Text  = " " + controller.DPad.Left.ToString();

                backTextBox.Text        = " " + controller.Back.ToString();
                startButtonTextBox.Text = " " + controller.Start.ToString();

                textBox1.Text = " " + controller.LeftStick.Clicked.ToString();
                textBox2.Text = " " + controller.RightStick.Clicked.ToString();

                aButtonTextBox.Text = " " + controller.A.ToString();
                bButtonTextBox.Text = " " + controller.B.ToString();
                xButtonTextBox.Text = " " + controller.X.ToString();
                yButtonTextBox.Text = " " + controller.Y.ToString();
            }

            Task updatecontrollerStateTask = new Task(() => updateControllerBuffers());

            updatecontrollerStateTask.Start();
        }
Ejemplo n.º 2
0
        private void updateControllerState()
        {
            if (controller != null && controller.Connected)
            {
                controller.Update();

                controller1_textBox.Text      = "Connected";
                controller1_textBox.ForeColor = System.Drawing.Color.Green;

                i = 0;

                i = (Convert.ToInt32(controller.A)) |
                    (Convert.ToInt32(controller.B) << 1) |
                    (Convert.ToInt32(controller.X) << 2) |
                    (Convert.ToInt32(controller.Y) << 3) |
                    (Convert.ToInt32(controller.LeftShoulder) << 4) |
                    (Convert.ToInt32(controller.RightShoulder) << 5) |
                    (Convert.ToInt32(controller.Start) << 6);

                controller_packet[0] = Convert.ToByte(i);

                i = (Convert.ToInt32(controller.DPad.Up)) |
                    (Convert.ToInt32(controller.DPad.Down) << 1) |
                    (Convert.ToInt32(controller.DPad.Left) << 2) |
                    (Convert.ToInt32(controller.DPad.Right) << 3) |
                    (Convert.ToInt32(controller.LeftStick.Clicked) << 4) |
                    (Convert.ToInt32(controller.RightStick.Clicked) << 5) |
                    (Convert.ToInt32(controller.Back) << 6);

                controller_packet[1] = Convert.ToByte(i);

                controller_packet[2] = Convert.ToByte(controller.LeftStick.Position.X * 100 + 100);

                controller_packet[3] = Convert.ToByte(controller.LeftStick.Position.Y * 100 + 100);

                controller_packet[4] = Convert.ToByte(controller.RightStick.Position.X * 100 + 100);

                controller_packet[5] = Convert.ToByte(controller.RightStick.Position.Y * 100 + 100);

                controller_packet[6] = Convert.ToByte(controller.LeftTrigger * 100);

                controller_packet[7] = Convert.ToByte(controller.RightTrigger * 100);
            }
            else
            {
                controller1_textBox.Text      = "Disconnected";
                controller1_textBox.ForeColor = System.Drawing.Color.DarkRed;

                controller_packet[0] = Convert.ToByte(0);
                controller_packet[1] = Convert.ToByte(0);
                controller_packet[2] = Convert.ToByte(100);
                controller_packet[3] = Convert.ToByte(100);
                controller_packet[4] = Convert.ToByte(100);
                controller_packet[5] = Convert.ToByte(100);
                controller_packet[6] = Convert.ToByte(0);
                controller_packet[7] = Convert.ToByte(0);
            }

            checkSumTX[0] = 0;
            for (i = 0; i < 8; i++)
            {
                checkSumTX[0] += controller_packet[i];
            }
        }
Ejemplo n.º 3
0
 private void CheckControllerButtons()
 {
     while (bRunThreads)
     {
         if (!bCheckAppsRunning)
         {
             gPS.Update();
             SimulateLeftMouseClick(gPS.A);
             SimulateRightMouseClick(gPS.B);
             if (gPS.RightStick.Position.Y != 0)
             {
                 mouse_event(MOUSEEVENTF_WHEEL, 0, 0, Convert.ToInt32(gPS.RightStick.Position.Y * 120), 0);
             }
             if (gPS.RightStick.Position.X != 0)
             {
                 mouse_event(MOUSEEVENTF_HWHEEL, 0, 0, Convert.ToInt32(gPS.RightStick.Position.X * 120), 0);
             }
             if (gPS.RightTrigger >= 0.75)
             {
                 if (!bRightTrigger)
                 {
                     bRightTrigger = true;
                     StartOSK();
                 }
             }
             else
             {
                 bRightTrigger = false;
             }
             if (gPS.LeftTrigger >= 0.75)
             {
                 if (!bLeftTrigger)
                 {
                     bLeftTrigger = true;
                     ChangePrimaryMonitor();
                 }
             }
             else
             {
                 bLeftTrigger = false;
             }
             if (gPS.RightShoulder)
             {
                 if (!bRightShoulder)
                 {
                     bRightShoulder = true;
                     SendKeys.SendWait("%{RIGHT}");
                 }
             }
             else
             {
                 bRightShoulder = false;
             }
             if (gPS.LeftShoulder)
             {
                 if (!bLeftShoulder)
                 {
                     bLeftShoulder = true;
                     SendKeys.SendWait("{BACKSPACE}");
                 }
             }
             else
             {
                 bLeftShoulder = false;
             }
         }
         Thread.Sleep(10);
     }
 }