Version 1.4.65

This commit is contained in:
Travis Nickles 2017-04-28 11:57:33 -07:00
parent 44501c24de
commit ca2074d76f
4 changed files with 50 additions and 24 deletions

View File

@ -337,6 +337,8 @@ namespace DS4Windows
//ControllerStatusChanged(this); //ControllerStatusChanged(this);
} }
/* TODO: Check if this method is really necessary. If not, delete it. For now, it is not being used because
* input reports are read async with a timeout now. */
public void TimeoutConnection(DS4Device d) public void TimeoutConnection(DS4Device d)
{ {
try try
@ -371,10 +373,11 @@ namespace DS4Windows
if (!d.IsAlive()) if (!d.IsAlive())
//return "Connecting..."; // awaiting the first battery charge indication //return "Connecting..."; // awaiting the first battery charge indication
{ {
var TimeoutThread = new System.Threading.Thread(() => TimeoutConnection(d)); /*var TimeoutThread = new System.Threading.Thread(() => TimeoutConnection(d));
TimeoutThread.IsBackground = true; TimeoutThread.IsBackground = true;
TimeoutThread.Name = "TimeoutFor" + d.getMacAddress().ToString(); TimeoutThread.Name = "TimeoutFor" + d.getMacAddress().ToString();
TimeoutThread.Start(); TimeoutThread.Start();
*/
return Properties.Resources.Connecting; return Properties.Resources.Connecting;
} }
@ -406,10 +409,11 @@ namespace DS4Windows
if (!d.IsAlive()) if (!d.IsAlive())
//return "Connecting..."; // awaiting the first battery charge indication //return "Connecting..."; // awaiting the first battery charge indication
{ {
var TimeoutThread = new System.Threading.Thread(() => TimeoutConnection(d)); /*var TimeoutThread = new System.Threading.Thread(() => TimeoutConnection(d));
TimeoutThread.IsBackground = true; TimeoutThread.IsBackground = true;
TimeoutThread.Name = "TimeoutFor" + d.getMacAddress().ToString(); TimeoutThread.Name = "TimeoutFor" + d.getMacAddress().ToString();
TimeoutThread.Start(); TimeoutThread.Start();
*/
return Properties.Resources.Connecting; return Properties.Resources.Connecting;
} }
return d.getMacAddress(); return d.getMacAddress();

View File

@ -1200,6 +1200,7 @@ namespace DS4Windows
Stream stream; Stream stream;
Stream profile = new StreamReader(appdatapath + "\\Profiles\\" + lBProfiles.SelectedItem.ToString() + ".xml").BaseStream; Stream profile = new StreamReader(appdatapath + "\\Profiles\\" + lBProfiles.SelectedItem.ToString() + ".xml").BaseStream;
if (saveProfiles.ShowDialog() == System.Windows.Forms.DialogResult.OK) if (saveProfiles.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
if ((stream = saveProfiles.OpenFile()) != null) if ((stream = saveProfiles.OpenFile()) != null)
{ {
profile.CopyTo(stream); profile.CopyTo(stream);
@ -1208,6 +1209,7 @@ namespace DS4Windows
} }
} }
} }
}
private void ShowOptions(int devID, string profile) private void ShowOptions(int devID, string profile)
{ {
@ -1278,10 +1280,14 @@ namespace DS4Windows
if (em.Text == Properties.Resources.ContextNew.Replace("*number*", (i + 1).ToString())) if (em.Text == Properties.Resources.ContextNew.Replace("*number*", (i + 1).ToString()))
ShowOptions(i, ""); ShowOptions(i, "");
else else
{
for (int t = 0; t < em.DropDownItems.Count - 2; t++) for (int t = 0; t < em.DropDownItems.Count - 2; t++)
{
if (((ToolStripMenuItem)em.DropDownItems[t]).Checked) if (((ToolStripMenuItem)em.DropDownItems[t]).Checked)
ShowOptions(i, ((ToolStripMenuItem)em.DropDownItems[t]).Text); ShowOptions(i, ((ToolStripMenuItem)em.DropDownItems[t]).Text);
} }
}
}
private void lnkControllers_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) private void lnkControllers_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{ {
@ -1293,13 +1299,19 @@ namespace DS4Windows
// Prevent the Game Controllers window from throwing an error when controllers are un/hidden // Prevent the Game Controllers window from throwing an error when controllers are un/hidden
System.Diagnostics.Process[] rundll64 = System.Diagnostics.Process.GetProcessesByName("rundll64"); System.Diagnostics.Process[] rundll64 = System.Diagnostics.Process.GetProcessesByName("rundll64");
foreach (System.Diagnostics.Process rundll64Instance in rundll64) foreach (System.Diagnostics.Process rundll64Instance in rundll64)
{
foreach (System.Diagnostics.ProcessModule module in rundll64Instance.Modules) foreach (System.Diagnostics.ProcessModule module in rundll64Instance.Modules)
{
if (module.FileName.Contains("joy.cpl")) if (module.FileName.Contains("joy.cpl"))
module.Dispose(); module.Dispose();
}
}
UseExclusiveMode = hideDS4CheckBox.Checked; bool exclusiveMode = hideDS4CheckBox.Checked;
UseExclusiveMode = exclusiveMode;
if (Environment.OSVersion.Version.Major >= 10 && Environment.OSVersion.Version.Build < 10586) if (Environment.OSVersion.Version.Major >= 10 && Environment.OSVersion.Version.Build < 10586)
btnConnectDS4Win10.Visible = hideDS4CheckBox.Checked; btnConnectDS4Win10.Visible = exclusiveMode;
btnStartStop_Clicked(false); btnStartStop_Clicked(false);
btnStartStop_Clicked(false); btnStartStop_Clicked(false);
Save(); Save();
@ -1345,6 +1357,7 @@ namespace DS4Windows
else else
ebns[tdevice].Text = Properties.Resources.EditProfile; ebns[tdevice].Text = Properties.Resources.EditProfile;
} }
ControllerStatusChanged(); //to update profile name in notify icon ControllerStatusChanged(); //to update profile name in notify icon
} }
@ -1353,11 +1366,13 @@ namespace DS4Windows
ToolStripMenuItem tS = (ToolStripMenuItem)sender; ToolStripMenuItem tS = (ToolStripMenuItem)sender;
int tdevice = Int32.Parse(tS.Tag.ToString()); int tdevice = Int32.Parse(tS.Tag.ToString());
if (!(e.ClickedItem is ToolStripSeparator)) if (!(e.ClickedItem is ToolStripSeparator))
{
if (e.ClickedItem != tS.DropDownItems[tS.DropDownItems.Count - 1]) //if +New Profile not selected if (e.ClickedItem != tS.DropDownItems[tS.DropDownItems.Count - 1]) //if +New Profile not selected
cbs[tdevice].SelectedIndex = tS.DropDownItems.IndexOf(e.ClickedItem); cbs[tdevice].SelectedIndex = tS.DropDownItems.IndexOf(e.ClickedItem);
else //if +New Profile selected else //if +New Profile selected
ShowOptions(tdevice, ""); ShowOptions(tdevice, "");
} }
}
private void exitToolStripMenuItem_Click(object sender, EventArgs e) private void exitToolStripMenuItem_Click(object sender, EventArgs e)
{ {
@ -1377,6 +1392,7 @@ namespace DS4Windows
{ {
btnStartStop_Clicked(); btnStartStop_Clicked();
} }
private void notifyIcon1_MouseClick(object sender, MouseEventArgs e) private void notifyIcon1_MouseClick(object sender, MouseEventArgs e)
{ {
if (e.Button == System.Windows.Forms.MouseButtons.Middle) if (e.Button == System.Windows.Forms.MouseButtons.Middle)
@ -1385,6 +1401,7 @@ namespace DS4Windows
this.Close(); this.Close();
} }
} }
private void notifyIcon1_BalloonTipClicked(object sender, EventArgs e) private void notifyIcon1_BalloonTipClicked(object sender, EventArgs e)
{ {
this.Show(); this.Show();
@ -1510,6 +1527,7 @@ namespace DS4Windows
case "cBCloseMini": lbLastMessage.Text = Properties.Resources.CloseMinimize; break; case "cBCloseMini": lbLastMessage.Text = Properties.Resources.CloseMinimize; break;
default: lbLastMessage.Text = Properties.Resources.HoverOverItems; break; default: lbLastMessage.Text = Properties.Resources.HoverOverItems; break;
} }
if (lbLastMessage.Text != Properties.Resources.HoverOverItems) if (lbLastMessage.Text != Properties.Resources.HoverOverItems)
lbLastMessage.ForeColor = Color.Black; lbLastMessage.ForeColor = Color.Black;
else else

