Exemplo n.º 1
0
        /// <summary>
        /// needed for detecting a change in joystick state
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }

            JoystickSubState jsObj = (JoystickSubState)obj;

            if (X != jsObj.X || Y != jsObj.Y || Z != jsObj.Z)
            {
                return(false);
            }

            for (int i = 0; i < buttons.Length && i < jsObj.buttons.Length; i++)
            {
                if (buttons[i] != jsObj.buttons[i])
                {
                    return(false);
                }
            }

            // all state elements we were interested in are the same
            return(true);
        }
Exemplo n.º 2
0
        public object Clone()
        {
            JoystickSubState jss = new JoystickSubState()
            {
                ControlDeviceType    = this.ControlDeviceType,
                InstanceName         = this.InstanceName,
                JoystickMinimumPower = this.JoystickMinimumPower,
                ProductName          = this.ProductName,
                X       = this.X,
                Y       = this.Y,
                Z       = this.Z,
                buttons = (bool[])this.buttons.Clone()
            };

            return(jss);
        }
Exemplo n.º 3
0
        private void Controller_JoystickDataChanged(object sender, XboxHidController.JoystickEventArgs e)
        {
            // receiving IJoystickRawState
            JoystickIsWorking = true;
            //Debug.WriteLine("JoystickRawState: X=" + e.jss.X + "  Y=" + e.jss.Y);

            lock (jssLock)
            {
                // keep a copy for those who poll the joystick:
                jssCurrent = new JoystickSubState(e.jss);
            }

            // if we have subscribers, notify them:
            //Debug.WriteLine("--------- 360: Controller_JoystickDataChanged");
            joystickEvent?.Invoke(this, (IJoystickSubState)jssCurrent.Clone());

            //Debug.WriteLine("JoystickSubState: Speed=" + jssCurrent.Speed + "  Turn=" + jssCurrent.Turn);
        }
Exemplo n.º 4
0
 public object Clone()
 {
     JoystickSubState jss = new JoystickSubState()
     {
         ControlDeviceType = this.ControlDeviceType,
         InstanceName = this.InstanceName,
         JoystickMinimumPower = this.JoystickMinimumPower,
         ProductName = this.ProductName,
         X = this.X,
         Y = this.Y,
         Z = this.Z,
         buttons = (bool[])this.buttons.Clone()
     };
     return jss;
 }
Exemplo n.º 5
0
        private void Controller_JoystickDataChanged(object sender, XboxHidController.JoystickEventArgs e)
        {
            // receiving IJoystickRawState
            JoystickIsWorking = true;
            //Debug.WriteLine("JoystickRawState: X=" + e.jss.X + "  Y=" + e.jss.Y);

            lock(jssLock)
            {
                // keep a copy for those who poll the joystick:
                jssCurrent = new JoystickSubState(e.jss);
            }

            // if we have subscribers, notify them:
            //Debug.WriteLine("--------- 360: Controller_JoystickDataChanged");
            joystickEvent?.Invoke(this, (IJoystickSubState)jssCurrent.Clone());

            //Debug.WriteLine("JoystickSubState: Speed=" + jssCurrent.Speed + "  Turn=" + jssCurrent.Turn);
        }