Ejemplo n.º 1
0
 private void advColorDialog_OnUpdateColor(object sender, EventArgs e)
 {
     if (sender is Color && (device < 4))
     {
         Color color = (Color)sender;
         DS4Color dcolor = new DS4Color { red = color.R, green = color.G, blue = color.B };
         DS4LightBar.forcedColor[device] = dcolor;
         DS4LightBar.forcedFlash[device] = 0;
         DS4LightBar.forcelight[device] = true;
     }
 }
Ejemplo n.º 2
0
 private void advColorDialog_OnUpdateColor(object sender, EventArgs e)
 {
     if (sender is Color && (Program.RootHub.DS4Controllers[0] != null))
     {
         Color color = (Color)sender;
         DS4Color dcolor = new DS4Color { red = color.R, green = color.G, blue = color.B };
         DS4LightBar.forcedColor[0] = dcolor;
         DS4LightBar.forcedFlash[0] = 0;
         DS4LightBar.forcelight[0] = true;
     }
 }
Ejemplo n.º 3
0
 private void advColorDialog_OnUpdateColor(object sender, EventArgs e)
 {
     if (sender is Color)
     {
         Color color = (Color)sender;
         DS4Color dcolor = new DS4Color(color);
         Console.WriteLine(dcolor);
         DS4LightBar.forcedColor[currentCustomLed] = dcolor;
         DS4LightBar.forcedFlash[currentCustomLed] = 0;
         DS4LightBar.forcelight[currentCustomLed] = true;
     }
 }
