Beispiel #1
0
        private void joystickTest(VMulti vmulti)
        {
            double i       = 0;
            bool   running = true;

            while (running)
            {
                JoystickButtonState joyButtonState = new JoystickButtonState();
                joyButtonState.A    = false;
                joyButtonState.X    = false;
                joyButtonState.Left = false;

                double x = Math.Sin(i);
                double y = Math.Cos(i);

                Console.WriteLine("x: " + x + " y: " + y);

                JoystickReport joystickReport = new JoystickReport(joyButtonState, x, y);

                Console.WriteLine("Update Joystick: " + vmulti.updateJoystick(joystickReport));

                i += 0.1;

                System.Threading.Thread.Sleep(100);
            }
        }
        public void UpdateButtonState(uint id, JoystickButtonState buttonState)
        {
            if (!joystickStates.ContainsKey(id))
                ActivateJoystick(id);

            _joy.SetBtn(buttonState.Pressed, buttonState.id, buttonState.ButtonId);
        }
Beispiel #3
0
            /// <summary>
            /// Function to set the state for a button.
            /// </summary>
            /// <param name="name">Name of the button.</param>
            /// <param name="state">State of the button.</param>
            public void SetButtonState(XI.GamepadButtonFlags name, bool state)
            {
                string enumName = name.ToString();

                if (Contains(enumName))
                {
                    this[enumName] = new JoystickButtonState(enumName, state);
                }
            }
 void Awake()
 {
     Instance          = this;
     buttonStates      = new JoystickButtonState[ButtonMax];
     buttonStickStates = new JoystickButtonState[4];
     for (int i = 0; i < buttonStates.Length; ++i)
     {
         buttonStates[i] = new JoystickButtonState();
     }
     for (int i = 0; i < buttonStickStates.Length; ++i)
     {
         buttonStickStates[i] = new JoystickButtonState();
     }
 }
Beispiel #5
0
 /// <summary>
 /// Function to set the button state.
 /// </summary>
 /// <param name="index">Index of the button.</param>
 /// <param name="state">State to set.</param>
 public void SetButtonState(int index, bool state)
 {
     this[index] = new JoystickButtonState(this[index].Name, state);
 }