public void PopulateFieldMapping(DS4State cState, DS4StateExposed exposeState, Mouse tp, bool priorMouse = false) { unchecked { AxisDirs[(int)DS4Controls.LXNeg] = cState.LX; AxisDirs[(int)DS4Controls.LXPos] = cState.LX; AxisDirs[(int)DS4Controls.LYNeg] = cState.LY; AxisDirs[(int)DS4Controls.LYPos] = cState.LY; AxisDirs[(int)DS4Controls.RXNeg] = cState.RX; AxisDirs[(int)DS4Controls.RXPos] = cState.RX; AxisDirs[(int)DS4Controls.RYNeg] = cState.RY; AxisDirs[(int)DS4Controls.RYPos] = cState.RY; Triggers[(int)DS4Controls.L2] = cState.L2; Triggers[(int)DS4Controls.R2] = cState.R2; Buttons[(int)DS4Controls.L1] = cState.L1; Buttons[(int)DS4Controls.L3] = cState.L3; Buttons[(int)DS4Controls.R1] = cState.R1; Buttons[(int)DS4Controls.R3] = cState.R3; Buttons[(int)DS4Controls.Cross] = cState.Cross; Buttons[(int)DS4Controls.Triangle] = cState.Triangle; Buttons[(int)DS4Controls.Circle] = cState.Circle; Buttons[(int)DS4Controls.Square] = cState.Square; Buttons[(int)DS4Controls.PS] = cState.PS; Buttons[(int)DS4Controls.Options] = cState.Options; Buttons[(int)DS4Controls.Share] = cState.Share; Buttons[(int)DS4Controls.DpadUp] = cState.DpadUp; Buttons[(int)DS4Controls.DpadRight] = cState.DpadRight; Buttons[(int)DS4Controls.DpadDown] = cState.DpadDown; Buttons[(int)DS4Controls.DpadLeft] = cState.DpadLeft; Buttons[(int)DS4Controls.TouchLeft] = tp != null ? (!priorMouse ? tp.leftDown : tp.priorLeftDown) : false; Buttons[(int)DS4Controls.TouchRight] = tp != null ? (!priorMouse ? tp.rightDown : tp.priorRightDown) : false; Buttons[(int)DS4Controls.TouchUpper] = tp != null ? (!priorMouse ? tp.upperDown : tp.priorUpperDown) : false; Buttons[(int)DS4Controls.TouchMulti] = tp != null ? (!priorMouse ? tp.multiDown : tp.priorMultiDown) : false; int sixAxisX = -exposeState.OutputAccelX; gryodirs[(int)DS4Controls.GyroXPos] = sixAxisX > 0 ? sixAxisX : 0; gryodirs[(int)DS4Controls.GyroXNeg] = sixAxisX < 0 ? sixAxisX : 0; int sixAxisZ = exposeState.OutputAccelZ; gryodirs[(int)DS4Controls.GyroZPos] = sixAxisZ > 0 ? sixAxisZ : 0; gryodirs[(int)DS4Controls.GyroZNeg] = sixAxisZ < 0 ? sixAxisZ : 0; swipedirs[(int)DS4Controls.SwipeLeft] = tp != null ? (!priorMouse ? tp.swipeLeftB : tp.priorSwipeLeftB) : (byte)0; swipedirs[(int)DS4Controls.SwipeRight] = tp != null ? (!priorMouse ? tp.swipeRightB : tp.priorSwipeRightB) : (byte)0; swipedirs[(int)DS4Controls.SwipeUp] = tp != null ? (!priorMouse ? tp.swipeUpB : tp.priorSwipeUpB) : (byte)0; swipedirs[(int)DS4Controls.SwipeDown] = tp != null ? (!priorMouse ? tp.swipeDownB : tp.priorSwipeDownB) : (byte)0; swipedirbools[(int)DS4Controls.SwipeLeft] = tp != null ? (!priorMouse ? tp.swipeLeft : tp.priorSwipeLeft) : false; swipedirbools[(int)DS4Controls.SwipeRight] = tp != null ? (!priorMouse ? tp.swipeRight : tp.priorSwipeRight) : false; swipedirbools[(int)DS4Controls.SwipeUp] = tp != null ? (!priorMouse ? tp.swipeUp : tp.priorSwipeUp) : false; swipedirbools[(int)DS4Controls.SwipeDown] = tp != null ? (!priorMouse ? tp.swipeDown : tp.priorSwipeDown) : false; touchButton = cState.TouchButton; } }
public DS4StateFieldMapping(DS4State cState, DS4StateExposed exposeState, Mouse tp, bool priorMouse = false) { axisdirs[(int)DS4Controls.LXNeg] = cState.LX; axisdirs[(int)DS4Controls.LXPos] = cState.LX; axisdirs[(int)DS4Controls.LYNeg] = cState.LY; axisdirs[(int)DS4Controls.LYPos] = cState.LY; axisdirs[(int)DS4Controls.RXNeg] = cState.RX; axisdirs[(int)DS4Controls.RXPos] = cState.RX; axisdirs[(int)DS4Controls.RYNeg] = cState.RY; axisdirs[(int)DS4Controls.RYPos] = cState.RY; triggers[(int)DS4Controls.L2] = cState.L2; triggers[(int)DS4Controls.R2] = cState.R2; buttons[(int)DS4Controls.L1] = cState.L1; buttons[(int)DS4Controls.L3] = cState.L3; buttons[(int)DS4Controls.R1] = cState.R1; buttons[(int)DS4Controls.R3] = cState.R3; buttons[(int)DS4Controls.Cross] = cState.Cross; buttons[(int)DS4Controls.Triangle] = cState.Triangle; buttons[(int)DS4Controls.Circle] = cState.Circle; buttons[(int)DS4Controls.Square] = cState.Square; buttons[(int)DS4Controls.PS] = cState.PS; buttons[(int)DS4Controls.Options] = cState.Options; buttons[(int)DS4Controls.Share] = cState.Share; buttons[(int)DS4Controls.DpadUp] = cState.DpadUp; buttons[(int)DS4Controls.DpadRight] = cState.DpadRight; buttons[(int)DS4Controls.DpadDown] = cState.DpadDown; buttons[(int)DS4Controls.DpadLeft] = cState.DpadLeft; buttons[(int)DS4Controls.TouchLeft] = tp != null ? (!priorMouse ? tp.leftDown : tp.priorLeftDown) : false; buttons[(int)DS4Controls.TouchRight] = tp != null ? (!priorMouse ? tp.rightDown : tp.priorRightDown) : false; buttons[(int)DS4Controls.TouchUpper] = tp != null ? (!priorMouse ? tp.upperDown : tp.priorUpperDown) : false; buttons[(int)DS4Controls.TouchMulti] = tp != null ? (!priorMouse ? tp.multiDown : tp.priorMultiDown) : false; int gyroX = exposeState.getGyroX(); gryodirs[(int)DS4Controls.GyroXPos] = gyroX > 0 ? gyroX : 0; gryodirs[(int)DS4Controls.GyroXNeg] = gyroX < 0 ? gyroX : 0; int gyroZ = exposeState.getGyroZ(); gryodirs[(int)DS4Controls.GyroZPos] = gyroZ > 0 ? gyroZ : 0; gryodirs[(int)DS4Controls.GyroZNeg] = gyroZ < 0 ? gyroZ : 0; swipedirs[(int)DS4Controls.SwipeLeft] = tp != null ? (!priorMouse ? tp.swipeLeftB : tp.priorSwipeLeftB): (byte)0; swipedirs[(int)DS4Controls.SwipeRight] = tp != null ? (!priorMouse ? tp.swipeRightB : tp.priorSwipeRightB) : (byte)0; swipedirs[(int)DS4Controls.SwipeUp] = tp != null ? (!priorMouse ? tp.swipeUpB : tp.priorSwipeUpB) : (byte)0; swipedirs[(int)DS4Controls.SwipeDown] = tp != null ? (!priorMouse ? tp.swipeDownB : tp.priorSwipeDownB) : (byte)0; swipedirbools[(int)DS4Controls.SwipeLeft] = tp != null ? (!priorMouse ? tp.swipeLeft : tp.priorSwipeLeft) : false; swipedirbools[(int)DS4Controls.SwipeRight] = tp != null ? (!priorMouse ? tp.swipeRight : tp.priorSwipeRight) : false; swipedirbools[(int)DS4Controls.SwipeUp] = tp != null ? (!priorMouse ? tp.swipeUp : tp.priorSwipeUp) : false; swipedirbools[(int)DS4Controls.SwipeDown] = tp != null ? (!priorMouse ? tp.swipeDown : tp.priorSwipeDown) : false; }
public Control() { x360Bus = new X360Device(); for (int i = 0; i < DS4Controllers.Length; i++) { processingData[i] = new X360Data(); MappedState[i] = new DS4State(); CurrentState[i] = new DS4State(); PreviousState[i] = new DS4State(); ExposedState[i] = new DS4StateExposed(CurrentState[i]); } }
public ControlService() { //sp.Stream = Diagnostics_Tool.Properties.Resources.EE; x360Bus = new X360Device(); AddtoDS4List(); for (int i = 0; i < DS4Controllers.Length; i++) { processingData[i] = new X360Data(); MappedState[i] = new DS4State(); CurrentState[i] = new DS4State(); PreviousState[i] = new DS4State(); ExposedState[i] = new DS4StateExposed(CurrentState[i]); } }
public DS4StateFieldMapping(DS4State cState, DS4StateExposed exposeState, Mouse tp, bool priorMouse = false) { PopulateFieldMapping(cState, exposeState, tp, priorMouse); }
public DS4Controls GetInputkeysDS4(int ind) { DS4State cState = CurrentState[ind]; DS4StateExposed eState = ExposedState[ind]; Mouse tp = touchPad[ind]; if (DS4Controllers[ind] != null) { if (Mapping.getBoolMapping(DS4Controls.Cross, cState, eState, tp)) { return(DS4Controls.Cross); } else if (Mapping.getBoolMapping(DS4Controls.Circle, cState, eState, tp)) { return(DS4Controls.Circle); } else if (Mapping.getBoolMapping(DS4Controls.Triangle, cState, eState, tp)) { return(DS4Controls.Triangle); } else if (Mapping.getBoolMapping(DS4Controls.Square, cState, eState, tp)) { return(DS4Controls.Square); } else if (Mapping.getBoolMapping(DS4Controls.L1, cState, eState, tp)) { return(DS4Controls.L1); } else if (Mapping.getBoolMapping(DS4Controls.R1, cState, eState, tp)) { return(DS4Controls.R1); } else if (Mapping.getBoolMapping(DS4Controls.L2, cState, eState, tp)) { return(DS4Controls.L2); } else if (Mapping.getBoolMapping(DS4Controls.R2, cState, eState, tp)) { return(DS4Controls.R2); } else if (Mapping.getBoolMapping(DS4Controls.L3, cState, eState, tp)) { return(DS4Controls.L3); } else if (Mapping.getBoolMapping(DS4Controls.R3, cState, eState, tp)) { return(DS4Controls.R3); } else if (Mapping.getBoolMapping(DS4Controls.DpadUp, cState, eState, tp)) { return(DS4Controls.DpadUp); } else if (Mapping.getBoolMapping(DS4Controls.DpadDown, cState, eState, tp)) { return(DS4Controls.DpadDown); } else if (Mapping.getBoolMapping(DS4Controls.DpadLeft, cState, eState, tp)) { return(DS4Controls.DpadLeft); } else if (Mapping.getBoolMapping(DS4Controls.DpadRight, cState, eState, tp)) { return(DS4Controls.DpadRight); } else if (Mapping.getBoolMapping(DS4Controls.Share, cState, eState, tp)) { return(DS4Controls.Share); } else if (Mapping.getBoolMapping(DS4Controls.Options, cState, eState, tp)) { return(DS4Controls.Options); } else if (Mapping.getBoolMapping(DS4Controls.PS, cState, eState, tp)) { return(DS4Controls.PS); } else if (Mapping.getBoolMapping(DS4Controls.LXPos, cState, eState, tp)) { return(DS4Controls.LXPos); } else if (Mapping.getBoolMapping(DS4Controls.LXNeg, cState, eState, tp)) { return(DS4Controls.LXNeg); } else if (Mapping.getBoolMapping(DS4Controls.LYPos, cState, eState, tp)) { return(DS4Controls.LYPos); } else if (Mapping.getBoolMapping(DS4Controls.LYNeg, cState, eState, tp)) { return(DS4Controls.LYNeg); } else if (Mapping.getBoolMapping(DS4Controls.RXPos, cState, eState, tp)) { return(DS4Controls.RXPos); } else if (Mapping.getBoolMapping(DS4Controls.RXNeg, cState, eState, tp)) { return(DS4Controls.RXNeg); } else if (Mapping.getBoolMapping(DS4Controls.RYPos, cState, eState, tp)) { return(DS4Controls.RYPos); } else if (Mapping.getBoolMapping(DS4Controls.RYNeg, cState, eState, tp)) { return(DS4Controls.RYNeg); } else if (Mapping.getBoolMapping(DS4Controls.TouchLeft, cState, eState, tp)) { return(DS4Controls.TouchLeft); } else if (Mapping.getBoolMapping(DS4Controls.TouchRight, cState, eState, tp)) { return(DS4Controls.TouchRight); } else if (Mapping.getBoolMapping(DS4Controls.TouchMulti, cState, eState, tp)) { return(DS4Controls.TouchMulti); } else if (Mapping.getBoolMapping(DS4Controls.TouchUpper, cState, eState, tp)) { return(DS4Controls.TouchUpper); } } return(DS4Controls.None); }
public string GetInputkeys(int ind) { DS4State cState = CurrentState[ind]; DS4StateExposed eState = ExposedState[ind]; Mouse tp = touchPad[ind]; if (DS4Controllers[ind] != null) { if (Mapping.getBoolMapping(DS4Controls.Cross, cState, eState, tp)) { return("Cross"); } else if (Mapping.getBoolMapping(DS4Controls.Circle, cState, eState, tp)) { return("Circle"); } else if (Mapping.getBoolMapping(DS4Controls.Triangle, cState, eState, tp)) { return("Triangle"); } else if (Mapping.getBoolMapping(DS4Controls.Square, cState, eState, tp)) { return("Square"); } else if (Mapping.getBoolMapping(DS4Controls.L1, cState, eState, tp)) { return("L1"); } else if (Mapping.getBoolMapping(DS4Controls.R1, cState, eState, tp)) { return("R1"); } else if (Mapping.getBoolMapping(DS4Controls.L2, cState, eState, tp)) { return("L2"); } else if (Mapping.getBoolMapping(DS4Controls.R2, cState, eState, tp)) { return("R2"); } else if (Mapping.getBoolMapping(DS4Controls.L3, cState, eState, tp)) { return("L3"); } else if (Mapping.getBoolMapping(DS4Controls.R3, cState, eState, tp)) { return("R3"); } else if (Mapping.getBoolMapping(DS4Controls.DpadUp, cState, eState, tp)) { return("Up"); } else if (Mapping.getBoolMapping(DS4Controls.DpadDown, cState, eState, tp)) { return("Down"); } else if (Mapping.getBoolMapping(DS4Controls.DpadLeft, cState, eState, tp)) { return("Left"); } else if (Mapping.getBoolMapping(DS4Controls.DpadRight, cState, eState, tp)) { return("Right"); } else if (Mapping.getBoolMapping(DS4Controls.Share, cState, eState, tp)) { return("Share"); } else if (Mapping.getBoolMapping(DS4Controls.Options, cState, eState, tp)) { return("Options"); } else if (Mapping.getBoolMapping(DS4Controls.PS, cState, eState, tp)) { return("PS"); } else if (Mapping.getBoolMapping(DS4Controls.LXPos, cState, eState, tp)) { return("LS Right"); } else if (Mapping.getBoolMapping(DS4Controls.LXNeg, cState, eState, tp)) { return("LS Left"); } else if (Mapping.getBoolMapping(DS4Controls.LYPos, cState, eState, tp)) { return("LS Down"); } else if (Mapping.getBoolMapping(DS4Controls.LYNeg, cState, eState, tp)) { return("LS Up"); } else if (Mapping.getBoolMapping(DS4Controls.RXPos, cState, eState, tp)) { return("RS Right"); } else if (Mapping.getBoolMapping(DS4Controls.RXNeg, cState, eState, tp)) { return("RS Left"); } else if (Mapping.getBoolMapping(DS4Controls.RYPos, cState, eState, tp)) { return("RS Down"); } else if (Mapping.getBoolMapping(DS4Controls.RYNeg, cState, eState, tp)) { return("RS Up"); } else if (Mapping.getBoolMapping(DS4Controls.TouchLeft, cState, eState, tp)) { return("Touch Left"); } else if (Mapping.getBoolMapping(DS4Controls.TouchRight, cState, eState, tp)) { return("Touch Right"); } else if (Mapping.getBoolMapping(DS4Controls.TouchMulti, cState, eState, tp)) { return("Touch Multi"); } else if (Mapping.getBoolMapping(DS4Controls.TouchUpper, cState, eState, tp)) { return("Touch Upper"); } } return("nothing"); }
private void DoExtras(int ind) { DS4State cState = CurrentState[ind]; DS4StateExposed eState = ExposedState[ind]; Mouse tp = touchPad[ind]; DS4Controls helddown = DS4Controls.None; foreach (KeyValuePair <DS4Controls, string> p in Global.getCustomExtras(ind)) { if (Mapping.getBoolMapping(p.Key, cState, eState, tp)) { helddown = p.Key; break; } } if (helddown != DS4Controls.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) { DS4Color color = new DS4Color { red = (byte)extras[3], green = (byte)extras[4], blue = (byte)extras[5] }; DS4LightBar.forcedColor[ind] = color; DS4LightBar.forcedFlash[ind] = (byte)extras[6]; DS4LightBar.forcelight[ind] = true; } if (extras[7] == 1) { if (oldmouse[ind] == -1) { oldmouse[ind] = Global.getButtonMouseSensitivity(ind); } Global.setButtonMouseSensitivity(ind, extras[8]); } } catch { } } else if (held[ind]) { DS4LightBar.forcelight[ind] = false; DS4LightBar.forcedFlash[ind] = 0; //Console.WriteLine(p.Key + " is done"); Global.setButtonMouseSensitivity(ind, oldmouse[ind]); oldmouse[ind] = -1; setRumble(0, 0, ind); held[ind] = false; } }
/* private void DoExtras(int ind) * { * DS4State cState = CurrentState[ind]; * DS4StateExposed eState = ExposedState[ind]; * Mouse tp = touchPad[ind]; * DS4Controls helddown = DS4Controls.None; * foreach (KeyValuePair<DS4Controls, string> p in getCustomExtras(ind)) * { * if (Mapping.getBoolMapping(ind, p.Key, cState, eState, tp)) * { * helddown = p.Key; * break; * } * } * if (helddown != DS4Controls.None) * { * string p = 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) * { * DS4Color color = new DS4Color { red = (byte)extras[3], green = (byte)extras[4], blue = (byte)extras[5] }; * DS4LightBar.forcedColor[ind] = color; * DS4LightBar.forcedFlash[ind] = (byte)extras[6]; * DS4LightBar.forcelight[ind] = true; * } * if (extras[7] == 1) * { * if (oldmouse[ind] == -1) * oldmouse[ind] = ButtonMouseSensitivity[ind]; * ButtonMouseSensitivity[ind] = extras[8]; * } * } * catch { } * } * else if (held[ind]) * { * DS4LightBar.forcelight[ind] = false; * DS4LightBar.forcedFlash[ind] = 0; * ButtonMouseSensitivity[ind] = oldmouse[ind]; * oldmouse[ind] = -1; * setRumble(0, 0, ind); * held[ind] = false; * } * }*/ public void EasterTime(int ind) { DS4State cState = CurrentState[ind]; DS4StateExposed eState = ExposedState[ind]; Mouse tp = touchPad[ind]; bool pb = false; foreach (DS4Controls dc in dcs) { if (Mapping.getBoolMapping(ind, 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.Cross && eCode == 9) { eCode++; } else if (!cState.Cross && 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.Circle && eCode == 8) { eCode++; } else if (!cState.Circle && 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; } }
public static void updateLightBar(DS4Device device, int deviceNum, DS4State cState, DS4StateExposed eState) { DS4Color color; if (!defualtLight) { if (Global.getShiftColorOn(deviceNum) && Global.getShiftModifier(deviceNum) > 0 && shiftMod(device, deviceNum, cState, eState)) { color = Global.loadShiftColor(deviceNum); } else { if (Global.getRainbow(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 (device.Charging) { counters[deviceNum] -= 1.5 * 3 / Global.getRainbow(deviceNum); } else { counters[deviceNum] += 1.5 * 3 / Global.getRainbow(deviceNum); } } if (counters[deviceNum] < 0) { counters[deviceNum] = 180000; } if (Global.getLedAsBatteryIndicator(deviceNum)) { color = HuetoRGB((float)counters[deviceNum] % 360, (byte)(2.55 * device.Battery)); } else { color = HuetoRGB((float)counters[deviceNum] % 360, 255); } } else if (Global.getLedAsBatteryIndicator(deviceNum)) { //if (device.Charging == false || device.Battery >= 100) // when charged, don't show the charging animation { DS4Color fullColor = new DS4Color { red = Global.loadColor(deviceNum).red, green = Global.loadColor(deviceNum).green, blue = Global.loadColor(deviceNum).blue }; color = Global.loadLowColor(deviceNum); DS4Color lowColor = new DS4Color { red = color.red, green = color.green, blue = color.blue }; color = Global.getTransitionedColor(lowColor, fullColor, (uint)device.Battery); } } else { color = Global.loadColor(deviceNum); } if (device.Battery <= Global.getFlashAt(deviceNum) && !defualtLight && !device.Charging) { if (!(Global.loadFlashColor(deviceNum).red == 0 && Global.loadFlashColor(deviceNum).green == 0 && Global.loadFlashColor(deviceNum).blue == 0)) { color = Global.loadFlashColor(deviceNum); } } if (Global.getIdleDisconnectTimeout(deviceNum) > 0 && Global.getLedAsBatteryIndicator(deviceNum) && (!device.Charging || device.Battery >= 100)) {//Fade lightbar by idle time TimeSpan timeratio = new TimeSpan(DateTime.UtcNow.Ticks - device.lastActive.Ticks); double botratio = timeratio.TotalMilliseconds; double topratio = TimeSpan.FromSeconds(Global.getIdleDisconnectTimeout(deviceNum)).TotalMilliseconds; double ratio = ((botratio / topratio) * 100); if (ratio >= 50 && ratio <= 100) { color = Global.getTransitionedColor(color, new DS4Color { red = 0, green = 0, blue = 0 }, (uint)((ratio - 50) * 2)); } else if (ratio >= 100) { color = Global.getTransitionedColor(color, new DS4Color { red = 0, green = 0, blue = 0 }, 100); } } if (device.Charging && device.Battery < 100) { switch (Global.getChargingType(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 DS4Color { red = 0, green = 0, blue = 0 }, fadetimer[deviceNum]); break; case 2: counters[deviceNum] += .167; color = HuetoRGB((float)counters[deviceNum] % 360, 255); break; case 3: color = Global.loadChargingColor(deviceNum); break; default: break; } } } } else if (shuttingdown) { color = new DS4Color { red = 0, green = 0, blue = 0 } } ; else { if (device.ConnectionType == ConnectionType.BT) { color = new DS4Color { red = 32, green = 64, blue = 64 } } ; else { color = new DS4Color { red = 0, green = 0, blue = 0 } }; } bool distanceprofile = (Global.getAProfile(deviceNum).ToLower().Contains("distance") || Global.tempprofilename[deviceNum].ToLower().Contains("distance")); if (distanceprofile && !defualtLight) { //Thing I did for Distance float rumble = device.LeftHeavySlowRumble / 2.55f; byte max = Math.Max(color.red, Math.Max(color.green, color.blue)); if (device.LeftHeavySlowRumble > 100) { color = getTransitionedColor(new DS4Color { green = max, red = max }, rumble, new DS4Color { red = 255 }); } else { color = getTransitionedColor(color, device.LeftHeavySlowRumble, getTransitionedColor(new DS4Color { green = max, red = max }, 39.6078f, new DS4Color { red = 255 })); } } DS4HapticState haptics = new DS4HapticState { LightBarColor = color }; if (haptics.IsLightBarSet()) { if (device.Battery <= Global.getFlashAt(deviceNum) && !defualtLight && !device.Charging) { int level = device.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 && device.LeftHeavySlowRumble > 155) //also part of Distance { haptics.LightBarFlashDurationOff = haptics.LightBarFlashDurationOn = (byte)((-device.LeftHeavySlowRumble + 265)); haptics.LightBarExplicitlyOff = true; } else { //haptics.LightBarFlashDurationOff = haptics.LightBarFlashDurationOn = 1; haptics.LightBarFlashDurationOff = haptics.LightBarFlashDurationOn = 0; haptics.LightBarExplicitlyOff = true; } } else { haptics.LightBarExplicitlyOff = true; } if (device.LightBarOnDuration != haptics.LightBarFlashDurationOn && device.LightBarOnDuration != 1 && haptics.LightBarFlashDurationOn == 0) { haptics.LightBarFlashDurationOff = haptics.LightBarFlashDurationOn = 1; } if (device.LightBarOnDuration == 1) //helps better reset the color { System.Threading.Thread.Sleep(5); } device.pushHapticState(haptics); }
public static bool shiftMod(DS4Device device, int deviceNum, DS4State cState, DS4StateExposed eState) { bool shift; switch (Global.getShiftModifier(deviceNum)) { case 1: shift = Mapping.getBoolMapping(DS4Controls.Cross, cState, eState); break; case 2: shift = Mapping.getBoolMapping(DS4Controls.Circle, cState, eState); break; case 3: shift = Mapping.getBoolMapping(DS4Controls.Square, cState, eState); break; case 4: shift = Mapping.getBoolMapping(DS4Controls.Triangle, cState, eState); break; case 5: shift = Mapping.getBoolMapping(DS4Controls.Options, cState, eState); break; case 6: shift = Mapping.getBoolMapping(DS4Controls.Share, cState, eState); break; case 7: shift = Mapping.getBoolMapping(DS4Controls.DpadUp, cState, eState); break; case 8: shift = Mapping.getBoolMapping(DS4Controls.DpadDown, cState, eState); break; case 9: shift = Mapping.getBoolMapping(DS4Controls.DpadLeft, cState, eState); break; case 10: shift = Mapping.getBoolMapping(DS4Controls.DpadRight, cState, eState); break; case 11: shift = Mapping.getBoolMapping(DS4Controls.PS, cState, eState); break; case 12: shift = Mapping.getBoolMapping(DS4Controls.L1, cState, eState); break; case 13: shift = Mapping.getBoolMapping(DS4Controls.R1, cState, eState); break; case 14: shift = Mapping.getBoolMapping(DS4Controls.L2, cState, eState); break; case 15: shift = Mapping.getBoolMapping(DS4Controls.R2, cState, eState); break; case 16: shift = Mapping.getBoolMapping(DS4Controls.L3, cState, eState); break; case 17: shift = Mapping.getBoolMapping(DS4Controls.R3, cState, eState); break; case 18: shift = Mapping.getBoolMapping(DS4Controls.TouchLeft, cState, eState); break; case 19: shift = Mapping.getBoolMapping(DS4Controls.TouchUpper, cState, eState); break; case 20: shift = Mapping.getBoolMapping(DS4Controls.TouchMulti, cState, eState); break; case 21: shift = Mapping.getBoolMapping(DS4Controls.TouchRight, cState, eState); break; case 22: shift = Mapping.getBoolMapping(DS4Controls.GyroZNeg, cState, eState); break; case 23: shift = Mapping.getBoolMapping(DS4Controls.GyroZPos, cState, eState); break; case 24: shift = Mapping.getBoolMapping(DS4Controls.GyroXPos, cState, eState); break; case 25: shift = Mapping.getBoolMapping(DS4Controls.GyroXNeg, cState, eState); break; case 26: shift = device.getCurrentState().Touch1; break; default: shift = false; break; } return(shift); }
public void PopulateFieldMapping(DS4State cState, DS4StateExposed exposeState, Mouse tp, bool priorMouse = false) { unchecked { axisdirs[(int)DS4Controls.LXNeg] = cState.LX; axisdirs[(int)DS4Controls.LXPos] = cState.LX; axisdirs[(int)DS4Controls.LYNeg] = cState.LY; axisdirs[(int)DS4Controls.LYPos] = cState.LY; triggers[(int)DS4Controls.LSOuter] = cState.OutputLSOuter; axisdirs[(int)DS4Controls.RXNeg] = cState.RX; axisdirs[(int)DS4Controls.RXPos] = cState.RX; axisdirs[(int)DS4Controls.RYNeg] = cState.RY; axisdirs[(int)DS4Controls.RYPos] = cState.RY; triggers[(int)DS4Controls.RSOuter] = cState.OutputRSOuter; triggers[(int)DS4Controls.L2] = cState.L2; triggers[(int)DS4Controls.R2] = cState.R2; buttons[(int)DS4Controls.L1] = cState.L1; buttons[(int)DS4Controls.L2FullPull] = cState.L2 == 255; buttons[(int)DS4Controls.L3] = cState.L3; buttons[(int)DS4Controls.R1] = cState.R1; buttons[(int)DS4Controls.R2FullPull] = cState.R2 == 255; buttons[(int)DS4Controls.R3] = cState.R3; buttons[(int)DS4Controls.Cross] = cState.Cross; buttons[(int)DS4Controls.Triangle] = cState.Triangle; buttons[(int)DS4Controls.Circle] = cState.Circle; buttons[(int)DS4Controls.Square] = cState.Square; buttons[(int)DS4Controls.PS] = cState.PS; buttons[(int)DS4Controls.Options] = cState.Options; buttons[(int)DS4Controls.Share] = cState.Share; buttons[(int)DS4Controls.Mute] = cState.Mute; buttons[(int)DS4Controls.Capture] = cState.Capture; buttons[(int)DS4Controls.SideL] = cState.SideL; buttons[(int)DS4Controls.SideR] = cState.SideR; buttons[(int)DS4Controls.DpadUp] = cState.DpadUp; buttons[(int)DS4Controls.DpadRight] = cState.DpadRight; buttons[(int)DS4Controls.DpadDown] = cState.DpadDown; buttons[(int)DS4Controls.DpadLeft] = cState.DpadLeft; buttons[(int)DS4Controls.TouchLeft] = tp != null ? (!priorMouse ? tp.leftDown : tp.priorLeftDown) : false; buttons[(int)DS4Controls.TouchRight] = tp != null ? (!priorMouse ? tp.rightDown : tp.priorRightDown) : false; buttons[(int)DS4Controls.TouchUpper] = tp != null ? (!priorMouse ? tp.upperDown : tp.priorUpperDown) : false; buttons[(int)DS4Controls.TouchMulti] = tp != null ? (!priorMouse ? tp.multiDown : tp.priorMultiDown) : false; int sixAxisX = -exposeState.getOutputAccelX(); gryodirs[(int)DS4Controls.GyroXPos] = sixAxisX > 0 ? sixAxisX : 0; gryodirs[(int)DS4Controls.GyroXNeg] = sixAxisX < 0 ? sixAxisX : 0; int sixAxisZ = exposeState.getOutputAccelZ(); gryodirs[(int)DS4Controls.GyroZPos] = sixAxisZ > 0 ? sixAxisZ : 0; gryodirs[(int)DS4Controls.GyroZNeg] = sixAxisZ < 0 ? sixAxisZ : 0; swipedirs[(int)DS4Controls.SwipeLeft] = tp != null ? (!priorMouse ? tp.swipeLeftB : tp.priorSwipeLeftB) : (byte)0; swipedirs[(int)DS4Controls.SwipeRight] = tp != null ? (!priorMouse ? tp.swipeRightB : tp.priorSwipeRightB) : (byte)0; swipedirs[(int)DS4Controls.SwipeUp] = tp != null ? (!priorMouse ? tp.swipeUpB : tp.priorSwipeUpB) : (byte)0; swipedirs[(int)DS4Controls.SwipeDown] = tp != null ? (!priorMouse ? tp.swipeDownB : tp.priorSwipeDownB) : (byte)0; swipedirbools[(int)DS4Controls.SwipeLeft] = tp != null ? (!priorMouse ? tp.swipeLeft : tp.priorSwipeLeft) : false; swipedirbools[(int)DS4Controls.SwipeRight] = tp != null ? (!priorMouse ? tp.swipeRight : tp.priorSwipeRight) : false; swipedirbools[(int)DS4Controls.SwipeUp] = tp != null ? (!priorMouse ? tp.swipeUp : tp.priorSwipeUp) : false; swipedirbools[(int)DS4Controls.SwipeDown] = tp != null ? (!priorMouse ? tp.swipeDown : tp.priorSwipeDown) : false; buttons[(int)DS4Controls.GyroSwipeLeft] = tp != null ? tp.gyroSwipe.swipeLeft : false; buttons[(int)DS4Controls.GyroSwipeRight] = tp != null ? tp.gyroSwipe.swipeRight : false; buttons[(int)DS4Controls.GyroSwipeUp] = tp != null ? tp.gyroSwipe.swipeUp : false; buttons[(int)DS4Controls.GyroSwipeDown] = tp != null ? tp.gyroSwipe.swipeDown : false; touchButton = cState.TouchButton; outputTouchButton = cState.OutputTouchButton; } }