// Use the "most recently set" haptic state for each of light bar/motor. private void setHapticState() { int i = 0; EAll4Color lightBarColor = LightBarColor.Value; byte lightBarFlashDurationOn = LightBarOnDuration, lightBarFlashDurationOff = LightBarOffDuration; byte rumbleMotorStrengthLeftHeavySlow = LeftHeavySlowRumble, rumbleMotorStrengthRightLightFast = rightLightFastRumble; foreach (EAll4HapticState haptic in hapticState) { if (i++ == hapticStackIndex) { break; // rest haven't been used this time } if (haptic.IsLightBarSet()) { lightBarColor = haptic.LightBarColor; lightBarFlashDurationOn = haptic.LightBarFlashDurationOn; lightBarFlashDurationOff = haptic.LightBarFlashDurationOff; } if (haptic.IsRumbleSet()) { rumbleMotorStrengthLeftHeavySlow = haptic.RumbleMotorStrengthLeftHeavySlow; rumbleMotorStrengthRightLightFast = haptic.RumbleMotorStrengthRightLightFast; } } LightBarColor = lightBarColor; LightBarOnDuration = lightBarFlashDurationOn; LightBarOffDuration = lightBarFlashDurationOff; LeftHeavySlowRumble = rumbleMotorStrengthLeftHeavySlow; RightLightFastRumble = rumbleMotorStrengthRightLightFast; }
private void advColorDialog_OnUpdateColor(object sender, EventArgs e) { if (sender is Color && device < 4) { Color color = (Color)sender; EAll4Color dcolor = new EAll4Color { Red = color.R, Green = color.G, Blue = color.B }; EAll4LightBar.forcedColor[device] = dcolor; EAll4LightBar.forcedFlash[device] = 0; EAll4LightBar.forcelight[device] = true; } }
public void LagFlashWarning(int ind, bool on) { if (on) { lag[ind] = true; LogDebug(Properties.Resources.LatencyOverTen.Replace("*number*", (ind + 1).ToString()), true); if (Global.FlashWhenLate) { EAll4Color color = new EAll4Color { Red = 50, Green = 0, Blue = 0 }; EAll4LightBar.forcedColor[ind] = color; EAll4LightBar.forcedFlash[ind] = 2; EAll4LightBar.forcelight[ind] = true; } } else { lag[ind] = false; LogDebug(Properties.Resources.LatencyNotOverTen.Replace("*number*", (ind + 1).ToString())); EAll4LightBar.forcelight[ind] = false; EAll4LightBar.forcedFlash[ind] = 0; } }
private void DoExtras(int ind) { ControllerState cState = CurrentState[ind]; EAll4StateExposed eState = ExposedState[ind]; Mouse tp = touchPad[ind]; GenericControls helddown = GenericControls.None; foreach (KeyValuePair <GenericControls, string> p in Global.getCustomExtras(ind)) { if (Mapping.getBoolMapping(p.Key, cState, eState, tp)) { helddown = p.Key; break; } } if (helddown != GenericControls.None) { string p = Global.getCustomExtras(ind)[helddown]; string[] extraS = p.Split(','); int[] extras = new int[extraS.Length]; for (int i = 0; i < extraS.Length; i++) { int b; if (int.TryParse(extraS[i], out b)) { extras[i] = b; } } held[ind] = true; try { if (!(extras[0] == extras[1] && extras[1] == 0)) { setRumble((byte)extras[0], (byte)extras[1], ind); } if (extras[2] == 1) { EAll4Color color = new EAll4Color { Red = (byte)extras[3], Green = (byte)extras[4], Blue = (byte)extras[5] }; EAll4LightBar.forcedColor[ind] = color; EAll4LightBar.forcedFlash[ind] = (byte)extras[6]; EAll4LightBar.forcelight[ind] = true; } if (extras[7] == 1) { if (oldmouse[ind] == -1) { oldmouse[ind] = Global.ButtonMouseSensitivity[ind]; } Global.ButtonMouseSensitivity[ind] = extras[8]; } } catch { } } else if (held[ind]) { EAll4LightBar.forcelight[ind] = false; EAll4LightBar.forcedFlash[ind] = 0; Global.ButtonMouseSensitivity[ind] = oldmouse[ind]; oldmouse[ind] = -1; setRumble(0, 0, ind); held[ind] = false; } }
public static void updateLightBar(IEAll4Device ieAll4Device, int deviceNum, ControllerState cState, EAll4StateExposed eState, Mouse tp) { EAll4Color color; if (!defaultLight && !forcelight[deviceNum]) { if (Global.ShiftColorOn[deviceNum] && Global.ShiftModifier[deviceNum] > 0 && shiftMod(ieAll4Device, deviceNum, cState, eState, tp)) { color = Global.ShiftColor[deviceNum]; } else { if (Global.Rainbow[deviceNum] > 0) { // Display rainbow DateTime now = DateTime.UtcNow; if (now >= oldnow + TimeSpan.FromMilliseconds(10)) //update by the millisecond that way it's a smooth transtion { oldnow = now; if (ieAll4Device.Charging) { counters[deviceNum] -= 1.5 * 3 / Global.Rainbow[deviceNum]; } else { counters[deviceNum] += 1.5 * 3 / Global.Rainbow[deviceNum]; } } if (counters[deviceNum] < 0) { counters[deviceNum] = 180000; } if (counters[deviceNum] > 180000) { counters[deviceNum] = 0; } if (Global.LedAsBatteryIndicator[deviceNum]) { color = HuetoRGB((float)counters[deviceNum] % 360, (byte)(2.55 * ieAll4Device.Battery)); } else { color = HuetoRGB((float)counters[deviceNum] % 360, 255); } } else if (Global.LedAsBatteryIndicator[deviceNum]) { //if (device.Charging == false || device.Battery >= 100) // when charged, don't show the charging animation { EAll4Color fullColor = Global.MainColor[deviceNum]; EAll4Color lowColor = Global.LowColor[deviceNum]; color = Global.getTransitionedColor(lowColor, fullColor, (uint)ieAll4Device.Battery); } } else { color = Global.MainColor[deviceNum]; } if (ieAll4Device.Battery <= Global.FlashAt[deviceNum] && !defaultLight && !ieAll4Device.Charging) { if (!(Global.FlashColor[deviceNum].Red == 0 && Global.FlashColor[deviceNum].Green == 0 && Global.FlashColor[deviceNum].Blue == 0)) { color = Global.FlashColor[deviceNum]; } if (Global.FlashType[deviceNum] == 1) { if (fadetimer[deviceNum] <= 0) { fadedirection[deviceNum] = true; } else if (fadetimer[deviceNum] >= 100) { fadedirection[deviceNum] = false; } if (fadedirection[deviceNum]) { fadetimer[deviceNum] += 1; } else { fadetimer[deviceNum] -= 1; } color = Global.getTransitionedColor(color, new EAll4Color(0, 0, 0), fadetimer[deviceNum]); } } if (Global.IdleDisconnectTimeout[deviceNum] > 0 && Global.LedAsBatteryIndicator[deviceNum] && (!ieAll4Device.Charging || ieAll4Device.Battery >= 100)) {//Fade lightbar by idle time TimeSpan timeratio = new TimeSpan(DateTime.UtcNow.Ticks - ieAll4Device.lastActive.Ticks); double botratio = timeratio.TotalMilliseconds; double topratio = TimeSpan.FromSeconds(Global.IdleDisconnectTimeout[deviceNum]).TotalMilliseconds; double ratio = ((botratio / topratio) * 100); if (ratio >= 50 && ratio <= 100) { color = Global.getTransitionedColor(color, new EAll4Color(0, 0, 0), (uint)((ratio - 50) * 2)); } else if (ratio >= 100) { color = Global.getTransitionedColor(color, new EAll4Color(0, 0, 0), 100); } } if (ieAll4Device.Charging && ieAll4Device.Battery < 100) { switch (Global.ChargingType[deviceNum]) { case 1: if (fadetimer[deviceNum] <= 0) { fadedirection[deviceNum] = true; } else if (fadetimer[deviceNum] >= 105) { fadedirection[deviceNum] = false; } if (fadedirection[deviceNum]) { fadetimer[deviceNum] += .1; } else { fadetimer[deviceNum] -= .1; } color = Global.getTransitionedColor(color, new EAll4Color(0, 0, 0), fadetimer[deviceNum]); break; case 2: counters[deviceNum] += .167; color = HuetoRGB((float)counters[deviceNum] % 360, 255); break; case 3: color = Global.ChargingColor[deviceNum]; break; default: break; } } } } else if (forcelight[deviceNum]) { color = forcedColor[deviceNum]; } else if (shuttingdown) { color = new EAll4Color(0, 0, 0); } else { if (ieAll4Device.ConnectionType == ConnectionType.BT) { color = new EAll4Color(32, 64, 64); } else { color = new EAll4Color(0, 0, 0); } } bool distanceprofile = (Global.ProfilePath[deviceNum].ToLower().Contains("distance") || Global.tempprofilename[deviceNum].ToLower().Contains("distance")); if (distanceprofile && !defaultLight) { //Thing I did for Distance float rumble = ieAll4Device.LeftHeavySlowRumble / 2.55f; byte max = Math.Max(color.Red, Math.Max(color.Green, color.Blue)); if (ieAll4Device.LeftHeavySlowRumble > 100) { color = Global.getTransitionedColor(new EAll4Color(max, max, 0), new EAll4Color(255, 0, 0), rumble); } else { color = Global.getTransitionedColor(color, Global.getTransitionedColor(new EAll4Color(max, max, 0), new EAll4Color(255, 0, 0), 39.6078f), ieAll4Device.LeftHeavySlowRumble); } } EAll4HapticState haptics = new EAll4HapticState { LightBarColor = color }; if (haptics.IsLightBarSet()) { if (forcelight[deviceNum] && forcedFlash[deviceNum] > 0) { haptics.LightBarFlashDurationOff = haptics.LightBarFlashDurationOn = (byte)(25 - forcedFlash[deviceNum]); haptics.LightBarExplicitlyOff = true; } else if (ieAll4Device.Battery <= Global.FlashAt[deviceNum] && Global.FlashType[deviceNum] == 0 && !defaultLight && !ieAll4Device.Charging) { int level = ieAll4Device.Battery / 10; //if (level >= 10) //level = 0; // all values of ~0% or >~100% are rendered the same haptics.LightBarFlashDurationOn = BatteryIndicatorDurations[level, 0]; haptics.LightBarFlashDurationOff = BatteryIndicatorDurations[level, 1]; } else if (distanceprofile && ieAll4Device.LeftHeavySlowRumble > 155) //also part of Distance { haptics.LightBarFlashDurationOff = haptics.LightBarFlashDurationOn = (byte)((-ieAll4Device.LeftHeavySlowRumble + 265)); haptics.LightBarExplicitlyOff = true; } else { //haptics.LightBarFlashDurationOff = haptics.LightBarFlashDurationOn = 1; haptics.LightBarFlashDurationOff = haptics.LightBarFlashDurationOn = 0; haptics.LightBarExplicitlyOff = true; } } else { haptics.LightBarExplicitlyOff = true; } if (ieAll4Device.LightBarOnDuration != haptics.LightBarFlashDurationOn && ieAll4Device.LightBarOnDuration != 1 && haptics.LightBarFlashDurationOn == 0) { haptics.LightBarFlashDurationOff = haptics.LightBarFlashDurationOn = 1; } if (ieAll4Device.LightBarOnDuration == 1) //helps better reset the color { System.Threading.Thread.Sleep(5); } ieAll4Device.pushHapticState(haptics); }