Ejemplo n.º 4
0
		public static void MapCustom(int device, DS4State cState, DS4State MappedState, DS4StateExposed eState, Mouse tp, ControlService ctrl)
		{
			MappedState.LX = 127;
			MappedState.LY = 127;
			MappedState.RX = 127;
			MappedState.RY = 127;
			int mouseDeltaX = 0;
			int mouseDeltaY = 0;

			SyntheticState state = deviceState[device];
			if ((Global.GetActions().Count > 0) && ((Global.ProfileActions[device].Count > 0) || !string.IsNullOrEmpty(Global.tempprofilename[device])))
			{
				MapCustomAction(device, cState, MappedState, eState, tp, ctrl);
			}
			if (ctrl.DS4Controllers[device] == null)
			{
				return;
			}

			cState.CopyTo(MappedState);

			List<DS4Controls> cross     = new List<DS4Controls>();
			List<DS4Controls> circle    = new List<DS4Controls>();
			List<DS4Controls> square    = new List<DS4Controls>();
			List<DS4Controls> triangle  = new List<DS4Controls>();
			List<DS4Controls> options   = new List<DS4Controls>();
			List<DS4Controls> share     = new List<DS4Controls>();
			List<DS4Controls> dPadUp    = new List<DS4Controls>();
			List<DS4Controls> dPadDown  = new List<DS4Controls>();
			List<DS4Controls> dPadLeft  = new List<DS4Controls>();
			List<DS4Controls> dpadRight = new List<DS4Controls>();
			List<DS4Controls> ps        = new List<DS4Controls>();
			List<DS4Controls> l1        = new List<DS4Controls>();
			List<DS4Controls> r1        = new List<DS4Controls>();
			List<DS4Controls> l2        = new List<DS4Controls>();
			List<DS4Controls> r2        = new List<DS4Controls>();
			List<DS4Controls> l3        = new List<DS4Controls>();
			List<DS4Controls> r3        = new List<DS4Controls>();
			List<DS4Controls> lxn       = new List<DS4Controls>();
			List<DS4Controls> lxp       = new List<DS4Controls>();
			List<DS4Controls> lyn       = new List<DS4Controls>();
			List<DS4Controls> lyp       = new List<DS4Controls>();
			List<DS4Controls> rxn       = new List<DS4Controls>();
			List<DS4Controls> rxp       = new List<DS4Controls>();
			List<DS4Controls> ryn       = new List<DS4Controls>();
			List<DS4Controls> ryp       = new List<DS4Controls>();

			DS4Controls usingExtra = DS4Controls.None;

			foreach (DS4ControlSettings dcs in Global.getDS4CSettings(device))
			{
				object action = null;
				DS4ControlSettings.ActionType actionType = 0;
				DS4KeyType keyType = DS4KeyType.None;
				if ((dcs.shiftAction != null) && ShiftTrigger(dcs.shiftTrigger, device, cState, eState, tp))
				{
					action = dcs.shiftAction;
					actionType = dcs.shiftActionType;
					keyType = dcs.shiftKeyType;
				}
				else if (dcs.action != null)
				{
					action = dcs.action;
					actionType = dcs.actionType;
					keyType = dcs.keyType;
				}
				if (action != null)
				{
					switch (actionType)
					{
						case DS4ControlSettings.ActionType.Macro:
							if (getBoolMapping(device, dcs.control, cState, eState, tp))
							{
								resetToDefaultValue(dcs.control, MappedState);
								PlayMacro(device, macroControl, string.Join("/", (int[])action), dcs.control, keyType);
							}
							else if (!getBoolMapping(device, dcs.control, cState, eState, tp))
							{
								EndMacro(device, macroControl, string.Join("/", (int[])action), dcs.control);
							}
							break;
						case DS4ControlSettings.ActionType.Key:
							ushort value = ushort.Parse(action.ToString());
							if (getBoolMapping(device, dcs.control, cState, eState, tp))
							{
								resetToDefaultValue(dcs.control, MappedState);
								SyntheticState.KeyPresses kp;
								if (!state.keyPresses.TryGetValue(value, out kp))
								{
									state.keyPresses[value] = kp = new SyntheticState.KeyPresses();
								}
								if (keyType.HasFlag(DS4KeyType.ScanCode))
								{
									kp.current.scanCodeCount++;
								}
								else
								{
									kp.current.vkCount++;
								}
								if (keyType.HasFlag(DS4KeyType.Toggle))
								{
									if (!pressedonce[value])
									{
										kp.current.toggle = !kp.current.toggle;
										pressedonce[value] = true;
									}
									kp.current.toggleCount++;
								}
								kp.current.repeatCount++;
							}
							else
							{
								pressedonce[value] = false;
							}
							break;
						case DS4ControlSettings.ActionType.Button:
							int keyvalue = 0;
							bool isAnalog = dcs.control.ToString().Contains("LX") ||
							                dcs.control.ToString().Contains("RX") ||
							                dcs.control.ToString().Contains("LY") ||
							                dcs.control.ToString().Contains("LY") ||
							                dcs.control.ToString().Contains("R2") ||
							                dcs.control.ToString().Contains("L2") ||
							                dcs.control.ToString().Contains("Gyro");
							switch (getX360ControlsByName(action.ToString()))
							{
								case X360Controls.A:
									cross.Add(dcs.control);
									break;
								case X360Controls.B:
									circle.Add(dcs.control);
									break;
								case X360Controls.X:
									square.Add(dcs.control);
									break;
								case X360Controls.Y:
									triangle.Add(dcs.control);
									break;
								case X360Controls.LB:
									l1.Add(dcs.control);
									break;
								case X360Controls.LS:
									l3.Add(dcs.control);
									break;
								case X360Controls.RB:
									r1.Add(dcs.control);
									break;
								case X360Controls.RS:
									r3.Add(dcs.control);
									break;
								case X360Controls.DpadUp:
									dPadUp.Add(dcs.control);
									break;
								case X360Controls.DpadDown:
									dPadDown.Add(dcs.control);
									break;
								case X360Controls.DpadLeft:
									dPadLeft.Add(dcs.control);
									break;
								case X360Controls.DpadRight:
									dpadRight.Add(dcs.control);
									break;
								case X360Controls.Start:
									options.Add(dcs.control);
									break;
								case X360Controls.Guide:
									ps.Add(dcs.control);
									break;
								case X360Controls.Back:
									share.Add(dcs.control);
									break;
								case X360Controls.LXNeg:
									lxn.Add(dcs.control);
									break;
								case X360Controls.LYNeg:
									lyn.Add(dcs.control);
									break;
								case X360Controls.RXNeg:
									rxn.Add(dcs.control);
									break;
								case X360Controls.RYNeg:
									ryn.Add(dcs.control);
									break;
								case X360Controls.LXPos:
									lxp.Add(dcs.control);
									break;
								case X360Controls.LYPos:
									lyp.Add(dcs.control);
									break;
								case X360Controls.RXPos:
									rxp.Add(dcs.control);
									break;
								case X360Controls.RYPos:
									ryp.Add(dcs.control);
									break;
								case X360Controls.LT:
									l2.Add(dcs.control);
									break;
								case X360Controls.RT:
									r2.Add(dcs.control);
									break;
								case X360Controls.LeftMouse:
									keyvalue = 256;
									if (getBoolMapping(device, dcs.control, cState, eState, tp))
									{
										state.currentClicks.leftCount++;
									}
									break;
								case X360Controls.RightMouse:
									keyvalue = 257;
									if (getBoolMapping(device, dcs.control, cState, eState, tp))
									{
										state.currentClicks.rightCount++;
									}
									break;
								case X360Controls.MiddleMouse:
									keyvalue = 258;
									if (getBoolMapping(device, dcs.control, cState, eState, tp))
									{
										state.currentClicks.middleCount++;
									}
									break;
								case X360Controls.FourthMouse:
									keyvalue = 259;
									if (getBoolMapping(device, dcs.control, cState, eState, tp))
									{
										state.currentClicks.fourthCount++;
									}
									break;
								case X360Controls.FifthMouse:
									keyvalue = 260;
									if (getBoolMapping(device, dcs.control, cState, eState, tp))
									{
										state.currentClicks.fifthCount++;
									}
									break;
								case X360Controls.WUP:
									if (getBoolMapping(device, dcs.control, cState, eState, tp))
									{
										if (isAnalog)
										{
											getMouseWheelMapping(device, dcs.control, cState, eState, tp, false);
										}
										else
										{
											state.currentClicks.wUpCount++;
										}
									}
									break;
								case X360Controls.WDOWN:
									if (getBoolMapping(device, dcs.control, cState, eState, tp))
									{
										if (isAnalog)
										{
											getMouseWheelMapping(device, dcs.control, cState, eState, tp, true);
										}
										else
										{
											state.currentClicks.wDownCount++;
										}
									}
									break;
								case X360Controls.MouseUp:
									if (mouseDeltaY == 0)
									{
										mouseDeltaY = getMouseMapping(device, dcs.control, cState, eState, 0);
										mouseDeltaY = -Math.Abs(mouseDeltaY == -2147483648 ? 0 : mouseDeltaY);
									}
									break;
								case X360Controls.MouseDown:
									if (mouseDeltaY == 0)
									{
										mouseDeltaY = getMouseMapping(device, dcs.control, cState, eState, 1);
										mouseDeltaY = Math.Abs(mouseDeltaY == -2147483648 ? 0 : mouseDeltaY);
									}
									break;
								case X360Controls.MouseLeft:
									if (mouseDeltaX == 0)
									{
										mouseDeltaX = getMouseMapping(device, dcs.control, cState, eState, 2);
										mouseDeltaX = -Math.Abs(mouseDeltaX == -2147483648 ? 0 : mouseDeltaX);
									}
									break;
								case X360Controls.MouseRight:
									if (mouseDeltaX == 0)
									{
										mouseDeltaX = getMouseMapping(device, dcs.control, cState, eState, 3);
										mouseDeltaX = Math.Abs(mouseDeltaX == -2147483648 ? 0 : mouseDeltaX);
									}
									break;
							}
							if (keyType.HasFlag(DS4KeyType.Toggle))
							{
								if (getBoolMapping(device, dcs.control, cState, eState, tp))
								{
									resetToDefaultValue(dcs.control, MappedState);
									if (!pressedonce[keyvalue])
									{
										state.currentClicks.toggle = !state.currentClicks.toggle;
										pressedonce[keyvalue] = true;
									}
									state.currentClicks.toggleCount++;
								}
								else
								{
									pressedonce[keyvalue] = false;
								}
							}
							resetToDefaultValue(dcs.control, MappedState); // erase default mappings for things that are remapped
							break;
					}
				}

				if ((usingExtra != DS4Controls.None) && (usingExtra != dcs.control))
				{
					continue;
				}

				bool shiftE = (dcs.shiftExtras != "0,0,0,0,0,0,0,0") && !string.IsNullOrEmpty(dcs.shiftExtras) && ShiftTrigger(dcs.shiftTrigger, device, cState, eState, tp);
				bool regE = (dcs.extras != "0,0,0,0,0,0,0,0") && !string.IsNullOrEmpty(dcs.extras);
				if ((regE || shiftE) && getBoolMapping(device, dcs.control, cState, eState, tp))
				{
					usingExtra = dcs.control;
					string p = shiftE ? dcs.shiftExtras : dcs.extras;
					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[device] = true;
					try
					{
						if (!((extras[0] == extras[1]) && (extras[1] == 0)))
						{
							ctrl.SetRumble((byte)extras[0], (byte)extras[1], device);
						}
						if (extras[2] == 1)
						{
							DS4Color color = new DS4Color { red = (byte)extras[3], green = (byte)extras[4], blue = (byte)extras[5] };
							DS4LightBar.forcedColor[device] = color;
							DS4LightBar.forcedFlash[device] = (byte)extras[6];
							DS4LightBar.forcelight[device] = true;
						}
						if (extras[7] == 1)
						{
							if (oldmouse[device] == -1)
							{
								oldmouse[device] = Global.ButtonMouseSensitivity[device];
							}
							Global.ButtonMouseSensitivity[device] = extras[8];
						}
					}
					catch
					{
						// ignored
					}
				}
				else if ((regE || shiftE) && held[device])
				{
					DS4LightBar.forcelight[device] = false;
					DS4LightBar.forcedFlash[device] = 0;
					Global.ButtonMouseSensitivity[device] = oldmouse[device];
					oldmouse[device] = -1;
					ctrl.SetRumble(0, 0, device);
					held[device] = false;
					usingExtra = DS4Controls.None;
				}
			}

			if (macroControl[00])
			{
				MappedState.Cross = true;
			}
			if (macroControl[01])
			{
				MappedState.Circle = true;
			}
			if (macroControl[02])
			{
				MappedState.Square = true;
			}
			if (macroControl[03])
			{
				MappedState.Triangle = true;
			}
			if (macroControl[04])
			{
				MappedState.Options = true;
			}
			if (macroControl[05])
			{
				MappedState.Share = true;
			}
			if (macroControl[06])
			{
				MappedState.DpadUp = true;
			}
			if (macroControl[07])
			{
				MappedState.DpadDown = true;
			}
			if (macroControl[08])
			{
				MappedState.DpadLeft = true;
			}
			if (macroControl[09])
			{
				MappedState.DpadRight = true;
			}
			if (macroControl[10])
			{
				MappedState.PS = true;
			}
			if (macroControl[11])
			{
				MappedState.L1 = true;
			}
			if (macroControl[12])
			{
				MappedState.R1 = true;
			}
			if (macroControl[13])
			{
				MappedState.L2 = 255;
			}
			if (macroControl[14])
			{
				MappedState.R2 = 255;
			}
			if (macroControl[15])
			{
				MappedState.L3 = true;
			}
			if (macroControl[16])
			{
				MappedState.R3 = true;
			}
			if (macroControl[17])
			{
				MappedState.LX = 255;
			}
			if (macroControl[18])
			{
				MappedState.LX = 0;
			}
			if (macroControl[19])
			{
				MappedState.LY = 255;
			}
			if (macroControl[20])
			{
				MappedState.LY = 0;
			}
			if (macroControl[21])
			{
				MappedState.RX = 255;
			}
			if (macroControl[22])
			{
				MappedState.RX = 0;
			}
			if (macroControl[23])
			{
				MappedState.RY = 255;
			}
			if (macroControl[24])
			{
				MappedState.RY = 0;
			}
			foreach (DS4Controls dc in cross)
			{
				if (getBoolMapping(device, dc, cState, eState, tp))
				{
					MappedState.Cross = true;
				}
			}
			foreach (DS4Controls dc in circle)
			{
				if (getBoolMapping(device, dc, cState, eState, tp))
				{
					MappedState.Circle = true;
				}
			}
			foreach (DS4Controls dc in square)
			{
				if (getBoolMapping(device, dc, cState, eState, tp))
				{
					MappedState.Square = true;
				}
			}
			foreach (DS4Controls dc in triangle)
			{
				if (getBoolMapping(device, dc, cState, eState, tp))
				{
					MappedState.Triangle = true;
				}
			}
			foreach (DS4Controls dc in l1)
			{
				if (getBoolMapping(device, dc, cState, eState, tp))
				{
					MappedState.L1 = true;
				}
			}
			foreach (DS4Controls dc in l2)
			{
				if (getByteMapping(device, dc, cState, eState, tp) > 5)
				{
					MappedState.L2 = getByteMapping(device, dc, cState, eState, tp);
				}
			}
			foreach (DS4Controls dc in l3)
			{
				if (getBoolMapping(device, dc, cState, eState, tp))
				{
					MappedState.L3 = true;
				}
			}
			foreach (DS4Controls dc in r1)
			{
				if (getBoolMapping(device, dc, cState, eState, tp))
				{
					MappedState.R1 = true;
				}
			}
			foreach (DS4Controls dc in r2)
			{
				if (getByteMapping(device, dc, cState, eState, tp) > 5)
				{
					MappedState.R2 = getByteMapping(device, dc, cState, eState, tp);
				}
			}
			foreach (DS4Controls dc in r3)
			{
				if (getBoolMapping(device, dc, cState, eState, tp))
				{
					MappedState.R3 = true;
				}
			}
			foreach (DS4Controls dc in dPadUp)
			{
				if (getBoolMapping(device, dc, cState, eState, tp))
				{
					MappedState.DpadUp = true;
				}
			}
			foreach (DS4Controls dc in dpadRight)
			{
				if (getBoolMapping(device, dc, cState, eState, tp))
				{
					MappedState.DpadRight = true;
				}
			}
			foreach (DS4Controls dc in dPadLeft)
			{
				if (getBoolMapping(device, dc, cState, eState, tp))
				{
					MappedState.DpadLeft = true;
				}
			}
			foreach (DS4Controls dc in dPadDown)
			{
				if (getBoolMapping(device, dc, cState, eState, tp))
				{
					MappedState.DpadDown = true;
				}
			}
			foreach (DS4Controls dc in options)
			{
				if (getBoolMapping(device, dc, cState, eState, tp))
				{
					MappedState.Options = true;
				}
			}
			foreach (DS4Controls dc in share)
			{
				if (getBoolMapping(device, dc, cState, eState, tp))
				{
					MappedState.Share = true;
				}
			}
			foreach (DS4Controls dc in ps)
			{
				if (getBoolMapping(device, dc, cState, eState, tp))
				{
					MappedState.PS = true;
				}
			}
			if (IfAxisIsNotModified(device, ShiftTrigger(Global.GetDS4STrigger(device, DS4Controls.LXNeg.ToString()), device, cState, eState, tp), DS4Controls.LXNeg))
			{
				lxn.Add(DS4Controls.LXNeg);
			}

			if (IfAxisIsNotModified(device, ShiftTrigger(Global.GetDS4STrigger(device, DS4Controls.LXPos.ToString()), device, cState, eState, tp), DS4Controls.LXPos))
			{
				lxp.Add(DS4Controls.LXPos);
			}

			if (IfAxisIsNotModified(device, ShiftTrigger(Global.GetDS4STrigger(device, DS4Controls.LYNeg.ToString()), device, cState, eState, tp), DS4Controls.LYNeg))
			{
				lyn.Add(DS4Controls.LYNeg);
			}

			if (IfAxisIsNotModified(device, ShiftTrigger(Global.GetDS4STrigger(device, DS4Controls.LYPos.ToString()), device, cState, eState, tp), DS4Controls.LYPos))
			{
				lyp.Add(DS4Controls.LYPos);
			}

			if (IfAxisIsNotModified(device, ShiftTrigger(Global.GetDS4STrigger(device, DS4Controls.RXNeg.ToString()), device, cState, eState, tp), DS4Controls.RXNeg))
			{
				rxn.Add(DS4Controls.RXNeg);
			}

			if (IfAxisIsNotModified(device, ShiftTrigger(Global.GetDS4STrigger(device, DS4Controls.RXPos.ToString()), device, cState, eState, tp), DS4Controls.RXPos))
			{
				rxp.Add(DS4Controls.RXPos);
			}

			if (IfAxisIsNotModified(device, ShiftTrigger(Global.GetDS4STrigger(device, DS4Controls.RYNeg.ToString()), device, cState, eState, tp), DS4Controls.RYNeg))
			{
				ryn.Add(DS4Controls.RYNeg);
			}

			if (IfAxisIsNotModified(device, ShiftTrigger(Global.GetDS4STrigger(device, DS4Controls.RYPos.ToString()), device, cState, eState, tp), DS4Controls.RYPos))
			{
				ryp.Add(DS4Controls.RYPos);
			}

			if (Math.Abs(MappedState.LX - 127) < 10)
			{
				if ((lxn.Count > 0) || (lxp.Count > 0))
				{
					foreach (DS4Controls dc in lxp)
					{
						if (Math.Abs(127 - getXYAxisMapping(device, dc, cState, eState, tp, true)) > 5)
						{
							MappedState.LX = getXYAxisMapping(device, dc, cState, eState, tp, true);
						}
					}
					foreach (DS4Controls dc in lxn)
					{
						if (Math.Abs(127 - getXYAxisMapping(device, dc, cState, eState, tp)) > 5)
						{
							MappedState.LX = getXYAxisMapping(device, dc, cState, eState, tp);
						}
					}
				}
			}
			//else
			//MappedState.LX = cState.LX;
			if (Math.Abs(MappedState.LY - 127) < 10)
			{
				if ((lyn.Count > 0) || (lyp.Count > 0))
				{
					foreach (DS4Controls dc in lyn)
					{
						if (Math.Abs(127 - getXYAxisMapping(device, dc, cState, eState, tp)) > 5)
						{
							MappedState.LY = getXYAxisMapping(device, dc, cState, eState, tp);
						}
					}
					foreach (DS4Controls dc in lyp)
					{
						if (Math.Abs(127 - getXYAxisMapping(device, dc, cState, eState, tp, true)) > 5)
						{
							MappedState.LY = getXYAxisMapping(device, dc, cState, eState, tp, true);
						}
					}
				}
			}
			//else
			//MappedState.LY = cState.LY;
			if (Math.Abs(MappedState.RX - 127) < 10)
			{
				if ((rxn.Count > 0) || (rxp.Count > 0))
				{
					foreach (DS4Controls dc in rxn)
					{
						if (Math.Abs(127 - getXYAxisMapping(device, dc, cState, eState, tp)) > 5)
						{
							MappedState.RX = getXYAxisMapping(device, dc, cState, eState, tp);
						}
					}
					foreach (DS4Controls dc in rxp)
					{
						if (Math.Abs(127 - getXYAxisMapping(device, dc, cState, eState, tp, true)) > 5)
						{
							MappedState.RX = getXYAxisMapping(device, dc, cState, eState, tp, true);
						}
					}
				}
			}
			//else
			// MappedState.RX = cState.RX;
			if (Math.Abs(MappedState.RY - 127) < 10)
			{
				if ((ryn.Count > 0) || (ryp.Count > 0))
				{
					foreach (DS4Controls dc in ryn)
					{
						if (Math.Abs(127 - getXYAxisMapping(device, dc, cState, eState, tp)) > 5)
						{
							MappedState.RY = getXYAxisMapping(device, dc, cState, eState, tp);
						}
					}
					foreach (DS4Controls dc in ryp)
					{
						if (Math.Abs(127 - getXYAxisMapping(device, dc, cState, eState, tp, true)) > 5)
						{
							MappedState.RY = getXYAxisMapping(device, dc, cState, eState, tp, true);
						}
					}
				}
			}
			// else
			// MappedState.RY = cState.RY;
			InputMethods.MoveCursorBy(mouseDeltaX, mouseDeltaY);
		}
