Added DS4 feedback event workaround for lightbar color

This commit is contained in:
Travis Nickles 2020-02-22 18:40:14 -06:00
parent 6442030926
commit 653b7424ee
3 changed files with 57 additions and 5 deletions

View File

@ -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);

View File

@ -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)

View File

@ -17,6 +17,7 @@ namespace DS4Windows
public byte red;
public byte green;
public byte blue;
public DS4Color(Color c)
{
red = c.R;