Allow BT poll rate to be specified. Use thread action queue now. Some bug fixes

This commit is contained in:
Travis Nickles 2017-05-16 23:02:12 -07:00
parent 9b78668935
commit ac23921978
10 changed files with 354 additions and 147 deletions

View File

@ -153,13 +153,13 @@ namespace DS4Windows
device.Report += this.On_Report;
TouchPadOn(i, device);
device.setIdleTimeout(getIdleDisconnectTimeout(i));
CheckProfileOptions(i, device, true);
device.StartUpdate();
//string filename = ProfilePath[ind];
//ind++;
if (showlog)
{
if (System.IO.File.Exists(appdatapath + "\\Profiles\\" + ProfilePath[i] + ".xml"))
if (File.Exists(appdatapath + "\\Profiles\\" + ProfilePath[i] + ".xml"))
{
string prolog = Properties.Resources.UsingProfile.Replace("*number*", (i + 1).ToString()).Replace("*Profile name*", ProfilePath[i]);
LogDebug(prolog);
@ -343,12 +343,11 @@ namespace DS4Windows
}
TouchPadOn(Index, device);
device.setIdleTimeout(getIdleDisconnectTimeout(Index));
CheckProfileOptions(Index, device);
device.StartUpdate();
//string filename = Path.GetFileName(ProfilePath[Index]);
if (System.IO.File.Exists(appdatapath + "\\Profiles\\" + ProfilePath[Index] + ".xml"))
if (File.Exists(appdatapath + "\\Profiles\\" + ProfilePath[Index] + ".xml"))
{
string prolog = Properties.Resources.UsingProfile.Replace("*number*", (Index + 1).ToString()).Replace("*Profile name*", ProfilePath[Index]);
LogDebug(prolog);
@ -370,7 +369,18 @@ namespace DS4Windows
return true;
}
private void CheckProfileOptions(int ind, DS4Device device)
private void CheckProfileOptions(int ind, DS4Device device, bool startUp=false)
{
device.setIdleTimeout(getIdleDisconnectTimeout(ind));
device.setBTPollRate(getBTPollRate(ind));
if (!startUp)
{
CheckLauchProfileOption(ind, device);
}
}
private void CheckLauchProfileOption(int ind, DS4Device device)
{
string programPath = LaunchProgram[ind];
if (programPath != string.Empty)

View File

@ -34,11 +34,6 @@ namespace DS4Windows
public static void updateLightBar(DS4Device device, int deviceNum, DS4State cState,
DS4StateExposed eState, Mouse tp)
{
/*
* TODO: Remove more property usage and use explicit getter methods instead.
* Testing in proper optimized release builds shows that it is
* still necessary to reduce lag.
*/
DS4Color color;
if (!defaultLight && !forcelight[deviceNum])
{

View File

@ -1890,6 +1890,7 @@ namespace DS4Windows
}
}
}
untriggeraction[device] = null;
LoadProfile(device, false, ctrl);
}

View File

