/**
         * Interface for anything that provides gamepad/joystick values (could be from a host pc or from USB attached gamepad).
         * @return  Negative If values could not be retrieved or values are very old.  toFill is cleared.
         *          Positive if values are updated. toFill is filled in.
         */

        private int SyncGet(ref GameControllerValues toFill, uint numDwords)
        {
            /* always get latest data for now */
            _updateCnt = 0;

            //TODO: Implement CTRE.Phoenix.Controller.GetCANJoy()
            int ret = GetCANJoy(ref _updateCnt, _gpInts, (uint)numDwords, _gpFlts, (uint)_gpFlts.Length);

            if (ret < 0)
            {
                /* negative error code means data is unreliable */
                if (toFill != null)
                {
                    toFill.Copy(ZeroGameControllerValues);
                }
                /* on the next poll, always get latest */
                _updateCnt = 0;
            }
            else
            {
                /* new data, copy it over */
                if (toFill != null)
                {
                    toFill.axes[0] = _gpFlts[0];
                    toFill.axes[1] = _gpFlts[1];
                    toFill.axes[2] = _gpFlts[2];
                    toFill.axes[3] = _gpFlts[3];
                    toFill.axes[4] = _gpFlts[4];
                    toFill.axes[5] = _gpFlts[5];
                    toFill.btns    = (uint)_gpInts[0];
                    toFill.pov     = _gpInts[1];
                }
            }
            return(ret);
        }
Exemple #2
0
 /**
  * Retrieves a copy of the internal gamepadvalues structure used in decoding signals.
  * This can be used to retrieve signals not readily available through the Gamepad API (such as vendor specific signals or VID/PID).
  * To use this function, first create a gamepadValues instance and pass by reference.
  * <pre>{@code
  *      GamepadValues values = new GamepadValues(); // Create only once and use functiont to update it periodically.
  *      ...
  *      gamepad.GetAllValues(gamepadValues); // Get latest values
  * }</pre>
  * @param gamepadValues reference to update with latest values.
  * @return object reference to gamepadValues for function chaining.
  */
 public GameControllerValues GetAllValues(ref GameControllerValues gamepadValues)
 {
     /* get latest copy if there is new data */
     _provider.Get(ref _values, _index);
     /* copy it to caller */
     gamepadValues.Copy(_values);
     return(gamepadValues);
 }