示例#1
0
 public static InputMap <PolarizedAxisId <TId>, float> PolarizeAxes <TId>(this InputMap <TId, float> inputMap)
 {
     return(inputMap.Source.SelectMany(sourceEntry => {
         TId axisId = sourceEntry.Key;
         Func <float> pollAxis = sourceEntry.Value;
         return new[] {
             new KeyValuePair <PolarizedAxisId <TId>, Func <float> >(
                 new PolarizedAxisId <TId>(axisId, AxisPolarity.Positive),
                 pollAxis.Adapt <float, float>(Adapters.FilterPositiveInput)),
             new KeyValuePair <PolarizedAxisId <TId>, Func <float> >(
                 new PolarizedAxisId <TId>(axisId, AxisPolarity.Negative),
                 pollAxis.Adapt <float, float>(Adapters.FilterNegativeInput)
                 .Adapt <float, float>(Adapters.Abs))
         };
     }).ToInputMap());
 }
示例#2
0
 public static InputMap <Axis, float> Axes(Func <GamePadState> pollState)
 {
     return(new InputMap <Axis, float>(new Dictionary <Axis, Func <float> > {
         { Axis.LeftStickX, pollState.Adapt(state => state.ThumbSticks.Left.X) },
         { Axis.LeftStickY, pollState.Adapt(state => state.ThumbSticks.Left.Y) },
         { Axis.RightStickX, pollState.Adapt(state => state.ThumbSticks.Right.X) },
         { Axis.RightStickY, pollState.Adapt(state => state.ThumbSticks.Right.Y) },
         { Axis.LeftTrigger, pollState.Adapt(state => state.Triggers.Left) },
         { Axis.RightTrigger, pollState.Adapt(state => state.Triggers.Right) },
     }.ToFastImmutableEnumDictionary()));
 }
示例#3
0
 public static InputMap <Button, ButtonState> Buttons(Func <GamePadState> pollState)
 {
     return(new InputMap <Button, XInputDotNetPure.ButtonState>(new Dictionary <Button, Func <XInputDotNetPure.ButtonState> > {
         { Button.Start, pollState.Adapt(state => state.Buttons.Start) },
         { Button.Back, pollState.Adapt(state => state.Buttons.Back) },
         { Button.LeftStick, pollState.Adapt(state => state.Buttons.LeftStick) },
         { Button.RightStick, pollState.Adapt(state => state.Buttons.RightStick) },
         { Button.LeftShoulder, pollState.Adapt(state => state.Buttons.LeftShoulder) },
         { Button.RightShoulder, pollState.Adapt(state => state.Buttons.RightShoulder) },
         { Button.Guide, pollState.Adapt(state => state.Buttons.Guide) },
         { Button.A, pollState.Adapt(state => state.Buttons.A) },
         { Button.B, pollState.Adapt(state => state.Buttons.B) },
         { Button.X, pollState.Adapt(state => state.Buttons.X) },
         { Button.Y, pollState.Adapt(state => state.Buttons.Y) },
         { Button.DPadUp, pollState.Adapt(state => state.DPad.Up) },
         { Button.DPadDown, pollState.Adapt(state => state.DPad.Down) },
         { Button.DPadLeft, pollState.Adapt(state => state.DPad.Left) },
         { Button.DPadRight, pollState.Adapt(state => state.DPad.Right) },
     }.ToFastImmutableEnumDictionary())
            .Adapt(XInputToImperoButtonState));
 }