mirror of
https://github.com/cemu-project/DS4Windows.git
synced 2024-11-26 11:04:21 +01:00
Remove some struct copying from lightbar routine
This commit is contained in:
parent
2a4570bb73
commit
ce0ac67dcd
@ -49,7 +49,7 @@ namespace DS4Windows
|
||||
{
|
||||
DS4Color fullColor = getCustomColor(deviceNum);
|
||||
DS4Color lowColor = getLowColor(deviceNum);
|
||||
color = getTransitionedColor(lowColor, fullColor, device.getBattery());
|
||||
color = getTransitionedColor(ref lowColor, ref fullColor, device.getBattery());
|
||||
}
|
||||
else
|
||||
color = getCustomColor(deviceNum);
|
||||
@ -85,7 +85,7 @@ namespace DS4Windows
|
||||
{
|
||||
DS4Color fullColor = getMainColor(deviceNum);
|
||||
DS4Color lowColor = getLowColor(deviceNum);
|
||||
color = getTransitionedColor(lowColor, fullColor, device.getBattery());
|
||||
color = getTransitionedColor(ref lowColor, ref fullColor, device.getBattery());
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -144,7 +144,8 @@ namespace DS4Windows
|
||||
}
|
||||
}
|
||||
|
||||
color = getTransitionedColor(color, new DS4Color(0, 0, 0), ratio);
|
||||
DS4Color tempCol = new DS4Color(0, 0, 0);
|
||||
color = getTransitionedColor(ref color, ref tempCol, ratio);
|
||||
}
|
||||
}
|
||||
|
||||
@ -159,11 +160,16 @@ namespace DS4Windows
|
||||
double ratio = 100.0 * (botratio / topratio), elapsed = ratio;
|
||||
if (ratio >= 50.0 && ratio < 100.0)
|
||||
{
|
||||
color = getTransitionedColor(color, new DS4Color(0, 0, 0),
|
||||
DS4Color emptyCol = new DS4Color(0, 0, 0);
|
||||
color = getTransitionedColor(ref color, ref emptyCol,
|
||||
(uint)(-100.0 * (elapsed = 0.02 * (ratio - 50.0)) * (elapsed - 2.0)));
|
||||
}
|
||||
else if (ratio >= 100.0)
|
||||
color = getTransitionedColor(color, new DS4Color(0, 0, 0), 100.0);
|
||||
{
|
||||
DS4Color emptyCol = new DS4Color(0, 0, 0);
|
||||
color = getTransitionedColor(ref color, ref emptyCol, 100.0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (device.isCharging() && device.getBattery() < 100)
|
||||
@ -217,7 +223,8 @@ namespace DS4Windows
|
||||
}
|
||||
}
|
||||
|
||||
color = getTransitionedColor(color, new DS4Color(0, 0, 0), ratio);
|
||||
DS4Color emptyCol = new DS4Color(0, 0, 0);
|
||||
color = getTransitionedColor(ref color, ref emptyCol, ratio);
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
@ -257,9 +264,22 @@ namespace DS4Windows
|
||||
float rumble = device.getLeftHeavySlowRumble() / 2.55f;
|
||||
byte max = Max(color.red, Max(color.green, color.blue));
|
||||
if (device.getLeftHeavySlowRumble() > 100)
|
||||
color = getTransitionedColor(new DS4Color(max, max, 0), new DS4Color(255, 0, 0), rumble);
|
||||
{
|
||||
DS4Color maxCol = new DS4Color(max, max, 0);
|
||||
DS4Color redCol = new DS4Color(255, 0, 0);
|
||||
color = getTransitionedColor(ref maxCol, ref redCol, rumble);
|
||||
}
|
||||
|
||||
else
|
||||
color = getTransitionedColor(color, getTransitionedColor(new DS4Color(max, max, 0), new DS4Color(255, 0, 0), 39.6078f), device.getLeftHeavySlowRumble());
|
||||
{
|
||||
DS4Color maxCol = new DS4Color(max, max, 0);
|
||||
DS4Color redCol = new DS4Color(255, 0, 0);
|
||||
DS4Color tempCol = getTransitionedColor(ref maxCol,
|
||||
ref redCol, 39.6078f);
|
||||
color = getTransitionedColor(ref color, ref tempCol,
|
||||
device.getLeftHeavySlowRumble());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
DS4HapticState haptics = new DS4HapticState
|
||||
|
@ -1885,9 +1885,9 @@ namespace DS4Windows
|
||||
}
|
||||
DS4Color empty = new DS4Color(byte.Parse(dets[3]), byte.Parse(dets[4]), byte.Parse(dets[5]));
|
||||
DS4Color full = new DS4Color(byte.Parse(dets[6]), byte.Parse(dets[7]), byte.Parse(dets[8]));
|
||||
DS4Color trans = getTransitionedColor(empty, full, d.Battery);
|
||||
DS4Color trans = getTransitionedColor(ref empty, ref full, d.Battery);
|
||||
if (fadetimer[device] < 100)
|
||||
DS4LightBar.forcedColor[device] = getTransitionedColor(lastColor[device], trans, fadetimer[device] += 2);
|
||||
DS4LightBar.forcedColor[device] = getTransitionedColor(ref lastColor[device], ref trans, fadetimer[device] += 2);
|
||||
}
|
||||
actionDone[index].dev[device] = true;
|
||||
}
|
||||
|
@ -1319,17 +1319,20 @@ namespace DS4Windows
|
||||
else if (r < 0.0)
|
||||
r = 0.0;
|
||||
|
||||
r /= 100.0;
|
||||
return (byte)Math.Round((b1 * (1 - r) + b2 * r), 0);
|
||||
r *= 0.01;
|
||||
return (byte)Math.Round((b1 * (1 - r)) + b2 * r, 0);
|
||||
}
|
||||
|
||||
public static DS4Color getTransitionedColor(DS4Color c1, DS4Color c2, double ratio)
|
||||
public static DS4Color getTransitionedColor(ref DS4Color c1, ref DS4Color c2, double ratio)
|
||||
{
|
||||
//Color cs = Color.FromArgb(c1.red, c1.green, c1.blue);
|
||||
c1.red = applyRatio(c1.red, c2.red, ratio);
|
||||
c1.green = applyRatio(c1.green, c2.green, ratio);
|
||||
c1.blue = applyRatio(c1.blue, c2.blue, ratio);
|
||||
return c1;
|
||||
DS4Color cs = new DS4Color
|
||||
{
|
||||
red = applyRatio(c1.red, c2.red, ratio),
|
||||
green = applyRatio(c1.green, c2.green, ratio),
|
||||
blue = applyRatio(c1.blue, c2.blue, ratio)
|
||||
};
|
||||
return cs;
|
||||
}
|
||||
|
||||
private static Color applyRatio(Color c1, Color c2, uint r)
|
||||
|
Loading…
Reference in New Issue
Block a user