-
Notifications
You must be signed in to change notification settings - Fork 33
/
DefaultControllerPresets.cs
71 lines (51 loc) · 3.86 KB
/
DefaultControllerPresets.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
using System;
using System.Collections.Generic;
namespace KSPAdvancedFlyByWire
{
class DefaultControllerPresets
{
public static List<ControllerPreset> GetDefaultPresets(IController controller)
{
List<ControllerPreset> presets = new List<ControllerPreset>();
#if !LINUX
if (Utility.CheckXInputSupport() && controller is XInputController)
{
presets.Add(GetXInputDefaultRocketPreset(controller));
}
#endif
return presets;
}
public static ControllerPreset GetXInputDefaultRocketPreset(IController controller)
{
ControllerPreset preset = new ControllerPreset();
preset.name = "XInput Default";
#if !LINUX
int buttonsCount = controller.GetButtonsCount();
preset.SetDiscreteBinding(new Bitset(buttonsCount, (int)XInput.Button.DPadLeft), DiscreteAction.SAS);
preset.SetDiscreteBinding(new Bitset(buttonsCount, (int)XInput.Button.DPadRight), DiscreteAction.Light);
preset.SetDiscreteBinding(new Bitset(buttonsCount, (int)XInput.Button.DPadUp), DiscreteAction.RCS);
preset.SetDiscreteBinding(new Bitset(buttonsCount, (int)XInput.Button.DPadDown), DiscreteAction.Gear);
preset.SetDiscreteBinding(new Bitset(buttonsCount, (int)XInput.Button.Back), DiscreteAction.Abort);
preset.SetDiscreteBinding(new Bitset(buttonsCount, (int)XInput.Button.X), DiscreteAction.NextPreset);
preset.SetDiscreteBinding(new Bitset(buttonsCount, (int)XInput.Button.Y), DiscreteAction.FullThrottle);
preset.SetDiscreteBinding(new Bitset(buttonsCount, (int)XInput.Button.A), DiscreteAction.Stage);
preset.SetDiscreteBinding(new Bitset(buttonsCount, (int)XInput.Button.B), DiscreteAction.CutThrottle);
preset.SetDiscreteBinding(new Bitset(buttonsCount, (int)XInput.Button.LeftStick), DiscreteAction.CameraViewToggle);
preset.SetDiscreteBinding(new Bitset(buttonsCount, (int)XInput.Button.RightStick), DiscreteAction.NavballToggle);
preset.SetDiscreteBinding(new Bitset(buttonsCount, (int)XInput.Button.Guide), DiscreteAction.OrbitMapToggle);
preset.SetContinuousBinding((int)XInput.AnalogInput.LeftStickX, new Bitset(buttonsCount), ContinuousAction.CameraX, false);
preset.SetContinuousBinding((int)XInput.AnalogInput.LeftStickY, new Bitset(buttonsCount), ContinuousAction.CameraY, false);
preset.SetContinuousBinding((int)XInput.AnalogInput.LeftStickY, new Bitset(buttonsCount, (int)XInput.Button.LB), ContinuousAction.CameraZoom, false);
preset.SetContinuousBinding((int)XInput.AnalogInput.RightStickX, new Bitset(buttonsCount), ContinuousAction.Yaw, false);
preset.SetContinuousBinding((int)XInput.AnalogInput.RightStickY, new Bitset(buttonsCount), ContinuousAction.Pitch, false);
preset.SetContinuousBinding((int)XInput.AnalogInput.RightStickX, new Bitset(buttonsCount, (int)XInput.Button.LB), ContinuousAction.Roll, false);
preset.SetContinuousBinding((int)XInput.AnalogInput.RightStickX, new Bitset(buttonsCount, (int)XInput.Button.RB), ContinuousAction.X, false);
preset.SetContinuousBinding((int)XInput.AnalogInput.RightStickY, new Bitset(buttonsCount, (int)XInput.Button.RB), ContinuousAction.Y, false);
preset.SetContinuousBinding((int)XInput.AnalogInput.RightStickX, new Bitset(buttonsCount, (int)XInput.Button.LB | (int)XInput.Button.RB), ContinuousAction.Z, false);
preset.SetContinuousBinding((int)XInput.AnalogInput.LeftTrigger, new Bitset(buttonsCount), ContinuousAction.ThrottleDecrement, false);
preset.SetContinuousBinding((int)XInput.AnalogInput.RightTrigger, new Bitset(buttonsCount), ContinuousAction.ThrottleIncrement, false);
#endif
return preset;
}
}
}