From 96268b0296fd0e006a20ea0d767e6b01f3cd9efa Mon Sep 17 00:00:00 2001 From: jays2kings Date: Sat, 24 May 2014 19:08:40 -0400 Subject: [PATCH] "Connecting..." issue Fixed again, I think... Pushing the Right stick down also works correctly now. In options,when changing values on the lightbar sliders, a tooltip shows up to the side showing the number. The lightbar now only fades out when idle when half the idle time has passed. --- DS4Control/Control.cs | 58 ++++++++++++++++++++++++------------- DS4Control/DS4LightBar.cs | 3 +- DS4Control/X360Device.cs | 2 +- DS4Tool/Options.Designer.cs | 26 ++++++++++++++++- DS4Tool/Options.cs | 30 +++++++++++++++++-- DS4Tool/ScpForm.cs | 6 ++-- 6 files changed, 96 insertions(+), 29 deletions(-) diff --git a/DS4Control/Control.cs b/DS4Control/Control.cs index 94fcbb6..698c64d 100644 --- a/DS4Control/Control.cs +++ b/DS4Control/Control.cs @@ -51,14 +51,18 @@ namespace DS4Control Log.LogToTray(message); } } - public bool Start() + public bool Start(bool showlog = true) { if (x360Bus.Open() && x360Bus.Start()) { + if (showlog) LogDebug("Starting..."); DS4Devices.isExclusiveMode = Global.getUseExclusiveMode(); - LogDebug("Searching for controllers...."); - LogDebug("Using " + (DS4Devices.isExclusiveMode ? "Exclusive Mode" : "Shared Mode")); + if (showlog) + { + LogDebug("Searching for controllers...."); + LogDebug("Using " + (DS4Devices.isExclusiveMode ? "Exclusive Mode" : "Shared Mode")); + } try { DS4Devices.findControllers(); @@ -66,7 +70,8 @@ namespace DS4Control int ind = 0; foreach (DS4Device device in devices) { - LogDebug("Found Controller: " + device.MacAddress + " (" + device.ConnectionType + ")"); + if (showlog) + LogDebug("Found Controller: " + device.MacAddress + " (" + device.ConnectionType + ")"); WarnExclusiveModeFailure(device); DS4Controllers[ind] = device; device.Removal -= DS4Devices.On_Removal; @@ -84,16 +89,17 @@ namespace DS4Control TouchPadOn(ind, device); string filename = Path.GetFileName(Global.getAProfile(ind)); ind++; - if (System.IO.File.Exists(Global.appdatapath + "\\Profiles\\" + filename)) - { - LogDebug("Controller " + ind + " is using Profile \"" + filename.Substring(0, filename.Length - 4) + "\""); - Log.LogToTray("Controller " + ind + " is using Profile \"" + filename.Substring(0, filename.Length - 4) + "\""); - } - else - { - LogDebug("Controller " + ind + " is not using a profile"); - Log.LogToTray("Controller " + ind + " is not using a profile"); - } + if (showlog) + if (System.IO.File.Exists(Global.appdatapath + "\\Profiles\\" + filename)) + { + LogDebug("Controller " + ind + " is using Profile \"" + filename.Substring(0, filename.Length - 4) + "\""); + Log.LogToTray("Controller " + ind + " is using Profile \"" + filename.Substring(0, filename.Length - 4) + "\""); + } + else + { + LogDebug("Controller " + ind + " is not using a profile"); + Log.LogToTray("Controller " + ind + " is not using a profile"); + } if (ind >= 4) // out of Xinput devices! break; } @@ -109,17 +115,21 @@ namespace DS4Control return true; } - public bool Stop() + public bool Stop(bool showlog = true) { if (running) { running = false; + if (showlog) LogDebug("Stopping X360 Controllers"); bool anyUnplugged = false; for (int i = 0; i < DS4Controllers.Length; i++) { if (DS4Controllers[i] != null) { + Global.setRainbow(i, 0); + Global.setLedAsBatteryIndicator(i, false); + Global.saveColor(i, 64, 128, 128); CurrentState[i].Battery = PreviousState[i].Battery = 0; // Reset for the next connection's initial status change. x360Bus.Unplug(i); anyUnplugged = true; @@ -130,8 +140,10 @@ namespace DS4Control if (anyUnplugged) System.Threading.Thread.Sleep(XINPUT_UNPLUG_SETTLE_TIME); x360Bus.Stop(); + if (showlog) LogDebug("Stopping DS4 Controllers"); DS4Devices.stopControllers(); + if (showlog) LogDebug("Stopped DS4 Tool"); Global.ControllerStatusChanged(this); } @@ -145,6 +157,8 @@ namespace DS4Control { DS4Devices.findControllers(); IEnumerable devices = DS4Devices.getDS4Controllers(); + //Stop(false); + //Start(false); foreach (DS4Device device in devices) { if (device.IsDisconnecting) @@ -152,8 +166,7 @@ namespace DS4Control if (((Func)delegate { for (Int32 Index = 0; Index < DS4Controllers.Length; Index++) - if (DS4Controllers[Index] != null && - DS4Controllers[Index].MacAddress == device.MacAddress) + if (DS4Controllers[Index] != null && DS4Controllers[Index].MacAddress == device.MacAddress) return true; return false; })()) @@ -205,7 +218,7 @@ namespace DS4Control Global.ControllerStatusChanged(this); } - public static void TimeoutConnection(DS4Device d) + public void TimeoutConnection(DS4Device d) { try { @@ -224,9 +237,14 @@ namespace DS4Control } sw.Reset(); } - catch (TimeoutException e) + catch (TimeoutException) { - d.DisconnectBT(); + //Global.setUseExclusiveMode(!Global.getUseExclusiveMode()); + Stop(false); + Start(false); + //Global.setUseExclusiveMode(!Global.getUseExclusiveMode()); + //Stop(false); + //Start(false); } } diff --git a/DS4Control/DS4LightBar.cs b/DS4Control/DS4LightBar.cs index 408a743..d0d3700 100644 --- a/DS4Control/DS4LightBar.cs +++ b/DS4Control/DS4LightBar.cs @@ -78,7 +78,8 @@ namespace DS4Control double botratio = timeratio.TotalMilliseconds; double topratio = TimeSpan.FromSeconds(Global.getIdleDisconnectTimeout(deviceNum)).TotalMilliseconds; double ratio = ((botratio / topratio) * 100); - color = Global.getTransitionedColor(color, new DS4Color { red = 0, green = 0, blue = 0 }, (uint)ratio); + if (ratio >= 50) + color = Global.getTransitionedColor(color, new DS4Color { red = 0, green = 0, blue = 0 }, (uint)((ratio-50)*2)); } DS4HapticState haptics = new DS4HapticState { diff --git a/DS4Control/X360Device.cs b/DS4Control/X360Device.cs index 2f69de4..8409f27 100644 --- a/DS4Control/X360Device.cs +++ b/DS4Control/X360Device.cs @@ -154,7 +154,7 @@ namespace DS4Control Output[18] = (Byte)((ThumbRX >> 0) & 0xFF); // RX Output[19] = (Byte)((ThumbRX >> 8) & 0xFF); } - if (state.LY > 127 + Global.getLSDeadzone(device) || state.RY < 127 - Global.getRSDeadzone(device)) + if (state.RY > 127 + Global.getRSDeadzone(device) || state.RY < 127 - Global.getRSDeadzone(device)) { Output[20] = (Byte)((ThumbRY >> 0) & 0xFF); // RY Output[21] = (Byte)((ThumbRY >> 8) & 0xFF); diff --git a/DS4Tool/Options.Designer.cs b/DS4Tool/Options.Designer.cs index bd6c297..bd2e3d7 100644 --- a/DS4Tool/Options.Designer.cs +++ b/DS4Tool/Options.Designer.cs @@ -989,6 +989,10 @@ this.blueBar.TickStyle = System.Windows.Forms.TickStyle.None; this.blueBar.Value = 255; this.blueBar.ValueChanged += new System.EventHandler(this.blueBar_ValueChanged); + this.blueBar.MouseDown += new System.Windows.Forms.MouseEventHandler(this.LightBar_MouseDown); + this.blueBar.MouseLeave += new System.EventHandler(this.Lightbar_MouseLeave); + this.blueBar.MouseHover += new System.EventHandler(this.LightbarValue_MouseHover); + this.blueBar.MouseUp += new System.Windows.Forms.MouseEventHandler(this.Lightbar_MouseUp); // // greenBar // @@ -1003,6 +1007,10 @@ this.greenBar.TickStyle = System.Windows.Forms.TickStyle.None; this.greenBar.Value = 255; this.greenBar.ValueChanged += new System.EventHandler(this.greenBar_ValueChanged); + this.greenBar.MouseDown += new System.Windows.Forms.MouseEventHandler(this.LightBar_MouseDown); + this.greenBar.MouseLeave += new System.EventHandler(this.Lightbar_MouseLeave); + this.greenBar.MouseHover += new System.EventHandler(this.LightbarValue_MouseHover); + this.greenBar.MouseUp += new System.Windows.Forms.MouseEventHandler(this.Lightbar_MouseUp); // // redBar // @@ -1017,6 +1025,10 @@ this.redBar.TickStyle = System.Windows.Forms.TickStyle.None; this.redBar.Value = 255; this.redBar.ValueChanged += new System.EventHandler(this.redBar_ValueChanged); + this.redBar.MouseDown += new System.Windows.Forms.MouseEventHandler(this.LightBar_MouseDown); + this.redBar.MouseLeave += new System.EventHandler(this.Lightbar_MouseLeave); + this.redBar.MouseHover += new System.EventHandler(this.LightbarValue_MouseHover); + this.redBar.MouseUp += new System.Windows.Forms.MouseEventHandler(this.Lightbar_MouseUp); // // batteryLed // @@ -1533,6 +1545,10 @@ this.lowRedBar.TickStyle = System.Windows.Forms.TickStyle.None; this.lowRedBar.Value = 255; this.lowRedBar.ValueChanged += new System.EventHandler(this.lowRedBar_ValueChanged); + this.lowRedBar.MouseDown += new System.Windows.Forms.MouseEventHandler(this.LightBar_MouseDown); + this.lowRedBar.MouseLeave += new System.EventHandler(this.Lightbar_MouseLeave); + this.lowRedBar.MouseHover += new System.EventHandler(this.LightbarValue_MouseHover); + this.lowRedBar.MouseUp += new System.Windows.Forms.MouseEventHandler(this.Lightbar_MouseUp); // // lowGreenBar // @@ -1547,6 +1563,10 @@ this.lowGreenBar.TickStyle = System.Windows.Forms.TickStyle.None; this.lowGreenBar.Value = 255; this.lowGreenBar.ValueChanged += new System.EventHandler(this.lowGreenBar_ValueChanged); + this.lowGreenBar.MouseDown += new System.Windows.Forms.MouseEventHandler(this.LightBar_MouseDown); + this.lowGreenBar.MouseLeave += new System.EventHandler(this.Lightbar_MouseLeave); + this.lowGreenBar.MouseHover += new System.EventHandler(this.LightbarValue_MouseHover); + this.lowGreenBar.MouseUp += new System.Windows.Forms.MouseEventHandler(this.Lightbar_MouseUp); // // lowBlueBar // @@ -1561,6 +1581,10 @@ this.lowBlueBar.TickStyle = System.Windows.Forms.TickStyle.None; this.lowBlueBar.Value = 255; this.lowBlueBar.ValueChanged += new System.EventHandler(this.lowBlueBar_ValueChanged); + this.lowBlueBar.MouseDown += new System.Windows.Forms.MouseEventHandler(this.LightBar_MouseDown); + this.lowBlueBar.MouseLeave += new System.EventHandler(this.Lightbar_MouseLeave); + this.lowBlueBar.MouseHover += new System.EventHandler(this.LightbarValue_MouseHover); + this.lowBlueBar.MouseUp += new System.Windows.Forms.MouseEventHandler(this.Lightbar_MouseUp); // // lBEmpty // @@ -1784,7 +1808,7 @@ this.gBOther.Controls.Add(this.lBControllerOff); this.gBOther.Location = new System.Drawing.Point(6, 221); this.gBOther.Name = "gBOther"; - this.gBOther.Size = new System.Drawing.Size(419, 70); + this.gBOther.Size = new System.Drawing.Size(421, 70); this.gBOther.TabIndex = 247; this.gBOther.TabStop = false; this.gBOther.Text = "Other"; diff --git a/DS4Tool/Options.cs b/DS4Tool/Options.cs index ed6aa22..37c0e06 100644 --- a/DS4Tool/Options.cs +++ b/DS4Tool/Options.cs @@ -20,7 +20,7 @@ namespace ScpServer private int alphacolor; private Color reg, full; private Image colored, greyscale; - + ToolTip tp = new ToolTip(); public Options(DS4Control.Control bus_device, int deviceNum, string name) { InitializeComponent(); @@ -117,12 +117,11 @@ namespace ScpServer b.MouseHover += button_MouseHover; if (filename != "" && filename != "New Profile") Global.LoadProfile(device, buttons.ToArray()); - ToolTip tp = new ToolTip(); tp.SetToolTip(cBlowerRCOn, "Best used with right side as a mouse function"); tp.SetToolTip(cBDoubleTap, "Tap and hold to drag, slight delay with single taps"); tp.SetToolTip(lBControlTip, "You can also use your controller to change controls"); tp.SetToolTip(touchpadJitterCompensation, "Use Sixaxis to help calulate touchpad movement"); - tp.SetToolTip(pBRainbow, "Always on Rainbow Mode"); + tp.SetToolTip(pBRainbow, "Always on Rainbow Mode"); advColorDialog.OnUpdateColor += advColorDialog_OnUpdateColor; btnLeftStick.Enter += btnSticks_Enter; btnRightStick.Enter += btnSticks_Enter; @@ -360,6 +359,7 @@ namespace ScpServer full = HuetoRGB(reg.GetHue(), reg.GetBrightness(), reg); pBController.BackColor = Color.FromArgb((alphacolor > 205 ? 255 : (alphacolor + 50)), full); Global.saveColor(device, (byte)redBar.Value, (byte)greenBar.Value, (byte)blueBar.Value); + tp.Show(((TrackBar)sender).Value.ToString(), ((TrackBar)sender), 100, 0, 2000); } private void greenBar_ValueChanged(object sender, EventArgs e) { @@ -372,6 +372,7 @@ namespace ScpServer full = HuetoRGB(reg.GetHue(), reg.GetBrightness(), reg); pBController.BackColor = Color.FromArgb((alphacolor > 205 ? 255 : (alphacolor + 50)), full); Global.saveColor(device, (byte)redBar.Value, (byte)greenBar.Value, (byte)blueBar.Value); + tp.Show(((TrackBar)sender).Value.ToString(), ((TrackBar)sender), 100, 0, 2000); } private void blueBar_ValueChanged(object sender, EventArgs e) { @@ -384,6 +385,7 @@ namespace ScpServer full = HuetoRGB(reg.GetHue(), reg.GetBrightness(), reg); pBController.BackColor = Color.FromArgb((alphacolor > 205 ? 255 : (alphacolor + 50)), full); Global.saveColor(device, (byte)redBar.Value, (byte)greenBar.Value, (byte)blueBar.Value); + tp.Show(((TrackBar)sender).Value.ToString(), ((TrackBar)sender), 100, 0, 2000); } private void lowRedBar_ValueChanged(object sender, EventArgs e) @@ -397,6 +399,7 @@ namespace ScpServer full = HuetoRGB(reg.GetHue(), reg.GetBrightness(), reg); lowColorChooserButton.BackColor = Color.FromArgb((alphacolor > 205 ? 255 : (alphacolor + 50)), full); Global.saveLowColor(device, (byte)lowRedBar.Value, (byte)lowGreenBar.Value, (byte)lowBlueBar.Value); + tp.Show(((TrackBar)sender).Value.ToString(), ((TrackBar)sender), 100, 0, 2000); } private void lowGreenBar_ValueChanged(object sender, EventArgs e) @@ -410,6 +413,7 @@ namespace ScpServer full = HuetoRGB(reg.GetHue(), reg.GetBrightness(), reg); lowColorChooserButton.BackColor = Color.FromArgb((alphacolor > 205 ? 255 : (alphacolor + 50)), full); Global.saveLowColor(device, (byte)lowRedBar.Value, (byte)lowGreenBar.Value, (byte)lowBlueBar.Value); + tp.Show(((TrackBar)sender).Value.ToString(), ((TrackBar)sender), 100, 0, 2000); } private void lowBlueBar_ValueChanged(object sender, EventArgs e) @@ -423,6 +427,7 @@ namespace ScpServer full = HuetoRGB(reg.GetHue(), reg.GetBrightness(), reg); lowColorChooserButton.BackColor = Color.FromArgb((alphacolor > 205 ? 255 : (alphacolor + 50)), full); Global.saveLowColor(device, (byte)lowRedBar.Value, (byte)lowGreenBar.Value, (byte)lowBlueBar.Value); + tp.Show(((TrackBar)sender).Value.ToString(), ((TrackBar)sender), 100, 0, 2000); } public Color HuetoRGB(float hue, float light, Color rgb) @@ -815,5 +820,24 @@ namespace ScpServer { } + + private void LightbarValue_MouseHover(object sender, EventArgs e) + { + //tp.SetToolTip(((TrackBar)sender), ((TrackBar)sender).Value.ToString()); + } + + private void Lightbar_MouseLeave(object sender, EventArgs e) + { + } + + private void LightBar_MouseDown(object sender, MouseEventArgs e) + { + tp.Show(((TrackBar)sender).Value.ToString(), ((TrackBar)sender), 100, 0); + } + + private void Lightbar_MouseUp(object sender, MouseEventArgs e) + { + tp.Hide(((TrackBar)sender)); + } } } diff --git a/DS4Tool/ScpForm.cs b/DS4Tool/ScpForm.cs index 4b9dfa4..4daeb1e 100644 --- a/DS4Tool/ScpForm.cs +++ b/DS4Tool/ScpForm.cs @@ -12,7 +12,7 @@ namespace ScpServer { public partial class ScpForm : Form { - double version = 7.6; + double version = 7.7; private DS4Control.Control rootHub; delegate void LogDebugDelegate(DateTime Time, String Data); @@ -283,7 +283,7 @@ namespace ScpServer { Global.setRainbow(i, 0); Global.setLedAsBatteryIndicator(i, false); - Global.saveColor(i, 128, 255, 255); + Global.saveColor(i, 64, 128, 128); } rootHub.Stop(); btnStartStop.Text = "Start"; @@ -577,7 +577,7 @@ namespace ScpServer { Global.setRainbow(i, 0); Global.setLedAsBatteryIndicator(i, false); - Global.saveColor(i, 128, 255, 255); + Global.saveColor(i, 64, 128, 128); } rootHub.Stop(); }