diff --git a/DS4Windows/DS4Control/ControlService.cs b/DS4Windows/DS4Control/ControlService.cs index cb852c1..2972ddd 100644 --- a/DS4Windows/DS4Control/ControlService.cs +++ b/DS4Windows/DS4Control/ControlService.cs @@ -413,7 +413,59 @@ namespace DS4Windows int devIndex = index; tempDS4.cont.FeedbackReceived += (sender, args) => { - SetDevRumble(device, args.LargeMotor, args.SmallMotor, devIndex); + bool useRumble = false; bool useLight = false; + byte largeMotor = args.LargeMotor; + byte smallMotor = args.SmallMotor; + DS4Color color = new DS4Color(args.LightbarColor.Red, + args.LightbarColor.Green, + args.LightbarColor.Blue); + /*Console.WriteLine("IN EVENT"); + Console.WriteLine("Rumble ({0}, {1}) | Light ({2}, {3}, {4}) {5}", + largeMotor, smallMotor, color.red, color.green, color.blue, DateTime.Now.ToLongTimeString()); + */ + if (largeMotor != 0 || smallMotor != 0) + { + useRumble = true; + } + + if (color.red != 0 || color.green != 0 || color.blue != 0) + { + useLight = true; + } + + if (!useRumble && !useLight) + { + //Console.WriteLine("Fallback"); + if (device.LeftHeavySlowRumble != 0 || device.RightLightFastRumble != 0) + { + useRumble = true; + } + /*else if (device.LightBarColor.red != 0 || + device.LightBarColor.green != 0 || + device.LightBarColor.blue != 0) + { + useLight = true; + } + */ + } + + if (useRumble) + { + //Console.WriteLine("Perform rumble"); + SetDevRumble(device, largeMotor, smallMotor, devIndex); + } + + if (useLight) + { + //Console.WriteLine("Change lightbar color"); + DS4HapticState haptics = new DS4HapticState + { + LightBarColor = color, + }; + device.SetHapticState(ref haptics); + } + + //Console.WriteLine(); }; outputslotMan.DeferredPlugin(tempDS4, index, outputDevices); diff --git a/DS4Windows/DS4Control/DS4LightBar.cs b/DS4Windows/DS4Control/DS4LightBar.cs index 2631ede..c7fb7c0 100644 --- a/DS4Windows/DS4Control/DS4LightBar.cs +++ b/DS4Windows/DS4Control/DS4LightBar.cs @@ -41,11 +41,12 @@ namespace DS4Windows public static void updateLightBar(DS4Device device, int deviceNum) { - DS4Color color; + DS4Color color = new DS4Color(); bool useForceLight = forcelight[deviceNum]; LightbarSettingInfo lightbarSettingInfo = getLightbarSettingsInfo(deviceNum); LightbarDS4WinInfo lightModeInfo = lightbarSettingInfo.ds4winSettings; bool useLightRoutine = lightbarSettingInfo.mode == LightbarMode.DS4Win; + //bool useLightRoutine = false; if (!defaultLight && !useForceLight && useLightRoutine) { if (lightModeInfo.useCustomLed) @@ -264,14 +265,12 @@ namespace DS4Windows color = new DS4Color(0, 0, 0); useLightRoutine = true; } - else + else if (useLightRoutine) { if (device.getConnectionType() == ConnectionType.BT) color = new DS4Color(32, 64, 64); else color = new DS4Color(0, 0, 0); - - useLightRoutine = true; } if (useLightRoutine) diff --git a/DS4Windows/DS4Library/DS4Device.cs b/DS4Windows/DS4Library/DS4Device.cs index 18e02b1..0e006b6 100644 --- a/DS4Windows/DS4Library/DS4Device.cs +++ b/DS4Windows/DS4Library/DS4Device.cs @@ -17,6 +17,7 @@ namespace DS4Windows public byte red; public byte green; public byte blue; + public DS4Color(Color c) { red = c.R;