@ -721,6 +721,12 @@ namespace DS4Windows
return m_Config.mouseAccel[device];
}
public static int[] BTPollRate => m_Config.btPollRate;
public static int getBTPollRate(int index)
{
return m_Config.btPollRate[index];
}
public static string[] LaunchProgram => m_Config.launchProgram;
public static string[] ProfilePath => m_Config.profilePath;
public static bool[] DistanceProfiles = m_Config.distanceProfiles;
@ -1047,6 +1053,7 @@ namespace DS4Windows
public double[] rainbow = { 0, 0, 0, 0, 0 };
public int[] flashAt = { 0, 0, 0, 0, 0 };
public bool[] mouseAccel = { true, true, true, true, true };
public int[] btPollRate = { 0, 0, 0, 0, 0 };
public DS4Color[] m_LowLeds = new DS4Color[]
{
new DS4Color(Color.Black),
@ -1317,6 +1324,7 @@ namespace DS4Windows
XmlNode xmlLSC = m_Xdoc.CreateNode(XmlNodeType.Element, "LSCurve", null); xmlLSC.InnerText = lsCurve[device].ToString(); Node.AppendChild(xmlLSC);
XmlNode xmlRSC = m_Xdoc.CreateNode(XmlNodeType.Element, "RSCurve", null); xmlRSC.InnerText = rsCurve[device].ToString(); Node.AppendChild(xmlRSC);
XmlNode xmlProfileActions = m_Xdoc.CreateNode(XmlNodeType.Element, "ProfileActions", null); xmlProfileActions.InnerText = string.Join("/", profileActions[device]); Node.AppendChild(xmlProfileActions);
XmlNode xmlBTPollRate = m_Xdoc.CreateNode(XmlNodeType.Element, "BTPollRate", null); xmlBTPollRate.InnerText = btPollRate[device].ToString(); Node.AppendChild(xmlBTPollRate);
XmlNode NodeControl = m_Xdoc.CreateNode(XmlNodeType.Element, "Control", null);
XmlNode Key = m_Xdoc.CreateNode(XmlNodeType.Element, "Key", null);
@ -1823,7 +1831,9 @@ namespace DS4Windows
return "Unbound";
}
public Boolean LoadProfile(int device, bool launchprogram, ControlService control, string propath = "", bool xinputChange = true)
/* TODO: Explicitly reset profile values back to default before loading new profile. */
public bool LoadProfile(int device, bool launchprogram, ControlService control,
string propath = "", bool xinputChange = true)
{
Boolean Loaded = true;
Dictionary<DS4Controls, DS4KeyType> customMapKeyTypes = new Dictionary<DS4Controls, DS4KeyType>();
@ -1854,11 +1864,13 @@ namespace DS4Windows
rootname = "ScpControl";
missingSetting = true;
}
if (device < 4)
{
DS4LightBar.forcelight[device] = false;
DS4LightBar.forcedFlash[device] = 0;
}
try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/flushHIDQueue"); Boolean.TryParse(Item.InnerText, out flushHIDQueue[device]); }
catch { missingSetting = true; }//rootname = }
@ -1915,6 +1927,7 @@ namespace DS4Windows
colors = Item.InnerText.Split(',');
else
colors = new string[0];
m_LowLeds[device].red = byte.Parse(colors[0]);
m_LowLeds[device].green = byte.Parse(colors[1]);
m_LowLeds[device].blue = byte.Parse(colors[2]);
@ -1923,11 +1936,11 @@ namespace DS4Windows
if (m_Xdoc.SelectSingleNode("/" + rootname + "/LowColor") == null)
{
//Old method of color saving
try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/LowRed"); Byte.TryParse(Item.InnerText, out m_LowLeds[device].red); }
try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/LowRed"); byte.TryParse(Item.InnerText, out m_LowLeds[device].red); }
catch { missingSetting = true; }
try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/LowGreen"); Byte.TryParse(Item.InnerText, out m_LowLeds[device].green); }
try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/LowGreen"); byte.TryParse(Item.InnerText, out m_LowLeds[device].green); }
catch { missingSetting = true; }
try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/LowBlue"); Byte.TryParse(Item.InnerText, out m_LowLeds[device].blue); }
try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/LowBlue"); byte.TryParse(Item.InnerText, out m_LowLeds[device].blue); }
catch { missingSetting = true; }
}
//New method for saving color
@ -1982,45 +1995,45 @@ namespace DS4Windows
try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/RightTriggerMiddle"); byte.TryParse(Item.InnerText, out r2Deadzone[device]); }
catch { missingSetting = true; }
try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/L2AntiDeadZone"); int.TryParse(Item.InnerText, out l2AntiDeadzone[device]); }
catch { missingSetting = true; }
catch { l2AntiDeadzone[device] = 0; missingSetting = true; }
try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/R2AntiDeadZone"); int.TryParse(Item.InnerText, out r2AntiDeadzone[device]); }
catch { missingSetting = true; }
catch { r2AntiDeadzone[device] = 0; missingSetting = true; }
try {
Item = m_Xdoc.SelectSingleNode("/" + rootname + "/L2MaxZone"); int temp = 100;
int.TryParse(Item.InnerText, out temp);
l2Maxzone[device] = Math.Min(Math.Max(temp, 0), 100);
}
catch { missingSetting = true; }
catch { l2Maxzone[device] = 100; missingSetting = true; }
try {
Item = m_Xdoc.SelectSingleNode("/" + rootname + "/R2MaxZone"); int temp = 100;
int.TryParse(Item.InnerText, out temp);
r2Maxzone[device] = Math.Min(Math.Max(temp, 0), 100);
}
catch { missingSetting = true; }
catch { r2Maxzone[device] = 100; missingSetting = true; }
try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/ButtonMouseSensitivity"); int.TryParse(Item.InnerText, out buttonMouseSensitivity[device]); }
catch { missingSetting = true; }
try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/Rainbow"); double.TryParse(Item.InnerText, out rainbow[device]); }
catch { rainbow[device] = 0; missingSetting = true; }
try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/LSDeadZone"); int.TryParse(Item.InnerText, out LSDeadzone[device]); }
catch { missingSetting = true; }
catch { LSDeadzone[device] = 0; missingSetting = true; }
try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/RSDeadZone"); int.TryParse(Item.InnerText, out RSDeadzone[device]); }
catch { missingSetting = true; }
catch { RSDeadzone[device] = 0; missingSetting = true; }
try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/LSAntiDeadZone"); int.TryParse(Item.InnerText, out LSAntiDeadzone[device]); }
catch { missingSetting = true; }
catch { LSAntiDeadzone[device] = 0; missingSetting = true; }
try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/RSAntiDeadZone"); int.TryParse(Item.InnerText, out RSAntiDeadzone[device]); }
catch { missingSetting = true; }
catch { RSAntiDeadzone[device] = 0; missingSetting = true; }
try {
Item = m_Xdoc.SelectSingleNode("/" + rootname + "/LSMaxZone"); int temp = 100;
int.TryParse(Item.InnerText, out temp);
LSMaxzone[device] = Math.Min(Math.Max(temp, 0), 100);
}
catch { missingSetting = true; }
catch { LSMaxzone[device] = 100; missingSetting = true; }
try {
Item = m_Xdoc.SelectSingleNode("/" + rootname + "/RSMaxZone"); int temp = 100;
int.TryParse(Item.InnerText, out temp);
RSMaxzone[device] = Math.Min(Math.Max(temp, 0), 100);
}
catch { missingSetting = true; }
catch { RSMaxzone[device] = 100; missingSetting = true; }
try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/SXDeadZone"); double.TryParse(Item.InnerText, out SXDeadzone[device]); }
catch { missingSetting = true; }
try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/SZDeadZone"); double.TryParse(Item.InnerText, out SZDeadzone[device]); }
@ -2049,6 +2062,7 @@ namespace DS4Windows
catch { missingSetting = true; }
try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/MouseAcceleration"); bool.TryParse(Item.InnerText, out mouseAccel[device]); }
catch { missingSetting = true; }
int shiftM = 0;
if (m_Xdoc.SelectSingleNode("/" + rootname + "/ShiftModifier") != null)
int.TryParse(m_Xdoc.SelectSingleNode("/" + rootname + "/ShiftModifier").InnerText, out shiftM);
@ -2101,18 +2115,22 @@ namespace DS4Windows
Item = m_Xdoc.SelectSingleNode("/" + rootname + "/DinputOnly");
bool.TryParse(Item.InnerText, out dinputOnly[device]);
}
catch { missingSetting = true; }
catch { dinputOnly[device] = false; missingSetting = true; }
bool oldUseDInputOnly = Global.useDInputOnly[device];
Global.useDInputOnly[device] = dinputOnly[device];
// Only change xinput devices under certain conditions. Avoid
// performing this upon program startup before loading devices.
if (xinputChange)
{
bool changed = false;
if (device < 4)
{
//bool changed = false;
DS4Device tempDevice = control.DS4Controllers[device];
if (dinputOnly[device] != oldUseDInputOnly)
{
if (dinputOnly[device] == true)
{
bool xinputResult = control.x360Bus.Unplug(device);
@ -2120,10 +2138,10 @@ namespace DS4Windows
{
int xinputIndex = control.x360Bus.FirstController + device;
Log.LogToGui("X360 Controller # " + xinputIndex + " unplugged", false);
Global.useDInputOnly[device] = false;
Global.useDInputOnly[device] = true;
}
changed = true;
//changed = true;
}
else if (tempDevice != null && tempDevice.IsAlive())
{
@ -2132,23 +2150,25 @@ namespace DS4Windows
{
int xinputIndex = control.x360Bus.FirstController + device;
Log.LogToGui("X360 Controller # " + xinputIndex + " connected", false);
Global.useDInputOnly[device] = true;
Global.useDInputOnly[device] = false;
}
changed = true;
}
//changed = true;
}
if (changed)
/*if (changed)
{
System.Threading.Thread.Sleep(Global.XINPUT_UNPLUG_SETTLE_TIME);
}
*/
}
}
}
try
{
Item = m_Xdoc.SelectSingleNode("/" + rootname + "/StartTouchpadOff");
Boolean.TryParse(Item.InnerText, out startTouchpadOff[device]);
bool.TryParse(Item.InnerText, out startTouchpadOff[device]);
if (startTouchpadOff[device] == true) control.StartTPOff(device);
}
catch { startTouchpadOff[device] = false; missingSetting = true; }
@ -2171,6 +2191,14 @@ namespace DS4Windows
catch { missingSetting = true; }
try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/RSCurve"); int.TryParse(Item.InnerText, out rsCurve[device]); }
catch { missingSetting = true; }
try {
Item = m_Xdoc.SelectSingleNode("/" + rootname + "/BTPollRate");
int temp = 0;
int.TryParse(Item.InnerText, out temp);
btPollRate[device] = (temp >= 0 && temp <= 16) ? temp : 0;
}
catch { btPollRate[device] = 0; missingSetting = true; }
try
{
Item = m_Xdoc.SelectSingleNode("/" + rootname + "/ProfileActions");
@ -2373,12 +2401,29 @@ namespace DS4Windows
this.shiftCustomMapMacros[device] = shiftCustomMapMacros;
this.shiftCustomMapExtras[device] = shiftCustomMapExtras;
}*/
// Only add missing settings if the actual load was graceful
if (missingSetting && Loaded)// && buttons != null)
SaveProfile(device, profilepath);
containsCustomAction[device] = HasCustomActions(device);
containsCustomExtras[device] = HasCustomExtras(device);
// If a device exists, make sure to transfer relevant profile device
// options to device instance
if (device < 4)
{
DS4Device tempDev = control.DS4Controllers[device];
if (tempDev != null)
{
tempDev.queueEvent(() =>
{
tempDev.setIdleTimeout(idleDisconnectTimeout[device]);
tempDev.setBTPollRate(btPollRate[device]);
});
}
}
return Loaded;
}

