Beispiel #1
0
        public (float, float) GetStick(StickInputId inputId)
        {
            if (inputId == StickInputId.Unbound)
            {
                return(0.0f, 0.0f);
            }

            short stickX;
            short stickY;

            if (inputId == StickInputId.Left)
            {
                stickX = SDL_GameControllerGetAxis(_gamepadHandle, SDL_GameControllerAxis.SDL_CONTROLLER_AXIS_LEFTX);
                stickY = SDL_GameControllerGetAxis(_gamepadHandle, SDL_GameControllerAxis.SDL_CONTROLLER_AXIS_LEFTY);
            }
            else if (inputId == StickInputId.Right)
            {
                stickX = SDL_GameControllerGetAxis(_gamepadHandle, SDL_GameControllerAxis.SDL_CONTROLLER_AXIS_RIGHTX);
                stickY = SDL_GameControllerGetAxis(_gamepadHandle, SDL_GameControllerAxis.SDL_CONTROLLER_AXIS_RIGHTY);
            }
            else
            {
                throw new NotSupportedException($"Unsupported stick {inputId}");
            }

            float resultX = ConvertRawStickValue(stickX);
            float resultY = -ConvertRawStickValue(stickY);

            if (HasConfiguration)
            {
                if ((inputId == StickInputId.Left && _configuration.LeftJoyconStick.InvertStickX) ||
                    (inputId == StickInputId.Right && _configuration.RightJoyconStick.InvertStickX))
                {
                    resultX = -resultX;
                }

                if ((inputId == StickInputId.Left && _configuration.LeftJoyconStick.InvertStickY) ||
                    (inputId == StickInputId.Right && _configuration.RightJoyconStick.InvertStickY))
                {
                    resultY = -resultY;
                }

                if ((inputId == StickInputId.Left && _configuration.LeftJoyconStick.Rotate90CW) ||
                    (inputId == StickInputId.Right && _configuration.RightJoyconStick.Rotate90CW))
                {
                    float temp = resultX;
                    resultX = resultY;
                    resultY = -temp;
                }
            }

            return(resultX, resultY);
        }
Beispiel #2
0
        private void CollectButtonStats()
        {
            if (_forStick)
            {
                for (StickInputId inputId = StickInputId.Left; inputId < StickInputId.Count; inputId++)
                {
                    (float x, float y) = _currState.GetStick(inputId);

                    float value;

                    if (x != 0.0f)
                    {
                        value = x;
                    }
                    else if (y != 0.0f)
                    {
                        value = y;
                    }
                    else
                    {
                        continue;
                    }

                    _detector.AddInput((GamepadButtonInputId)inputId, value);
                }
            }
            else
            {
                for (GamepadButtonInputId inputId = GamepadButtonInputId.A; inputId < GamepadButtonInputId.Count; inputId++)
                {
                    if (_currState.IsPressed(inputId) && !_prevState.IsPressed(inputId))
                    {
                        _detector.AddInput(inputId, 1);
                    }

                    if (!_currState.IsPressed(inputId) && _prevState.IsPressed(inputId))
                    {
                        _detector.AddInput(inputId, -1);
                    }
                }
            }
        }
Beispiel #3
0
 public (float, float) GetStick(StickInputId inputId)
 {
     throw new NotSupportedException();
 }
 public void SetStick(StickInputId inputId, float x, float y)
 {
     _joysticksState[(int)inputId][0] = x;
     _joysticksState[(int)inputId][1] = y;
 }
        public (float, float) GetStick(StickInputId inputId)
        {
            var result = _joysticksState[(int)inputId];

            return(result[0], result[1]);
        }
Beispiel #6
0
 public (float, float) GetStick(StickInputId inputId)
 {
     throw new NotImplementedException();
 }