From 1c9cfc1decfceadf92b723c9ad3d96916dec1b77 Mon Sep 17 00:00:00 2001 From: Travis Nickles Date: Mon, 9 Apr 2018 16:04:44 -0500 Subject: [PATCH] Remove controller array scan from each report process --- DS4Windows/DS4Control/ControlService.cs | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/DS4Windows/DS4Control/ControlService.cs b/DS4Windows/DS4Control/ControlService.cs index 70d5ec0..ae43ac1 100644 --- a/DS4Windows/DS4Control/ControlService.cs +++ b/DS4Windows/DS4Control/ControlService.cs @@ -206,7 +206,11 @@ namespace DS4Windows } } - device.Report += this.On_Report; + int tempIdx = i; + device.Report += (sender, e) => + { + this.On_Report(sender, e, tempIdx); + }; TouchPadOn(i, device); CheckProfileOptions(i, device, true); device.StartUpdate(); @@ -378,7 +382,12 @@ namespace DS4Windows LoadProfile(Index, false, this, false, false); touchPad[Index] = new Mouse(Index, device); device.LightBarColor = getMainColor(Index); - device.Report += this.On_Report; + //device.Report += this.On_Report; + int tempIdx = Index; + device.Report += (sender, e) => + { + this.On_Report(sender, e, tempIdx); + }; if (!getDInputOnly(Index) && device.isSynced()) { int xinputIndex = x360Bus.FirstController + Index; @@ -746,17 +755,18 @@ namespace DS4Windows private string[] tempStrings = new string[4] { string.Empty, string.Empty, string.Empty, string.Empty }; // Called every time a new input report has arrived - protected virtual void On_Report(object sender, EventArgs e) + protected virtual void On_Report(object sender, EventArgs e, int ind) { DS4Device device = (DS4Device)sender; - int ind = -1; + /*int ind = -1; for (int i = 0, arlength = DS4_CONTROLLER_COUNT; ind == -1 && i < arlength; i++) { DS4Device tempDev = DS4Controllers[i]; if (tempDev != null && device == tempDev) ind = i; } + */ if (ind != -1) {