private void DoUpdateInput(OutputControllerDualShock4InputState new_state) { controller.SetButtonState(DualShock4Button.Triangle, new_state.triangle); controller.SetButtonState(DualShock4Button.Circle, new_state.circle); controller.SetButtonState(DualShock4Button.Cross, new_state.cross); controller.SetButtonState(DualShock4Button.Square, new_state.square); controller.SetButtonState(DualShock4Button.ShoulderLeft, new_state.shoulder_left); controller.SetButtonState(DualShock4Button.ShoulderRight, new_state.shoulder_right); controller.SetButtonState(DualShock4Button.TriggerLeft, new_state.trigger_left); controller.SetButtonState(DualShock4Button.TriggerRight, new_state.trigger_right); controller.SetButtonState(DualShock4Button.ThumbLeft, new_state.thumb_left); controller.SetButtonState(DualShock4Button.ThumbRight, new_state.thumb_right); controller.SetButtonState(DualShock4Button.Share, new_state.share); controller.SetButtonState(DualShock4Button.Options, new_state.options); controller.SetButtonState(DualShock4SpecialButton.Ps, new_state.ps); controller.SetButtonState(DualShock4SpecialButton.Touchpad, new_state.touchpad); controller.SetDPadDirection(MapDPadDirection(new_state.dPad)); controller.SetAxisValue(DualShock4Axis.LeftThumbX, new_state.thumb_left_x); controller.SetAxisValue(DualShock4Axis.LeftThumbY, new_state.thumb_left_y); controller.SetAxisValue(DualShock4Axis.RightThumbX, new_state.thumb_right_x); controller.SetAxisValue(DualShock4Axis.RightThumbY, new_state.thumb_right_y); controller.SetSliderValue(DualShock4Slider.LeftTrigger, new_state.trigger_left_value); controller.SetSliderValue(DualShock4Slider.RightTrigger, new_state.trigger_right_value); controller.SubmitReport(); current_state = new_state; }
private void LeftAnalogStick(State state) { short x = state.Gamepad.LeftThumbX; short y = state.Gamepad.LeftThumbY; xinput.SetAxisValue(0, x); xinput.SetAxisValue(1, (short)(-y - 1)); }
private void SetValueIfNeeded(DualShock4Axis axis, double?value) { if (value.HasValue) { var newValue = (byte)(value.Value * byte.MaxValue); controller.SetAxisValue(axis, newValue); } }
// DualShockState from PS4RemotePlayInjection public static void ConvertandSendReport(IDualShock4Controller controller, DualShockState state) { // 2021.12.21 pancakeslp // ` controller.ResetReport(); ` // it might make sense to reset the controller/report // but sometimes the report might auto submit, resulting in what looks like a twitch // // this is most easilly observed with having the ADS toggle on, // and then ADSing and taking your hand off the mouse //Left controller.SetButtonState(DualShock4Button.ShoulderLeft, state.L1); SetTriggerLeft(controller, state.L2); controller.SetButtonState(DualShock4Button.ThumbLeft, state.L3); DualShock4DPadDirection tempDPad = DualShock4DPadDirection.None; if (state.DPad_Up && state.DPad_Right) { tempDPad = DualShock4DPadDirection.Northeast; } else if (state.DPad_Up && state.DPad_Left) { tempDPad = DualShock4DPadDirection.Northwest; } else if (state.DPad_Up) { tempDPad = DualShock4DPadDirection.North; } else if (state.DPad_Right && state.DPad_Down) { tempDPad = DualShock4DPadDirection.Southeast; } else if (state.DPad_Right) { tempDPad = DualShock4DPadDirection.East; } else if (state.DPad_Down && state.DPad_Left) { tempDPad = DualShock4DPadDirection.Southwest; } else if (state.DPad_Down) { tempDPad = DualShock4DPadDirection.South; } else if (state.DPad_Left) { tempDPad = DualShock4DPadDirection.West; } controller.SetDPadDirection(tempDPad); controller.SetAxisValue(DualShock4Axis.LeftThumbX, state.LX); controller.SetAxisValue(DualShock4Axis.LeftThumbY, state.LY); //middle controller.SetButtonState(DualShock4Button.Options, state.Options); controller.SetButtonState(DualShock4Button.Share, state.Share); controller.SetButtonState(DualShock4SpecialButton.Ps, state.PS); controller.SetButtonState(DualShock4SpecialButton.Touchpad, state.TouchButton); //Right controller.SetButtonState(DualShock4Button.ShoulderRight, state.R1); SetTriggerRight(controller, state.R2); controller.SetButtonState(DualShock4Button.ThumbRight, state.R3); controller.SetButtonState(DualShock4Button.Circle, state.Circle); controller.SetButtonState(DualShock4Button.Cross, state.Cross); controller.SetButtonState(DualShock4Button.Square, state.Square); controller.SetButtonState(DualShock4Button.Triangle, state.Triangle); controller.SetAxisValue(DualShock4Axis.RightThumbX, state.RX); controller.SetAxisValue(DualShock4Axis.RightThumbY, state.RY); controller.SubmitReport(); }