Minor changes

This commit is contained in:
Travis Nickles 2017-05-11 08:13:51 -07:00
parent 81b54a7dd9
commit f3c9e08398
5 changed files with 32 additions and 65 deletions

View File

@ -24,7 +24,7 @@ namespace DS4Windows
List<DS4Controls> dcs = new List<DS4Controls>();
bool[] held = new bool[DS4_CONTROLLER_COUNT];
int[] oldmouse = new int[DS4_CONTROLLER_COUNT] { -1, -1, -1, -1 };
SoundPlayer sp = new SoundPlayer();
//SoundPlayer sp = new SoundPlayer();
private class X360Data
{
@ -36,7 +36,7 @@ namespace DS4Windows
public ControlService()
{
sp.Stream = Properties.Resources.EE;
//sp.Stream = Properties.Resources.EE;
x360Bus = new X360Device();
AddtoDS4List();
@ -389,48 +389,13 @@ namespace DS4Windows
//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)
{
try
{
System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
sw.Start();
while (!d.IsAlive())
{
if (sw.ElapsedMilliseconds < 1000)
System.Threading.Thread.SpinWait(500);
//If weve been waiting less than 1 second let the thread keep its processing chunk
else
System.Threading.Thread.Sleep(500);
//If weve been waiting more than 1 second give up some resources
if (sw.ElapsedMilliseconds > 5000) throw new TimeoutException(); //Weve waited long enough
}
sw.Reset();
}
catch (TimeoutException)
{
Stop(false);
Start(false);
}
}
*/
public string getDS4ControllerInfo(int index)
{
DS4Device d = DS4Controllers[index];
if (d != null)
{
if (!d.IsAlive())
//return "Connecting..."; // awaiting the first battery charge indication
{
/*var TimeoutThread = new System.Threading.Thread(() => TimeoutConnection(d));
TimeoutThread.IsBackground = true;
TimeoutThread.Name = "TimeoutFor" + d.getMacAddress().ToString();
TimeoutThread.Start();
*/
return Properties.Resources.Connecting;
}
@ -460,15 +425,10 @@ namespace DS4Windows
if (d != null)
{
if (!d.IsAlive())
//return "Connecting..."; // awaiting the first battery charge indication
{
/*var TimeoutThread = new System.Threading.Thread(() => TimeoutConnection(d));
TimeoutThread.IsBackground = true;
TimeoutThread.Name = "TimeoutFor" + d.getMacAddress().ToString();
TimeoutThread.Start();
*/
return Properties.Resources.Connecting;
}
return d.getMacAddress();
}
else
@ -987,16 +947,20 @@ namespace DS4Windows
oldscrollvalue[deviceID] = getScrollSensitivity(deviceID);
getTouchSensitivity()[deviceID] = 0;
getScrollSensitivity()[deviceID] = 0;
LogDebug(getTouchSensitivity(deviceID) > 0 ? Properties.Resources.TouchpadMovementOn : Properties.Resources.TouchpadMovementOff);
Log.LogToTray(getTouchSensitivity(deviceID) > 0 ? Properties.Resources.TouchpadMovementOn : Properties.Resources.TouchpadMovementOff);
LogDebug(getTouchSensitivity(deviceID) > 0 ? Properties.Resources.TouchpadMovementOn :
Properties.Resources.TouchpadMovementOff);
Log.LogToTray(getTouchSensitivity(deviceID) > 0 ? Properties.Resources.TouchpadMovementOn :
Properties.Resources.TouchpadMovementOff);
touchreleased[deviceID] = false;
}
else if (touchreleased[deviceID])
{
getTouchSensitivity()[deviceID] = oldtouchvalue[deviceID];
getScrollSensitivity()[deviceID] = oldscrollvalue[deviceID];
LogDebug(getTouchSensitivity(deviceID) > 0 ? Properties.Resources.TouchpadMovementOn : Properties.Resources.TouchpadMovementOff);
Log.LogToTray(getTouchSensitivity(deviceID) > 0 ? Properties.Resources.TouchpadMovementOn : Properties.Resources.TouchpadMovementOff);
LogDebug(getTouchSensitivity(deviceID) > 0 ? Properties.Resources.TouchpadMovementOn :
Properties.Resources.TouchpadMovementOff);
Log.LogToTray(getTouchSensitivity(deviceID) > 0 ? Properties.Resources.TouchpadMovementOn :
Properties.Resources.TouchpadMovementOff);
touchreleased[deviceID] = false;
}
}
@ -1071,8 +1035,9 @@ namespace DS4Windows
if (deviceNum < 4)
{
if (DS4Controllers[deviceNum] != null)
DS4Controllers[deviceNum].setRumble((byte)lightBoosted, (byte)heavyBoosted);
DS4Device device = DS4Controllers[deviceNum];
if (device != null)
device.setRumble((byte)lightBoosted, (byte)heavyBoosted);
}
}

View File

@ -1149,8 +1149,6 @@ namespace DS4Windows
{
Enable_Controls(Index, true);
}
else
opt.inputtimer.Stop();
}
else
{
@ -1251,13 +1249,7 @@ namespace DS4Windows
if (Pads[Index].Text != Properties.Resources.Connecting)
{
Enable_Controls(Index, true);
//if (opt != null)
// if (opt.Visible && tabMain.SelectedIndex == 1)
//opt.inputtimer.Start();
//MinimumSize = new Size(MinimumSize.Width, 137 + 29 * Index);
}
else
opt.inputtimer.Stop();
}
else
{
@ -1439,8 +1431,6 @@ namespace DS4Windows
private void ShowOptions(int devID, string profile)
{
//if (opt != null)
//opt.Close();
Show();
WindowState = FormWindowState.Normal;
toolStrip1.Enabled = false;
@ -1450,7 +1440,7 @@ namespace DS4Windows
tSTBProfile.Text = profile;
else
tSTBProfile.Text = "<" + Properties.Resources.TypeProfileName + ">";
//opt = new Options(devID, profile, this);
lBProfiles.SendToBack();
toolStrip1.SendToBack();
tSOptions.SendToBack();
@ -1462,8 +1452,10 @@ namespace DS4Windows
if (Size.Width < (int)(20 * dpix) + Options.mSize.Width)
Size = new System.Drawing.Size((int)(20 * dpix) + Options.mSize.Width, Size.Height);
}
tabMain.SelectedIndex = 1;
opt.Reload(devID, profile);
opt.inputtimer.Start();
opt.Visible = true;
}
@ -1487,6 +1479,9 @@ namespace DS4Windows
if (!lbNoControllers.Visible)
tabMain.SelectedIndex = 0;
opt.inputtimer.Stop();
opt.sixaxisTimer.Stop();
}
private void editButtons_Click(object sender, EventArgs e)
@ -1734,10 +1729,11 @@ namespace DS4Windows
else
lbLastMessage.Text = "";
if (tabMain.SelectedIndex != 1 || !opt.Visible)
/*if (tabMain.SelectedIndex != 1 || !opt.Visible)
opt.inputtimer.Stop();
else if (opt.Visible && tabMain.SelectedIndex == 1)
opt.inputtimer.Start();
*/
}
private void Items_MouseHover(object sender, EventArgs e)
@ -2157,12 +2153,12 @@ namespace DS4Windows
toolTip1.Show(Properties.Resources.InputDelay.Replace("*number*", latency.ToString()), lb, lb.Size.Width, 0);
}
}
private void Pads_MouseLeave(object sender, EventArgs e)
{
toolTip1.Hide((Label)sender);
}
Process bat;
private void btnConnectDS4Win10_Click(object sender, EventArgs e)
{
@ -2179,6 +2175,7 @@ namespace DS4Windows
bat = Process.Start(exepath + "\\ConnectDS4.bat");
}
}
int currentCustomLed;
private void EditCustomLed(object sender, EventArgs e)
{
@ -2205,6 +2202,7 @@ namespace DS4Windows
UseCustomLed[currentCustomLed] = true;
Global.Save();
}
DS4LightBar.forcedFlash[currentCustomLed] = 0;
DS4LightBar.forcelight[currentCustomLed] = false;
}

