11-05-2015, 09:10 PM
(11-05-2015, 09:01 PM)ZmeyNet Wrote: (LOW PRIORITY)
Looking for a way to turn off/disconnect gamepadd remotely (save power) or by pressing some magical button in UI .
I found few places one of them in UsbDs3.cs method ParseHidReport
Code:// detect Quick Disconnect combo (L1, R1 and PS buttons pressed at the same time)
if ((buttons & Ds3Button.L1) == Ds3Button.L1
&& (buttons & Ds3Button.R1) == Ds3Button.R1
&& (buttons & Ds3Button.PS) == Ds3Button.PS) {...
Combination L1+R1+PS wont work (PS3 joy). "PS" button block any other.
my suggestion will be : implementing long PS button press (~5 sec) as trigger:
Code:private int MAGIC_NUMBER_5 = 5;
private bool wasPsButtonPressed;
private DateTime? firstPSButtonPressedTime;
....
public override bool Start(){...
wasPsButtonPressed = false;
firstPSButtonPressedTime = null;
return base.Start();
}
public override void ParseHidReport(byte[] report)
{...
bool isPsButtonPressed = (buttons & Ds3Button.PS) == Ds3Button.PS;
if (isPsButtonPressed && wasPsButtonPressed)
{
if (firstPSButtonPressedTime.HasValue)
{
if ((DateTime.Now - firstPSButtonPressedTime.Value).Seconds > MAGIC_NUMBER_5)
{
trigger = true;
report[13] ^= 0x1;
wasPsButtonPressed = false;
firstPSButtonPressedTime = null;
}
}
else
{
wasPsButtonPressed = false;
firstPSButtonPressedTime = null;
}
}
else
{
if (isPsButtonPressed && !wasPsButtonPressed)
{
wasPsButtonPressed = true;
firstPSButtonPressedTime = DateTime.Now;
}
if (wasPsButtonPressed && !isPsButtonPressed)
{
wasPsButtonPressed = false;
firstPSButtonPressedTime = null;
}
}
...
} //end ParseHidReport
But the existing combo does already work...?!