mirror of
https://github.com/cemu-project/DS4Windows.git
synced 2025-01-11 15:59:08 +01:00
Remove some property usage and use explicit getter methods instead.
This shouldn't have been necessary but testing with optimized release builds has shown that the overhead of using properties frequently introduces undesired input lag.
This commit is contained in:
parent
983e55a0fa
commit
4e33578686
@ -31,6 +31,11 @@ namespace DS4Windows
|
||||
public static byte[] forcedFlash = new byte[4];
|
||||
public static void updateLightBar(DS4Device device, int deviceNum, DS4State cState, DS4StateExposed eState, Mouse tp)
|
||||
{
|
||||
/*
|
||||
* TODO: Remove more property usage and use explicit getter methods instead.
|
||||
* Testing in proper optimized release builds shows that it is
|
||||
* still necessary to reduce lag.
|
||||
*/
|
||||
DS4Color color;
|
||||
if (!defualtLight && !forcelight[deviceNum])
|
||||
{
|
||||
@ -86,7 +91,7 @@ namespace DS4Windows
|
||||
|
||||
}
|
||||
|
||||
if (device.Battery <= FlashAt[deviceNum] && !defualtLight && !device.Charging)
|
||||
if (device.getBattery() <= FlashAt[deviceNum] && !defualtLight && !device.isCharging())
|
||||
{
|
||||
if (!(FlashColor[deviceNum].red == 0 &&
|
||||
FlashColor[deviceNum].green == 0 &&
|
||||
@ -106,7 +111,7 @@ namespace DS4Windows
|
||||
}
|
||||
}
|
||||
|
||||
if (IdleDisconnectTimeout[deviceNum] > 0 && LedAsBatteryIndicator[deviceNum] && (!device.Charging || device.Battery >= 100))
|
||||
if (IdleDisconnectTimeout[deviceNum] > 0 && LedAsBatteryIndicator[deviceNum] && (!device.isCharging() || device.getBattery() >= 100))
|
||||
{//Fade lightbar by idle time
|
||||
TimeSpan timeratio = new TimeSpan(DateTime.UtcNow.Ticks - device.lastActive.Ticks);
|
||||
double botratio = timeratio.TotalMilliseconds;
|
||||
@ -164,7 +169,7 @@ namespace DS4Windows
|
||||
if (device.LeftHeavySlowRumble > 100)
|
||||
color = getTransitionedColor(new DS4Color(max, max, 0), new DS4Color(255, 0, 0), rumble);
|
||||
else
|
||||
color = getTransitionedColor(color, getTransitionedColor(new DS4Color(max, max, 0), new DS4Color(255, 0, 0), 39.6078f), device.LeftHeavySlowRumble);
|
||||
color = getTransitionedColor(color, getTransitionedColor(new DS4Color(max, max, 0), new DS4Color(255, 0, 0), 39.6078f), device.getLeftHeavySlowRumble());
|
||||
}
|
||||
DS4HapticState haptics = new DS4HapticState
|
||||
{
|
||||
@ -177,7 +182,7 @@ namespace DS4Windows
|
||||
haptics.LightBarFlashDurationOff = haptics.LightBarFlashDurationOn = (byte)(25 - forcedFlash[deviceNum]);
|
||||
haptics.LightBarExplicitlyOff = true;
|
||||
}
|
||||
else if (device.Battery <= FlashAt[deviceNum] && FlashType[deviceNum] == 0 && !defualtLight && !device.Charging)
|
||||
else if (device.getBattery() <= getFlashAt(deviceNum) && getFlashType(deviceNum) == 0 && !defualtLight && !device.isCharging())
|
||||
{
|
||||
int level = device.Battery / 10;
|
||||
//if (level >= 10)
|
||||
@ -185,9 +190,9 @@ namespace DS4Windows
|
||||
haptics.LightBarFlashDurationOn = BatteryIndicatorDurations[level, 0];
|
||||
haptics.LightBarFlashDurationOff = BatteryIndicatorDurations[level, 1];
|
||||
}
|
||||
else if (distanceprofile && device.LeftHeavySlowRumble > 155) //also part of Distance
|
||||
else if (distanceprofile && device.getLeftHeavySlowRumble() > 155) //also part of Distance
|
||||
{
|
||||
haptics.LightBarFlashDurationOff = haptics.LightBarFlashDurationOn = (byte)((-device.LeftHeavySlowRumble + 265));
|
||||
haptics.LightBarFlashDurationOff = haptics.LightBarFlashDurationOn = (byte)((-device.getLeftHeavySlowRumble() + 265));
|
||||
haptics.LightBarExplicitlyOff = true;
|
||||
}
|
||||
else
|
||||
@ -201,7 +206,9 @@ namespace DS4Windows
|
||||
{
|
||||
haptics.LightBarExplicitlyOff = true;
|
||||
}
|
||||
if (device.LightBarOnDuration != haptics.LightBarFlashDurationOn && device.LightBarOnDuration != 1 && haptics.LightBarFlashDurationOn == 0)
|
||||
|
||||
byte tempLightBarOnDuration = device.getLightBarOnDuration();
|
||||
if (tempLightBarOnDuration != haptics.LightBarFlashDurationOn && tempLightBarOnDuration != 1 && haptics.LightBarFlashDurationOn == 0)
|
||||
haptics.LightBarFlashDurationOff = haptics.LightBarFlashDurationOn = 1;
|
||||
|
||||
// Comment out code for now. This condition gets hit too often and bogs down the GUI
|
||||
|
@ -280,7 +280,17 @@ namespace DS4Windows
|
||||
public static int[] IdleDisconnectTimeout => m_Config.idleDisconnectTimeout;
|
||||
public static byte[] TouchSensitivity => m_Config.touchSensitivity;
|
||||
public static byte[] FlashType => m_Config.flashType;
|
||||
public static byte getFlashType(int index)
|
||||
{
|
||||
return m_Config.flashType[index];
|
||||
}
|
||||
|
||||
public static int[] FlashAt => m_Config.flashAt;
|
||||
public static int getFlashAt(int index)
|
||||
{
|
||||
return m_Config.flashAt[index];
|
||||
}
|
||||
|
||||
public static bool[] LedAsBatteryIndicator => m_Config.ledAsBattery;
|
||||
public static int[] ChargingType => m_Config.chargingType;
|
||||
public static bool[] DinputOnly => m_Config.dinputOnly;
|
||||
@ -320,7 +330,7 @@ namespace DS4Windows
|
||||
public static bool[] MouseAccel => m_Config.mouseAccel;
|
||||
public static string[] LaunchProgram => m_Config.launchProgram;
|
||||
public static string[] ProfilePath => m_Config.profilePath;
|
||||
public static bool[] DistanceProfiles => m_Config.distanceProfiles;
|
||||
public static bool[] DistanceProfiles = m_Config.distanceProfiles;
|
||||
public static List<string>[] ProfileActions => m_Config.profileActions;
|
||||
|
||||
public static void UpdateDS4CSetting (int deviceNum, string buttonName, bool shift, object action, string exts, DS4KeyType kt, int trigger = 0)
|
||||
|
@ -156,7 +156,16 @@ namespace DS4Windows
|
||||
public int IdleTimeout { get; set; } // behavior only active when > 0
|
||||
|
||||
public int Battery => battery;
|
||||
public int getBattery()
|
||||
{
|
||||
return battery;
|
||||
}
|
||||
|
||||
public bool Charging => charging;
|
||||
public bool isCharging()
|
||||
{
|
||||
return charging;
|
||||
}
|
||||
|
||||
public byte RightLightFastRumble
|
||||
{
|
||||
@ -178,6 +187,11 @@ namespace DS4Windows
|
||||
}
|
||||
}
|
||||
|
||||
public byte getLeftHeavySlowRumble()
|
||||
{
|
||||
return leftHeavySlowRumble;
|
||||
}
|
||||
|
||||
public DS4Color LightBarColor
|
||||
{
|
||||
get { return ligtBarColor; }
|
||||
@ -201,6 +215,11 @@ namespace DS4Windows
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public byte getLightBarOnDuration()
|
||||
{
|
||||
return ledFlashOn;
|
||||
}
|
||||
|
||||
public byte LightBarOffDuration
|
||||
{
|
||||
@ -214,6 +233,11 @@ namespace DS4Windows
|
||||
}
|
||||
}
|
||||
|
||||
public byte getLightBarOffDuration()
|
||||
{
|
||||
return ledFlashOff;
|
||||
}
|
||||
|
||||
public DS4Touchpad Touchpad { get { return touchpad; } }
|
||||
public DS4SixAxis SixAxis { get { return sixAxis; } }
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user