Ejemplo n.º 5
0
		public static async void MapCustomAction(int device, DS4State cState, DS4State MappedState, DS4StateExposed eState, Mouse tp, ControlService ctrl)
		{
			try
			{
				foreach (string actionname in Global.ProfileActions[device])
				{
					//DS4KeyType keyType = getShiftCustomKeyType(device, customKey.Key);
					SpecialAction action = Global.GetAction(actionname);
					int index = Global.GetActionIndexOf(actionname);
					//If a key or button is assigned to the trigger, a key special action is used like
					//a quick tap to use and hold to use the regular custom button/key
					bool triggerToBeTapped = (action.type == "Key") && (action.trigger.Count == 1) &&
					                         (Global.GetDS4Action(device, action.trigger[0].ToString(), false) == null);
					if ((action.name == "null") || (index < 0))
					{
						continue;
					}

					bool triggeractivated = true;
					if (action.delayTime > 0)
					{
						triggeractivated = false;
						bool subtriggeractivated = action.trigger.All(dc => getBoolMapping(device, dc, cState, eState, tp));
						if (subtriggeractivated)
						{
							double time = action.delayTime;
							nowAction[device] = DateTime.UtcNow;
							if (nowAction[device] >= oldnowAction[device] + TimeSpan.FromSeconds(time))
							{
								triggeractivated = true;
							}
						}
						else if (nowAction[device] < DateTime.UtcNow - TimeSpan.FromMilliseconds(100))
						{
							oldnowAction[device] = DateTime.UtcNow;
						}
					}
					else if (triggerToBeTapped && (oldnowKeyAct[device] == DateTime.MinValue))
					{
						triggeractivated = false;
						bool subtriggeractivated = action.trigger.All(dc => getBoolMapping(device, dc, cState, eState, tp));
						if (subtriggeractivated)
						{
							oldnowKeyAct[device] = DateTime.UtcNow;
						}
					}
					else if (triggerToBeTapped && (oldnowKeyAct[device] != DateTime.MinValue))
					{
						triggeractivated = false;
						bool subtriggeractivated = action.trigger.All(dc => getBoolMapping(device, dc, cState, eState, tp));
						DateTime now = DateTime.UtcNow;
						if (!subtriggeractivated && (now <= oldnowKeyAct[device] + TimeSpan.FromMilliseconds(250)))
						{
							await Task.Delay(3); //if the button is assigned to the same key use a delay so the key down is the last action, not key up
							triggeractivated = true;
							oldnowKeyAct[device] = DateTime.MinValue;
						}
						else if (!subtriggeractivated)
						{
							oldnowKeyAct[device] = DateTime.MinValue;
						}
					}
					else if (action.trigger.Any(dc => !getBoolMapping(device, dc, cState, eState, tp)))
					{
						triggeractivated = false;
					}

					bool utriggeractivated = true;
					if ((action.type == "Key") && (action.uTrigger.Count > 0))
					{
						if (action.uTrigger.Any(dc => !getBoolMapping(device, dc, cState, eState, tp)))
						{
							utriggeractivated = false;
						}
						if (action.pressRelease)
						{
							utriggeractivated = !utriggeractivated;
						}
					}

					if (triggeractivated && (action.type == "Program"))
					{
						if (actionDone[device, index])
						{
							continue;
						}
						actionDone[device, index] = true;
						if (!string.IsNullOrEmpty(action.extra))
						{
							Process.Start(action.details, action.extra);
						}
						else
						{
							Process.Start(action.details);
						}
					}
					else if (triggeractivated && (action.type == "Profile"))
					{
						if (actionDone[device, index] || !string.IsNullOrEmpty(Global.tempprofilename[device]))
						{
							continue;
						}

						actionDone[device, index] = true;
						untriggeraction[device] = action;
						untriggerindex[device] = index;
						foreach (DS4Controls dc in action.trigger)
						{
							DS4ControlSettings dcs = Global.getDS4CSetting(device, dc.ToString());
							if (dcs.action == null)
							{
								continue;
							}
							if (dcs.actionType == DS4ControlSettings.ActionType.Key)
							{
								InputMethods.PerformKeyRelease(ushort.Parse(action.ToString()));
							}
							else if (dcs.actionType == DS4ControlSettings.ActionType.Macro)
							{
								int[] keys = (int[])dcs.action;
								foreach (int key in keys)
								{
									InputMethods.PerformKeyRelease((ushort)key);
								}
							}
						}
						Global.LoadTempProfile(device, action.details, true, ctrl);
						return;
					}
					else if (triggeractivated && (action.type == "Macro"))
					{
						if (!actionDone[device, index])
						{
							DS4KeyType keyType = action.keyType;
							actionDone[device, index] = true;
							foreach (DS4Controls dc in action.trigger)
							{
								resetToDefaultValue(dc, MappedState);
							}
							PlayMacro(device, macroControl, string.Join("/", action.macro), DS4Controls.None, keyType);
						}
						else
						{
							EndMacro(device, macroControl, string.Join("/", action.macro), DS4Controls.None);
						}
					}
					else if (triggeractivated && (action.type == "Key"))
					{
						if ((action.uTrigger.Count != 0) && ((action.uTrigger.Count <= 0) || (untriggerindex[device] != -1) || actionDone[device, index]))
						{
							continue;
						}
						actionDone[device, index] = true;
						untriggerindex[device] = index;
						ushort key;
						ushort.TryParse(action.details, out key);
						if (action.uTrigger.Count == 0)
						{
							SyntheticState.KeyPresses kp;
							if (!deviceState[device].keyPresses.TryGetValue(key, out kp))
							{
								deviceState[device].keyPresses[key] = kp = new SyntheticState.KeyPresses();
							}
							if (action.keyType.HasFlag(DS4KeyType.ScanCode))
							{
								kp.current.scanCodeCount++;
							}
							else
							{
								kp.current.vkCount++;
							}
							kp.current.repeatCount++;
						}
						else if (action.keyType.HasFlag(DS4KeyType.ScanCode))
						{
							InputMethods.PerformScKeyPress(key);
						}
						else
						{
							InputMethods.PerformKeyPress(key);
						}
					}
					else if ((action.uTrigger.Count > 0) && utriggeractivated && (action.type == "Key"))
					{
						if ((untriggerindex[device] <= -1) || actionDone[device, index])
						{
							continue;
						}
						actionDone[device, index] = true;
						untriggerindex[device] = -1;
						ushort key;
						ushort.TryParse(action.details, out key);
						if (action.keyType.HasFlag(DS4KeyType.ScanCode))
						{
							InputMethods.PerformScKeyRelease(key);
						}
						else
						{
							InputMethods.PerformKeyRelease(key);
						}
					}
					else if (triggeractivated && (action.type == "DisconnectBT"))
					{
						DS4Device d = ctrl.DS4Controllers[device];
						if (d.Charging)
						{
							continue;
						}
						d.DisconnectBluetooth();
						foreach (DS4Controls dc in action.trigger)
						{
							DS4ControlSettings dcs = Global.getDS4CSetting(device, dc.ToString());
							if (dcs.action != null)
							{
								if (dcs.actionType == DS4ControlSettings.ActionType.Key)
								{
									InputMethods.PerformKeyRelease((ushort)dcs.action);
								}
								else if (dcs.actionType == DS4ControlSettings.ActionType.Macro)
								{
									int[] keys = (int[])dcs.action;
									foreach (int key in keys)
									{
										InputMethods.PerformKeyRelease((ushort)key);
									}
								}
							}
						}
						return;
					}
					else if (triggeractivated && (action.type == "BatteryCheck"))
					{
						string[] dets = action.details.Split(',');
						if (bool.Parse(dets[1]) && !actionDone[device, index])
						{
							Log.LogToTray("Controller " + (device + 1) + ": " +
							              ctrl.GetDS4Battery(device), LogWarning.Yes);
						}
						if (bool.Parse(dets[2]))
						{
							DS4Device d = ctrl.DS4Controllers[device];
							if (!actionDone[device, index])
							{
								lastColor[device] = d.LightBarColor;
								DS4LightBar.forcelight[device] = true;
							}
							DS4Color empty = new DS4Color(byte.Parse(dets[3]), byte.Parse(dets[4]), byte.Parse(dets[5]));
							DS4Color full = new DS4Color(byte.Parse(dets[6]), byte.Parse(dets[7]), byte.Parse(dets[8]));
							DS4Color trans = Global.getTransitionedColor(empty, full, d.Battery);
							if (fadetimer[device] < 100)
							{
								DS4LightBar.forcedColor[device] = Global.getTransitionedColor(lastColor[device], trans, fadetimer[device] += 2);
							}
						}
						actionDone[device, index] = true;
					}
					else if (!triggeractivated && (action.type == "BatteryCheck"))
					{
						if (actionDone[device, index])
						{
							fadetimer[device] = 0;
							DS4LightBar.forcelight[device] = false;
							actionDone[device, index] = false;
						}
					}
					else if (action.type == "XboxGameDVR")
					{
						/*if (getCustomButton(device, action.trigger[0]) != X360Controls.Unbound)
								getCustomButtons(device)[action.trigger[0]] = X360Controls.Unbound;
							if (getCustomMacro(device, action.trigger[0]) != "0")
								getCustomMacros(device).Remove(action.trigger[0]);
							if (getCustomKey(device, action.trigger[0]) != 0)
								getCustomMacros(device).Remove(action.trigger[0]);*/
						string[] dets = action.details.Split(',');
						DS4Device d = ctrl.DS4Controllers[device];
						//cus
						if (getBoolMapping(device, action.trigger[0], cState, eState, tp) && !getBoolMapping(device, action.trigger[0], d.GetPreviousState(), eState, tp))
						{
							//pressed down
							pastTime = DateTime.UtcNow;
							if (DateTime.UtcNow <= firstTap + TimeSpan.FromMilliseconds(150))
							{
								tappedOnce = false;
								secondtouchbegin = true;
							}
							else
							{
								firstTouch = true;
							}
						}
						else if (!getBoolMapping(device, action.trigger[0], cState, eState, tp) && getBoolMapping(device, action.trigger[0], d.GetPreviousState(), eState, tp))
						{
							//released
							if (secondtouchbegin)
							{
								firstTouch = false;
								secondtouchbegin = false;
							}
							else if (firstTouch)
							{
								firstTouch = false;
								if ((DateTime.UtcNow <= pastTime + TimeSpan.FromMilliseconds(200)) && !tappedOnce)
								{
									tappedOnce = true;
									firstTap = DateTime.UtcNow;
									TimeofEnd = DateTime.UtcNow;
								}
							}
						}

						int type;
						string macro = string.Empty;
						if (tappedOnce) //single tap
						{
							if (int.TryParse(dets[0], out type))
							{
								switch (type)
								{
									case 0:
										macro = "91/71/71/91";
										break;
									case 1:
										macro = "91/164/82/82/164/91";
										break;
									case 2:
										macro = "91/164/44/44/164/91";
										break;
									case 3:
										macro = dets[3] + "/" + dets[3];
										break;
									case 4:
										macro = "91/164/71/71/164/91";
										break;
								}
							}
							if (DateTime.UtcNow - TimeofEnd > TimeSpan.FromMilliseconds(150))
							{
								PlayMacro(device, macroControl, macro, DS4Controls.None, DS4KeyType.None);
								tappedOnce = false;
							}
							//if it fails the method resets, and tries again with a new tester value (gives tap a delay so tap and hold can work)
						}
						else if (firstTouch && (DateTime.UtcNow - pastTime > TimeSpan.FromMilliseconds(1000))) //helddown
						{
							if (int.TryParse(dets[1], out type))
							{
								switch (type)
								{
									case 0:
										macro = "91/71/71/91";
										break;
									case 1:
										macro = "91/164/82/82/164/91";
										break;
									case 2:
										macro = "91/164/44/44/164/91";
										break;
									case 3:
										macro = dets[3] + "/" + dets[3];
										break;
									case 4:
										macro = "91/164/71/71/164/91";
										break;
								}
							}
							PlayMacro(device, macroControl, macro, DS4Controls.None, DS4KeyType.None);
							firstTouch = false;
						}
						else if (secondtouchbegin) //if double tap
						{
							if (int.TryParse(dets[2], out type))
							{
								switch (type)
								{
									case 0:
										macro = "91/71/71/91";
										break;
									case 1:
										macro = "91/164/82/82/164/91";
										break;
									case 2:
										macro = "91/164/44/44/164/91";
										break;
									case 3:
										macro = dets[3] + "/" + dets[3];
										break;
									case 4:
										macro = "91/164/71/71/164/91";
										break;
								}
							}
							PlayMacro(device, macroControl, macro, DS4Controls.None, DS4KeyType.None);
							secondtouchbegin = false;
						}
					}
					else
					{
						actionDone[device, index] = false;
					}
				}
			}
			catch
			{
				return;
			}

			if (untriggeraction[device] != null)
			{
				SpecialAction action = untriggeraction[device];
				int index = untriggerindex[device];

				if (action.uTrigger.All(dc => getBoolMapping(device, dc, cState, eState, tp)) && (action.type == "Profile"))
				{
					if (((action.controls != action.ucontrols) || actionDone[device, index]) && (action.controls == action.ucontrols))
					{
						return;
					}

					if (string.IsNullOrEmpty(Global.tempprofilename[device]))
					{
						return;
					}

					foreach (DS4Controls dc in action.uTrigger)
					{
						actionDone[device, index] = true;
						DS4ControlSettings dcs = Global.getDS4CSetting(device, dc.ToString());
						if (dcs.action == null)
						{
							continue;
						}

						if (dcs.actionType == DS4ControlSettings.ActionType.Key)
						{
							InputMethods.PerformKeyRelease((ushort)dcs.action);
						}
						else if (dcs.actionType == DS4ControlSettings.ActionType.Macro)
						{
							int[] keys = (int[])dcs.action;
							foreach (int key in keys)
							{
								InputMethods.PerformKeyRelease((ushort)key);
							}
						}
					}

					untriggeraction[device] = null;
					Global.LoadProfile(device, false, ctrl);
				}
				else
				{
					actionDone[device, index] = false;
				}
			}
		}