View File

@ -266,7 +266,7 @@ namespace DS4Windows
get { return rightLightFastRumble; } get { return rightLightFastRumble; }
set set
{ {
if (value == rightLightFastRumble) return; if (rightLightFastRumble != value)
rightLightFastRumble = value; rightLightFastRumble = value;
} }
} }
@ -276,7 +276,7 @@ namespace DS4Windows
get { return leftHeavySlowRumble; } get { return leftHeavySlowRumble; }
set set
{ {
if (value == leftHeavySlowRumble) return; if (leftHeavySlowRumble != value)
leftHeavySlowRumble = value; leftHeavySlowRumble = value;
} }
} }
@ -608,10 +608,10 @@ namespace DS4Windows
cState.L2 = inputReport[8]; cState.L2 = inputReport[8];
cState.R2 = inputReport[9]; cState.R2 = inputReport[9];
cState.Triangle = ((byte)inputReport[5] & (1 << 7)) != 0; cState.Triangle = (inputReport[5] & (1 << 7)) != 0;
cState.Circle = ((byte)inputReport[5] & (1 << 6)) != 0; cState.Circle = (inputReport[5] & (1 << 6)) != 0;
cState.Cross = ((byte)inputReport[5] & (1 << 5)) != 0; cState.Cross = (inputReport[5] & (1 << 5)) != 0;
cState.Square = ((byte)inputReport[5] & (1 << 4)) != 0; cState.Square = (inputReport[5] & (1 << 4)) != 0;
// First 4 bits denote dpad state. Clock representation // First 4 bits denote dpad state. Clock representation
// with 8 meaning centered and 0 meaning DpadUp. // with 8 meaning centered and 0 meaning DpadUp.
@ -627,18 +627,18 @@ namespace DS4Windows
case 5: cState.DpadUp = false; cState.DpadDown = true; cState.DpadLeft = true; cState.DpadRight = false; break; case 5: cState.DpadUp = false; cState.DpadDown = true; cState.DpadLeft = true; cState.DpadRight = false; break;
case 6: cState.DpadUp = false; cState.DpadDown = false; cState.DpadLeft = true; cState.DpadRight = false; break; case 6: cState.DpadUp = false; cState.DpadDown = false; cState.DpadLeft = true; cState.DpadRight = false; break;
case 7: cState.DpadUp = true; cState.DpadDown = false; cState.DpadLeft = true; cState.DpadRight = false; break; case 7: cState.DpadUp = true; cState.DpadDown = false; cState.DpadLeft = true; cState.DpadRight = false; break;
case 8: cState.DpadUp = false; cState.DpadDown = false; cState.DpadLeft = false; cState.DpadRight = false; break; case 8:
default: break; default: cState.DpadUp = false; cState.DpadDown = false; cState.DpadLeft = false; cState.DpadRight = false; break;
} }
cState.R3 = ((byte)inputReport[6] & (1 << 7)) != 0; cState.R3 = (inputReport[6] & (1 << 7)) != 0;
cState.L3 = ((byte)inputReport[6] & (1 << 6)) != 0; cState.L3 = (inputReport[6] & (1 << 6)) != 0;
cState.Options = ((byte)inputReport[6] & (1 << 5)) != 0; cState.Options = (inputReport[6] & (1 << 5)) != 0;
cState.Share = ((byte)inputReport[6] & (1 << 4)) != 0; cState.Share = (inputReport[6] & (1 << 4)) != 0;
cState.R1 = ((byte)inputReport[6] & (1 << 1)) != 0; cState.R1 = (inputReport[6] & (1 << 1)) != 0;
cState.L1 = ((byte)inputReport[6] & (1 << 0)) != 0; cState.L1 = (inputReport[6] & (1 << 0)) != 0;
cState.PS = ((byte)inputReport[7] & (1 << 0)) != 0; cState.PS = (inputReport[7] & (1 << 0)) != 0;
cState.TouchButton = (inputReport[7] & (1 << 2 - 1)) != 0; cState.TouchButton = (inputReport[7] & (1 << 2 - 1)) != 0;
cState.FrameCounter = (byte)(inputReport[7] >> 2); cState.FrameCounter = (byte)(inputReport[7] >> 2);
@ -847,7 +847,7 @@ namespace DS4Windows
string[] sbytes = Mac.Split(':'); string[] sbytes = Mac.Split(':');
for (int i = 0; i < 6; i++) for (int i = 0; i < 6; i++)
{ {
//parse hex byte in reverse order // parse hex byte in reverse order
btAddr[5 - i] = Convert.ToByte(sbytes[i], 16); btAddr[5 - i] = Convert.ToByte(sbytes[i], 16);
} }
@ -998,18 +998,21 @@ namespace DS4Windows
DS4HapticState haptic = hapticState[i]; DS4HapticState haptic = hapticState[i];
if (i == hapticStackIndex) if (i == hapticStackIndex)
break; // rest haven't been used this time break; // rest haven't been used this time
if (haptic.IsLightBarSet()) if (haptic.IsLightBarSet())
{ {
lightBarColor = haptic.LightBarColor; lightBarColor = haptic.LightBarColor;
lightBarFlashDurationOn = haptic.LightBarFlashDurationOn; lightBarFlashDurationOn = haptic.LightBarFlashDurationOn;
lightBarFlashDurationOff = haptic.LightBarFlashDurationOff; lightBarFlashDurationOff = haptic.LightBarFlashDurationOff;
} }
if (haptic.IsRumbleSet()) if (haptic.IsRumbleSet())
{ {
rumbleMotorStrengthLeftHeavySlow = haptic.RumbleMotorStrengthLeftHeavySlow; rumbleMotorStrengthLeftHeavySlow = haptic.RumbleMotorStrengthLeftHeavySlow;
rumbleMotorStrengthRightLightFast = haptic.RumbleMotorStrengthRightLightFast; rumbleMotorStrengthRightLightFast = haptic.RumbleMotorStrengthRightLightFast;
} }
} }
LightBarColor = lightBarColor; LightBarColor = lightBarColor;
LightBarOnDuration = lightBarFlashDurationOn; LightBarOnDuration = lightBarFlashDurationOn;
LightBarOffDuration = lightBarFlashDurationOff; LightBarOffDuration = lightBarFlashDurationOff;
@ -1026,6 +1029,7 @@ namespace DS4Windows
Array.Copy(hapticState, newHaptics, hapsLen); Array.Copy(hapticState, newHaptics, hapsLen);
hapticState = newHaptics; hapticState = newHaptics;
} }
hapticState[hapticStackIndex++] = hs; hapticState[hapticStackIndex++] = hs;
} }

View File

@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.4.64")] [assembly: AssemblyVersion("1.4.65")]
[assembly: AssemblyFileVersion("1.4.64")] [assembly: AssemblyFileVersion("1.4.65")]