View File

@ -114,6 +114,8 @@
this.bnSwipeRight = new System.Windows.Forms.Button();
this.lbSwipeRight = new System.Windows.Forms.Label();
this.gBOther = new System.Windows.Forms.GroupBox();
this.btPollRateLabel = new System.Windows.Forms.Label();
this.btPollRateComboBox = new System.Windows.Forms.ComboBox();
this.enableTouchToggleCheckbox = new System.Windows.Forms.CheckBox();
this.cBDinput = new System.Windows.Forms.CheckBox();
this.pBProgram = new System.Windows.Forms.PictureBox();
@ -1162,6 +1164,8 @@
// gBOther
//
this.gBOther.BackColor = System.Drawing.Color.WhiteSmoke;
this.gBOther.Controls.Add(this.btPollRateLabel);
this.gBOther.Controls.Add(this.btPollRateComboBox);
this.gBOther.Controls.Add(this.enableTouchToggleCheckbox);
this.gBOther.Controls.Add(this.cBDinput);
this.gBOther.Controls.Add(this.pBProgram);
@ -1181,6 +1185,38 @@
this.gBOther.Name = "gBOther";
this.gBOther.TabStop = false;
//
// btPollRateLabel
//
resources.ApplyResources(this.btPollRateLabel, "btPollRateLabel");
this.btPollRateLabel.Name = "btPollRateLabel";
//
// btPollRateComboBox
//
this.btPollRateComboBox.BackColor = System.Drawing.SystemColors.Window;
this.btPollRateComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.btPollRateComboBox.FormattingEnabled = true;
this.btPollRateComboBox.Items.AddRange(new object[] {
resources.GetString("btPollRateComboBox.Items"),
resources.GetString("btPollRateComboBox.Items1"),
resources.GetString("btPollRateComboBox.Items2"),
resources.GetString("btPollRateComboBox.Items3"),
resources.GetString("btPollRateComboBox.Items4"),
resources.GetString("btPollRateComboBox.Items5"),
resources.GetString("btPollRateComboBox.Items6"),
resources.GetString("btPollRateComboBox.Items7"),
resources.GetString("btPollRateComboBox.Items8"),
resources.GetString("btPollRateComboBox.Items9"),
resources.GetString("btPollRateComboBox.Items10"),
resources.GetString("btPollRateComboBox.Items11"),
resources.GetString("btPollRateComboBox.Items12"),
resources.GetString("btPollRateComboBox.Items13"),
resources.GetString("btPollRateComboBox.Items14"),
resources.GetString("btPollRateComboBox.Items15"),
resources.GetString("btPollRateComboBox.Items16")});
resources.ApplyResources(this.btPollRateComboBox, "btPollRateComboBox");
this.btPollRateComboBox.Name = "btPollRateComboBox";
this.btPollRateComboBox.SelectedIndexChanged += new System.EventHandler(this.btPollRateComboBox_SelectedIndexChanged);
//
// enableTouchToggleCheckbox
//
resources.ApplyResources(this.enableTouchToggleCheckbox, "enableTouchToggleCheckbox");
@ -3793,5 +3829,7 @@
private System.Windows.Forms.NumericUpDown nUDL2Maxzone;
private System.Windows.Forms.Label label8;
private System.Windows.Forms.Label label7;
private System.Windows.Forms.Label btPollRateLabel;
private System.Windows.Forms.ComboBox btPollRateComboBox;
}
}

