From 425b1dd47abbcdf5becb6e71e72a53c0e2321fa7 Mon Sep 17 00:00:00 2001 From: Travis Nickles Date: Sun, 3 Mar 2019 00:35:17 -0600 Subject: [PATCH] Change haptic changing routine to skip always searching for existing device --- DS4Windows/DS4Control/ControlService.cs | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/DS4Windows/DS4Control/ControlService.cs b/DS4Windows/DS4Control/ControlService.cs index 580efe4..3f497a5 100644 --- a/DS4Windows/DS4Control/ControlService.cs +++ b/DS4Windows/DS4Control/ControlService.cs @@ -1109,7 +1109,7 @@ namespace DS4Windows if (processingData[ind].Rumble[1] == 0x08) { - setRumble(Big, Small, ind); + SetDevRumble(device, Big, Small, ind); } } } @@ -1304,8 +1304,22 @@ namespace DS4Windows 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) + { + 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); uint lightBoosted = ((uint)lightMotor * (uint)boost) / 100; @@ -1315,12 +1329,7 @@ namespace DS4Windows if (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)