Only read one touch packet

This commit is contained in:
Travis Nickles 2017-05-02 06:29:46 -07:00
parent 633b0d224f
commit 272eba4432
2 changed files with 10 additions and 9 deletions

View File

@ -960,21 +960,20 @@ namespace DS4Windows
bool inHotPlug = false; bool inHotPlug = false;
protected override void WndProc(ref Message m) 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(); Int32 Type = m.WParam.ToInt32();
InnerHotplug2(); 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 // If this is WM_QUERYENDSESSION, the closing event should be
// raised in the base WndProc. // raised in the base WndProc.
@ -997,7 +996,6 @@ namespace DS4Windows
protected async void InnerHotplug2() protected async void InnerHotplug2()
{ {
await System.Threading.Tasks.Task.Delay(50); await System.Threading.Tasks.Task.Delay(50);
if (inHotPlug) if (inHotPlug)

View File

@ -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. // XXX DS4State mapping needs fixup, turn touches into an array[4] of structs. And include the touchpad details there instead.
try 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.TouchPacketCounter = inputReport[-1 + DS4Touchpad.TOUCHPAD_DATA_OFFSET + touchOffset];
cState.Touch1 = (inputReport[0 + DS4Touchpad.TOUCHPAD_DATA_OFFSET + touchOffset] >> 7) != 0 ? false : true; // >= 1 touch detected cState.Touch1 = (inputReport[0 + DS4Touchpad.TOUCHPAD_DATA_OFFSET + touchOffset] >> 7) != 0 ? false : true; // >= 1 touch detected