From 272eba4432dc021d980d848e9f3c2b80cd1286f1 Mon Sep 17 00:00:00 2001 From: Travis Nickles Date: Tue, 2 May 2017 06:29:46 -0700 Subject: [PATCH] Only read one touch packet --- DS4Windows/DS4Forms/DS4Form.cs | 14 ++++++-------- DS4Windows/DS4Library/DS4Device.cs | 5 ++++- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/DS4Windows/DS4Forms/DS4Form.cs b/DS4Windows/DS4Forms/DS4Form.cs index 830c0a1..12cc8d4 100644 --- a/DS4Windows/DS4Forms/DS4Form.cs +++ b/DS4Windows/DS4Forms/DS4Form.cs @@ -960,21 +960,20 @@ namespace DS4Windows bool inHotPlug = false; protected override void WndProc(ref Message m) { - if (runHotPlug) + try { - try + if (m.Msg == ScpDevice.WM_DEVICECHANGE) { - if (m.Msg == ScpDevice.WM_DEVICECHANGE) + if (runHotPlug) { Int32 Type = m.WParam.ToInt32(); - InnerHotplug2(); } } - catch { } - if (m.Msg == WM_QUERYENDSESSION) - systemShutdown = true; } + catch { } + if (m.Msg == WM_QUERYENDSESSION) + systemShutdown = true; // If this is WM_QUERYENDSESSION, the closing event should be // raised in the base WndProc. @@ -997,7 +996,6 @@ namespace DS4Windows protected async void InnerHotplug2() { - await System.Threading.Tasks.Task.Delay(50); if (inHotPlug) diff --git a/DS4Windows/DS4Library/DS4Device.cs b/DS4Windows/DS4Library/DS4Device.cs index 09b4f2a..ccc4916 100644 --- a/DS4Windows/DS4Library/DS4Device.cs +++ b/DS4Windows/DS4Library/DS4Device.cs @@ -668,7 +668,10 @@ namespace DS4Windows // XXX DS4State mapping needs fixup, turn touches into an array[4] of structs. And include the touchpad details there instead. try { - for (int touches = inputReport[-1 + DS4Touchpad.TOUCHPAD_DATA_OFFSET - 1], touchOffset = 0; touches > 0; touches--, touchOffset += 9) + // Only care if one touch packet is detected. Other touch packets + // don't seem to contain relevant data. ds4drv does not use them either. + for (int touches = Math.Max((int)(inputReport[-1 + DS4Touchpad.TOUCHPAD_DATA_OFFSET - 1]), 1), touchOffset = 0; touches > 0; touches--, touchOffset += 9) + //for (int touches = inputReport[-1 + DS4Touchpad.TOUCHPAD_DATA_OFFSET - 1], touchOffset = 0; touches > 0; touches--, touchOffset += 9) { cState.TouchPacketCounter = inputReport[-1 + DS4Touchpad.TOUCHPAD_DATA_OFFSET + touchOffset]; cState.Touch1 = (inputReport[0 + DS4Touchpad.TOUCHPAD_DATA_OFFSET + touchOffset] >> 7) != 0 ? false : true; // >= 1 touch detected