Change haptic changing routine to skip always searching for existing device

This commit is contained in:
Travis Nickles 2019-03-03 00:35:17 -06:00
parent a4d7372e7b
commit 425b1dd47a

View File

@ -1109,7 +1109,7 @@ namespace DS4Windows
if (processingData[ind].Rumble[1] == 0x08) if (processingData[ind].Rumble[1] == 0x08)
{ {
setRumble(Big, Small, ind); SetDevRumble(device, Big, Small, ind);
} }
} }
} }
@ -1304,8 +1304,22 @@ namespace DS4Windows
Debug(this, args); Debug(this, args);
} }
//sets the rumble adjusted with rumble boost // sets the rumble adjusted with rumble boost. General use method
public virtual void setRumble(byte heavyMotor, byte lightMotor, int deviceNum) public virtual void setRumble(byte heavyMotor, byte lightMotor, int deviceNum)
{
if (deviceNum < 4)
{
DS4Device device = DS4Controllers[deviceNum];
if (device != null)
SetDevRumble(device, heavyMotor, lightMotor, deviceNum);
//device.setRumble((byte)lightBoosted, (byte)heavyBoosted);
}
}
// sets the rumble adjusted with rumble boost. Method more used for
// report handling. Avoid constant checking for a device.
public void SetDevRumble(DS4Device device,
byte heavyMotor, byte lightMotor, int deviceNum)
{ {
byte boost = getRumbleBoost(deviceNum); byte boost = getRumbleBoost(deviceNum);
uint lightBoosted = ((uint)lightMotor * (uint)boost) / 100; uint lightBoosted = ((uint)lightMotor * (uint)boost) / 100;
@ -1315,13 +1329,8 @@ namespace DS4Windows
if (heavyBoosted > 255) if (heavyBoosted > 255)
heavyBoosted = 255; heavyBoosted = 255;
if (deviceNum < 4)
{
DS4Device device = DS4Controllers[deviceNum];
if (device != null)
device.setRumble((byte)lightBoosted, (byte)heavyBoosted); device.setRumble((byte)lightBoosted, (byte)heavyBoosted);
} }
}
public DS4State getDS4State(int ind) public DS4State getDS4State(int ind)
{ {