mirror of
https://github.com/cemu-project/DS4Windows.git
synced 2024-11-25 18:46:58 +01:00
Enforce lightbar mode setting
This commit is contained in:
parent
fcb081ee5d
commit
6442030926
@ -45,7 +45,8 @@ namespace DS4Windows
|
|||||||
bool useForceLight = forcelight[deviceNum];
|
bool useForceLight = forcelight[deviceNum];
|
||||||
LightbarSettingInfo lightbarSettingInfo = getLightbarSettingsInfo(deviceNum);
|
LightbarSettingInfo lightbarSettingInfo = getLightbarSettingsInfo(deviceNum);
|
||||||
LightbarDS4WinInfo lightModeInfo = lightbarSettingInfo.ds4winSettings;
|
LightbarDS4WinInfo lightModeInfo = lightbarSettingInfo.ds4winSettings;
|
||||||
if (!defaultLight && !useForceLight && lightbarSettingInfo.mode == LightbarMode.DS4Win)
|
bool useLightRoutine = lightbarSettingInfo.mode == LightbarMode.DS4Win;
|
||||||
|
if (!defaultLight && !useForceLight && useLightRoutine)
|
||||||
{
|
{
|
||||||
if (lightModeInfo.useCustomLed)
|
if (lightModeInfo.useCustomLed)
|
||||||
{
|
{
|
||||||
@ -256,87 +257,94 @@ namespace DS4Windows
|
|||||||
else if (useForceLight)
|
else if (useForceLight)
|
||||||
{
|
{
|
||||||
color = forcedColor[deviceNum];
|
color = forcedColor[deviceNum];
|
||||||
|
useLightRoutine = true;
|
||||||
}
|
}
|
||||||
else if (shuttingdown)
|
else if (shuttingdown)
|
||||||
|
{
|
||||||
color = new DS4Color(0, 0, 0);
|
color = new DS4Color(0, 0, 0);
|
||||||
|
useLightRoutine = true;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (device.getConnectionType() == ConnectionType.BT)
|
if (device.getConnectionType() == ConnectionType.BT)
|
||||||
color = new DS4Color(32, 64, 64);
|
color = new DS4Color(32, 64, 64);
|
||||||
else
|
else
|
||||||
color = new DS4Color(0, 0, 0);
|
color = new DS4Color(0, 0, 0);
|
||||||
|
|
||||||
|
useLightRoutine = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool distanceprofile = DistanceProfiles[deviceNum] || tempprofileDistance[deviceNum];
|
if (useLightRoutine)
|
||||||
//distanceprofile = (ProfilePath[deviceNum].ToLower().Contains("distance") || tempprofilename[deviceNum].ToLower().Contains("distance"));
|
|
||||||
if (distanceprofile && !defaultLight)
|
|
||||||
{
|
{
|
||||||
// Thing I did for Distance
|
bool distanceprofile = DistanceProfiles[deviceNum] || tempprofileDistance[deviceNum];
|
||||||
float rumble = device.getLeftHeavySlowRumble() / 2.55f;
|
//distanceprofile = (ProfilePath[deviceNum].ToLower().Contains("distance") || tempprofilename[deviceNum].ToLower().Contains("distance"));
|
||||||
byte max = Max(color.red, Max(color.green, color.blue));
|
if (distanceprofile && !defaultLight)
|
||||||
if (device.getLeftHeavySlowRumble() > 100)
|
|
||||||
{
|
{
|
||||||
DS4Color maxCol = new DS4Color(max, max, 0);
|
// Thing I did for Distance
|
||||||
DS4Color redCol = new DS4Color(255, 0, 0);
|
float rumble = device.getLeftHeavySlowRumble() / 2.55f;
|
||||||
color = getTransitionedColor(ref maxCol, ref redCol, rumble);
|
byte max = Max(color.red, Max(color.green, color.blue));
|
||||||
|
if (device.getLeftHeavySlowRumble() > 100)
|
||||||
|
{
|
||||||
|
DS4Color maxCol = new DS4Color(max, max, 0);
|
||||||
|
DS4Color redCol = new DS4Color(255, 0, 0);
|
||||||
|
color = getTransitionedColor(ref maxCol, ref redCol, rumble);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
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());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
|
||||||
{
|
|
||||||
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
|
DS4HapticState haptics = new DS4HapticState
|
||||||
{
|
{
|
||||||
LightBarColor = color
|
LightBarColor = color
|
||||||
};
|
};
|
||||||
|
|
||||||
if (haptics.IsLightBarSet())
|
if (haptics.IsLightBarSet())
|
||||||
{
|
|
||||||
if (useForceLight && forcedFlash[deviceNum] > 0)
|
|
||||||
{
|
{
|
||||||
haptics.LightBarFlashDurationOff = haptics.LightBarFlashDurationOn = (byte)(25 - forcedFlash[deviceNum]);
|
if (useForceLight && forcedFlash[deviceNum] > 0)
|
||||||
haptics.LightBarExplicitlyOff = true;
|
{
|
||||||
}
|
haptics.LightBarFlashDurationOff = haptics.LightBarFlashDurationOn = (byte)(25 - forcedFlash[deviceNum]);
|
||||||
else if (device.getBattery() <= lightModeInfo.flashAt && lightModeInfo.flashType == 0 && !defaultLight && !device.isCharging())
|
haptics.LightBarExplicitlyOff = true;
|
||||||
{
|
}
|
||||||
int level = device.getBattery() / 10;
|
else if (device.getBattery() <= lightModeInfo.flashAt && lightModeInfo.flashType == 0 && !defaultLight && !device.isCharging())
|
||||||
if (level >= 10)
|
{
|
||||||
level = 10; // all values of >~100% are rendered the same
|
int level = device.getBattery() / 10;
|
||||||
|
if (level >= 10)
|
||||||
|
level = 10; // all values of >~100% are rendered the same
|
||||||
|
|
||||||
haptics.LightBarFlashDurationOn = BatteryIndicatorDurations[level, 0];
|
haptics.LightBarFlashDurationOn = BatteryIndicatorDurations[level, 0];
|
||||||
haptics.LightBarFlashDurationOff = BatteryIndicatorDurations[level, 1];
|
haptics.LightBarFlashDurationOff = BatteryIndicatorDurations[level, 1];
|
||||||
}
|
}
|
||||||
else if (distanceprofile && device.getLeftHeavySlowRumble() > 155) //also part of Distance
|
else if (distanceprofile && device.getLeftHeavySlowRumble() > 155) //also part of Distance
|
||||||
{
|
{
|
||||||
haptics.LightBarFlashDurationOff = haptics.LightBarFlashDurationOn = (byte)((-device.getLeftHeavySlowRumble() + 265));
|
haptics.LightBarFlashDurationOff = haptics.LightBarFlashDurationOn = (byte)((-device.getLeftHeavySlowRumble() + 265));
|
||||||
haptics.LightBarExplicitlyOff = true;
|
haptics.LightBarExplicitlyOff = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//haptics.LightBarFlashDurationOff = haptics.LightBarFlashDurationOn = 1;
|
||||||
|
haptics.LightBarFlashDurationOff = haptics.LightBarFlashDurationOn = 0;
|
||||||
|
haptics.LightBarExplicitlyOff = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//haptics.LightBarFlashDurationOff = haptics.LightBarFlashDurationOn = 1;
|
|
||||||
haptics.LightBarFlashDurationOff = haptics.LightBarFlashDurationOn = 0;
|
|
||||||
haptics.LightBarExplicitlyOff = true;
|
haptics.LightBarExplicitlyOff = true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
haptics.LightBarExplicitlyOff = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
byte tempLightBarOnDuration = device.getLightBarOnDuration();
|
byte tempLightBarOnDuration = device.getLightBarOnDuration();
|
||||||
if (tempLightBarOnDuration != haptics.LightBarFlashDurationOn && tempLightBarOnDuration != 1 && haptics.LightBarFlashDurationOn == 0)
|
if (tempLightBarOnDuration != haptics.LightBarFlashDurationOn && tempLightBarOnDuration != 1 && haptics.LightBarFlashDurationOn == 0)
|
||||||
haptics.LightBarFlashDurationOff = haptics.LightBarFlashDurationOn = 1;
|
haptics.LightBarFlashDurationOff = haptics.LightBarFlashDurationOn = 1;
|
||||||
|
|
||||||
device.SetHapticState(ref haptics);
|
device.SetHapticState(ref haptics);
|
||||||
//device.pushHapticState(ref haptics);
|
//device.pushHapticState(ref haptics);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool defaultLight = false, shuttingdown = false;
|
public static bool defaultLight = false, shuttingdown = false;
|
||||||
|
Loading…
Reference in New Issue
Block a user