mirror of
https://github.com/cemu-project/DS4Windows.git
synced 2024-11-23 01:39:17 +01:00
Use delegate method of grabbing struct reference
Might replace the delegate with a class method later but this method works pretty well as is
This commit is contained in:
parent
05def00614
commit
41fa8cac82
@ -300,7 +300,7 @@ namespace DS4Windows
|
||||
if (tempLightBarOnDuration != haptics.LightBarFlashDurationOn && tempLightBarOnDuration != 1 && haptics.LightBarFlashDurationOn == 0)
|
||||
haptics.LightBarFlashDurationOff = haptics.LightBarFlashDurationOn = 1;
|
||||
|
||||
device.pushHapticState(haptics);
|
||||
device.pushHapticState(ref haptics);
|
||||
}
|
||||
|
||||
public static bool defaultLight = false, shuttingdown = false;
|
||||
|
@ -1231,7 +1231,7 @@ namespace DS4Windows
|
||||
{
|
||||
if (testRumble.IsRumbleSet())
|
||||
{
|
||||
pushHapticState(testRumble);
|
||||
pushHapticState(ref testRumble);
|
||||
if (testRumble.RumbleMotorsExplicitlyOff)
|
||||
testRumble.RumbleMotorsExplicitlyOff = false;
|
||||
}
|
||||
@ -1295,23 +1295,24 @@ namespace DS4Windows
|
||||
hapticStackIndex = 0;
|
||||
}
|
||||
|
||||
delegate void HapticItem(ref DS4HapticState haptic);
|
||||
|
||||
// Use the "most recently set" haptic state for each of light bar/motor.
|
||||
private void setHapticState()
|
||||
{
|
||||
DS4Color lightBarColor = ligtBarColor;
|
||||
byte lightBarFlashDurationOn = ledFlashOn, lightBarFlashDurationOff = ledFlashOff;
|
||||
byte rumbleMotorStrengthLeftHeavySlow = leftHeavySlowRumble,
|
||||
rumbleMotorStrengthRightLightFast = rightLightFastRumble;
|
||||
int hapticLen = hapticState.Length;
|
||||
for (int i=0; i < hapticLen; i++)
|
||||
{
|
||||
DS4HapticState haptic = hapticState[i];
|
||||
if (i == hapticStackIndex)
|
||||
break; // rest haven't been used this time
|
||||
|
||||
((HapticItem)((ref DS4HapticState haptic) => {
|
||||
if (haptic.IsLightBarSet())
|
||||
{
|
||||
lightBarColor = haptic.LightBarColor;
|
||||
ligtBarColor = haptic.LightBarColor;
|
||||
lightBarFlashDurationOn = haptic.LightBarFlashDurationOn;
|
||||
lightBarFlashDurationOff = haptic.LightBarFlashDurationOff;
|
||||
}
|
||||
@ -1321,16 +1322,16 @@ namespace DS4Windows
|
||||
rumbleMotorStrengthLeftHeavySlow = haptic.RumbleMotorStrengthLeftHeavySlow;
|
||||
rumbleMotorStrengthRightLightFast = haptic.RumbleMotorStrengthRightLightFast;
|
||||
}
|
||||
}))(ref hapticState[i]);
|
||||
}
|
||||
|
||||
ligtBarColor = lightBarColor;
|
||||
ledFlashOn = lightBarFlashDurationOn;
|
||||
ledFlashOff = lightBarFlashDurationOff;
|
||||
leftHeavySlowRumble = rumbleMotorStrengthLeftHeavySlow;
|
||||
rightLightFastRumble = rumbleMotorStrengthRightLightFast;
|
||||
}
|
||||
|
||||
public void pushHapticState(DS4HapticState hs)
|
||||
public void pushHapticState(ref DS4HapticState hs)
|
||||
{
|
||||
int hapsLen = hapticState.Length;
|
||||
if (hapticStackIndex == hapsLen)
|
||||
|
Loading…
Reference in New Issue
Block a user