Exemplo n.º 1
0
        public byte GetTriggerState(uint trigger)
        {
            if (!Enum.IsDefined(typeof(XboxTrigger), trigger))
            {
                throw new InvalidOperationException("Xbox controller has no such trigger: " + trigger);
            }

            return(VirtualXboxController.GetTriggerValue(this.UserIndex, (XboxTrigger)trigger));
        }
Exemplo n.º 2
0
        public bool GetCustomFunctionState(uint function)
        {
            if (!Enum.IsDefined(typeof(XboxCustomFunction), function))
            {
                throw new InvalidOperationException("Xbox controller has no such custom function: " + function);
            }

            var xboxCustomFunction = (XboxCustomFunction)function;
            var functionType       = Helpers.CustomFunctionHelper.GetFunctionType(xboxCustomFunction);

            switch (functionType)
            {
            case FunctionType.Button:
                return(VirtualXboxController.GetButtonValue(
                           this.UserIndex,
                           Helpers.CustomFunctionHelper.GetXboxButton(xboxCustomFunction)));

            case FunctionType.Axis:
                XboxAxisPosition pos;
                var axis = Helpers.CustomFunctionHelper.GetXboxAxis(xboxCustomFunction, out pos);
                return(VirtualXboxController.GetAxisValue(this.UserIndex, axis) != 0);

            case FunctionType.Dpad:
                return(VirtualXboxController.GetDpadDirectionValue(
                           this.UserIndex,
                           Helpers.CustomFunctionHelper.GetDpadDirection(xboxCustomFunction)));

            case FunctionType.Trigger:
                return(VirtualXboxController.GetTriggerValue(
                           this.UserIndex,
                           Helpers.CustomFunctionHelper.GetXboxTrigger(xboxCustomFunction)) != 0);

            default:
                throw new NotImplementedException("Not implemented Function Type: " + functionType);
            }
        }