Ejemplo n.º 6
0
		public static DS4Color getTransitionedColor(DS4Color c1, DS4Color c2, double ratio)
		{
			c1.red = applyRatio(c1.red, c2.red, ratio);
			c1.green = applyRatio(c1.green, c2.green, ratio);
			c1.blue = applyRatio(c1.blue, c2.blue, ratio);
			return c1;
		}
Ejemplo n.º 7
0
		public static void updateLightBar(DS4Device device, int deviceNum, DS4State cState, DS4StateExposed eState, Mouse tp)
		{
			DS4Color color;
			if (!defualtLight && !forcelight[deviceNum])
			{
				if (Global.UseCustomLed[deviceNum])
				{
					if (Global.LedAsBatteryIndicator[deviceNum])
					{
						DS4Color fullColor = Global.CustomColor[deviceNum];
						DS4Color lowColor = Global.LowColor[deviceNum];

						color = Global.getTransitionedColor(lowColor, fullColor, device.Battery);
					}
					else
					{
						color = Global.CustomColor[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 (device.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;
						}

						color = Global.LedAsBatteryIndicator[deviceNum]
							? HuetoRGB((float)counters[deviceNum] % 360, (byte)(2.55 * device.Battery))
							: 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
						{
							DS4Color fullColor = Global.MainColor[deviceNum];
							DS4Color lowColor = Global.LowColor[deviceNum];

							color = Global.getTransitionedColor(lowColor, fullColor, (uint)device.Battery);
						}
					}
					else
					{
						color = Global.MainColor[deviceNum];
					}
				}

				if ((device.Battery <= Global.FlashAt[deviceNum]) && !defualtLight && !device.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 DS4Color(0, 0, 0), fadetimer[deviceNum]);
					}
				}

				if ((Global.IdleDisconnectTimeout[deviceNum] > 0) && Global.LedAsBatteryIndicator[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.IdleDisconnectTimeout[deviceNum]).TotalMilliseconds;
					double ratio = botratio / topratio * 100;
					if ((ratio >= 50) && (ratio <= 100))
					{
						color = Global.getTransitionedColor(color, new DS4Color(0, 0, 0), (uint)((ratio - 50) * 2));
					}
					else if (ratio >= 100)
					{
						color = Global.getTransitionedColor(color, new DS4Color(0, 0, 0), 100);
					}
				}
				if (device.Charging && (device.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 DS4Color(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;
					}
				}
			}
			else if (forcelight[deviceNum])
			{
				color = forcedColor[deviceNum];
			}
			else if (shuttingdown)
			{
				color = new DS4Color(0, 0, 0);
			}
			else
			{
				color = device.ConnectionType == ConnectionType.BT ? new DS4Color(32, 64, 64) : new DS4Color(0, 0, 0);
			}
			bool distanceprofile = Global.ProfilePath[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));
				color = device.LeftHeavySlowRumble > 100
					? Global.getTransitionedColor(new DS4Color(max, max, 0), new DS4Color(255, 0, 0), rumble)
					: Global.getTransitionedColor(color, Global.getTransitionedColor(new DS4Color(max, max, 0), new DS4Color(255, 0, 0), 39.6078f), device.LeftHeavySlowRumble);
			}
			DS4HapticState haptics = new DS4HapticState
			{
				LightBarColor = color
			};
			if (haptics.IsLightBarSet())
			{
				if (forcelight[deviceNum] && (forcedFlash[deviceNum] > 0))
				{
					haptics.LightBarFlashDurationOff = haptics.LightBarFlashDurationOn = (byte)(25 - forcedFlash[deviceNum]);
					haptics.LightBarExplicitlyOff = true;
				}
				else if ((device.Battery <= Global.FlashAt[deviceNum]) && (Global.FlashType[deviceNum] == 0) && !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
			{
				Thread.Sleep(5);
			}
			device.PushHapticState(haptics);
		}
Ejemplo n.º 8
0
		private void btnFlashColor_Click(object sender, EventArgs e)
		{
			advColorDialog.Color = btnFlashColor.BackColor != main ? btnFlashColor.BackColor : Color.Black;
			advColorDialog_OnUpdateColor(lbPercentFlashBar.ForeColor, e);
			if (advColorDialog.ShowDialog() == DialogResult.OK)
			{
				btnFlashColor.BackColor = advColorDialog.Color.GetBrightness() > 0 ? advColorDialog.Color : main;
				FlashColor[Device] = new DS4Color(advColorDialog.Color);
			}
			if (Device < 4)
			{
				DS4LightBar.forcelight[Device] = false;
			}
		}
Ejemplo n.º 9
0
		private void SetColorToolTip(TrackBar tb, int type)
		{
			if (tb != null)
			{
				int value = tb.Value;
				int sat = bgc - (value < bgc ? value : bgc);
				int som = bgc + 11 * (int)(value * 0.0039215);
				tb.BackColor = Color.FromArgb(tb.Name.ToLower().Contains("red") ? som : sat, tb.Name.ToLower().Contains("green") ? som : sat, tb.Name.ToLower().Contains("blue") ? som : sat);
			}
			if (type == 0) //main
			{
				alphacolor = Math.Max(tBRedBar.Value, Math.Max(tBGreenBar.Value, tBBlueBar.Value));
				reg = Color.FromArgb(tBRedBar.Value, tBGreenBar.Value, tBBlueBar.Value);
				full = HuetoRGB(reg.GetHue(), reg.GetBrightness(), reg);
				main = Color.FromArgb((alphacolor > 205 ? 255 : (alphacolor + 50)), full);
				btnLightbar.BackgroundImage = RecolorImage((Bitmap)btnLightbar.BackgroundImage, main);
				if (FlashColor[Device].Equals(new DS4Color { red = 0, green = 0, blue = 0 }))
				{
					btnFlashColor.BackColor = main;
				}
				btnFlashColor.BackgroundImage = nUDRainbow.Enabled ? rainbowImg : null;
				MainColor[Device] = new DS4Color((byte)tBRedBar.Value, (byte)tBGreenBar.Value, (byte)tBBlueBar.Value);
			}
			else if (type == 1)
			{
				alphacolor = Math.Max(tBLowRedBar.Value, Math.Max(tBLowGreenBar.Value, tBLowBlueBar.Value));
				reg = Color.FromArgb(tBLowRedBar.Value, tBLowGreenBar.Value, tBLowBlueBar.Value);
				full = HuetoRGB(reg.GetHue(), reg.GetBrightness(), reg);
				lowColorChooserButton.BackColor = Color.FromArgb((alphacolor > 205 ? 255 : (alphacolor + 50)), full);
				LowColor[Device] = new DS4Color((byte)tBLowRedBar.Value, (byte)tBLowGreenBar.Value, (byte)tBLowBlueBar.Value);
			}
			if (!Saving && !loading && (tb != null))
			{
				tp.Show(tb.Value.ToString(), tb, (int)(dpix * 100), 0, 2000);
			}
		}
Ejemplo n.º 10
0
		private void btnChargingColor_Click(object sender, EventArgs e)
		{
			advColorDialog.Color = btnChargingColor.BackColor;
			advColorDialog_OnUpdateColor(btnChargingColor.BackColor, e);
			if (advColorDialog.ShowDialog() == DialogResult.OK)
			{
				btnChargingColor.BackColor = advColorDialog.Color;
			}
			if (Device < 4)
			{
				DS4LightBar.forcelight[Device] = false;
			}
			ChargingColor[Device] = new DS4Color(btnChargingColor.BackColor);
		}
Ejemplo n.º 11
0
		public void Set()
		{
			pnlLowBattery.Visible = cBLightbyBattery.Checked;
			lbFull.Text = (cBLightbyBattery.Checked ? Resources.Full + ":" : Resources.Color + ":");
			MainColor[Device] = new DS4Color((byte)tBRedBar.Value, (byte)tBGreenBar.Value, (byte)tBBlueBar.Value);
			LowColor[Device] = new DS4Color((byte)tBLowRedBar.Value, (byte)tBLowGreenBar.Value, (byte)tBLowBlueBar.Value);
			ChargingColor[Device] = new DS4Color(btnChargingColor.BackColor);
			FlashType[Device] = (byte)cBFlashType.SelectedIndex;
			if (btnFlashColor.BackColor != main)
			{
				FlashColor[Device] = new DS4Color(btnFlashColor.BackColor);
			}
			else
			{
				FlashColor[Device] = new DS4Color(Color.Black);
			}
			L2Deadzone[Device]                 = (byte)Math.Round((nUDL2.Value * 255), 0);
			R2Deadzone[Device]                 = (byte)Math.Round((nUDR2.Value * 255), 0);
			RumbleBoost[Device]                = (byte)nUDRumbleBoost.Value;
			TouchSensitivity[Device]           = (byte)nUDTouch.Value;
			TouchpadJitterCompensation[Device] = cBTouchpadJitterCompensation.Checked;
			LowerRCOn[Device]                  = cBlowerRCOn.Checked;
			ScrollSensitivity[Device]          = (int)nUDScroll.Value;
			DoubleTap[Device]                  = cBDoubleTap.Checked;
			TapSensitivity[Device]             = (byte)nUDTap.Value;
			IdleDisconnectTimeout[Device]      = (int)(nUDIdleDisconnect.Value * 60);
			Rainbow[Device]                    = (int)nUDRainbow.Value;
			RSDeadzone[Device]                 = (int)Math.Round((nUDRS.Value * 127), 0);
			LSDeadzone[Device]                 = (int)Math.Round((nUDLS.Value * 127), 0);
			ButtonMouseSensitivity[Device]     = (int)numUDMouseSens.Value;
			FlashAt[Device]                    = (int)nUDflashLED.Value;
			SXDeadzone[Device]                 = (double)nUDSX.Value;
			SZDeadzone[Device]                 = (double)nUDSZ.Value;
			MouseAccel[Device]                 = cBMouseAccel.Checked;
			DinputOnly[Device]                 = cBDinput.Checked;
			StartTouchpadOff[Device]           = cbStartTouchpadOff.Checked;
			UseTPforControls[Device]           = rBTPControls.Checked;
			UseSAforMouse[Device]              = rBSAMouse.Checked;
			DS4Mapping                         = cBControllerInput.Checked;
			LSCurve[Device]                    = (int)Math.Round(nUDLSCurve.Value, 0);
			RSCurve[Device]                    = (int)Math.Round(nUDRSCurve.Value, 0);
			List<string> pactions              = (from ListViewItem lvi in lVActions.Items where lvi.Checked select lvi.Text).ToList();
			ProfileActions[Device]             = pactions;
			pnlTPMouse.Visible                 = rBTPMouse.Checked;
			pnlSAMouse.Visible                 = rBSAMouse.Checked;
			fLPTiltControls.Visible            = rBSAControls.Checked;
			fLPTouchSwipe.Visible              = rBTPControls.Checked;

			GyroSensitivity[Device] = (int)Math.Round(nUDGyroSensitivity.Value, 0);
			int invert = 0;
			if (cBGyroInvertX.Checked)
			{
				invert += 2;
			}
			if (cBGyroInvertY.Checked)
			{
				invert += 1;
			}
			GyroInvert[Device] = invert;

			List<int> ints = new List<int>();
			for (int i = 0; i < cMGyroTriggers.Items.Count - 1; i++)
			{
				if (((ToolStripMenuItem)cMGyroTriggers.Items[i]).Checked)
				{
					ints.Add(i);
				}
			}
			if (ints.Count == 0)
			{
				ints.Add(-1);
			}
			SATriggers[Device] = string.Join(",", ints);
			btnRainbow.Image = nUDRainbow.Value == 0 ? greyscale : colored;
		}
Ejemplo n.º 12
0
		public static bool TryParse(string value, ref DS4Color ds4color)
		{
			try
			{
				string[] ss = value.Split(',');
				return byte.TryParse(ss[0], out ds4color.red) && byte.TryParse(ss[1], out ds4color.green) && byte.TryParse(ss[2], out ds4color.blue);
			}
			catch
			{
				return false;
			}
		}
Ejemplo n.º 13
0
		public void LagFlashWarning(int ind, bool on)
		{
			if (on)
			{
				lag[ind] = true;
				LogDebug(Resources.LatencyOverTen.Replace("*number*", (ind + 1).ToString()), true);

				if (!Global.FlashWhenLate)
				{
					return;
				}

				DS4Color color = new DS4Color { red = 50, green = 0, blue = 0 };
				DS4LightBar.forcedColor[ind] = color;
				DS4LightBar.forcedFlash[ind] = 2;
				DS4LightBar.forcelight[ind] = true;
			}
			else
			{
				lag[ind] = false;
				LogDebug(Resources.LatencyNotOverTen.Replace("*number*", (ind + 1).ToString()));
				DS4LightBar.forcelight[ind] = false;
				DS4LightBar.forcedFlash[ind] = 0;
			}
		}