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;
public static void updateLightBar(DS4Device device, int deviceNum)
{
DS4Color color;
DS4Color color;
if (Global.getRainbow(deviceNum) > 0)
{// Display rainbow
DateTime now = DateTime.Now;
if (now >= oldnow + TimeSpan.FromMilliseconds(10)) //update by the millisecond that way it's a smooth transtion
{
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
color = HuetoRGB((float)counters[deviceNum] % 360, (byte)(2.55 * device.Battery));
else
color = HuetoRGB((float)counters[deviceNum] % 360, 255);
}
else if (Global.getLedAsBatteryIndicator(deviceNum))
{
@ -62,7 +63,7 @@ namespace DS4Control
}
else // Display rainbow when charging.
{
counters[deviceNum]+= .167;
counters[deviceNum] += .167;
color = HuetoRGB((float)counters[deviceNum] % 360, 255);
}
}
@ -71,6 +72,14 @@ namespace DS4Control
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
{
LightBarColor = color

View File

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

View File

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

View File

@ -55,7 +55,7 @@ namespace ScpServer
touchpadJitterCompensation.Checked = Global.getTouchpadJitterCompensation(device);
cBlowerRCOn.Checked = Global.getLowerRCOn(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);
lBMouseSens.Text = tBMouseSens.Value.ToString();
// Force update of color choosers
@ -79,8 +79,8 @@ namespace ScpServer
pBRainbow.Image = colored;
ToggleRainbow(true);
}
numUDLS.Value = (decimal)Global.getLSDeadzone(device) / 127;
numUDRS.Value = (decimal)Global.getRSDeadzone(device) / 127;
numUDLS.Value = Math.Round((decimal)(Global.getLSDeadzone(device) / 127d ), 3);
numUDRS.Value = Math.Round((decimal)(Global.getRSDeadzone(device) / 127d ), 3);
}
else
Set();
@ -216,8 +216,8 @@ namespace ScpServer
{
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.setLeftTriggerMiddle(device, (byte)(numUDL2.Value * 255));
Global.setRightTriggerMiddle(device, (byte)(numUDR2.Value * 255));
Global.setLeftTriggerMiddle(device, (byte)Math.Round((numUDL2.Value * 255), 0));
Global.setRightTriggerMiddle(device, (byte)Math.Round((numUDR2.Value * 255), 0));
Global.saveRumbleBoost(device, (byte)rumbleBoostBar.Value);
Global.setFlashWhenLowBattery(device, flashLed.Checked);
Global.setTouchSensitivity(device, (byte)numUDTouch.Value);
@ -227,11 +227,11 @@ namespace ScpServer
Global.setDoubleTap(device, cBDoubleTap.Checked);
Global.setButtonMouseSensitivity(device, tBMouseSens.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.setRainbow(device, (int)numUDRainbow.Value);
Global.setRSDeadzone(device, (byte)(numUDRS.Value * 127));
Global.setLSDeadzone(device, (byte)(numUDLS.Value * 127));
Global.setRSDeadzone(device, (byte)Math.Round((numUDRS.Value * 127), 0));
Global.setLSDeadzone(device, (byte)Math.Round((numUDLS.Value * 127), 0));
if (numUDRainbow.Value == 0) pBRainbow.Image = greyscale;
else pBRainbow.Image = colored;
}
@ -810,12 +810,12 @@ namespace ScpServer
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)
{
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;
delegate void LogDebugDelegate(DateTime Time, String Data);
double version = 7.31;
double version = 7.4;
protected Label[] Pads;
protected ComboBox[] cbs;
@ -408,7 +408,7 @@ namespace ScpServer
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)
{
System.IO.File.Delete(Global.appdatapath + filename + ".xml");
System.IO.File.Delete(Global.appdatapath + "\\Profiles\\" +filename + ".xml");
Global.setAProfile(tdevice, null);
RefreshProfiles();
}