11 protected const string XboxController =
"Xbox Controller";
12 protected const string XboxOneForWindows =
"Xbox One For Windows";
13 protected const string XboxBluetoothGamePad =
"Xbox Bluetooth Gamepad";
14 protected const string XboxWirelessController =
"Xbox Wireless Controller";
15 protected const string MotionControllerLeft =
"Spatial Controller - Left";
16 protected const string MotionControllerRight =
"Spatial Controller - Right";
21 [Tooltip(
"Time in seconds to determine if an Input Device has been connected or disconnected")]
22 protected float DeviceRefreshInterval = 3.0f;
27 protected const string DefaultHorizontalAxis =
"Horizontal";
28 protected const string DefaultVerticalAxis =
"Vertical";
29 protected const string DefaultSubmitButton =
"Submit";
30 protected const string DefaultCancelButton =
"Cancel";
31 protected const bool DefaultForceActiveState =
false;
39 private float deviceRefreshTimer;
45 InputModule = FindObjectOfType<StandaloneInputModule>();
47 if (InputModule == null)
49 Debug.LogError(
"Missing the Standalone Input Module for GamePad Input Source!\n" +
50 "Ensure you have an Event System in your scene.");
56 deviceRefreshTimer += Time.unscaledDeltaTime;
58 if (deviceRefreshTimer >= DeviceRefreshInterval)
60 deviceRefreshTimer = 0.0f;
65 #endregion // Unity methods 69 var joystickNames = Input.GetJoystickNames();
71 if (joystickNames.Length <= 0) {
return; }
73 for (var i = 0; i < joystickNames.Length; i++)
75 Debug.LogWarningFormat(
"Joystick \"{0}\" has not been setup with the input manager. Create a new class that inherits from \"GamePadInputSource\" and implement it.", joystickNames[i]);
79 #region Base Input Source Methods 89 position = Vector3.zero;
95 rotation = Quaternion.identity;
101 pointingRay =
default(Ray);
107 position = Vector3.zero;
113 rotation = Quaternion.identity;
122 public override bool TryGetThumbstick(uint sourceId, out
bool isPressed, out Vector2 position)
125 position = Vector2.zero;
129 public override bool TryGetTouchpad(uint sourceId, out
bool isPressed, out
bool isTouched, out Vector2 position)
133 position = Vector2.zero;
137 public override bool TryGetSelect(uint sourceId, out
bool isPressed, out
double pressedAmount)
144 public override bool TryGetGrasp(uint sourceId, out
bool isPressed)
150 public override bool TryGetMenu(uint sourceId, out
bool isPressed)
156 #endregion // Base Input Source Methods