Exemple #1
0
        public short GetAnalog(uint port, RETRO_DEVICE_INDEX_ANALOG index, RETRO_DEVICE_ID_ANALOG direction)
        {
            RetroAnalogDevice positive;
            RetroAnalogDevice negative;

            RetroPadMapping.GetAnalogEnums(index, direction, out positive, out negative);

            short positivePosition = 0;
            short negativePosition = 0;

            Keys key;

            if (_analogMappings.TryGetValue(positive, out key) && Keyboard.IsKeyDown(key))
            {
                positivePosition = short.MaxValue;
            }
            if (_analogMappings.TryGetValue(negative, out key) && Keyboard.IsKeyDown(key))
            {
                negativePosition = short.MinValue;
            }

            if (positivePosition != 0 && negativePosition == 0)
            {
                return(positivePosition);
            }
            if (positivePosition == 0 && negativePosition != 0)
            {
                return(negativePosition);
            }
            return(0);
        }
Exemple #2
0
 public static void GetAnalogEnums(RETRO_DEVICE_INDEX_ANALOG index, RETRO_DEVICE_ID_ANALOG direction, out RetroAnalogDevice positive, out RetroAnalogDevice negative)
 {
     if (index == RETRO_DEVICE_INDEX_ANALOG.LEFT)
     {
         if (direction == RETRO_DEVICE_ID_ANALOG.X)
         {
             positive = RetroAnalogDevice.LeftThumbRight;
             negative = RetroAnalogDevice.LeftThumbLeft;
         }
         else
         {
             //Libretro defines positive Y values as down
             positive = RetroAnalogDevice.LeftThumbDown;
             negative = RetroAnalogDevice.LeftThumbUp;
         }
     }
     else
     {
         if (direction == RETRO_DEVICE_ID_ANALOG.X)
         {
             positive = RetroAnalogDevice.RightThumbRight;
             negative = RetroAnalogDevice.RightThumbLeft;
         }
         else
         {
             //Libretro defines positive Y values as down
             positive = RetroAnalogDevice.RightThumbDown;
             negative = RetroAnalogDevice.RightThumbUp;
         }
     }
 }
Exemple #3
0
        public short GetAnalog(uint port, RETRO_DEVICE_INDEX_ANALOG index, RETRO_DEVICE_ID_ANALOG direction)
        {
            HidState state = _currentState;

            if (state == null)
            {
                return(0);
            }

            RetroAnalogDevice positive;
            RetroAnalogDevice negative;

            RetroPadMapping.GetAnalogEnums(index, direction, out positive, out negative);
            short positivePosition = 0;
            short negativePosition = 0;

            HidAxis           axis;
            ushort            button;
            DirectionPadState directionPadState;

            if (_analogToAnalogMappings.TryGetValue(positive, out axis))
            {
                positivePosition = GetAxisPositionMapped(axis, state, true);
            }
            else if (_directionPadToAnalogMappings.TryGetValue(positive, out directionPadState) && IsDirectionPadPressed(directionPadState, state))
            {
                positivePosition = short.MaxValue;
            }
            else if (_buttonToAnalogMappings.TryGetValue(positive, out button) && IsButtonPressed(button, state))
            {
                positivePosition = short.MaxValue;
            }

            if (_analogToAnalogMappings.TryGetValue(negative, out axis))
            {
                negativePosition = GetAxisPositionMapped(axis, state, false);
            }
            else if (_directionPadToAnalogMappings.TryGetValue(negative, out directionPadState) && IsDirectionPadPressed(directionPadState, state))
            {
                positivePosition = short.MinValue;
            }
            else if (_buttonToAnalogMappings.TryGetValue(negative, out button) && IsButtonPressed(button, state))
            {
                negativePosition = short.MinValue;
            }

            if (positivePosition != 0 && negativePosition == 0)
            {
                return(positivePosition);
            }
            if (positivePosition == 0 && negativePosition != 0)
            {
                return(negativePosition);
            }
            return(0);
        }
        public short GetAnalog(uint port, RETRO_DEVICE_INDEX_ANALOG index, RETRO_DEVICE_ID_ANALOG direction)
        {
            if (port != _controllerIndex)
            {
                return(0);
            }
            Gamepad gamepad;

            if (!TryGetGamepad(out gamepad))
            {
                return(0);
            }

            RetroAnalogDevice positive;
            RetroAnalogDevice negative;

            RetroPadMapping.GetAnalogEnums(index, direction, out positive, out negative);
            short positivePosition = 0;
            short negativePosition = 0;

            XInputAxis         axis;
            GamepadButtonFlags buttonFlag;

            if (_analogToAnalogMappings.TryGetValue(positive, out axis))
            {
                positivePosition = GetAxisPositionMapped(axis, gamepad, true);
            }
            else if (_buttonToAnalogMappings.TryGetValue(positive, out buttonFlag) && IsButtonPressed(buttonFlag, gamepad))
            {
                positivePosition = short.MaxValue;
            }

            if (_analogToAnalogMappings.TryGetValue(negative, out axis))
            {
                negativePosition = GetAxisPositionMapped(axis, gamepad, false);
            }
            else if (_buttonToAnalogMappings.TryGetValue(negative, out buttonFlag) && IsButtonPressed(buttonFlag, gamepad))
            {
                negativePosition = short.MinValue;
            }

            if (positivePosition != 0 && negativePosition == 0)
            {
                return(positivePosition);
            }
            if (positivePosition == 0 && negativePosition != 0)
            {
                return(negativePosition);
            }
            return(0);
        }
Exemple #5
0
 public short GetAnalog(uint port, RETRO_DEVICE_INDEX_ANALOG index, RETRO_DEVICE_ID_ANALOG direction)
 {
     return(0);
 }
Exemple #6
0
 public short GetAnalog(uint port, RETRO_DEVICE_INDEX_ANALOG index, RETRO_DEVICE_ID_ANALOG direction)
 {
     return(port < _maxControllers ? _retroAnalogs[port].GetAnalog(port, index, direction) : (short)0);
 }
 protected short GetAnalogStatus(uint port, RETRO_DEVICE_INDEX_ANALOG analogIndex, RETRO_DEVICE_ID_ANALOG analogDirection)
 {
     return(_retroAnalog != null?_retroAnalog.GetAnalog(port, analogIndex, analogDirection) : FALSE_SHORT);
 }