/// <summary> /// Submits an <see cref="DualShock4Report"/> to this device which will update its state. /// </summary> /// <param name="report">The <see cref="DualShock4Report"/> to submit.</param> public void SendReport(DualShock4Report report) { // Convert managed to unmanaged structure var submit = new ViGEmClient.DS4_REPORT { wButtons = report.Buttons, bSpecial = report.SpecialButtons, bThumbLX = report.LeftThumbX, bThumbLY = report.LeftThumbY, bThumbRX = report.RightThumbX, bThumbRY = report.RightThumbY, bTriggerL = report.LeftTrigger, bTriggerR = report.RightTrigger }; var error = ViGEmClient.vigem_target_ds4_update(Client.NativeHandle, NativeHandle, submit); switch (error) { case ViGEmClient.VIGEM_ERROR.VIGEM_ERROR_BUS_NOT_FOUND: throw new VigemBusNotFoundException(); case ViGEmClient.VIGEM_ERROR.VIGEM_ERROR_INVALID_TARGET: throw new VigemInvalidTargetException(); } }
public void ResetReport() { _nativeReport = default(ViGEmClient.DS4_REPORT); _nativeReport.wButtons &= unchecked ((ushort)~0xF); _nativeReport.wButtons |= 0x08; // resting HAT switch position _nativeReport.bThumbLX = 0x80; // centered axis value _nativeReport.bThumbLY = 0x80; // centered axis value _nativeReport.bThumbRX = 0x80; // centered axis value _nativeReport.bThumbRY = 0x80; // centered axis value }
private void SubmitNativeReport(ViGEmClient.DS4_REPORT report) { var error = ViGEmClient.vigem_target_ds4_update(Client.NativeHandle, NativeHandle, report); switch (error) { case ViGEmClient.VIGEM_ERROR.VIGEM_ERROR_NONE: break; case ViGEmClient.VIGEM_ERROR.VIGEM_ERROR_BUS_INVALID_HANDLE: throw new VigemBusInvalidHandleException(); case ViGEmClient.VIGEM_ERROR.VIGEM_ERROR_INVALID_TARGET: throw new VigemInvalidTargetException(); case ViGEmClient.VIGEM_ERROR.VIGEM_ERROR_BUS_NOT_FOUND: throw new VigemBusNotFoundException(); default: throw new Win32Exception(Marshal.GetLastWin32Error()); } }