private State ProcessState(State state) { var eventArgs = new ModifyStateEventArgs(state); OnModifyState(this, eventArgs); state = eventArgs.State; var rtXorig = state.Gamepad.RightThumbX; var rtYorig = state.Gamepad.RightThumbY; int rtX = rtXorig + (int)(DeltaX * 32676); int rtY = rtYorig + (int)(-DeltaY * 32676); rtX = Math.Max(Math.Min(rtX, short.MaxValue), short.MinValue); rtY = Math.Max(Math.Min(rtY, short.MaxValue), short.MinValue); //var deadzone = 10; //if ((Math.Abs(state.Gamepad.RightThumbX) < deadzone) // && (Math.Abs(state.Gamepad.RightThumbY) < deadzone)) { state.Gamepad.RightThumbX = (short)rtX; state.Gamepad.RightThumbY = (short)rtY; } return(state); }
private State ProcessState(State state) { try { var eventArgs = new ModifyStateEventArgs(state); OnModifyState(this, eventArgs); state = eventArgs.State; int rtXorig = state.Gamepad.RightThumbX; int rtYorig = state.Gamepad.RightThumbY; int deadzone = 8689; if (Math.Abs(rtYorig) < deadzone) //deadzone for xbox controller { rtYorig = 0; } int rtX = rtXorig + (int)(DeltaX * 32676); int rtY = rtYorig + (int)(-DeltaY * 32676); rtX = Math.Max(Math.Min(rtX, short.MaxValue), short.MinValue); rtY = Math.Max(Math.Min(rtY, short.MaxValue), short.MinValue); state.Gamepad.RightThumbX = (short)rtX; state.Gamepad.RightThumbY = (short)rtY; } catch (Exception e) { Util.Log("ProcessState: " + e.Message); } return(state); }
private void OnModifyControllerState(object sender, ModifyStateEventArgs modifyStateEventArgs) { if (_shutDownRequestFlag) return; if (_isPaused) return; var timePausedThershold = TimeSpan.FromSeconds(0.5); if (_tickStopwatch.Elapsed > timePausedThershold) return; var state = modifyStateEventArgs.State; var disableA = false; var disableB = false; var disableLeftShoulder = false; var disableRightShoulder = false; var disableLeftThumb = false; var disableRightStick = false; var disableStart = false; if (_isInVehicle) { if (_isInAircraft) { if (_settings.MissilesAtGazeEnabled) disableB = true; if (_settings.IncinerateAtGazeEnabled) disableA = true; } else { if (_settings.AimWithGazeEnabled) disableLeftShoulder = true; if (_settings.MissilesAtGazeEnabled) disableB = true; if (_settings.TaseAtGazeEnabled) disableRightShoulder = true; if (_settings.IncinerateAtGazeEnabled) disableA = true; } } else { if (_settings.AimWithGazeEnabled) { disableLeftThumb = true; if (state.Gamepad.Buttons.HasFlag(GamepadButtonFlags.LeftThumb)) { disableRightStick = true; } } if (_settings.MissilesAtGazeEnabled) disableB = true; if (_settings.TaseAtGazeEnabled) disableRightShoulder = true; if (_settings.IncinerateAtGazeEnabled) disableA = true; } //Toggle menu if (state.Gamepad.Buttons.HasFlag(GamepadButtonFlags.LeftThumb) && state.Gamepad.Buttons.HasFlag(GamepadButtonFlags.Start)) { disableStart = true; disableLeftThumb = true; } if (_menuOpen) { disableA = false; disableB = false; //disableStart = false; } if (_injectRightTrigger>0) { state.Gamepad.RightTrigger = 255; } if (disableStart && state.Gamepad.Buttons.HasFlag(GamepadButtonFlags.Start)) { state.Gamepad.Buttons &= ~GamepadButtonFlags.Start; } if (disableLeftThumb && state.Gamepad.Buttons.HasFlag(GamepadButtonFlags.LeftThumb)) { state.Gamepad.Buttons &= ~GamepadButtonFlags.LeftThumb; } if (disableRightStick) { state.Gamepad.RightThumbX = 0; state.Gamepad.RightThumbY = 0; } if (disableLeftShoulder && state.Gamepad.Buttons.HasFlag(GamepadButtonFlags.LeftShoulder)) { state.Gamepad.Buttons &= ~GamepadButtonFlags.LeftShoulder; } if (disableRightShoulder && state.Gamepad.Buttons.HasFlag(GamepadButtonFlags.RightShoulder)) { state.Gamepad.Buttons &= ~GamepadButtonFlags.RightShoulder; } if (disableA && state.Gamepad.Buttons.HasFlag(GamepadButtonFlags.A)) { state.Gamepad.Buttons &= ~GamepadButtonFlags.A; } if (disableB && state.Gamepad.Buttons.HasFlag(GamepadButtonFlags.B)) { state.Gamepad.Buttons &= ~GamepadButtonFlags.B; } modifyStateEventArgs.State = state; }
private State ProcessState(State state) { var eventArgs = new ModifyStateEventArgs(state); OnModifyState(this, eventArgs); state = eventArgs.State; var rtXorig = state.Gamepad.RightThumbX; var rtYorig = state.Gamepad.RightThumbY; int rtX = rtXorig + (int)(DeltaX * 32676); int rtY = rtYorig + (int)(-DeltaY * 32676); rtX = Math.Max(Math.Min(rtX, short.MaxValue), short.MinValue); rtY = Math.Max(Math.Min(rtY, short.MaxValue), short.MinValue); //var deadzone = 10; //if ((Math.Abs(state.Gamepad.RightThumbX) < deadzone) // && (Math.Abs(state.Gamepad.RightThumbY) < deadzone)) { state.Gamepad.RightThumbX = (short)rtX; state.Gamepad.RightThumbY = (short)rtY; } return state; }
private State ProcessState(State state) { try { var eventArgs = new ModifyStateEventArgs(state); OnModifyState(this, eventArgs); state = eventArgs.State; int rtXorig = state.Gamepad.RightThumbX; int rtYorig = state.Gamepad.RightThumbY; int deadzone = 8689; if (Math.Abs(rtYorig) < deadzone) //deadzone for xbox controller { rtYorig = 0; } int rtX = rtXorig + (int)(DeltaX * 32676); int rtY = rtYorig + (int)(-DeltaY * 32676); rtX = Math.Max(Math.Min(rtX, short.MaxValue), short.MinValue); rtY = Math.Max(Math.Min(rtY, short.MaxValue), short.MinValue); state.Gamepad.RightThumbX = (short)rtX; state.Gamepad.RightThumbY = (short)rtY; } catch (Exception e) { Debug.Log("ProcessState: " + e.Message); } return state; }
private void OnModifyControllerState(object sender, ModifyStateEventArgs modifyStateEventArgs) { if (_shutDownRequestFlag) return; if (_gameState.IsPaused) return; var timePausedThershold = TimeSpan.FromSeconds(0.5); if (DateTime.UtcNow - _lastTickTime > timePausedThershold) return; var state = modifyStateEventArgs.State; var disableA = false; var disableB = false; var disableLeftShoulder = false; var disableRightShoulder = false; var disableLeftThumb = false; var disableRightStick = false; var disableStart = false; var disableRightTrigger = false; if (_gameState.IsInVehicle) { if (_gameState.IsInAircraft) { if (_settings.MissilesAtGazeEnabled) disableB = true; if (_settings.IncinerateAtGazeEnabled) disableA = true; } else { if (_settings.FireAtGazeEnabled) disableLeftShoulder = true; if (_settings.MissilesAtGazeEnabled) disableB = true; if (_settings.TaseAtGazeEnabled) disableRightShoulder = true; if (_settings.IncinerateAtGazeEnabled) disableA = true; } } else { if (_settings.FireAtGazeEnabled) { disableLeftThumb = true; if (state.Gamepad.Buttons.HasFlag(GamepadButtonFlags.LeftThumb)) { disableRightStick = true; } if (!_gameState.IsPaused && !_gameState.IsInRadialMenu && !_gameState.IsMeleeWeapon && !_gameState.IsThrowableWeapon && !_gameState.IsSniperWeaponAndZoomed) { disableRightTrigger = true; } } if (_settings.MissilesAtGazeEnabled) disableB = true; if (_settings.TaseAtGazeEnabled) disableRightShoulder = true; if (_settings.IncinerateAtGazeEnabled) disableA = true; } //Toggle menu if (state.Gamepad.Buttons.HasFlag(GamepadButtonFlags.LeftThumb) && state.Gamepad.Buttons.HasFlag(GamepadButtonFlags.Start)) { disableStart = true; disableLeftThumb = true; } if (_gameState.IsMenuOpen) { disableA = false; disableB = false; //disableStart = false; } if (disableRightTrigger) { state.Gamepad.RightTrigger = 0; } if (disableStart && state.Gamepad.Buttons.HasFlag(GamepadButtonFlags.Start)) { state.Gamepad.Buttons &= ~GamepadButtonFlags.Start; } if (disableLeftThumb && state.Gamepad.Buttons.HasFlag(GamepadButtonFlags.LeftThumb)) { state.Gamepad.Buttons &= ~GamepadButtonFlags.LeftThumb; } if (disableRightStick) { state.Gamepad.RightThumbX = 0; state.Gamepad.RightThumbY = 0; } if (disableLeftShoulder && state.Gamepad.Buttons.HasFlag(GamepadButtonFlags.LeftShoulder)) { state.Gamepad.Buttons &= ~GamepadButtonFlags.LeftShoulder; } if (disableRightShoulder && state.Gamepad.Buttons.HasFlag(GamepadButtonFlags.RightShoulder)) { state.Gamepad.Buttons &= ~GamepadButtonFlags.RightShoulder; } if (disableA && state.Gamepad.Buttons.HasFlag(GamepadButtonFlags.A)) { state.Gamepad.Buttons &= ~GamepadButtonFlags.A; } if (disableB && state.Gamepad.Buttons.HasFlag(GamepadButtonFlags.B)) { state.Gamepad.Buttons &= ~GamepadButtonFlags.B; } modifyStateEventArgs.State = state; }