void StopVibration() { #if UNITY_XBOXONE && !UNITY_EDITOR GamepadPlugin.SetGamepadVibration(XboxOneInput.GetControllerId(0), 0f, 0f, 0, 0); #endif #if UNITY_PS4 && !UNITY_EDITOR int val = 0; if (int.TryParse(LoginHandler.instance.UserID, out val)) { PS4Input.PadSetVibration(val, 0, 0); } #endif }
void DoVibration() { #if UNITY_XBOXONE && !UNITY_EDITOR GamepadPlugin.SetGamepadVibration(XboxOneInput.GetControllerId(0), .5f, .5f, 0, 0); #endif #if UNITY_PS4 && !UNITY_EDITOR int val = 0; if (int.TryParse(LoginHandler.instance.UserID, out val)) { PS4Input.PadSetVibration(val, (int)Mathf.Clamp(127 * scale, 0, 255), (int)Mathf.Clamp(127 * scale, 0, 255)); } #endif }
public XboxOneInputDevice(uint joystickId) : base("Xbox One Controller") { JoystickId = joystickId; SortOrder = (int)joystickId; Meta = "Xbox One Device #" + joystickId; DeviceClass = InputDeviceClass.Controller; DeviceStyle = InputDeviceStyle.XboxOne; CacheAnalogAxisNames(); #if UNITY_XBOXONE ControllerId = XboxOneInput.GetControllerId(joystickId); #endif AddControl(InputControlType.LeftStickLeft, "Left Stick Left", LowerDeadZone, UpperDeadZone); AddControl(InputControlType.LeftStickRight, "Left Stick Right", LowerDeadZone, UpperDeadZone); AddControl(InputControlType.LeftStickUp, "Left Stick Up", LowerDeadZone, UpperDeadZone); AddControl(InputControlType.LeftStickDown, "Left Stick Down", LowerDeadZone, UpperDeadZone); AddControl(InputControlType.RightStickLeft, "Right Stick Left", LowerDeadZone, UpperDeadZone); AddControl(InputControlType.RightStickRight, "Right Stick Right", LowerDeadZone, UpperDeadZone); AddControl(InputControlType.RightStickUp, "Right Stick Up", LowerDeadZone, UpperDeadZone); AddControl(InputControlType.RightStickDown, "Right Stick Down", LowerDeadZone, UpperDeadZone); AddControl(InputControlType.LeftTrigger, "Left Trigger", LowerDeadZone, UpperDeadZone); AddControl(InputControlType.RightTrigger, "Right Trigger", LowerDeadZone, UpperDeadZone); AddControl(InputControlType.DPadUp, "DPad Up", LowerDeadZone, UpperDeadZone); AddControl(InputControlType.DPadDown, "DPad Down", LowerDeadZone, UpperDeadZone); AddControl(InputControlType.DPadLeft, "DPad Left", LowerDeadZone, UpperDeadZone); AddControl(InputControlType.DPadRight, "DPad Right", LowerDeadZone, UpperDeadZone); AddControl(InputControlType.Action1, "A"); AddControl(InputControlType.Action2, "B"); AddControl(InputControlType.Action3, "X"); AddControl(InputControlType.Action4, "Y"); AddControl(InputControlType.LeftBumper, "Left Bumper"); AddControl(InputControlType.RightBumper, "Right Bumper"); AddControl(InputControlType.LeftStickButton, "Left Stick Button"); AddControl(InputControlType.RightStickButton, "Right Stick Button"); AddControl(InputControlType.View, "View"); AddControl(InputControlType.Menu, "Menu"); }
void OnPreRender() { if (shakeTime > 0) { shook = true; originalPosition = T.position; Vector3 newPosition = originalPosition; newPosition.x += xAdjustment * scale; newPosition.y += yAdjustment * scale; T.position = newPosition; } else { #if UNITY_XBOXONE && !UNITY_EDITOR GamepadPlugin.SetGamepadVibration(XboxOneInput.GetControllerId(0), 0, 0, 0, 0); #endif } }
public override void Update(ulong updateTick, float deltaTime) { #if UNITY_XBOXONE ControllerId = XboxOneInput.GetControllerId(JoystickId); Debug.Log(XboxOneInput + ":" + JoystickId + ":" + ControllerId); var lsv = new Vector2(GetAnalogValue(AnalogLeftStickX), -GetAnalogValue(AnalogLeftStickY)); UpdateLeftStickWithValue(lsv, updateTick, deltaTime); var rsv = new Vector2(GetAnalogValue(AnalogRightStickX), -GetAnalogValue(AnalogRightStickY)); UpdateRightStickWithValue(rsv, updateTick, deltaTime); UpdateWithValue(InputControlType.LeftTrigger, GetAnalogValue(AnalogLeftTrigger), updateTick, deltaTime); UpdateWithValue(InputControlType.RightTrigger, GetAnalogValue(AnalogRightTrigger), updateTick, deltaTime); UpdateWithState(InputControlType.DPadUp, GetButtonState(XboxOneKeyCode.GamepadButtonDPadUp), updateTick, deltaTime); UpdateWithState(InputControlType.DPadDown, GetButtonState(XboxOneKeyCode.GamepadButtonDPadDown), updateTick, deltaTime); UpdateWithState(InputControlType.DPadLeft, GetButtonState(XboxOneKeyCode.GamepadButtonDPadLeft), updateTick, deltaTime); UpdateWithState(InputControlType.DPadRight, GetButtonState(XboxOneKeyCode.GamepadButtonDPadRight), updateTick, deltaTime); UpdateWithState(InputControlType.Action1, GetButtonState(XboxOneKeyCode.GamepadButtonA), updateTick, deltaTime); UpdateWithState(InputControlType.Action2, GetButtonState(XboxOneKeyCode.GamepadButtonB), updateTick, deltaTime); UpdateWithState(InputControlType.Action3, GetButtonState(XboxOneKeyCode.GamepadButtonX), updateTick, deltaTime); UpdateWithState(InputControlType.Action4, GetButtonState(XboxOneKeyCode.GamepadButtonY), updateTick, deltaTime); UpdateWithState(InputControlType.LeftBumper, GetButtonState(XboxOneKeyCode.GamepadButtonLeftShoulder), updateTick, deltaTime); UpdateWithState(InputControlType.RightBumper, GetButtonState(XboxOneKeyCode.GamepadButtonRightShoulder), updateTick, deltaTime); UpdateWithState(InputControlType.LeftStickButton, GetButtonState(XboxOneKeyCode.GamepadButtonLeftThumbstick), updateTick, deltaTime); UpdateWithState(InputControlType.RightStickButton, GetButtonState(XboxOneKeyCode.GamepadButtonRightThumbstick), updateTick, deltaTime); UpdateWithState(InputControlType.View, GetButtonState(XboxOneKeyCode.GamepadButtonView), updateTick, deltaTime); UpdateWithState(InputControlType.Menu, GetButtonState(XboxOneKeyCode.GamepadButtonMenu), updateTick, deltaTime); Commit(updateTick, deltaTime); #endif }
public ulong XboxOneInput_GetControllerId(uint unityJoystickId) { return(XboxOneInput.GetControllerId(unityJoystickId)); }