public void DeviceArrived(IDualShockDevice device) { var target = _client.CreateXbox360Controller(); target.AutoSubmitReport = false; _deviceMap.Add(device, target); if (Configuration.Rumble.IsEnabled) { target.FeedbackReceived += (sender, args) => { var source = _deviceMap.First(m => m.Value.Equals(sender)).Key; RumbleRequestReceived?.Invoke(source, new RumbleRequestEventArgs(args.LargeMotor, args.SmallMotor)); }; } else { Log.Warning("Rumble disabled by configuration"); } try { Log.Information("Connecting ViGEm target {Target}", target); target.Connect(); Log.Information("ViGEm target {Target} connected successfully", target); } catch (Exception ex) { Log.Error("Failed to connect target {@Target}: {Exception}", target, ex); } }
public void DeviceArrived(IDualShockDevice device) { Log.Information("Device {Device} got attached", device); var target = new DualShock4Controller(_client); _deviceMap.Add(device, target); target.FeedbackReceived += (sender, args) => { var source = _deviceMap.First(m => m.Value.Equals(sender)).Key; RumbleRequestReceived?.Invoke(source, new RumbleRequestEventArgs(args.LargeMotor, args.SmallMotor)); }; try { Log.Information("Connecting ViGEm target {Target}", target); target.Connect(); Log.Information("ViGEm target {Target} connected successfully", target); } catch (Exception ex) { Log.Error("Failed to connect target {@Target}: {Exception}", target, ex); } }
public void DeviceRemoved(IDualShockDevice device) { Log.Information("Device {Device} got removed", device); _deviceMap[device].Dispose(); _deviceMap.Remove(device); }
public void DeviceArrived(IDualShockDevice device) { Log.Information("ViGEmNavMergeX360: Device with index {Index} attached", device.DeviceIndex); // Only create virtual 360 controller if one hasn't been created yet if (_target == null) { _target = _client.CreateXbox360Controller(); _target.AutoSubmitReport = false; _target.FeedbackReceived += (sender, args) => { //TODO: Check if needed }; try { Log.Information("ViGEmNavMergeX360: Connecting ViGEm target {Target}", _target); _target.Connect(); Log.Information("ViGEmNavMergeX360: ViGEm target {Target} connected successfully", _target); } catch (Exception ex) { Log.Error("ViGEmNavMergeX360: Failed to connect target {@Target}: {Exception}", _target, ex); } } _deviceCount++; }
public virtual void RemoveDevice(IDualShockDevice Device) { foreach (var dev in ChildDevices) { if (dev.Equals(Device)) { dev.Dispose(); ChildDevices.Remove(dev); break; } } }
public void InputReportReceived(IDualShockDevice device, IInputReport report) { _target.ResetReport(); //This may be able to be optimized, look into later... // Convert report to DS3 format and store latest report for this device var ds3Report = (DualShock3InputReport)report; if (device.DeviceIndex == 0) { _Nav0Report = ds3Report; } if (device.DeviceIndex == 1) { _Nav1Report = ds3Report; } // Only combine reports and submit if we've seen input from each controller at least once if (_Nav0Report != null && _Nav1Report != null) { // Map buttons from Navigation #1 into input report _target.SetAxisValue(Xbox360Axis.LeftThumbX, Scale(_Nav0Report[DualShock3Axes.LeftThumbX], false)); _target.SetAxisValue(Xbox360Axis.LeftThumbY, Scale(_Nav0Report[DualShock3Axes.LeftThumbY], true)); _target.SetAxisValue(Xbox360Axis.RightThumbX, Scale(_Nav1Report[DualShock3Axes.LeftThumbX], false)); _target.SetAxisValue(Xbox360Axis.RightThumbY, Scale(_Nav1Report[DualShock3Axes.LeftThumbY], true)); _target.SetSliderValue(Xbox360Slider.LeftTrigger, _Nav0Report[DualShock3Axes.LeftTrigger]); _target.SetSliderValue(Xbox360Slider.RightTrigger, _Nav1Report[DualShock3Axes.LeftTrigger]); foreach (var button in _btnMap0.Where(m => _Nav0Report.EngagedButtons.Contains(m.Key)) .Select(m => m.Value)) { _target.SetButtonState(button, true); } foreach (var button in _btnMap1.Where(m => _Nav1Report.EngagedButtons.Contains(m.Key)) .Select(m => m.Value)) { _target.SetButtonState(button, true); } _target.SubmitReport(); } }
public void DeviceRemoved(IDualShockDevice device) { Log.Information("ViGEmNavMergeX360: Device with index {Index} detached", device.DeviceIndex); // Only remove the virtual 360 controller if we only had one controller left connected if (_deviceCount == 1) { _target.Disconnect(); _target = null; } _deviceCount--; if (device.DeviceIndex == 0) { _Nav0Report = null; } if (device.DeviceIndex == 1) { _Nav1Report = null; } }
public void InputReportReceived(IDualShockDevice device, IInputReport report) { switch (device.DeviceType) { case DualShockDeviceType.DualShock3: var ds3Report = (DualShock3InputReport)report; if (ds3Report.BatteryState != status) { Log.Information("Battery status for device #{0}: {1}", device, ds3Report.BatteryState); status = ds3Report.BatteryState; } break; default: Log.Information("Break"); break; } }
public void InputReportReceived(IDualShockDevice device, IInputReport report) { switch (device.DeviceType) { case DualShockDeviceType.DualShock3: var target = _deviceMap[device]; target.ResetReport(); var ds3Report = (DualShock3InputReport)report; foreach (var axis in _XaxisMap) { target.SetAxisValue(axis.Value, Scale(ds3Report[axis.Key], false)); } foreach (var axis in _YaxisMap) { target.SetAxisValue(axis.Value, Scale(ds3Report[axis.Key], true)); } foreach (var axis in _triggerAxisMap) { target.SetSliderValue(axis.Value, ds3Report[axis.Key]); } foreach (var button in _btnMap.Where(m => ds3Report.EngagedButtons.Contains(m.Key)) .Select(m => m.Value)) { target.SetButtonState(button, true); } target.SubmitReport(); break; } }
public ChildDeviceRemovedEventArgs(IDualShockDevice device) { Device = device; }
protected void OnInputReportReceived(IDualShockDevice sender, IInputReport report) { InputReportReceived?.Invoke(this, new InputReportReceivedEventArgs(sender, report)); }
public void DeviceRemoved(IDualShockDevice device) { _deviceMap[device].Disconnect(); _deviceMap.Remove(device); }
public void DeviceRemoved(IDualShockDevice device) { }
public void DeviceArrived(IDualShockDevice device) { }
public InputReportReceivedEventArgs(IDualShockDevice device, IInputReport report) { Device = device; Report = report; }
public void InputReportReceived(IDualShockDevice device, IInputReport report) { switch (device.DeviceType) { case DualShockDeviceType.DualShock3: var target = _deviceMap[device]; var ds3Report = (DualShock3InputReport)report; var ds4Report = new DualShock4Report(); ds4Report.SetAxis(DualShock4Axes.LeftThumbX, ds3Report[DualShock3Axes.LeftThumbX]); ds4Report.SetAxis(DualShock4Axes.LeftThumbY, ds3Report[DualShock3Axes.LeftThumbY]); ds4Report.SetAxis(DualShock4Axes.RightThumbX, ds3Report[DualShock3Axes.RightThumbX]); ds4Report.SetAxis(DualShock4Axes.RightThumbY, ds3Report[DualShock3Axes.RightThumbY]); ds4Report.SetAxis(DualShock4Axes.LeftTrigger, ds3Report[DualShock3Axes.LeftTrigger]); ds4Report.SetAxis(DualShock4Axes.RightTrigger, ds3Report[DualShock3Axes.RightTrigger]); ds4Report.SetButtons(_btnMap.Where(m => ds3Report.EngagedButtons.Contains(m.Key)) .Select(m => m.Value).ToArray()); if (ds3Report.EngagedButtons.Contains(DualShock3Buttons.DPadUp)) { ds4Report.SetDPad(DualShock4DPadValues.North); } if (ds3Report.EngagedButtons.Contains(DualShock3Buttons.DPadRight)) { ds4Report.SetDPad(DualShock4DPadValues.East); } if (ds3Report.EngagedButtons.Contains(DualShock3Buttons.DPadDown)) { ds4Report.SetDPad(DualShock4DPadValues.South); } if (ds3Report.EngagedButtons.Contains(DualShock3Buttons.DPadLeft)) { ds4Report.SetDPad(DualShock4DPadValues.West); } if (ds3Report.EngagedButtons.Contains(DualShock3Buttons.DPadUp) && ds3Report.EngagedButtons.Contains(DualShock3Buttons.DPadRight)) { ds4Report.SetDPad(DualShock4DPadValues.Northeast); } if (ds3Report.EngagedButtons.Contains(DualShock3Buttons.DPadRight) && ds3Report.EngagedButtons.Contains(DualShock3Buttons.DPadDown)) { ds4Report.SetDPad(DualShock4DPadValues.Southeast); } if (ds3Report.EngagedButtons.Contains(DualShock3Buttons.DPadDown) && ds3Report.EngagedButtons.Contains(DualShock3Buttons.DPadLeft)) { ds4Report.SetDPad(DualShock4DPadValues.Southwest); } if (ds3Report.EngagedButtons.Contains(DualShock3Buttons.DPadLeft) && ds3Report.EngagedButtons.Contains(DualShock3Buttons.DPadUp)) { ds4Report.SetDPad(DualShock4DPadValues.Northwest); } if (ds3Report.EngagedButtons.Contains(DualShock3Buttons.Ps)) { ds4Report.SetSpecialButtons(DualShock4SpecialButtons.Ps); } target.SendReport(ds4Report); break; } }
public ChildDeviceAttachedEventArgs(IDualShockDevice device) { Device = device; }
public void InputReportReceived(IDualShockDevice device, IInputReport report) { switch (device.DeviceType) { case DualShockDeviceType.DualShock3: var target = _deviceMap[device]; target.ResetReport(); var ds3Report = (DualShock3InputReport)report; foreach (var axis in _XaxisMap) { target.SetAxisValue(axis.Value, ds3Report[axis.Key]); } foreach (var axis in _YaxisMap) { target.SetAxisValue(axis.Value, ds3Report[axis.Key]); } foreach (var axis in _triggerAxisMap) { target.SetSliderValue(axis.Value, ds3Report[axis.Key]); } foreach (var button in _btnMap.Where(m => ds3Report.EngagedButtons.Contains(m.Key)) .Select(m => m.Value)) { target.SetButtonState(button, true); } if (ds3Report.EngagedButtons.Contains(DualShock3Buttons.DPadUp)) { target.SetDPadDirection(DualShock4DPadDirection.North); } if (ds3Report.EngagedButtons.Contains(DualShock3Buttons.DPadRight)) { target.SetDPadDirection(DualShock4DPadDirection.East); } if (ds3Report.EngagedButtons.Contains(DualShock3Buttons.DPadDown)) { target.SetDPadDirection(DualShock4DPadDirection.South); } if (ds3Report.EngagedButtons.Contains(DualShock3Buttons.DPadLeft)) { target.SetDPadDirection(DualShock4DPadDirection.West); } if (ds3Report.EngagedButtons.Contains(DualShock3Buttons.DPadUp) && ds3Report.EngagedButtons.Contains(DualShock3Buttons.DPadRight)) { target.SetDPadDirection(DualShock4DPadDirection.Northeast); } if (ds3Report.EngagedButtons.Contains(DualShock3Buttons.DPadRight) && ds3Report.EngagedButtons.Contains(DualShock3Buttons.DPadDown)) { target.SetDPadDirection(DualShock4DPadDirection.Southeast); } if (ds3Report.EngagedButtons.Contains(DualShock3Buttons.DPadDown) && ds3Report.EngagedButtons.Contains(DualShock3Buttons.DPadLeft)) { target.SetDPadDirection(DualShock4DPadDirection.Southwest); } if (ds3Report.EngagedButtons.Contains(DualShock3Buttons.DPadLeft) && ds3Report.EngagedButtons.Contains(DualShock3Buttons.DPadUp)) { target.SetDPadDirection(DualShock4DPadDirection.Northwest); } target.SubmitReport(); break; } }