When using Idle timeout, The lightbar now will fade as the controller sits idle. Added a decimal place to idle timeout so you can use half/etc. minutes now. Proper Display of percentages of dead-zones when reentering options

This commit is contained in:
jays2kings 2014-05-22 15:13:38 -04:00
parent c1d39f9cc5
commit 36f01ac30c
5 changed files with 26 additions and 16 deletions

View File

@ -25,19 +25,20 @@ namespace DS4Control
static DateTime oldnow = DateTime.Now; static DateTime oldnow = DateTime.Now;
public static void updateLightBar(DS4Device device, int deviceNum) public static void updateLightBar(DS4Device device, int deviceNum)
{ {
DS4Color color; DS4Color color;
if (Global.getRainbow(deviceNum) > 0) if (Global.getRainbow(deviceNum) > 0)
{// Display rainbow {// Display rainbow
DateTime now = DateTime.Now; DateTime now = DateTime.Now;
if (now >= oldnow + TimeSpan.FromMilliseconds(10)) //update by the millisecond that way it's a smooth transtion if (now >= oldnow + TimeSpan.FromMilliseconds(10)) //update by the millisecond that way it's a smooth transtion
{ {
oldnow = now; oldnow = now;
counters[deviceNum] += 1.5*3 / Global.getRainbow(deviceNum); counters[deviceNum] += 1.5 * 3 / Global.getRainbow(deviceNum);
} }
if (Global.getLedAsBatteryIndicator(deviceNum) && (device.Charging == false || device.Battery >= 100))// when charged, don't show the charging animation if (Global.getLedAsBatteryIndicator(deviceNum) && (device.Charging == false || device.Battery >= 100))// when charged, don't show the charging animation
color = HuetoRGB((float)counters[deviceNum] % 360, (byte)(2.55 * device.Battery)); color = HuetoRGB((float)counters[deviceNum] % 360, (byte)(2.55 * device.Battery));
else else
color = HuetoRGB((float)counters[deviceNum] % 360, 255); color = HuetoRGB((float)counters[deviceNum] % 360, 255);
} }
else if (Global.getLedAsBatteryIndicator(deviceNum)) else if (Global.getLedAsBatteryIndicator(deviceNum))
{ {
@ -62,7 +63,7 @@ namespace DS4Control
} }
else // Display rainbow when charging. else // Display rainbow when charging.
{ {
counters[deviceNum]+= .167; counters[deviceNum] += .167;
color = HuetoRGB((float)counters[deviceNum] % 360, 255); color = HuetoRGB((float)counters[deviceNum] % 360, 255);
} }
} }
@ -71,6 +72,14 @@ namespace DS4Control
color = Global.loadColor(deviceNum); color = Global.loadColor(deviceNum);
} }
if (Global.getIdleDisconnectTimeout(deviceNum) > 0)
{//Fade lightbar by idle time
TimeSpan timeratio = new TimeSpan(DateTime.Now.Ticks - device.lastActive.Ticks) + new TimeSpan(4, 0, 0); //The nows are off by 4 hours, not sure why...
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);
}
DS4HapticState haptics = new DS4HapticState DS4HapticState haptics = new DS4HapticState
{ {
LightBarColor = color LightBarColor = color

View File

@ -67,7 +67,7 @@ namespace DS4Library
private byte ledFlashOn, ledFlashOff; private byte ledFlashOn, ledFlashOff;
private Thread ds4Input, ds4Output; private Thread ds4Input, ds4Output;
private int battery; private int battery;
private DateTime lastActive = DateTime.UtcNow; public DateTime lastActive = DateTime.UtcNow;
private bool charging; private bool charging;
public event EventHandler<EventArgs> Report = null; public event EventHandler<EventArgs> Report = null;
public event EventHandler<EventArgs> Removal = null; public event EventHandler<EventArgs> Removal = null;

View File

@ -1272,6 +1272,7 @@
// //
// idleDisconnectTimeout // idleDisconnectTimeout
// //
this.idleDisconnectTimeout.DecimalPlaces = 1;
this.idleDisconnectTimeout.Location = new System.Drawing.Point(114, 247); this.idleDisconnectTimeout.Location = new System.Drawing.Point(114, 247);
this.idleDisconnectTimeout.Maximum = new decimal(new int[] { this.idleDisconnectTimeout.Maximum = new decimal(new int[] {
60, 60,

View File

@ -55,7 +55,7 @@ namespace ScpServer
touchpadJitterCompensation.Checked = Global.getTouchpadJitterCompensation(device); touchpadJitterCompensation.Checked = Global.getTouchpadJitterCompensation(device);
cBlowerRCOn.Checked = Global.getLowerRCOn(device); cBlowerRCOn.Checked = Global.getLowerRCOn(device);
flushHIDQueue.Checked = Global.getFlushHIDQueue(device); flushHIDQueue.Checked = Global.getFlushHIDQueue(device);
idleDisconnectTimeout.Value = (int)(Global.getIdleDisconnectTimeout(device)/60); idleDisconnectTimeout.Value = Math.Round((decimal)(Global.getIdleDisconnectTimeout(device) / 60d), 1);
tBMouseSens.Value = Global.getButtonMouseSensitivity(device); tBMouseSens.Value = Global.getButtonMouseSensitivity(device);
lBMouseSens.Text = tBMouseSens.Value.ToString(); lBMouseSens.Text = tBMouseSens.Value.ToString();
// Force update of color choosers // Force update of color choosers
@ -79,8 +79,8 @@ namespace ScpServer
pBRainbow.Image = colored; pBRainbow.Image = colored;
ToggleRainbow(true); ToggleRainbow(true);
} }
numUDLS.Value = (decimal)Global.getLSDeadzone(device) / 127; numUDLS.Value = Math.Round((decimal)(Global.getLSDeadzone(device) / 127d ), 3);
numUDRS.Value = (decimal)Global.getRSDeadzone(device) / 127; numUDRS.Value = Math.Round((decimal)(Global.getRSDeadzone(device) / 127d ), 3);
} }
else else
Set(); Set();
@ -216,8 +216,8 @@ namespace ScpServer
{ {
Global.saveColor(device, (byte)redBar.Value, (byte)greenBar.Value, (byte)blueBar.Value); Global.saveColor(device, (byte)redBar.Value, (byte)greenBar.Value, (byte)blueBar.Value);
Global.saveLowColor(device, (byte)lowRedBar.Value, (byte)lowGreenBar.Value, (byte)lowBlueBar.Value); Global.saveLowColor(device, (byte)lowRedBar.Value, (byte)lowGreenBar.Value, (byte)lowBlueBar.Value);
Global.setLeftTriggerMiddle(device, (byte)(numUDL2.Value * 255)); Global.setLeftTriggerMiddle(device, (byte)Math.Round((numUDL2.Value * 255), 0));
Global.setRightTriggerMiddle(device, (byte)(numUDR2.Value * 255)); Global.setRightTriggerMiddle(device, (byte)Math.Round((numUDR2.Value * 255), 0));
Global.saveRumbleBoost(device, (byte)rumbleBoostBar.Value); Global.saveRumbleBoost(device, (byte)rumbleBoostBar.Value);
Global.setFlashWhenLowBattery(device, flashLed.Checked); Global.setFlashWhenLowBattery(device, flashLed.Checked);
Global.setTouchSensitivity(device, (byte)numUDTouch.Value); Global.setTouchSensitivity(device, (byte)numUDTouch.Value);
@ -227,11 +227,11 @@ namespace ScpServer
Global.setDoubleTap(device, cBDoubleTap.Checked); Global.setDoubleTap(device, cBDoubleTap.Checked);
Global.setButtonMouseSensitivity(device, tBMouseSens.Value); Global.setButtonMouseSensitivity(device, tBMouseSens.Value);
Global.setTapSensitivity(device, (byte)numUDTap.Value); Global.setTapSensitivity(device, (byte)numUDTap.Value);
Global.setIdleDisconnectTimeout(device, (int)(idleDisconnectTimeout.Value * 60)); Global.setIdleDisconnectTimeout(device, (int)(idleDisconnectTimeout.Value * 60));
Global.setButtonMouseSensitivity(device, tBMouseSens.Value); Global.setButtonMouseSensitivity(device, tBMouseSens.Value);
Global.setRainbow(device, (int)numUDRainbow.Value); Global.setRainbow(device, (int)numUDRainbow.Value);
Global.setRSDeadzone(device, (byte)(numUDRS.Value * 127)); Global.setRSDeadzone(device, (byte)Math.Round((numUDRS.Value * 127), 0));
Global.setLSDeadzone(device, (byte)(numUDLS.Value * 127)); Global.setLSDeadzone(device, (byte)Math.Round((numUDLS.Value * 127), 0));
if (numUDRainbow.Value == 0) pBRainbow.Image = greyscale; if (numUDRainbow.Value == 0) pBRainbow.Image = greyscale;
else pBRainbow.Image = colored; else pBRainbow.Image = colored;
} }
@ -810,12 +810,12 @@ namespace ScpServer
private void numUDRS_ValueChanged(object sender, EventArgs e) private void numUDRS_ValueChanged(object sender, EventArgs e)
{ {
Global.setRSDeadzone(device, (byte)(numUDRS.Value * 127)); Global.setRSDeadzone(device, (byte)Math.Round((numUDRS.Value * 127),0));
} }
private void numUDLS_ValueChanged(object sender, EventArgs e) private void numUDLS_ValueChanged(object sender, EventArgs e)
{ {
Global.setLSDeadzone(device, (byte)(numUDLS.Value * 127)); Global.setLSDeadzone(device, (byte)Math.Round((numUDLS.Value * 127),0));
} }
} }

View File

@ -14,7 +14,7 @@ namespace ScpServer
{ {
private DS4Control.Control rootHub; private DS4Control.Control rootHub;
delegate void LogDebugDelegate(DateTime Time, String Data); delegate void LogDebugDelegate(DateTime Time, String Data);
double version = 7.31; double version = 7.4;
protected Label[] Pads; protected Label[] Pads;
protected ComboBox[] cbs; protected ComboBox[] cbs;
@ -408,7 +408,7 @@ namespace ScpServer
string filename = cbs[tdevice].Items[cbs[tdevice].SelectedIndex].ToString(); string filename = cbs[tdevice].Items[cbs[tdevice].SelectedIndex].ToString();
if (MessageBox.Show("\"" + filename + "\" cannot be restored.", "Delete Profile?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes) if (MessageBox.Show("\"" + filename + "\" cannot be restored.", "Delete Profile?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes)
{ {
System.IO.File.Delete(Global.appdatapath + filename + ".xml"); System.IO.File.Delete(Global.appdatapath + "\\Profiles\\" +filename + ".xml");
Global.setAProfile(tdevice, null); Global.setAProfile(tdevice, null);
RefreshProfiles(); RefreshProfiles();
} }