public ControlService() { sp.Stream = Properties.Resources.EE; x360Bus = new X360Device(); AddtoEAll4List(); for (int i = 0; i < controllers.Length; i++) { processingData[i] = new X360Data(); MappedState[i] = new ControllerState(); CurrentState[i] = new ControllerState(); PreviousState[i] = new ControllerState(); ExposedState[i] = new EAll4StateExposed(CurrentState[i]); } }
public GenericControls GetInputkeysEAll4(int ind) { ControllerState cState = CurrentState[ind]; EAll4StateExposed eState = ExposedState[ind]; Mouse tp = touchPad[ind]; if (controllers[ind] != null) { if (Mapping.getBoolMapping(GenericControls.A, cState, eState, tp)) { return(GenericControls.A); } else if (Mapping.getBoolMapping(GenericControls.B, cState, eState, tp)) { return(GenericControls.B); } else if (Mapping.getBoolMapping(GenericControls.Y, cState, eState, tp)) { return(GenericControls.Y); } else if (Mapping.getBoolMapping(GenericControls.X, cState, eState, tp)) { return(GenericControls.X); } else if (Mapping.getBoolMapping(GenericControls.LB, cState, eState, tp)) { return(GenericControls.LB); } else if (Mapping.getBoolMapping(GenericControls.RB, cState, eState, tp)) { return(GenericControls.RB); } else if (Mapping.getBoolMapping(GenericControls.LT, cState, eState, tp)) { return(GenericControls.LT); } else if (Mapping.getBoolMapping(GenericControls.RT, cState, eState, tp)) { return(GenericControls.RT); } else if (Mapping.getBoolMapping(GenericControls.LS, cState, eState, tp)) { return(GenericControls.LS); } else if (Mapping.getBoolMapping(GenericControls.RS, cState, eState, tp)) { return(GenericControls.RS); } else if (Mapping.getBoolMapping(GenericControls.DpadUp, cState, eState, tp)) { return(GenericControls.DpadUp); } else if (Mapping.getBoolMapping(GenericControls.DpadDown, cState, eState, tp)) { return(GenericControls.DpadDown); } else if (Mapping.getBoolMapping(GenericControls.DpadLeft, cState, eState, tp)) { return(GenericControls.DpadLeft); } else if (Mapping.getBoolMapping(GenericControls.DpadRight, cState, eState, tp)) { return(GenericControls.DpadRight); } else if (Mapping.getBoolMapping(GenericControls.Back, cState, eState, tp)) { return(GenericControls.Back); } else if (Mapping.getBoolMapping(GenericControls.Start, cState, eState, tp)) { return(GenericControls.Start); } else if (Mapping.getBoolMapping(GenericControls.Guide, cState, eState, tp)) { return(GenericControls.Guide); } else if (Mapping.getBoolMapping(GenericControls.LXPos, cState, eState, tp)) { return(GenericControls.LXPos); } else if (Mapping.getBoolMapping(GenericControls.LXNeg, cState, eState, tp)) { return(GenericControls.LXNeg); } else if (Mapping.getBoolMapping(GenericControls.LYPos, cState, eState, tp)) { return(GenericControls.LYPos); } else if (Mapping.getBoolMapping(GenericControls.LYNeg, cState, eState, tp)) { return(GenericControls.LYNeg); } else if (Mapping.getBoolMapping(GenericControls.RXPos, cState, eState, tp)) { return(GenericControls.RXPos); } else if (Mapping.getBoolMapping(GenericControls.RXNeg, cState, eState, tp)) { return(GenericControls.RXNeg); } else if (Mapping.getBoolMapping(GenericControls.RYPos, cState, eState, tp)) { return(GenericControls.RYPos); } else if (Mapping.getBoolMapping(GenericControls.RYNeg, cState, eState, tp)) { return(GenericControls.RYNeg); } else if (Mapping.getBoolMapping(GenericControls.TouchLeft, cState, eState, tp)) { return(GenericControls.TouchLeft); } else if (Mapping.getBoolMapping(GenericControls.TouchRight, cState, eState, tp)) { return(GenericControls.TouchRight); } else if (Mapping.getBoolMapping(GenericControls.TouchMulti, cState, eState, tp)) { return(GenericControls.TouchMulti); } else if (Mapping.getBoolMapping(GenericControls.TouchUpper, cState, eState, tp)) { return(GenericControls.TouchUpper); } } return(GenericControls.None); }
public string GetInputkeys(int ind) { ControllerState cState = CurrentState[ind]; EAll4StateExposed eState = ExposedState[ind]; Mouse tp = touchPad[ind]; if (controllers[ind] != null) { if (Mapping.getBoolMapping(GenericControls.A, cState, eState, tp)) { return("A"); } else if (Mapping.getBoolMapping(GenericControls.B, cState, eState, tp)) { return("B"); } else if (Mapping.getBoolMapping(GenericControls.Y, cState, eState, tp)) { return("Y"); } else if (Mapping.getBoolMapping(GenericControls.X, cState, eState, tp)) { return("X"); } else if (Mapping.getBoolMapping(GenericControls.LB, cState, eState, tp)) { return("LB"); } else if (Mapping.getBoolMapping(GenericControls.RB, cState, eState, tp)) { return("RB"); } else if (Mapping.getBoolMapping(GenericControls.LT, cState, eState, tp)) { return("LT"); } else if (Mapping.getBoolMapping(GenericControls.RT, cState, eState, tp)) { return("RT"); } else if (Mapping.getBoolMapping(GenericControls.LS, cState, eState, tp)) { return("LS"); } else if (Mapping.getBoolMapping(GenericControls.RS, cState, eState, tp)) { return("RS"); } else if (Mapping.getBoolMapping(GenericControls.DpadUp, cState, eState, tp)) { return("Up"); } else if (Mapping.getBoolMapping(GenericControls.DpadDown, cState, eState, tp)) { return("Down"); } else if (Mapping.getBoolMapping(GenericControls.DpadLeft, cState, eState, tp)) { return("Left"); } else if (Mapping.getBoolMapping(GenericControls.DpadRight, cState, eState, tp)) { return("Right"); } else if (Mapping.getBoolMapping(GenericControls.Back, cState, eState, tp)) { return("Back"); } else if (Mapping.getBoolMapping(GenericControls.Start, cState, eState, tp)) { return("Start"); } else if (Mapping.getBoolMapping(GenericControls.Guide, cState, eState, tp)) { return("Guide"); } else if (Mapping.getBoolMapping(GenericControls.LXPos, cState, eState, tp)) { return("LS Right"); } else if (Mapping.getBoolMapping(GenericControls.LXNeg, cState, eState, tp)) { return("LS Left"); } else if (Mapping.getBoolMapping(GenericControls.LYPos, cState, eState, tp)) { return("LS Down"); } else if (Mapping.getBoolMapping(GenericControls.LYNeg, cState, eState, tp)) { return("LS Up"); } else if (Mapping.getBoolMapping(GenericControls.RXPos, cState, eState, tp)) { return("RS Right"); } else if (Mapping.getBoolMapping(GenericControls.RXNeg, cState, eState, tp)) { return("RS Left"); } else if (Mapping.getBoolMapping(GenericControls.RYPos, cState, eState, tp)) { return("RS Down"); } else if (Mapping.getBoolMapping(GenericControls.RYNeg, cState, eState, tp)) { return("RS Up"); } else if (Mapping.getBoolMapping(GenericControls.TouchLeft, cState, eState, tp)) { return("Touch Left"); } else if (Mapping.getBoolMapping(GenericControls.TouchRight, cState, eState, tp)) { return("Touch Right"); } else if (Mapping.getBoolMapping(GenericControls.TouchMulti, cState, eState, tp)) { return("Touch Multi"); } else if (Mapping.getBoolMapping(GenericControls.TouchUpper, cState, eState, tp)) { return("Touch Upper"); } } return("nothing"); }
public void EasterTime(int ind) { ControllerState cState = CurrentState[ind]; EAll4StateExposed eState = ExposedState[ind]; Mouse tp = touchPad[ind]; bool pb = false; foreach (GenericControls dc in dcs) { if (Mapping.getBoolMapping(dc, cState, eState, tp)) { pb = true; break; } } int temp = eCode; //Looks like you found the easter egg code, since you're already cheating, //I scrambled the code for you :) if (pb && !buttonsdown[ind]) { if (cState.A && eCode == 9) { eCode++; } else if (!cState.A && eCode == 9) { eCode = 0; } else if (cState.DpadLeft && eCode == 6) { eCode++; } else if (!cState.DpadLeft && eCode == 6) { eCode = 0; } else if (cState.DpadRight && eCode == 7) { eCode++; } else if (!cState.DpadRight && eCode == 7) { eCode = 0; } else if (cState.DpadLeft && eCode == 4) { eCode++; } else if (!cState.DpadLeft && eCode == 4) { eCode = 0; } else if (cState.DpadDown && eCode == 2) { eCode++; } else if (!cState.DpadDown && eCode == 2) { eCode = 0; } else if (cState.DpadRight && eCode == 5) { eCode++; } else if (!cState.DpadRight && eCode == 5) { eCode = 0; } else if (cState.DpadUp && eCode == 1) { eCode++; } else if (!cState.DpadUp && eCode == 1) { eCode = 0; } else if (cState.DpadDown && eCode == 3) { eCode++; } else if (!cState.DpadDown && eCode == 3) { eCode = 0; } else if (cState.B && eCode == 8) { eCode++; } else if (!cState.B && eCode == 8) { eCode = 0; } if (cState.DpadUp && eCode == 0) { eCode++; } if (eCode == 10) { string message = "(!)"; sp.Play(); LogDebug(message, true); eCode = 0; } if (temp != eCode) { Console.WriteLine(eCode); } buttonsdown[ind] = true; } else if (!pb) { buttonsdown[ind] = false; } }
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 void getExposedState(EAll4StateExposed expState, ControllerState state) { cState.CopyTo(state); //expState.Accel = accel; //expState.Gyro = gyro; }
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); }
public static bool shiftMod(IEAll4Device ieAll4Device, int deviceNum, ControllerState cState, EAll4StateExposed eState, Mouse tp) { bool shift; switch (Global.ShiftModifier[deviceNum]) { case 1: shift = Mapping.getBoolMapping(GenericControls.A, cState, eState, tp); break; case 2: shift = Mapping.getBoolMapping(GenericControls.B, cState, eState, tp); break; case 3: shift = Mapping.getBoolMapping(GenericControls.X, cState, eState, tp); break; case 4: shift = Mapping.getBoolMapping(GenericControls.Y, cState, eState, tp); break; case 5: shift = Mapping.getBoolMapping(GenericControls.Start, cState, eState, tp); break; case 6: shift = Mapping.getBoolMapping(GenericControls.Back, cState, eState, tp); break; case 7: shift = Mapping.getBoolMapping(GenericControls.DpadUp, cState, eState, tp); break; case 8: shift = Mapping.getBoolMapping(GenericControls.DpadDown, cState, eState, tp); break; case 9: shift = Mapping.getBoolMapping(GenericControls.DpadLeft, cState, eState, tp); break; case 10: shift = Mapping.getBoolMapping(GenericControls.DpadRight, cState, eState, tp); break; case 11: shift = Mapping.getBoolMapping(GenericControls.Guide, cState, eState, tp); break; case 12: shift = Mapping.getBoolMapping(GenericControls.LB, cState, eState, tp); break; case 13: shift = Mapping.getBoolMapping(GenericControls.RB, cState, eState, tp); break; case 14: shift = Mapping.getBoolMapping(GenericControls.LT, cState, eState, tp); break; case 15: shift = Mapping.getBoolMapping(GenericControls.RT, cState, eState, tp); break; case 16: shift = Mapping.getBoolMapping(GenericControls.LS, cState, eState, tp); break; case 17: shift = Mapping.getBoolMapping(GenericControls.RS, cState, eState, tp); break; case 18: shift = Mapping.getBoolMapping(GenericControls.TouchLeft, cState, eState, tp); break; case 19: shift = Mapping.getBoolMapping(GenericControls.TouchUpper, cState, eState, tp); break; case 20: shift = Mapping.getBoolMapping(GenericControls.TouchMulti, cState, eState, tp); break; case 21: shift = Mapping.getBoolMapping(GenericControls.TouchRight, cState, eState, tp); break; case 22: shift = Mapping.getBoolMapping(GenericControls.GyroZNeg, cState, eState, tp); break; case 23: shift = Mapping.getBoolMapping(GenericControls.GyroZPos, cState, eState, tp); break; case 24: shift = Mapping.getBoolMapping(GenericControls.GyroXPos, cState, eState, tp); break; case 25: shift = Mapping.getBoolMapping(GenericControls.GyroXNeg, cState, eState, tp); break; case 26: shift = ieAll4Device.getCurrentState().Touch1; break; default: shift = false; break; } return(shift); }
public void getExposedState(EAll4StateExposed expState, ControllerState state) { cState.CopyTo(state); }