View File

@ -82,19 +82,19 @@ namespace DS4Windows
b.Text = "";
}
foreach (System.Windows.Forms.Control control in Controls)
foreach (Control control in Controls)
{
if (control.HasChildren)
{
foreach (System.Windows.Forms.Control ctrl in control.Controls)
foreach (Control ctrl in control.Controls)
{
if (ctrl.HasChildren)
{
foreach (System.Windows.Forms.Control ctrl2 in ctrl.Controls)
foreach (Control ctrl2 in ctrl.Controls)
{
if (ctrl2.HasChildren)
{
foreach (System.Windows.Forms.Control ctrl3 in ctrl2.Controls)
foreach (Control ctrl3 in ctrl2.Controls)
ctrl3.MouseHover += Items_MouseHover;
}
@ -313,10 +313,11 @@ namespace DS4Windows
DS4Color cColor = ChargingColor[device];
btnChargingColor.BackColor = Color.FromArgb(cColor.red, cColor.green, cColor.blue);
if (FlashType[device] > cBFlashType.Items.Count - 1)
byte tempFlashType = FlashType[device];
if (tempFlashType > cBFlashType.Items.Count - 1)
cBFlashType.SelectedIndex = 0;
else
cBFlashType.SelectedIndex = FlashType[device];
cBFlashType.SelectedIndex = tempFlashType;
DS4Color fColor = FlashColor[device];
if (fColor.Equals(new DS4Color { red = 0, green = 0, blue = 0 }))
@ -352,10 +353,13 @@ namespace DS4Windows
full = HuetoRGB(reg.GetHue(), reg.GetBrightness(), reg);
lowColorChooserButton.BackColor = Color.FromArgb((alphacolor > 205 ? 255 : (alphacolor + 50)), full);
nUDRainbow.Value = (decimal)Rainbow[device];
if (ChargingType[device] > cBWhileCharging.Items.Count - 1)
int tempWhileCharging = ChargingType[device];
if (tempWhileCharging > cBWhileCharging.Items.Count - 1)
cBWhileCharging.SelectedIndex = 0;
else
cBWhileCharging.SelectedIndex = ChargingType[device];
cBWhileCharging.SelectedIndex = tempWhileCharging;
btPollRateComboBox.SelectedIndex = getBTPollRate(device);
try
{
@ -579,6 +583,7 @@ namespace DS4Windows
{
cBFlashType.SelectedIndex = 0;
cBWhileCharging.SelectedIndex = 0;
btPollRateComboBox.SelectedIndex = 0;
rBTPMouse.Checked = true;
rBSAControls.Checked = true;
ToggleRainbow(false);
@ -663,59 +668,6 @@ namespace DS4Windows
saving = false;
}
/* TODO: Possibly remove. Currently not used. */
/*private string getDS4ControlsByName(DS4Controls key)
{
switch (key)
{
case DS4Controls.Share: return "bnShare";
case DS4Controls.L3: return "bnL3";
case DS4Controls.R3: return "bnR3";
case DS4Controls.Options: return "bnOptions";
case DS4Controls.DpadUp: return "bnUp";
case DS4Controls.DpadRight: return "bnRight";
case DS4Controls.DpadDown: return "bnDown";
case DS4Controls.DpadLeft: return "bnLeft";
case DS4Controls.L1: return "bnL1";
case DS4Controls.R1: return "bnR1";
case DS4Controls.Triangle: return "bnTriangle";
case DS4Controls.Circle: return "bnCircle";
case DS4Controls.Cross: return "bnCross";
case DS4Controls.Square: return "bnSquare";
case DS4Controls.PS: return "bnPS";
case DS4Controls.LXNeg: return "bnLSLeft";
case DS4Controls.LYNeg: return "bnLSUp";
case DS4Controls.RXNeg: return "bnRSLeft";
case DS4Controls.RYNeg: return "bnRSUp";
case DS4Controls.LXPos: return "bnLSRight";
case DS4Controls.LYPos: return "bnLSDown";
case DS4Controls.RXPos: return "bnRSRight";
case DS4Controls.RYPos: return "bnRSDown";
case DS4Controls.L2: return "bnL2";
case DS4Controls.R2: return "bnR2";
case DS4Controls.TouchLeft: return "bnTouchLeft";
case DS4Controls.TouchMulti: return "bnTouchMulti";
case DS4Controls.TouchUpper: return "bnTouchUpper";
case DS4Controls.TouchRight: return "bnTouchRight";
case DS4Controls.GyroXPos: return "bnGyroXP";
case DS4Controls.GyroXNeg: return "bnGyroXN";
case DS4Controls.GyroZPos: return "bnGyroZP";
case DS4Controls.GyroZNeg: return "bnGyroZN";
case DS4Controls.SwipeUp: return "bnSwipeUp";
case DS4Controls.SwipeDown: return "bnSwipeDown";
case DS4Controls.SwipeLeft: return "bnSwipeLeft";
case DS4Controls.SwipeRight: return "bnSwipeRight";
}
return "";
}
*/
public void LoadActions(bool newp)
{
lVActions.Items.Clear();
@ -1296,6 +1248,7 @@ namespace DS4Windows
else
FlashColor[device] = new DS4Color(Color.Black);
BTPollRate[device] = btPollRateComboBox.SelectedIndex;
L2Deadzone[device] = (byte)Math.Round((nUDL2.Value * 255), 0);
R2Deadzone[device] = (byte)Math.Round((nUDR2.Value * 255), 0);
L2AntiDeadzone[device] = (int)(nUDL2AntiDead.Value * 100);
@ -1683,23 +1636,34 @@ namespace DS4Windows
if (btnRumbleHeavyTest.Text == Properties.Resources.StopText)
Program.rootHub.setRumble(0, 0, (int)nUDSixaxis.Value - 1);
inputtimer.Stop();
sixaxisTimer.Stop();
root.OptionsClosed();
Visible = false;
e.Cancel = true;
if (saving)
{
if (device < 4)
{
DS4Device tempDev = Program.rootHub.DS4Controllers[device];
if (tempDev != null)
{
int discon = getIdleDisconnectTimeout(device);
tempDev.queueEvent(() => { tempDev.setIdleTimeout(discon); });
int btCurrentIndex = btPollRateComboBox.SelectedIndex;
tempDev.queueEvent(() =>
{
tempDev.setIdleTimeout(discon);
if (btCurrentIndex >= 0)
{
tempDev.setBTPollRate(btCurrentIndex);
}
});
}
}
}
inputtimer.Stop();
sixaxisTimer.Stop();
root.OptionsClosed();
Visible = false;
e.Cancel = true;
}
private void cBSlide_CheckedChanged(object sender, EventArgs e)
{
bool slideChecked = cBSlide.Checked;
@ -2246,6 +2210,8 @@ namespace DS4Windows
case "bnSwipeDown": root.lbLastMessage.Text = Properties.Resources.RightClickPresets; break;
case "bnL3": root.lbLastMessage.Text = Properties.Resources.RightClickPresets; break;
case "bnR3": root.lbLastMessage.Text = Properties.Resources.RightClickPresets; break;
case "btPollRateLabel": root.lbLastMessage.Text = Properties.Resources.BTPollRate; break;
case "btPollRateComboBox": root.lbLastMessage.Text = Properties.Resources.BTPollRate; break;
default: root.lbLastMessage.Text = Properties.Resources.HoverOverItems; break;
}
@ -2754,6 +2720,12 @@ namespace DS4Windows
R2Maxzone[device] = (int)(nUDR2Maxzone.Value * 100);
}
private void btPollRateComboBox_SelectedIndexChanged(object sender, EventArgs e)
{
int currentIndex = btPollRateComboBox.SelectedIndex;
BTPollRate[device] = currentIndex;
}
private void Options_Resize(object sender, EventArgs e)
{
fLPSettings.AutoScroll = false;

View File

@ -625,7 +625,7 @@
<value>gBOther</value>
</data>
<data name="&gt;&gt;lbButtonMouseSens.ZOrder" xml:space="preserve">
<value>11</value>
<value>13</value>
</data>
<data name="cBlowerRCOn.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
@ -781,7 +781,7 @@
<value>gBOther</value>
</data>
<data name="&gt;&gt;lbIdleMinutes.ZOrder" xml:space="preserve">
<value>14</value>
<value>16</value>
</data>
<data name="nUDIdleDisconnect.Location" type="System.Drawing.Point, System.Drawing">
<value>115, 64</value>
@ -802,7 +802,7 @@
<value>gBOther</value>
</data>
<data name="&gt;&gt;nUDIdleDisconnect.ZOrder" xml:space="preserve">
<value>9</value>
<value>11</value>
</data>
<data name="nUDR2.Location" type="System.Drawing.Point, System.Drawing">
<value>105, 29</value>
@ -859,7 +859,7 @@
<value>gBOther</value>
</data>
<data name="&gt;&gt;cBFlushHIDQueue.ZOrder" xml:space="preserve">
<value>13</value>
<value>15</value>
</data>
<data name="nUDRumbleBoost.Location" type="System.Drawing.Point, System.Drawing">
<value>4, 18</value>
@ -1285,7 +1285,7 @@
<value>gBOther</value>
</data>
<data name="&gt;&gt;numUDMouseSens.ZOrder" xml:space="preserve">
<value>12</value>
<value>14</value>
</data>
<data name="nUDLS.Location" type="System.Drawing.Point, System.Drawing">
<value>30, 3</value>
@ -1911,6 +1911,108 @@
<data name="&gt;&gt;gBTouchpad.ZOrder" xml:space="preserve">
<value>1</value>
</data>
<data name="btPollRateLabel.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
<data name="btPollRateLabel.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
<value>NoControl</value>
</data>
<data name="btPollRateLabel.Location" type="System.Drawing.Point, System.Drawing">
<value>10, 227</value>
</data>
<data name="btPollRateLabel.Size" type="System.Drawing.Size, System.Drawing">
<value>67, 13</value>
</data>
<data name="btPollRateLabel.TabIndex" type="System.Int32, mscorlib">
<value>259</value>
</data>
<data name="btPollRateLabel.Text" xml:space="preserve">
<value>BT Poll Rate</value>
</data>
<data name="&gt;&gt;btPollRateLabel.Name" xml:space="preserve">
<value>btPollRateLabel</value>
</data>
<data name="&gt;&gt;btPollRateLabel.Type" xml:space="preserve">
<value>System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;btPollRateLabel.Parent" xml:space="preserve">
<value>gBOther</value>
</data>
<data name="&gt;&gt;btPollRateLabel.ZOrder" xml:space="preserve">
<value>0</value>
</data>
<data name="btPollRateComboBox.Items" xml:space="preserve">
<value>Full (1 ms)</value>
</data>
<data name="btPollRateComboBox.Items1" xml:space="preserve">
<value>1000 Hz (1 ms)</value>
</data>
<data name="btPollRateComboBox.Items2" xml:space="preserve">
<value>500 Hz (2 ms)</value>
</data>
<data name="btPollRateComboBox.Items3" xml:space="preserve">
<value>333 Hz (3 ms)</value>
</data>
<data name="btPollRateComboBox.Items4" xml:space="preserve">
<value>250 Hz (4 ms)</value>
</data>
<data name="btPollRateComboBox.Items5" xml:space="preserve">
<value>200 Hz (5 ms)</value>
</data>
<data name="btPollRateComboBox.Items6" xml:space="preserve">
<value>166 Hz (6 ms)</value>
</data>
<data name="btPollRateComboBox.Items7" xml:space="preserve">
<value>142 Hz (7 ms)</value>
</data>
<data name="btPollRateComboBox.Items8" xml:space="preserve">
<value>125 Hz (8 ms)</value>
</data>
<data name="btPollRateComboBox.Items9" xml:space="preserve">
<value>111 Hz (9 ms)</value>
</data>
<data name="btPollRateComboBox.Items10" xml:space="preserve">
<value>100 Hz (10 ms)</value>
</data>
<data name="btPollRateComboBox.Items11" xml:space="preserve">
<value>90 Hz (11 ms)</value>
</data>
<data name="btPollRateComboBox.Items12" xml:space="preserve">
<value>83 Hz (12 ms)</value>
</data>
<data name="btPollRateComboBox.Items13" xml:space="preserve">
<value>76 Hz (13 ms)</value>
</data>
<data name="btPollRateComboBox.Items14" xml:space="preserve">
<value>71 Hz (14 ms)</value>
</data>
<data name="btPollRateComboBox.Items15" xml:space="preserve">
<value>66 Hz (15 ms)</value>
</data>
<data name="btPollRateComboBox.Items16" xml:space="preserve">
<value>62 Hz (16 ms)</value>
</data>
<data name="btPollRateComboBox.Location" type="System.Drawing.Point, System.Drawing">
<value>85, 224</value>
</data>
<data name="btPollRateComboBox.Size" type="System.Drawing.Size, System.Drawing">
<value>121, 21</value>
</data>
<data name="btPollRateComboBox.TabIndex" type="System.Int32, mscorlib">
<value>258</value>
</data>
<data name="&gt;&gt;btPollRateComboBox.Name" xml:space="preserve">
<value>btPollRateComboBox</value>
</data>
<data name="&gt;&gt;btPollRateComboBox.Type" xml:space="preserve">
<value>System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;btPollRateComboBox.Parent" xml:space="preserve">
<value>gBOther</value>
</data>
<data name="&gt;&gt;btPollRateComboBox.ZOrder" xml:space="preserve">
<value>1</value>
</data>
<data name="enableTouchToggleCheckbox.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
@ -1942,7 +2044,7 @@
<value>gBOther</value>
</data>
<data name="&gt;&gt;enableTouchToggleCheckbox.ZOrder" xml:space="preserve">
<value>0</value>
<value>2</value>
</data>
<data name="cBDinput.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
@ -1975,7 +2077,7 @@
<value>gBOther</value>
</data>
<data name="&gt;&gt;cBDinput.ZOrder" xml:space="preserve">
<value>1</value>
<value>3</value>
</data>
<data name="pBProgram.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
<value>NoControl</value>
@ -2002,7 +2104,7 @@
<value>gBOther</value>
</data>
<data name="&gt;&gt;pBProgram.ZOrder" xml:space="preserve">
<value>2</value>
<value>4</value>
</data>
<data name="cBLaunchProgram.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
@ -2036,7 +2138,7 @@ with profile</value>
<value>gBOther</value>
</data>
<data name="&gt;&gt;cBLaunchProgram.ZOrder" xml:space="preserve">
<value>3</value>
<value>5</value>
</data>
<data name="btnBrowse.BackgroundImageLayout" type="System.Windows.Forms.ImageLayout, System.Windows.Forms">
<value>Zoom</value>
@ -2069,7 +2171,7 @@ with profile</value>
<value>gBOther</value>
</data>
<data name="&gt;&gt;btnBrowse.ZOrder" xml:space="preserve">
<value>4</value>
<value>6</value>
</data>
<data name="lbUseController.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
@ -2099,7 +2201,7 @@ with profile</value>
<value>gBOther</value>
</data>
<data name="&gt;&gt;lbUseController.ZOrder" xml:space="preserve">
<value>5</value>
<value>7</value>
</data>
<data name="cBMouseAccel.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
@ -2132,7 +2234,7 @@ with profile</value>
<value>gBOther</value>
</data>
<data name="&gt;&gt;cBMouseAccel.ZOrder" xml:space="preserve">
<value>6</value>
<value>8</value>
</data>
<data name="nUDSixaxis.Location" type="System.Drawing.Point, System.Drawing">
<value>85, 95</value>
@ -2153,7 +2255,7 @@ with profile</value>
<value>gBOther</value>
</data>
<data name="&gt;&gt;nUDSixaxis.ZOrder" xml:space="preserve">
<value>7</value>
<value>9</value>
</data>
<data name="cBControllerInput.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
@ -2186,7 +2288,7 @@ with profile</value>
<value>gBOther</value>
</data>
<data name="&gt;&gt;cBControllerInput.ZOrder" xml:space="preserve">
<value>8</value>
<value>10</value>
</data>
<data name="cBIdleDisconnect.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
@ -2219,13 +2321,13 @@ with profile</value>
<value>gBOther</value>
</data>
<data name="&gt;&gt;cBIdleDisconnect.ZOrder" xml:space="preserve">
<value>10</value>
<value>12</value>
</data>
<data name="gBOther.Location" type="System.Drawing.Point, System.Drawing">
<value>281, 221</value>
</data>
<data name="gBOther.Size" type="System.Drawing.Size, System.Drawing">
<value>272, 236</value>
<value>272, 256</value>
</data>
<data name="gBOther.TabIndex" type="System.Int32, mscorlib">
<value>247</value>
@ -3518,7 +3620,7 @@ with profile</value>
<value>3, 3, 3, 3</value>
</data>
<data name="lbL2TrackS.Size" type="System.Drawing.Size, System.Drawing">
<value>438, 448</value>
<value>438, 455</value>
</data>
<data name="lbL2TrackS.TabIndex" type="System.Int32, mscorlib">
<value>2</value>
@ -5618,7 +5720,7 @@ with profile</value>
<value>3, 3, 3, 3</value>
</data>
<data name="tPControls.Size" type="System.Drawing.Size, System.Drawing">
<value>438, 448</value>
<value>438, 455</value>
</data>
<data name="tPControls.TabIndex" type="System.Int32, mscorlib">
<value>0</value>
@ -5663,7 +5765,7 @@ with profile</value>
<value>0, 66</value>
</data>
<data name="lVActions.Size" type="System.Drawing.Size, System.Drawing">
<value>438, 382</value>
<value>438, 389</value>
</data>
<data name="lVActions.TabIndex" type="System.Int32, mscorlib">
<value>13</value>
@ -5852,7 +5954,7 @@ with profile</value>
<value>0, 0</value>
</data>
<data name="pnlActions.Size" type="System.Drawing.Size, System.Drawing">
<value>438, 448</value>
<value>438, 455</value>
</data>
<data name="pnlActions.TabIndex" type="System.Int32, mscorlib">
<value>15</value>
@ -5873,7 +5975,7 @@ with profile</value>
<value>4, 22</value>
</data>
<data name="tPSpecial.Size" type="System.Drawing.Size, System.Drawing">
<value>438, 448</value>
<value>438, 455</value>
</data>
<data name="tPSpecial.TabIndex" type="System.Int32, mscorlib">
<value>3</value>
@ -5900,7 +6002,7 @@ with profile</value>
<value>0, 0</value>
</data>
<data name="tCControls.Size" type="System.Drawing.Size, System.Drawing">
<value>446, 474</value>
<value>446, 481</value>
</data>
<data name="tCControls.TabIndex" type="System.Int32, mscorlib">
<value>253</value>
@ -7310,7 +7412,7 @@ with profile</value>
<value>2, 2, 2, 2</value>
</data>
<data name="fLPSettings.Size" type="System.Drawing.Size, System.Drawing">
<value>564, 474</value>
<value>564, 481</value>
</data>
<data name="fLPSettings.TabIndex" type="System.Int32, mscorlib">
<value>254</value>
@ -7472,7 +7574,7 @@ with profile</value>
<value>True</value>
</data>
<data name="$this.ClientSize" type="System.Drawing.Size, System.Drawing">
<value>1010, 474</value>
<value>1010, 481</value>
</data>
<data name="$this.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>4, 4, 4, 4</value>
@ -7778,7 +7880,7 @@ with profile</value>
<value>advColorDialog</value>
</data>
<data name="&gt;&gt;advColorDialog.Type" xml:space="preserve">
<value>DS4Windows.AdvancedColorDialog, DS4Windows, Version=1.4.69.0, Culture=neutral, PublicKeyToken=null</value>
<value>DS4Windows.AdvancedColorDialog, DS4Windows, Version=1.4.70.0, Culture=neutral, PublicKeyToken=null</value>
</data>
<data name="&gt;&gt;$this.Name" xml:space="preserve">
<value>Options</value>

View File

@ -330,6 +330,34 @@ namespace DS4Windows
return ledFlashOff;
}
// Specify the poll rate interval used for the DS4 hardware when
// connected via Bluetooth
private int btPollRate = 0;
public int BTPollRate
{
get { return btPollRate; }
set
{
if (btPollRate != value && value >= 0 && value <= 16)
{
btPollRate = value;
}
}
}
public int getBTPollRate()
{
return btPollRate;
}
public void setBTPollRate(int value)
{
if (btPollRate != value && value >= 0 && value <= 16)
{
btPollRate = value;
}
}
public DS4Touchpad Touchpad { get { return touchpad; } }
public DS4SixAxis SixAxis { get { return sixAxis; } }
@ -806,12 +834,14 @@ namespace DS4Windows
lock (eventQueueLock)
{
Action tempAct = null;
//while (eventQueue.TryDequeue(out tempAct))
for (int actInd = 0, actLen = eventQueue.Count; actInd < actLen; actInd++)
//foreach (Action tempAct in eventQueue)
{
tempAct = eventQueue.Dequeue();
tempAct.Invoke();
}
//eventQueue.Clear();
}
}
}
@ -829,7 +859,9 @@ namespace DS4Windows
if (conType == ConnectionType.BT)
{
outputReportBuffer[0] = 0x11;
outputReportBuffer[1] = 0x80;
//outputReportBuffer[1] = 0x80;
//outputReportBuffer[1] = 0x84;
outputReportBuffer[1] = (byte)(0x80 | btPollRate);
outputReportBuffer[3] = 0xff;
outputReportBuffer[6] = rightLightFastRumble; //fast motor
outputReportBuffer[7] = leftHeavySlowRumble; //slow motor

View File

@ -211,6 +211,15 @@ namespace DS4Windows.Properties {
}
}
/// <summary>
/// Looks up a localized string similar to Determines the poll rate used for the DS4 hardware when connected via Bluetooth.
/// </summary>
internal static string BTPollRate {
get {
return ResourceManager.GetString("BTPollRate", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Cannot move files to new location, Please rename the DS4Tool folder to &quot;DS4Windows&quot;.
/// </summary>

View File

@ -781,4 +781,7 @@
<data name="UACTask" xml:space="preserve">
<value>You need to run DS4Windows as the Administrator in order to activate this mode.</value>
</data>
<data name="BTPollRate" xml:space="preserve">
<value>Determines the poll rate used for the DS4 hardware when connected via Bluetooth</value>
</data>
</root>