View File

@ -658,7 +658,6 @@ namespace DS4Windows
}
UpdateLists();
inputtimer.Start();
LoadActions(string.IsNullOrEmpty(filename));
loading = false;
saving = false;

View File

@ -149,8 +149,8 @@ namespace DS4Windows
private byte ledFlashOn, ledFlashOff;
private Thread ds4Input, ds4Output;
private int battery;
private DS4Audio audio = new DS4Audio();
private DS4Audio micAudio = new DS4Audio(DS4Library.CoreAudio.DataFlow.Render);
private DS4Audio audio = null;
private DS4Audio micAudio = null;
public DateTime lastActive = DateTime.UtcNow;
public DateTime firstActive = DateTime.UtcNow;
private bool charging;
@ -173,6 +173,7 @@ namespace DS4Windows
{
return HidDevice.IsExclusive;
}
private bool isDisconnecting = false;
public bool IsDisconnecting
{
@ -182,6 +183,7 @@ namespace DS4Windows
this.isDisconnecting = value;
}
}
public bool isDisconnectingStatus()
{
return this.isDisconnecting;
@ -375,6 +377,8 @@ namespace DS4Windows
else
{
warnInterval = WARN_INTERVAL_BT;
audio = new DS4Audio();
micAudio = new DS4Audio(DS4Library.CoreAudio.DataFlow.Render);
}
}
else

View File

@ -300,6 +300,7 @@ namespace DS4Windows
safeReadHandle = OpenHandle(_devicePath, true);
if (fileStream == null && !safeReadHandle.IsInvalid)
fileStream = new FileStream(safeReadHandle, FileAccess.ReadWrite, inputBuffer.Length, true);
if (!safeReadHandle.IsInvalid && fileStream.CanRead)
{
Task<int> readTask = fileStream.ReadAsync(inputBuffer, 0, inputBuffer.Length);