5 using System.Collections.Generic;
18 private class MappingEntry
21 public string Value =
string.Empty;
24 private readonly Dictionary<uint, XboxControllerData> gamePadInputDatas =
new Dictionary<uint, XboxControllerData>(0);
46 private MappingEntry[] mapping = null;
48 private int motionControllerCount = 0;
62 PreviousForceActiveState = InputModule.forceModuleActive;
63 PreviousHorizontalAxis = InputModule.horizontalAxis;
64 PreviousVerticalAxis = InputModule.verticalAxis;
65 PreviousSubmitButton = InputModule.submitButton;
66 PreviousCancelButton = InputModule.cancelButton;
75 if (gamePadInputDatas.Count != 1 || motionControllerCount > 0) {
return; }
125 var joystickNames = Input.GetJoystickNames();
127 if (joystickNames.Length <= 0) {
return; }
129 bool devicesChanged = LastDeviceList == null;
131 if (LastDeviceList != null && joystickNames.Length == LastDeviceList.Length)
133 for (
int i = 0; i < LastDeviceList.Length; i++)
135 if (!joystickNames[i].Equals(LastDeviceList[i]))
137 devicesChanged =
true;
138 if (LastDeviceList == null)
140 LastDeviceList = joystickNames;
146 if (LastDeviceList != null && devicesChanged)
148 foreach (var gamePadInputSource
in gamePadInputDatas)
153 gamePadInputDatas.Clear();
155 if (gamePadInputDatas.Count == 0)
158 InputModule.forceModuleActive = PreviousForceActiveState;
159 InputModule.verticalAxis = PreviousVerticalAxis;
160 InputModule.horizontalAxis = PreviousHorizontalAxis;
161 InputModule.submitButton = PreviousSubmitButton;
162 InputModule.cancelButton = PreviousCancelButton;
166 motionControllerCount = 0;
168 for (var i = 0; i < joystickNames.Length; i++)
170 if (joystickNames[i].Contains(MotionControllerLeft) ||
171 joystickNames[i].Contains(MotionControllerRight))
175 motionControllerCount++;
179 if (joystickNames[i].Contains(XboxController) ||
180 joystickNames[i].Contains(XboxOneForWindows) ||
181 joystickNames[i].Contains(XboxBluetoothGamePad) ||
182 joystickNames[i].Contains(XboxWirelessController))
185 if (gamePadInputDatas.Count != 0) {
return; }
189 gamePadInputDatas.Add(SourceId, controllerData);
194 InputModule.forceModuleActive =
true;
218 LastDeviceList = joystickNames;
219 LastDeviceUpdateCount = joystickNames.Length;