示例#1
0
        public static byte getByteMapping(DS4Controls control, DS4State cState)
        {
            switch (control)
            {
            case DS4Controls.Share: return((byte)(cState.Share ? 255 : 0));

            case DS4Controls.Options: return((byte)(cState.Options ? 255 : 0));

            case DS4Controls.L1: return((byte)(cState.L1 ? 255 : 0));

            case DS4Controls.R1: return((byte)(cState.R1 ? 255 : 0));

            case DS4Controls.L3: return((byte)(cState.L3 ? 255 : 0));

            case DS4Controls.R3: return((byte)(cState.R3 ? 255 : 0));

            case DS4Controls.DpadUp: return((byte)(cState.DpadUp ? 255 : 0));

            case DS4Controls.DpadDown: return((byte)(cState.DpadDown ? 255 : 0));

            case DS4Controls.DpadLeft: return((byte)(cState.DpadLeft ? 255 : 0));

            case DS4Controls.DpadRight: return((byte)(cState.DpadRight ? 255 : 0));

            case DS4Controls.PS: return((byte)(cState.PS ? 255 : 0));

            case DS4Controls.Cross: return((byte)(cState.Cross ? 255 : 0));

            case DS4Controls.Square: return((byte)(cState.Square ? 255 : 0));

            case DS4Controls.Triangle: return((byte)(cState.Triangle ? 255 : 0));

            case DS4Controls.Circle: return((byte)(cState.Circle ? 255 : 0));

            case DS4Controls.LXNeg: return(cState.LX);

            case DS4Controls.LYNeg: return(cState.LY);

            case DS4Controls.RXNeg: return(cState.RX);

            case DS4Controls.RYNeg: return(cState.RY);

            case DS4Controls.LXPos: return((byte)(cState.LX - 127 < 0 ? 0 : (cState.LX - 127)));

            case DS4Controls.LYPos: return((byte)(cState.LY - 123 < 0 ? 0 : (cState.LY - 123)));

            case DS4Controls.RXPos: return((byte)(cState.RX - 125 < 0 ? 0 : (cState.RX - 125)));

            case DS4Controls.RYPos: return((byte)(cState.RY - 127 < 0 ? 0 : (cState.RY - 127)));

            case DS4Controls.L2: return(cState.L2);

            case DS4Controls.R2: return(cState.R2);
            }
            return(0);
        }
示例#2
0
        public static bool getBoolMapping(DS4Controls control, DS4State cState)
        {
            switch (control)
            {
            case DS4Controls.Share: return(cState.Share);

            case DS4Controls.Options: return(cState.Options);

            case DS4Controls.L1: return(cState.L1);

            case DS4Controls.R1: return(cState.R1);

            case DS4Controls.L3: return(cState.L3);

            case DS4Controls.R3: return(cState.R3);

            case DS4Controls.DpadUp: return(cState.DpadUp);

            case DS4Controls.DpadDown: return(cState.DpadDown);

            case DS4Controls.DpadLeft: return(cState.DpadLeft);

            case DS4Controls.DpadRight: return(cState.DpadRight);

            case DS4Controls.PS: return(cState.PS);

            case DS4Controls.Cross: return(cState.Cross);

            case DS4Controls.Square: return(cState.Square);

            case DS4Controls.Triangle: return(cState.Triangle);

            case DS4Controls.Circle: return(cState.Circle);

            case DS4Controls.LXNeg: return(cState.LX < 55);

            case DS4Controls.LYNeg: return(cState.LY < 55);

            case DS4Controls.RXNeg: return(cState.RX < 55);

            case DS4Controls.RYNeg: return(cState.RY < 55);

            case DS4Controls.LXPos: return(cState.LX > 200);

            case DS4Controls.LYPos: return(cState.LY > 200);

            case DS4Controls.RXPos: return(cState.RX > 200);

            case DS4Controls.RYPos: return(cState.RY > 200);

            case DS4Controls.L2: return(cState.L2 > 100);

            case DS4Controls.R2: return(cState.R2 > 100);
            }
            return(false);
        }
示例#3
0
        public static int DS4ControltoInt(DS4Controls ctrl)
        {
            switch (ctrl)
            {
            case DS4Controls.Cross: return(261);

            case DS4Controls.Circle: return(262);

            case DS4Controls.Square: return(263);

            case DS4Controls.Triangle: return(264);

            case DS4Controls.Options: return(265);

            case DS4Controls.Share: return(266);

            case DS4Controls.DpadUp: return(267);

            case DS4Controls.DpadDown: return(268);

            case DS4Controls.DpadLeft: return(269);

            case DS4Controls.DpadRight: return(270);

            case DS4Controls.PS: return(271);

            case DS4Controls.L1: return(272);

            case DS4Controls.R1: return(273);

            case DS4Controls.L2: return(274);

            case DS4Controls.R2: return(275);

            case DS4Controls.L3: return(276);

            case DS4Controls.R3: return(277);

            case DS4Controls.LXPos: return(278);

            case DS4Controls.LXNeg: return(279);

            case DS4Controls.LYPos: return(280);

            case DS4Controls.LYNeg: return(281);

            case DS4Controls.RXPos: return(282);

            case DS4Controls.RXNeg: return(283);

            case DS4Controls.RYPos: return(284);

            case DS4Controls.RYNeg: return(285);
            }
            return(0);
        }
示例#4
0
        public static string DS4ControltoX360(DS4Controls ctrl)
        {
            switch (ctrl)
            {
            case DS4Controls.Cross: return("A Button");

            case DS4Controls.Circle: return("B Button");

            case DS4Controls.Square: return("X Button");

            case DS4Controls.Triangle: return("Y Button");

            case DS4Controls.Options: return("Start");

            case DS4Controls.Share: return("Back");

            case DS4Controls.DpadUp: return("Up Button");

            case DS4Controls.DpadDown: return("Down Button");

            case DS4Controls.DpadLeft: return("Left Button");

            case DS4Controls.DpadRight: return("Right Button");

            case DS4Controls.PS: return("Guide");

            case DS4Controls.L1: return("Left Bumper");

            case DS4Controls.R1: return("Right Bumper");

            case DS4Controls.L2: return("Left Trigger");

            case DS4Controls.R2: return("Right Trigger");

            case DS4Controls.L3: return("Left Stick");

            case DS4Controls.R3: return("Right Stick");

            case DS4Controls.LXPos: return("LS Right");

            case DS4Controls.LXNeg: return("LS Left");

            case DS4Controls.LYPos: return("LS Down");

            case DS4Controls.LYNeg: return("LS Up");

            case DS4Controls.RXPos: return("RS Right");

            case DS4Controls.RXNeg: return("RS Left");

            case DS4Controls.RYPos: return("RS Down");

            case DS4Controls.RYNeg: return("RS Up");
            }
            return("None");
        }
示例#5
0
        //Returns false for any bool,
        //if control is one of the xy axis returns 127
        //if its a trigger returns 0
        public static void resetToDefaultValue(DS4Controls control, ref DS4State cState)
        {
            switch (control)
            {
            case DS4Controls.Share: cState.Share = false; break;

            case DS4Controls.Options: cState.Options = false; break;

            case DS4Controls.L1: cState.L1 = false; break;

            case DS4Controls.R1: cState.R1 = false; break;

            case DS4Controls.L3: cState.L3 = false; break;

            case DS4Controls.R3: cState.R3 = false; break;

            case DS4Controls.DpadUp: cState.DpadUp = false; break;

            case DS4Controls.DpadDown: cState.DpadDown = false; break;

            case DS4Controls.DpadLeft: cState.DpadLeft = false; break;

            case DS4Controls.DpadRight: cState.DpadRight = false; break;

            case DS4Controls.PS: cState.PS = false; break;

            case DS4Controls.Cross: cState.Cross = false; break;

            case DS4Controls.Square: cState.Square = false; break;

            case DS4Controls.Triangle: cState.Triangle = false; break;

            case DS4Controls.Circle: cState.Circle = false; break;

            case DS4Controls.LXNeg: cState.LX = 127; break;

            case DS4Controls.LYNeg: cState.LY = 127; break;

            case DS4Controls.RXNeg: cState.RX = 127; break;

            case DS4Controls.RYNeg: cState.RY = 127; break;

            case DS4Controls.LXPos: cState.LX = 127; break;

            case DS4Controls.LYPos: cState.LY = 127; break;

            case DS4Controls.RXPos: cState.RX = 127; break;

            case DS4Controls.RYPos: cState.RY = 127; break;

            case DS4Controls.L2: cState.L2 = 0; break;

            case DS4Controls.R2: cState.R2 = 0; break;
            }
        }
示例#6
0
 public X360Controls GetCustomButton(DS4Controls controlName)
 {
     if (customMapButtons.ContainsKey(controlName))
     {
         return(customMapButtons[controlName]);
     }
     else
     {
         return(0);
     }
 }
示例#7
0
 public UInt16 GetCustomKey(DS4Controls controlName)
 {
     if (customMapKeys.ContainsKey(controlName))
     {
         return(customMapKeys[controlName]);
     }
     else
     {
         return(0);
     }
 }
示例#8
0
 public virtual void touchButtonUp(object sender, TouchpadEventArgs arg)
 {
     pushed    = DS4Controls.None;
     upperDown = leftDown = rightDown = multiDown = false;
     dev.setRumble(0, 0);
     dev.getCurrentState(s);
     if (s.Touch1 || s.Touch2)
     {
         synthesizeMouseButtons();
     }
 }
示例#9
0
 public DS4KeyType GetCustomKeyType(DS4Controls controlName)
 {
     if (customMapKeyTypes.ContainsKey(controlName))
     {
         return(customMapKeyTypes[controlName]);
     }
     else
     {
         return(0);
     }
 }
示例#10
0
        bool mapTouchPad(DS4Controls padControl, bool release = false)
        {
            ushort key = Global.getCustomKey(padControl);

            if (key == 0)
            {
                return(false);
            }
            else
            {
                DS4KeyType keyType = Global.getCustomKeyType(padControl);
                if (!release)
                {
                    if (keyType.HasFlag(DS4KeyType.ScanCode))
                    {
                        performSCKeyPress(key);
                    }
                    else
                    {
                        performKeyPress(key);
                    }
                }
                else
                if (!keyType.HasFlag(DS4KeyType.Repeat))
                {
                    if (keyType.HasFlag(DS4KeyType.ScanCode))
                    {
                        performSCKeyRelease(key);
                    }
                    else
                    {
                        performKeyRelease(key);
                    }
                }
                return(true);
            }
        }
示例#11
0
        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;
            }
        }
示例#12
0
文件: Mouse.cs 项目: Conist/ds4-tool
 bool mapTouchPad(DS4Controls padControl, bool release = false)
 {
     ushort key = Global.getCustomKey(padControl);
     if (key == 0)
         return false;
     else
     {
         DS4KeyType keyType = Global.getCustomKeyType(padControl);
         if (!release)
             if (keyType.HasFlag(DS4KeyType.ScanCode))
                 performSCKeyPress(key);
             else performKeyPress(key);
         else
             if (!keyType.HasFlag(DS4KeyType.Repeat))
                 if (keyType.HasFlag(DS4KeyType.ScanCode))
                     performSCKeyRelease(key);
                 else performKeyRelease(key);
         return true;
     }
 }
示例#13
0
		public DS4ControlSettings(DS4Controls ctrl)
		{
			control = ctrl;
		}
示例#14
0
		public static byte getByteMapping(int device, DS4Controls control, DS4State cState, DS4StateExposed eState, Mouse tp)
		{
			double SXD = Global.SXDeadzone[device];
			double SZD = Global.SZDeadzone[device];
			bool sOff = Global.UseSAforMouse[device];
			switch (control)
			{
				case DS4Controls.Share:
					return (byte)(cState.Share ? 255 : 0);
				case DS4Controls.Options:
					return (byte)(cState.Options ? 255 : 0);
				case DS4Controls.L1:
					return (byte)(cState.L1 ? 255 : 0);
				case DS4Controls.R1:
					return (byte)(cState.R1 ? 255 : 0);
				case DS4Controls.L3:
					return (byte)(cState.L3 ? 255 : 0);
				case DS4Controls.R3:
					return (byte)(cState.R3 ? 255 : 0);
				case DS4Controls.DpadUp:
					return (byte)(cState.DpadUp ? 255 : 0);
				case DS4Controls.DpadDown:
					return (byte)(cState.DpadDown ? 255 : 0);
				case DS4Controls.DpadLeft:
					return (byte)(cState.DpadLeft ? 255 : 0);
				case DS4Controls.DpadRight:
					return (byte)(cState.DpadRight ? 255 : 0);
				case DS4Controls.PS:
					return (byte)(cState.PS ? 255 : 0);
				case DS4Controls.Cross:
					return (byte)(cState.Cross ? 255 : 0);
				case DS4Controls.Square:
					return (byte)(cState.Square ? 255 : 0);
				case DS4Controls.Triangle:
					return (byte)(cState.Triangle ? 255 : 0);
				case DS4Controls.Circle:
					return (byte)(cState.Circle ? 255 : 0);
				case DS4Controls.TouchLeft:
					return (byte)((tp != null) && tp.leftDown ? 255 : 0);
				case DS4Controls.TouchRight:
					return (byte)((tp != null) && tp.rightDown ? 255 : 0);
				case DS4Controls.TouchMulti:
					return (byte)((tp != null) && tp.multiDown ? 255 : 0);
				case DS4Controls.TouchUpper:
					return (byte)((tp != null) && tp.upperDown ? 255 : 0);
				case DS4Controls.LXNeg:
					return (byte)(cState.LX - 127.5f > 0 ? 0 : -(cState.LX - 127.5f) * 2);
				case DS4Controls.LYNeg:
					return (byte)(cState.LY - 127.5f > 0 ? 0 : -(cState.LY - 127.5f) * 2);
				case DS4Controls.RXNeg:
					return (byte)(cState.RX - 127.5f > 0 ? 0 : -(cState.RX - 127.5f) * 2);
				case DS4Controls.RYNeg:
					return (byte)(cState.RY - 127.5f > 0 ? 0 : -(cState.RY - 127.5f) * 2);
				case DS4Controls.LXPos:
					return (byte)(cState.LX - 127.5f < 0 ? 0 : (cState.LX - 127.5f) * 2);
				case DS4Controls.LYPos:
					return (byte)(cState.LY - 127.5f < 0 ? 0 : (cState.LY - 127.5f) * 2);
				case DS4Controls.RXPos:
					return (byte)(cState.RX - 127.5f < 0 ? 0 : (cState.RX - 127.5f) * 2);
				case DS4Controls.RYPos:
					return (byte)(cState.RY - 127.5f < 0 ? 0 : (cState.RY - 127.5f) * 2);
				case DS4Controls.L2:
					return cState.L2;
				case DS4Controls.R2:
					return cState.R2;
				case DS4Controls.GyroXPos:
					return (byte)(!sOff && (Global.SXSens[device] * eState.GyroX > SXD * 10) ? Math.Min(255, Global.SXSens[device] * eState.GyroX * 2) : 0);
				case DS4Controls.GyroXNeg:
					return (byte)(!sOff && (Global.SXSens[device] * eState.GyroX < -SXD * 10) ? Math.Min(255, Global.SXSens[device] * -eState.GyroX * 2) : 0);
				case DS4Controls.GyroZPos:
					return (byte)(!sOff && (Global.SZSens[device] * eState.GyroZ > SZD * 10) ? Math.Min(255, Global.SZSens[device] * eState.GyroZ * 2) : 0);
				case DS4Controls.GyroZNeg:
					return (byte)(!sOff && (Global.SZSens[device] * eState.GyroZ < -SZD * 10) ? Math.Min(255, Global.SZSens[device] * -eState.GyroZ * 2) : 0);
				case DS4Controls.SwipeUp:
					return (byte)(tp != null ? tp.swipeUpB : 0);
				case DS4Controls.SwipeDown:
					return (byte)(tp != null ? tp.swipeDownB : 0);
				case DS4Controls.SwipeLeft:
					return (byte)(tp != null ? tp.swipeLeftB : 0);
				case DS4Controls.SwipeRight:
					return (byte)(tp != null ? tp.swipeRightB : 0);
			}
			return 0;
		}
示例#15
0
 public ControlSettings(DS4Controls ctrl)
 {
     control = ctrl;
 }
示例#16
0
		private static async void PlayMacro(int device, bool[] macrocontrol, string macro, DS4Controls control, DS4KeyType keyType)
		{
			if (macro.StartsWith("164/9/9/164", StringComparison.Ordinal) || macro.StartsWith("18/9/9/18", StringComparison.Ordinal))
			{
				int wait = 1000;
				if (!string.IsNullOrEmpty(macro))
				{
					string[] skeys = macro.Split('/');
					ushort delay;
					if (ushort.TryParse(skeys[skeys.Length - 1], out delay) && (delay > 300))
					{
						wait = delay - 300;
					}
				}
				AltTabSwapping(wait, device);
				if (control != DS4Controls.None)
				{
					macrodone[DS4ControltoInt(control)] = true;
				}
			}
			else
			{
				string[] skeys;
				int[] keys;
				if (!string.IsNullOrEmpty(macro))
				{
					skeys = macro.Split('/');
					keys = new int[skeys.Length];
				}
				else
				{
					skeys = new string[0];
					keys = new int[0];
				}
				for (int i = 0; i < keys.Length; i++)
				{
					keys[i] = int.Parse(skeys[i]);
				}
				bool[] keydown = new bool[286];
				if ((control == DS4Controls.None) || !macrodone[DS4ControltoInt(control)])
				{
					if (control != DS4Controls.None)
					{
						macrodone[DS4ControltoInt(control)] = true;
					}
					foreach (int i in keys)
					{
						if (i >= 1000000000)
						{
							string lb = i.ToString().Substring(1);
							if (i > 1000000000)
							{
								byte r = (byte)(int.Parse(lb[0].ToString()) * 100 + int.Parse(lb[1].ToString()) * 10 + int.Parse(lb[2].ToString()));
								byte g = (byte)(int.Parse(lb[3].ToString()) * 100 + int.Parse(lb[4].ToString()) * 10 + int.Parse(lb[5].ToString()));
								byte b = (byte)(int.Parse(lb[6].ToString()) * 100 + int.Parse(lb[7].ToString()) * 10 + int.Parse(lb[8].ToString()));
								DS4LightBar.forcelight[device] = true;
								DS4LightBar.forcedFlash[device] = 0;
								DS4LightBar.forcedColor[device] = new DS4Color(r, g, b);
							}
							else
							{
								DS4LightBar.forcedFlash[device] = 0;
								DS4LightBar.forcelight[device] = false;
							}
						}
						else if (i >= 1000000)
						{
							DS4Device d = Program.RootHub.DS4Controllers[device];
							string r = i.ToString().Substring(1);
							byte heavy = (byte)(int.Parse(r[0].ToString()) * 100 + int.Parse(r[1].ToString()) * 10 + int.Parse(r[2].ToString()));
							byte light = (byte)(int.Parse(r[3].ToString()) * 100 + int.Parse(r[4].ToString()) * 10 + int.Parse(r[5].ToString()));
							d.SetRumble(light, heavy);
						}
						else if (i >= 300) //ints over 300 used to delay
						{
							await Task.Delay(i - 300);
						}
						else if (!keydown[i])
						{
							switch (i)
							{
								case 256:
									InputMethods.MouseEvent(InputMethods.MOUSEEVENTF_LEFTDOWN); //anything above 255 is not a keyvalue
									break;
								case 257:
									InputMethods.MouseEvent(InputMethods.MOUSEEVENTF_RIGHTDOWN);
									break;
								case 258:
									InputMethods.MouseEvent(InputMethods.MOUSEEVENTF_MIDDLEDOWN);
									break;
								case 259:
									InputMethods.MouseEvent(InputMethods.MOUSEEVENTF_XBUTTONDOWN, 1);
									break;
								case 260:
									InputMethods.MouseEvent(InputMethods.MOUSEEVENTF_XBUTTONDOWN, 2);
									break;
								case 261:
									macroControl[0] = true;
									break;
								case 262:
									macroControl[1] = true;
									break;
								case 263:
									macroControl[2] = true;
									break;
								case 264:
									macroControl[3] = true;
									break;
								case 265:
									macroControl[4] = true;
									break;
								case 266:
									macroControl[5] = true;
									break;
								case 267:
									macroControl[6] = true;
									break;
								case 268:
									macroControl[7] = true;
									break;
								case 269:
									macroControl[8] = true;
									break;
								case 270:
									macroControl[9] = true;
									break;
								case 271:
									macroControl[10] = true;
									break;
								case 272:
									macroControl[11] = true;
									break;
								case 273:
									macroControl[12] = true;
									break;
								case 274:
									macroControl[13] = true;
									break;
								case 275:
									macroControl[14] = true;
									break;
								case 276:
									macroControl[15] = true;
									break;
								case 277:
									macroControl[16] = true;
									break;
								case 278:
									macroControl[17] = true;
									break;
								case 279:
									macroControl[18] = true;
									break;
								case 280:
									macroControl[19] = true;
									break;
								case 281:
									macroControl[20] = true;
									break;
								case 282:
									macroControl[21] = true;
									break;
								case 283:
									macroControl[22] = true;
									break;
								case 284:
									macroControl[23] = true;
									break;
								case 285:
									macroControl[24] = true;
									break;
								default:
									if (keyType.HasFlag(DS4KeyType.ScanCode))
									{
										InputMethods.PerformScKeyPress((ushort)i);
									}
									else
									{
										InputMethods.PerformKeyPress((ushort)i);
									}
									break;
							}
							keydown[i] = true;
						}
						else
						{
							switch (i)
							{
								case 256:
									InputMethods.MouseEvent(InputMethods.MOUSEEVENTF_LEFTUP); //anything above 255 is not a keyvalue
									break;
								case 257:
									InputMethods.MouseEvent(InputMethods.MOUSEEVENTF_RIGHTUP);
									break;
								case 258:
									InputMethods.MouseEvent(InputMethods.MOUSEEVENTF_MIDDLEUP);
									break;
								case 259:
									InputMethods.MouseEvent(InputMethods.MOUSEEVENTF_XBUTTONUP, 1);
									break;
								case 260:
									InputMethods.MouseEvent(InputMethods.MOUSEEVENTF_XBUTTONUP, 2);
									break;
								case 261:
									macroControl[0] = false;
									break;
								case 262:
									macroControl[1] = false;
									break;
								case 263:
									macroControl[2] = false;
									break;
								case 264:
									macroControl[3] = false;
									break;
								case 265:
									macroControl[4] = false;
									break;
								case 266:
									macroControl[5] = false;
									break;
								case 267:
									macroControl[6] = false;
									break;
								case 268:
									macroControl[7] = false;
									break;
								case 269:
									macroControl[8] = false;
									break;
								case 270:
									macroControl[9] = false;
									break;
								case 271:
									macroControl[10] = false;
									break;
								case 272:
									macroControl[11] = false;
									break;
								case 273:
									macroControl[12] = false;
									break;
								case 274:
									macroControl[13] = false;
									break;
								case 275:
									macroControl[14] = false;
									break;
								case 276:
									macroControl[15] = false;
									break;
								case 277:
									macroControl[16] = false;
									break;
								case 278:
									macroControl[17] = false;
									break;
								case 279:
									macroControl[18] = false;
									break;
								case 280:
									macroControl[19] = false;
									break;
								case 281:
									macroControl[20] = false;
									break;
								case 282:
									macroControl[21] = false;
									break;
								case 283:
									macroControl[22] = false;
									break;
								case 284:
									macroControl[23] = false;
									break;
								case 285:
									macroControl[24] = false;
									break;
								default:
									if (keyType.HasFlag(DS4KeyType.ScanCode))
									{
										InputMethods.PerformScKeyRelease((ushort)i);
									}
									else
									{
										InputMethods.PerformKeyRelease((ushort)i);
									}
									break;
							}
							keydown[i] = false;
						}
					}
					for (ushort i = 0; i < keydown.Length; i++)
					{
						if (!keydown[i])
						{
							continue;
						}

						switch (i)
						{
							case 256:
								InputMethods.MouseEvent(InputMethods.MOUSEEVENTF_LEFTUP); //anything above 255 is not a keyvalue
								break;
							case 257:
								InputMethods.MouseEvent(InputMethods.MOUSEEVENTF_RIGHTUP);
								break;
							case 258:
								InputMethods.MouseEvent(InputMethods.MOUSEEVENTF_MIDDLEUP);
								break;
							case 259:
								InputMethods.MouseEvent(InputMethods.MOUSEEVENTF_XBUTTONUP, 1);
								break;
							case 260:
								InputMethods.MouseEvent(InputMethods.MOUSEEVENTF_XBUTTONUP, 2);
								break;
							case 261:
								macroControl[0] = false;
								break;
							case 262:
								macroControl[1] = false;
								break;
							case 263:
								macroControl[2] = false;
								break;
							case 264:
								macroControl[3] = false;
								break;
							case 265:
								macroControl[4] = false;
								break;
							case 266:
								macroControl[5] = false;
								break;
							case 267:
								macroControl[6] = false;
								break;
							case 268:
								macroControl[7] = false;
								break;
							case 269:
								macroControl[8] = false;
								break;
							case 270:
								macroControl[9] = false;
								break;
							case 271:
								macroControl[10] = false;
								break;
							case 272:
								macroControl[11] = false;
								break;
							case 273:
								macroControl[12] = false;
								break;
							case 274:
								macroControl[13] = false;
								break;
							case 275:
								macroControl[14] = false;
								break;
							case 276:
								macroControl[15] = false;
								break;
							case 277:
								macroControl[16] = false;
								break;
							case 278:
								macroControl[17] = false;
								break;
							case 279:
								macroControl[18] = false;
								break;
							case 280:
								macroControl[19] = false;
								break;
							case 281:
								macroControl[20] = false;
								break;
							case 282:
								macroControl[21] = false;
								break;
							case 283:
								macroControl[22] = false;
								break;
							case 284:
								macroControl[23] = false;
								break;
							case 285:
								macroControl[24] = false;
								break;
							default:
								if (keyType.HasFlag(DS4KeyType.ScanCode))
								{
									InputMethods.PerformScKeyRelease(i);
								}
								else
								{
									InputMethods.PerformKeyRelease(i);
								}
								break;
						}
					}
					DS4LightBar.forcedFlash[device] = 0;
					DS4LightBar.forcelight[device] = false;
					Program.RootHub.DS4Controllers[device].SetRumble(0, 0);
					if (!keyType.HasFlag(DS4KeyType.HoldMacro))
					{
						return;
					}
					await Task.Delay(50);
					if (control != DS4Controls.None)
					{
						macrodone[DS4ControltoInt(control)] = false;
					}
				}
			}
		}
示例#17
0
		private static void getMouseWheelMapping(int device, DS4Controls control, DS4State cState, DS4StateExposed eState, Mouse tp, bool down)
		{
			DateTime now = DateTime.UtcNow;
			if ((now < oldnow + TimeSpan.FromMilliseconds(10)) || pressagain)
			{
				return;
			}
			oldnow = now;
			InputMethods.MouseWheel((int)(getByteMapping(device, control, cState, eState, tp) / 51f * (down ? -1 : 1)), 0);
		}
示例#18
0
 public static byte getByteMapping(DS4Controls control, DS4State cState)
 {
     switch (control)
     {
         case DS4Controls.Share: return (byte)(cState.Share ? 255 : 0);
         case DS4Controls.Options: return (byte)(cState.Options ? 255 : 0);
         case DS4Controls.L1: return (byte)(cState.L1 ? 255 : 0);
         case DS4Controls.R1: return (byte)(cState.R1 ? 255 : 0);
         case DS4Controls.L3: return (byte)(cState.L3 ? 255 : 0);
         case DS4Controls.R3: return (byte)(cState.R3 ? 255 : 0);
         case DS4Controls.DpadUp: return (byte)(cState.DpadUp ? 255 : 0);
         case DS4Controls.DpadDown: return (byte)(cState.DpadDown ? 255 : 0);
         case DS4Controls.DpadLeft: return (byte)(cState.DpadLeft ? 255 : 0);
         case DS4Controls.DpadRight: return (byte)(cState.DpadRight ? 255 : 0);
         case DS4Controls.PS: return (byte)(cState.PS ? 255 : 0);
         case DS4Controls.Cross: return (byte)(cState.Cross ? 255 : 0);
         case DS4Controls.Square: return (byte)(cState.Square ? 255 : 0);
         case DS4Controls.Triangle: return (byte)(cState.Triangle ? 255 : 0);
         case DS4Controls.Circle: return (byte)(cState.Circle ? 255 : 0);
         case DS4Controls.LXNeg: return cState.LX;
         case DS4Controls.LYNeg: return cState.LY;
         case DS4Controls.RXNeg: return cState.RX;
         case DS4Controls.RYNeg: return cState.RY;
         case DS4Controls.LXPos: return (byte)(cState.LX - 127 < 0 ? 0 : (cState.LX - 127));
         case DS4Controls.LYPos: return (byte)(cState.LY - 123 < 0 ? 0 : (cState.LY - 123));
         case DS4Controls.RXPos: return (byte)(cState.RX - 125 < 0 ? 0 : (cState.RX - 125));
         case DS4Controls.RYPos: return (byte)(cState.RY - 127 < 0 ? 0 : (cState.RY - 127));
         case DS4Controls.L2: return cState.L2;
         case DS4Controls.R2: return cState.R2;
     }
     return 0;
 }
示例#19
0
		public static byte getXYAxisMapping(int device, DS4Controls control, DS4State cState, DS4StateExposed eState, Mouse tp, bool alt = false)
		{
			byte trueVal = 0;
			byte falseVal = 127;
			double SXD = Global.SXDeadzone[device];
			double SZD = Global.SZDeadzone[device];
			bool sOff = Global.UseSAforMouse[device];
			if (alt)
			{
				trueVal = 255;
			}
			switch (control)
			{
				case DS4Controls.Share:
					return cState.Share ? trueVal : falseVal;
				case DS4Controls.Options:
					return cState.Options ? trueVal : falseVal;
				case DS4Controls.L1:
					return cState.L1 ? trueVal : falseVal;
				case DS4Controls.R1:
					return cState.R1 ? trueVal : falseVal;
				case DS4Controls.L3:
					return cState.L3 ? trueVal : falseVal;
				case DS4Controls.R3:
					return cState.R3 ? trueVal : falseVal;
				case DS4Controls.DpadUp:
					return cState.DpadUp ? trueVal : falseVal;
				case DS4Controls.DpadDown:
					return cState.DpadDown ? trueVal : falseVal;
				case DS4Controls.DpadLeft:
					return cState.DpadLeft ? trueVal : falseVal;
				case DS4Controls.DpadRight:
					return cState.DpadRight ? trueVal : falseVal;
				case DS4Controls.PS:
					return cState.PS ? trueVal : falseVal;
				case DS4Controls.Cross:
					return cState.Cross ? trueVal : falseVal;
				case DS4Controls.Square:
					return cState.Square ? trueVal : falseVal;
				case DS4Controls.Triangle:
					return cState.Triangle ? trueVal : falseVal;
				case DS4Controls.Circle:
					return cState.Circle ? trueVal : falseVal;
				case DS4Controls.TouchLeft:
					return (tp != null) && tp.leftDown ? trueVal : falseVal;
				case DS4Controls.TouchRight:
					return (tp != null) && tp.rightDown ? trueVal : falseVal;
				case DS4Controls.TouchMulti:
					return (tp != null) && tp.multiDown ? trueVal : falseVal;
				case DS4Controls.TouchUpper:
					return (tp != null) && tp.upperDown ? trueVal : falseVal;
				case DS4Controls.L2:
					if (alt)
					{
						return (byte)(127.5f + cState.L2 / 2f);
					}
					return (byte)(127.5f - cState.L2 / 2f);
				case DS4Controls.R2:
					if (alt)
					{
						return (byte)(127.5f + cState.R2 / 2f);
					}
					return (byte)(127.5f - cState.R2 / 2f);
				case DS4Controls.SwipeUp:
					if (alt)
					{
						return (byte)(tp != null ? 127.5f + tp.swipeUpB / 2f : 0);
					}
					return (byte)(tp != null ? 127.5f - tp.swipeUpB / 2f : 0);
				case DS4Controls.SwipeDown:
					if (alt)
					{
						return (byte)(tp != null ? 127.5f + tp.swipeDownB / 2f : 0);
					}
					return (byte)(tp != null ? 127.5f - tp.swipeDownB / 2f : 0);
				case DS4Controls.SwipeLeft:
					if (alt)
					{
						return (byte)(tp != null ? 127.5f + tp.swipeLeftB / 2f : 0);
					}
					return (byte)(tp != null ? 127.5f - tp.swipeLeftB / 2f : 0);
				case DS4Controls.SwipeRight:
					if (alt)
					{
						return (byte)(tp != null ? 127.5f + tp.swipeRightB / 2f : 0);
					}
					return (byte)(tp != null ? 127.5f - tp.swipeRightB / 2f : 0);
				case DS4Controls.GyroXPos:
					if (!sOff && (eState.GyroX > SXD * 10))
					{
						if (alt)
						{
							return (byte)Math.Min(255, 127 + Global.SXSens[device] * eState.GyroX);
						}
						return (byte)Math.Max(0, 127 - Global.SXSens[device] * eState.GyroX);
					}
					return falseVal;
				case DS4Controls.GyroXNeg:
					if (!sOff && (eState.GyroX < -SXD * 10))
					{
						if (alt)
						{
							return (byte)Math.Min(255, 127 + Global.SXSens[device] * -eState.GyroX);
						}
						return (byte)Math.Max(0, 127 - Global.SXSens[device] * -eState.GyroX);
					}
					return falseVal;
				case DS4Controls.GyroZPos:
					if (!sOff && (eState.GyroZ > SZD * 10))
					{
						if (alt)
						{
							return (byte)Math.Min(255, 127 + Global.SZSens[device] * eState.GyroZ);
						}
						return (byte)Math.Max(0, 127 - Global.SZSens[device] * eState.GyroZ);
					}
					return falseVal;
				case DS4Controls.GyroZNeg:
					if (sOff || !(eState.GyroZ < -SZD * 10))
					{
						return falseVal;
					}
					return alt ? (byte)Math.Min(255, 127 + Global.SZSens[device] * -eState.GyroZ) : (byte)Math.Max(0, 127 - Global.SZSens[device] * -eState.GyroZ);
			}
			if (!alt)
			{
				switch (control)
				{
					case DS4Controls.LXNeg:
						return cState.LX;
					case DS4Controls.LYNeg:
						return cState.LY;
					case DS4Controls.RXNeg:
						return cState.RX;
					case DS4Controls.RYNeg:
						return cState.RY;
					case DS4Controls.LXPos:
						return (byte)(255 - cState.LX);
					case DS4Controls.LYPos:
						return (byte)(255 - cState.LY);
					case DS4Controls.RXPos:
						return (byte)(255 - cState.RX);
					case DS4Controls.RYPos:
						return (byte)(255 - cState.RY);
				}
			}
			else
			{
				switch (control)
				{
					case DS4Controls.LXNeg:
						return (byte)(255 - cState.LX);
					case DS4Controls.LYNeg:
						return (byte)(255 - cState.LY);
					case DS4Controls.RXNeg:
						return (byte)(255 - cState.RX);
					case DS4Controls.RYNeg:
						return (byte)(255 - cState.RY);
					case DS4Controls.LXPos:
						return cState.LX;
					case DS4Controls.LYPos:
						return cState.LY;
					case DS4Controls.RXPos:
						return cState.RX;
					case DS4Controls.RYPos:
						return cState.RY;
				}
			}
			return 0;
		}
示例#20
0
 public static DS4KeyType getCustomKeyType(DS4Controls controlName)
 {
     return(m_Config.GetCustomKeyType(controlName));
 }
示例#21
0
 public static bool getBoolMapping(DS4Controls control, DS4State cState)
 {
     switch (control)
     {
         case DS4Controls.Share: return cState.Share;
         case DS4Controls.Options: return cState.Options;
         case DS4Controls.L1: return cState.L1;
         case DS4Controls.R1: return cState.R1;
         case DS4Controls.L3: return cState.L3;
         case DS4Controls.R3: return cState.R3;
         case DS4Controls.DpadUp: return cState.DpadUp;
         case DS4Controls.DpadDown: return cState.DpadDown;
         case DS4Controls.DpadLeft: return cState.DpadLeft;
         case DS4Controls.DpadRight: return cState.DpadRight;
         case DS4Controls.PS: return cState.PS;
         case DS4Controls.Cross: return cState.Cross;
         case DS4Controls.Square: return cState.Square;
         case DS4Controls.Triangle: return cState.Triangle;
         case DS4Controls.Circle: return cState.Circle;
         case DS4Controls.LXNeg: return cState.LX < 55;
         case DS4Controls.LYNeg: return cState.LY < 55;
         case DS4Controls.RXNeg: return cState.RX < 55;
         case DS4Controls.RYNeg: return cState.RY < 55;
         case DS4Controls.LXPos: return cState.LX > 200;
         case DS4Controls.LYPos: return cState.LY > 200;
         case DS4Controls.RXPos: return cState.RX > 200;
         case DS4Controls.RYPos: return cState.RY > 200;
         case DS4Controls.L2: return cState.L2 > 100;
         case DS4Controls.R2: return cState.R2 > 100;
     }
     return false;
 }
示例#22
0
 public static ushort getCustomKey(DS4Controls controlName)
 {
     return(m_Config.GetCustomKey(controlName));
 }
示例#23
0
 public static X360Controls getCustomButton(DS4Controls controlName)
 {
     return(m_Config.GetCustomButton(controlName));
 }
示例#24
0
        public static byte getXYAxisMapping(DS4Controls control, DS4State cState, bool alt = false)
        {
            byte trueVal = 0;
            byte falseVal = 127;
            if (alt)
            {
                trueVal = 255;
            }
            switch (control)
            {
                case DS4Controls.Share: return (byte)(cState.Share ? trueVal : falseVal);
                case DS4Controls.Options: return (byte)(cState.Options ? trueVal : falseVal);
                case DS4Controls.L1: return (byte)(cState.L1 ? trueVal : falseVal);
                case DS4Controls.R1: return (byte)(cState.R1 ? trueVal : falseVal);
                case DS4Controls.L3: return (byte)(cState.L3 ? trueVal : falseVal);
                case DS4Controls.R3: return (byte)(cState.R3 ? trueVal : falseVal);
                case DS4Controls.DpadUp: return (byte)(cState.DpadUp ? trueVal : falseVal);
                case DS4Controls.DpadDown: return (byte)(cState.DpadDown ? trueVal : falseVal);
                case DS4Controls.DpadLeft: return (byte)(cState.DpadLeft ? trueVal : falseVal);
                case DS4Controls.DpadRight: return (byte)(cState.DpadRight ? trueVal : falseVal);
                case DS4Controls.PS: return (byte)(cState.PS ? trueVal : falseVal);
                case DS4Controls.Cross: return (byte)(cState.Cross ? trueVal : falseVal);
                case DS4Controls.Square: return (byte)(cState.Square ? trueVal : falseVal);
                case DS4Controls.Triangle: return (byte)(cState.Triangle ? trueVal : falseVal);
                case DS4Controls.Circle: return (byte)(cState.Circle ? trueVal : falseVal);
                case DS4Controls.L2: return (byte)(cState.L2 == 255 ? trueVal : falseVal);
                case DS4Controls.R2: return (byte)(cState.R2 == 255 ? trueVal : falseVal);
            }

            if (!alt)
            {
                switch (control)
                {
                    case DS4Controls.LXNeg: return cState.LX;
                    case DS4Controls.LYNeg: return cState.LY;
                    case DS4Controls.RXNeg: return cState.RX;
                    case DS4Controls.RYNeg: return cState.RY;
                    case DS4Controls.LXPos: return (byte)(255 - cState.LX);
                    case DS4Controls.LYPos: return (byte)(255 - cState.LY);
                    case DS4Controls.RXPos: return (byte)(255 - cState.RX);
                    case DS4Controls.RYPos: return (byte)(255 - cState.RY);
                }
            }
            else
            {
                switch (control)
                {
                    case DS4Controls.LXNeg: return (byte)(255 - cState.LX);
                    case DS4Controls.LYNeg: return (byte)(255 - cState.LY);
                    case DS4Controls.RXNeg: return (byte)(255 - cState.RX);
                    case DS4Controls.RYNeg: return (byte)(255 - cState.RY);
                    case DS4Controls.LXPos: return cState.LX;
                    case DS4Controls.LYPos: return cState.LY;
                    case DS4Controls.RXPos: return cState.RX;
                    case DS4Controls.RYPos: return cState.RY;
                }
            }
            return 0;
        }
示例#25
0
 public UInt16 GetCustomKey(DS4Controls controlName)
 {
     if (customMapKeys.ContainsKey(controlName))
         return customMapKeys[controlName];
     else return 0;
 }
示例#26
0
		public static int DS4ControltoInt(DS4Controls ctrl)
		{
			switch (ctrl)
			{
				case DS4Controls.Share:
					return 1;
				case DS4Controls.Options:
					return 2;
				case DS4Controls.L1:
					return 3;
				case DS4Controls.R1:
					return 4;
				case DS4Controls.L3:
					return 5;
				case DS4Controls.R3:
					return 6;
				case DS4Controls.DpadUp:
					return 7;
				case DS4Controls.DpadDown:
					return 8;
				case DS4Controls.DpadLeft:
					return 9;
				case DS4Controls.DpadRight:
					return 10;
				case DS4Controls.PS:
					return 11;
				case DS4Controls.Cross:
					return 12;
				case DS4Controls.Square:
					return 13;
				case DS4Controls.Triangle:
					return 14;
				case DS4Controls.Circle:
					return 15;
				case DS4Controls.LXNeg:
					return 16;
				case DS4Controls.LYNeg:
					return 17;
				case DS4Controls.RXNeg:
					return 18;
				case DS4Controls.RYNeg:
					return 19;
				case DS4Controls.LXPos:
					return 20;
				case DS4Controls.LYPos:
					return 21;
				case DS4Controls.RXPos:
					return 22;
				case DS4Controls.RYPos:
					return 23;
				case DS4Controls.L2:
					return 24;
				case DS4Controls.R2:
					return 25;
				case DS4Controls.TouchMulti:
					return 26;
				case DS4Controls.TouchLeft:
					return 27;
				case DS4Controls.TouchRight:
					return 28;
				case DS4Controls.TouchUpper:
					return 29;
				case DS4Controls.GyroXNeg:
					return 30;
				case DS4Controls.GyroXPos:
					return 31;
				case DS4Controls.GyroZNeg:
					return 32;
				case DS4Controls.GyroZPos:
					return 33;
			}
			return 0;
		}
示例#27
0
		private static bool IfAxisIsNotModified(int device, bool shift, DS4Controls dc)
		{
			return !shift && Global.GetDS4Action(device, dc.ToString(), false) == null;
		}
示例#28
0
 public X360Controls GetCustomButton(DS4Controls controlName)
 {
     if (customMapButtons.ContainsKey(controlName))
         return customMapButtons[controlName];
     else return 0;
 }
示例#29
0
		private static void EndMacro(int device, bool[] macrocontrol, string macro, DS4Controls control)
		{
			if ((macro.StartsWith("164/9/9/164", StringComparison.Ordinal) || macro.StartsWith("18/9/9/18", StringComparison.Ordinal)) && !altTabDone)
			{
				AltTabSwappingRelease();
			}
			if (control != DS4Controls.None)
			{
				macrodone[DS4ControltoInt(control)] = false;
			}
		}
示例#30
0
 public static ushort getCustomKey(DS4Controls controlName)
 {
     return m_Config.GetCustomKey(controlName);
 }
示例#31
0
		private static int getMouseMapping(int device, DS4Controls control, DS4State cState, DS4StateExposed eState, int mnum)
		{
			int controlnum = DS4ControltoInt(control);
			double SXD = Global.SXDeadzone[device];
			double SZD = Global.SZDeadzone[device];
			int deadzoneL = 3;
			int deadzoneR = 3;
			if (Global.LSDeadzone[device] >= 3)
			{
				deadzoneL = 0;
			}
			if (Global.RSDeadzone[device] >= 3)
			{
				deadzoneR = 0;
			}
			double value = 0;
			int speed = Global.ButtonMouseSensitivity[device] + 15;
			const double root = 1.002;
			const double divide = 10000d;
			//DateTime now = mousenow[mnum];
			switch (control)
			{
				case DS4Controls.LXNeg:
					if (cState.LX - 127.5f < -deadzoneL)
					{
						value = -(cState.LX - 127.5f) / 2550d * speed;
					}
					break;
				case DS4Controls.LXPos:
					if (cState.LX - 127.5f > deadzoneL)
					{
						value = (cState.LX - 127.5f) / 2550d * speed;
					}
					break;
				case DS4Controls.RXNeg:
					if (cState.RX - 127.5f < -deadzoneR)
					{
						value = -(cState.RX - 127.5f) / 2550d * speed;
					}
					break;
				case DS4Controls.RXPos:
					if (cState.RX - 127.5f > deadzoneR)
					{
						value = (cState.RX - 127.5f) / 2550d * speed;
					}
					break;
				case DS4Controls.LYNeg:
					if (cState.LY - 127.5f < -deadzoneL)
					{
						value = -(cState.LY - 127.5f) / 2550d * speed;
					}
					break;
				case DS4Controls.LYPos:
					if (cState.LY - 127.5f > deadzoneL)
					{
						value = (cState.LY - 127.5f) / 2550d * speed;
					}
					break;
				case DS4Controls.RYNeg:
					if (cState.RY - 127.5f < -deadzoneR)
					{
						value = -(cState.RY - 127.5f) / 2550d * speed;
					}
					break;
				case DS4Controls.RYPos:
					if (cState.RY - 127.5f > deadzoneR)
					{
						value = (cState.RY - 127.5f) / 2550d * speed;
					}
					break;
				case DS4Controls.Share:
					value = cState.Share ? Math.Pow(root + speed / divide, 100) - 1 : 0;
					break;
				case DS4Controls.Options:
					value = cState.Options ? Math.Pow(root + speed / divide, 100) - 1 : 0;
					break;
				case DS4Controls.L1:
					value = cState.L1 ? Math.Pow(root + speed / divide, 100) - 1 : 0;
					break;
				case DS4Controls.R1:
					value = cState.R1 ? Math.Pow(root + speed / divide, 100) - 1 : 0;
					break;
				case DS4Controls.L3:
					value = cState.L3 ? Math.Pow(root + speed / divide, 100) - 1 : 0;
					break;
				case DS4Controls.R3:
					value = cState.R3 ? Math.Pow(root + speed / divide, 100) - 1 : 0;
					break;
				case DS4Controls.DpadUp:
					value = cState.DpadUp ? Math.Pow(root + speed / divide, 100) - 1 : 0;
					break;
				case DS4Controls.DpadDown:
					value = cState.DpadDown ? Math.Pow(root + speed / divide, 100) - 1 : 0;
					break;
				case DS4Controls.DpadLeft:
					value = cState.DpadLeft ? Math.Pow(root + speed / divide, 100) - 1 : 0;
					break;
				case DS4Controls.DpadRight:
					value = cState.DpadRight ? Math.Pow(root + speed / divide, 100) - 1 : 0;
					break;
				case DS4Controls.PS:
					value = cState.PS ? Math.Pow(root + speed / divide, 100) - 1 : 0;
					break;
				case DS4Controls.Cross:
					value = cState.Cross ? Math.Pow(root + speed / divide, 100) - 1 : 0;
					break;
				case DS4Controls.Square:
					value = cState.Square ? Math.Pow(root + speed / divide, 100) - 1 : 0;
					break;
				case DS4Controls.Triangle:
					value = cState.Triangle ? Math.Pow(root + speed / divide, 100) - 1 : 0;
					break;
				case DS4Controls.Circle:
					value = cState.Circle ? Math.Pow(root + speed / divide, 100) - 1 : 0;
					break;
				case DS4Controls.L2:
					value = Math.Pow(root + speed / divide, cState.L2 / 2d) - 1;
					break;
				case DS4Controls.R2:
					value = Math.Pow(root + speed / divide, cState.R2 / 2d) - 1;
					break;
				case DS4Controls.GyroXPos:
					return (byte)(eState.GyroX > SXD * 10 ? Math.Pow(root + speed / divide, eState.GyroX) : 0);
				case DS4Controls.GyroXNeg:
					return (byte)(eState.GyroX < -SXD * 10 ? Math.Pow(root + speed / divide, -eState.GyroX) : 0);
				case DS4Controls.GyroZPos:
					return (byte)(eState.GyroZ > SZD * 10 ? Math.Pow(root + speed / divide, eState.GyroZ) : 0);
				case DS4Controls.GyroZNeg:
					return (byte)(eState.GyroZ < -SZD * 10 ? Math.Pow(root + speed / divide, -eState.GyroZ) : 0);

				case DS4Controls.None:
					break;
				case DS4Controls.TouchLeft:
					break;
				case DS4Controls.TouchUpper:
					break;
				case DS4Controls.TouchMulti:
					break;
				case DS4Controls.TouchRight:
					break;
				case DS4Controls.SwipeLeft:
					break;
				case DS4Controls.SwipeRight:
					break;
				case DS4Controls.SwipeUp:
					break;
				case DS4Controls.SwipeDown:
					break;

				default:
					throw new ArgumentOutOfRangeException(nameof(control), control, null);
			}
			bool LXChanged = Math.Abs(127 - cState.LX) < deadzoneL;
			bool LYChanged = Math.Abs(127 - cState.LY) < deadzoneL;
			bool RXChanged = Math.Abs(127 - cState.RX) < deadzoneR;
			bool RYChanged = Math.Abs(127 - cState.RY) < deadzoneR;
			bool contains = control.ToString().Contains("LX") ||
			                control.ToString().Contains("LY") ||
			                control.ToString().Contains("RX") ||
			                control.ToString().Contains("RY");

			if (Global.MouseAccel[device])
			{
				if (value > 0)
				{
					mcounter = 34;
					mouseaccel++;
				}
				if (mouseaccel == prevmouseaccel)
				{
					mcounter--;
				}
				if (mcounter <= 0)
				{
					mouseaccel = 0;
					mcounter = 34;
				}
				value *= 1 + Math.Min(20000, mouseaccel) / 10000d;
				prevmouseaccel = mouseaccel;
			}
			int intValue;
			if (mnum > 1)
			{
				if (((value > 0.0) && (horizontalRemainder > 0.0)) || ((value < 0.0) && (horizontalRemainder < 0.0)))
				{
					value += horizontalRemainder;
				}
				intValue = (int)value;
				horizontalRemainder = value - intValue;
			}
			else
			{
				if (((value > 0.0) && (verticalRemainder > 0.0)) || ((value < 0.0) && (verticalRemainder < 0.0)))
				{
					value += verticalRemainder;
				}
				intValue = (int)value;
				verticalRemainder = value - intValue;
			}
			return intValue;
		}
示例#32
0
 public DS4KeyType GetCustomKeyType(DS4Controls controlName)
 {
     if (customMapKeyTypes.ContainsKey(controlName))
         return customMapKeyTypes[controlName];
     else return 0;
 }
示例#33
0
		public static bool getBoolMapping(int device, DS4Controls control, DS4State cState, DS4StateExposed eState, Mouse tp)
		{
			bool sOff = Global.UseSAforMouse[device];
			switch (control)
			{
				case DS4Controls.Share:
					return cState.Share;
				case DS4Controls.Options:
					return cState.Options;
				case DS4Controls.L1:
					return cState.L1;
				case DS4Controls.R1:
					return cState.R1;
				case DS4Controls.L3:
					return cState.L3;
				case DS4Controls.R3:
					return cState.R3;
				case DS4Controls.DpadUp:
					return cState.DpadUp;
				case DS4Controls.DpadDown:
					return cState.DpadDown;
				case DS4Controls.DpadLeft:
					return cState.DpadLeft;
				case DS4Controls.DpadRight:
					return cState.DpadRight;
				case DS4Controls.PS:
					return cState.PS;
				case DS4Controls.Cross:
					return cState.Cross;
				case DS4Controls.Square:
					return cState.Square;
				case DS4Controls.Triangle:
					return cState.Triangle;
				case DS4Controls.Circle:
					return cState.Circle;
				case DS4Controls.TouchLeft:
					return tp != null ? tp.leftDown : false;
				case DS4Controls.TouchRight:
					return tp != null ? tp.rightDown : false;
				case DS4Controls.TouchMulti:
					return tp != null ? tp.multiDown : false;
				case DS4Controls.TouchUpper:
					return tp != null ? tp.upperDown : false;
				case DS4Controls.LXNeg:
					return cState.LX < 127 - 55;
				case DS4Controls.LYNeg:
					return cState.LY < 127 - 55;
				case DS4Controls.RXNeg:
					return cState.RX < 127 - 55;
				case DS4Controls.RYNeg:
					return cState.RY < 127 - 55;
				case DS4Controls.LXPos:
					return cState.LX > 127 + 55;
				case DS4Controls.LYPos:
					return cState.LY > 127 + 55;
				case DS4Controls.RXPos:
					return cState.RX > 127 + 55;
				case DS4Controls.RYPos:
					return cState.RY > 127 + 55;
				case DS4Controls.L2:
					return cState.L2 > 100;
				case DS4Controls.R2:
					return cState.R2 > 100;
				case DS4Controls.GyroXPos:
					return !sOff && Global.SXSens[device] * eState.GyroX > 67;
				case DS4Controls.GyroXNeg:
					return !sOff && Global.SXSens[device] * eState.GyroX < -67;
				case DS4Controls.GyroZPos:
					return !sOff && Global.SZSens[device] * eState.GyroZ > 67;
				case DS4Controls.GyroZNeg:
					return !sOff && Global.SZSens[device] * eState.GyroZ < -67;
				case DS4Controls.SwipeUp:
					return (tp != null) && tp.swipeUp;
				case DS4Controls.SwipeDown:
					return (tp != null) && tp.swipeDown;
				case DS4Controls.SwipeLeft:
					return (tp != null) && tp.swipeLeft;
				case DS4Controls.SwipeRight:
					return (tp != null) && tp.swipeRight;
			}
			return false;
		}
示例#34
0
		private string GetDS4ControlsByName(DS4Controls key)
		{
			switch (key)
			{
				case DS4Controls.Share:
					return "bnShare";
				case DS4Controls.L3:
					return "bnL3";
				case DS4Controls.R3:
					return "bnR3";
				case DS4Controls.Options:
					return "bnOptions";
				case DS4Controls.DpadUp:
					return "bnUp";
				case DS4Controls.DpadRight:
					return "bnRight";
				case DS4Controls.DpadDown:
					return "bnDown";
				case DS4Controls.DpadLeft:
					return "bnLeft";

				case DS4Controls.L1:
					return "bnL1";
				case DS4Controls.R1:
					return "bnR1";
				case DS4Controls.Triangle:
					return "bnTriangle";
				case DS4Controls.Circle:
					return "bnCircle";
				case DS4Controls.Cross:
					return "bnCross";
				case DS4Controls.Square:
					return "bnSquare";

				case DS4Controls.PS:
					return "bnPS";
				case DS4Controls.LXNeg:
					return "bnLSLeft";
				case DS4Controls.LYNeg:
					return "bnLSUp";
				case DS4Controls.RXNeg:
					return "bnRSLeft";
				case DS4Controls.RYNeg:
					return "bnRSUp";

				case DS4Controls.LXPos:
					return "bnLSRight";
				case DS4Controls.LYPos:
					return "bnLSDown";
				case DS4Controls.RXPos:
					return "bnRSRight";
				case DS4Controls.RYPos:
					return "bnRSDown";
				case DS4Controls.L2:
					return "bnL2";
				case DS4Controls.R2:
					return "bnR2";

				case DS4Controls.TouchLeft:
					return "bnTouchLeft";
				case DS4Controls.TouchMulti:
					return "bnTouchMulti";
				case DS4Controls.TouchUpper:
					return "bnTouchUpper";
				case DS4Controls.TouchRight:
					return "bnTouchRight";
				case DS4Controls.GyroXPos:
					return "bnGyroXP";
				case DS4Controls.GyroXNeg:
					return "bnGyroXN";
				case DS4Controls.GyroZPos:
					return "bnGyroZP";
				case DS4Controls.GyroZNeg:
					return "bnGyroZN";

				case DS4Controls.SwipeUp:
					return "bnSwipeUp";
				case DS4Controls.SwipeDown:
					return "bnSwipeDown";
				case DS4Controls.SwipeLeft:
					return "bnSwipeLeft";
				case DS4Controls.SwipeRight:
					return "bnSwipeRight";

				default:
					return string.Empty;
			}
		}
示例#35
0
		//Returns false for any bool, 
		//if control is one of the xy axis returns 127
		//if its a trigger returns 0
		public static void resetToDefaultValue(DS4Controls control, DS4State cState)
		{
			switch (control)
			{
				case DS4Controls.Share:
					cState.Share = false;
					break;
				case DS4Controls.Options:
					cState.Options = false;
					break;
				case DS4Controls.L1:
					cState.L1 = false;
					break;
				case DS4Controls.R1:
					cState.R1 = false;
					break;
				case DS4Controls.L3:
					cState.L3 = false;
					break;
				case DS4Controls.R3:
					cState.R3 = false;
					break;
				case DS4Controls.DpadUp:
					cState.DpadUp = false;
					break;
				case DS4Controls.DpadDown:
					cState.DpadDown = false;
					break;
				case DS4Controls.DpadLeft:
					cState.DpadLeft = false;
					break;
				case DS4Controls.DpadRight:
					cState.DpadRight = false;
					break;
				case DS4Controls.PS:
					cState.PS = false;
					break;
				case DS4Controls.Cross:
					cState.Cross = false;
					break;
				case DS4Controls.Square:
					cState.Square = false;
					break;
				case DS4Controls.Triangle:
					cState.Triangle = false;
					break;
				case DS4Controls.Circle:
					cState.Circle = false;
					break;
				case DS4Controls.LXNeg:
					cState.LX = 127;
					break;
				case DS4Controls.LYNeg:
					cState.LY = 127;
					break;
				case DS4Controls.RXNeg:
					cState.RX = 127;
					break;
				case DS4Controls.RYNeg:
					cState.RY = 127;
					break;
				case DS4Controls.LXPos:
					cState.LX = 127;
					break;
				case DS4Controls.LYPos:
					cState.LY = 127;
					break;
				case DS4Controls.RXPos:
					cState.RX = 127;
					break;
				case DS4Controls.RYPos:
					cState.RY = 127;
					break;
				case DS4Controls.L2:
					cState.L2 = 0;
					break;
				case DS4Controls.R2:
					cState.R2 = 0;
					break;
			}
		}
示例#36
0
 public static string DS4ControltoX360(DS4Controls ctrl)
 {
     switch (ctrl)
     {
         case DS4Controls.Cross:
             return "A Button";
         case DS4Controls.Circle:
             return "B Button";
         case DS4Controls.Square:
             return "X Button";
         case DS4Controls.Triangle:
             return "Y Button";
         case DS4Controls.Options:
             return "Start";
         case DS4Controls.Share:
             return "Back";
         case DS4Controls.DpadUp:
             return "Up Button";
         case DS4Controls.DpadDown:
             return "Down Button";
         case DS4Controls.DpadLeft:
             return "Left Button";
         case DS4Controls.DpadRight:
             return "Right Button";
         case DS4Controls.PS:
             return "Guide";
         case DS4Controls.L1:
             return "Left Bumper";
         case DS4Controls.R1:
             return "Right Bumper";
         case DS4Controls.L2:
             return "Left Trigger";
         case DS4Controls.R2:
             return "Right Trigger";
         case DS4Controls.L3:
             return "Left Stick";
         case DS4Controls.R3:
             return "Right Stick";
         case DS4Controls.LXPos:
             return "LS Right";
         case DS4Controls.LXNeg:
             return "LS Left";
         case DS4Controls.LYPos:
             return "LS Down";
         case DS4Controls.LYNeg:
             return "LS Up";
         case DS4Controls.RXPos:
             return "RS Right";
         case DS4Controls.RXNeg:
             return "RS Left";
         case DS4Controls.RYPos:
             return "RS Down";
         case DS4Controls.RYNeg:
             return "RS Up";
     }
     return "None";
 }
示例#37
0
        public void anybtn_Click(object sender, EventArgs e)
        {
            if (rb == null && sender is Button && ((Button)sender).Name != "bnMacro" && ((Button)sender).Name != "bnTest")
            {
                Button bn = ((Button)sender);
                macrostag.Clear();
                string keyname;
                ushort val;

                /*if (((Button)sender).Text.Contains('↑') || ((Button)sender).Text.Contains('↓') || ((Button)sender).Text.Contains('→') || ((Button)sender).Text.Contains('←') || ((Button)sender).Text.Contains('Ø'))
                 *  keyname = ((Button)sender).Tag.ToString();
                 * else if (((Button)sender).Font.Name == "Webdings")
                 * {
                 *  if (((Button)sender).Text == "9")
                 *      keyname = "Previous Track";
                 *  else if (((Button)sender).Text == "<")
                 *      keyname = "Stop Track";
                 *  else if (((Button)sender).Text == "4")
                 *      keyname = "Play/Pause";
                 *  else if (((Button)sender).Text == ":")
                 *      keyname = "Next Track";
                 *  else
                 *      keyname = "How did you get here?";
                 * }
                 * else */
                if (bn.Tag == null)
                {
                    keyname = bn.Text;
                }
                else if (bn.Tag.ToString().Contains("X360"))
                {
                    keyname = bn.Tag.ToString().Substring(4);
                }
                else if (bn.Tag != null && ushort.TryParse(bn.Tag.ToString(), out val))
                {
                    keyname = ((Keys)val).ToString();
                }
                else
                {
                    keyname = bn.Tag.ToString();
                }

                object keytag;
                //ushort val;
                if (bn.Tag != null && bn.Tag.ToString().Contains("X360"))
                {
                    //keytag = ((Button)sender).Tag.ToString().Substring(4);
                    keytag = Global.getX360ControlsByName(bn.Tag.ToString().Substring(4));
                    DS4Controls psButton = Global.getDS4ControlsByName(button.Name);
                    if ((X360Controls)keytag == Global.getDefaultX360ControlBinding(psButton) &&
                        !cBScanCode.Checked && !cBToggle.Checked && !rBShiftModifer.Checked)
                    {
                        // Reset action
                        keytag = null;
                    }
                }
                else if (bn.Tag != null && ushort.TryParse(bn.Tag.ToString(), out val))
                {
                    keytag = val;
                }
                else
                {
                    keytag = bn.Tag;
                }

                lBMacroOn.Visible = false;
                string extras = null;
                if (IsUsingExtras())
                {
                    extras = GetExtras();
                }

                KeyValuePair <object, string> tag = new KeyValuePair <object, string>(keytag, extras);

                newaction = true;
                int  value;
                bool tagisint   = keytag != null && int.TryParse(keytag.ToString(), out value);
                bool scanavail  = tagisint;
                bool toggleavil = tagisint;
                if (ops != null)
                {
                    ops.ChangeButtonText(button, rBShiftModifer.Checked, tag,
                                         (scanavail ? cBScanCode.Checked : false), (toggleavil ? cBToggle.Checked : false),
                                         false, false, cBShiftButton.SelectedIndex);
                }
                else if (sA != null)
                {
                    button.Text      = keyname;
                    button.Tag       = keytag;
                    button.ForeColor = Color.Black;
                }

                this.Close();
            }
        }
示例#38
0
 public static DS4KeyType getCustomKeyType(DS4Controls controlName)
 {
     return m_Config.GetCustomKeyType(controlName);
 }
示例#39
0
 public static int DS4ControltoInt(DS4Controls ctrl)
 {
     switch (ctrl)
     {
         case DS4Controls.Cross:
             return 261;
         case DS4Controls.Circle:
             return 262;
         case DS4Controls.Square:
             return 263;
         case DS4Controls.Triangle:
             return 264;
         case DS4Controls.Options:
             return 265;
         case DS4Controls.Share:
             return 266;
         case DS4Controls.DpadUp:
             return 267;
         case DS4Controls.DpadDown:
             return 268;
         case DS4Controls.DpadLeft:
             return 269;
         case DS4Controls.DpadRight:
             return 270;
         case DS4Controls.PS:
             return 271;
         case DS4Controls.L1:
             return 272;
         case DS4Controls.R1:
             return 273;
         case DS4Controls.L2:
             return 274;
         case DS4Controls.R2:
             return 275;
         case DS4Controls.L3:
             return 276;
         case DS4Controls.R3:
             return 277;
         case DS4Controls.LXPos:
             return 278;
         case DS4Controls.LXNeg:
             return 279;
         case DS4Controls.LYPos:
             return 280;
         case DS4Controls.LYNeg:
             return 281;
         case DS4Controls.RXPos:
             return 282;
         case DS4Controls.RXNeg:
             return 283;
         case DS4Controls.RYPos:
             return 284;
         case DS4Controls.RYNeg:
             return 285;
     }
     return 0;
 }
示例#40
0
        public static byte getXYAxisMapping(DS4Controls control, DS4State cState, bool alt = false)
        {
            byte trueVal  = 0;
            byte falseVal = 127;

            if (alt)
            {
                trueVal = 255;
            }
            switch (control)
            {
            case DS4Controls.Share: return((byte)(cState.Share ? trueVal : falseVal));

            case DS4Controls.Options: return((byte)(cState.Options ? trueVal : falseVal));

            case DS4Controls.L1: return((byte)(cState.L1 ? trueVal : falseVal));

            case DS4Controls.R1: return((byte)(cState.R1 ? trueVal : falseVal));

            case DS4Controls.L3: return((byte)(cState.L3 ? trueVal : falseVal));

            case DS4Controls.R3: return((byte)(cState.R3 ? trueVal : falseVal));

            case DS4Controls.DpadUp: return((byte)(cState.DpadUp ? trueVal : falseVal));

            case DS4Controls.DpadDown: return((byte)(cState.DpadDown ? trueVal : falseVal));

            case DS4Controls.DpadLeft: return((byte)(cState.DpadLeft ? trueVal : falseVal));

            case DS4Controls.DpadRight: return((byte)(cState.DpadRight ? trueVal : falseVal));

            case DS4Controls.PS: return((byte)(cState.PS ? trueVal : falseVal));

            case DS4Controls.Cross: return((byte)(cState.Cross ? trueVal : falseVal));

            case DS4Controls.Square: return((byte)(cState.Square ? trueVal : falseVal));

            case DS4Controls.Triangle: return((byte)(cState.Triangle ? trueVal : falseVal));

            case DS4Controls.Circle: return((byte)(cState.Circle ? trueVal : falseVal));

            case DS4Controls.L2: return((byte)(cState.L2 == 255 ? trueVal : falseVal));

            case DS4Controls.R2: return((byte)(cState.R2 == 255 ? trueVal : falseVal));
            }

            if (!alt)
            {
                switch (control)
                {
                case DS4Controls.LXNeg: return(cState.LX);

                case DS4Controls.LYNeg: return(cState.LY);

                case DS4Controls.RXNeg: return(cState.RX);

                case DS4Controls.RYNeg: return(cState.RY);

                case DS4Controls.LXPos: return((byte)(255 - cState.LX));

                case DS4Controls.LYPos: return((byte)(255 - cState.LY));

                case DS4Controls.RXPos: return((byte)(255 - cState.RX));

                case DS4Controls.RYPos: return((byte)(255 - cState.RY));
                }
            }
            else
            {
                switch (control)
                {
                case DS4Controls.LXNeg: return((byte)(255 - cState.LX));

                case DS4Controls.LYNeg: return((byte)(255 - cState.LY));

                case DS4Controls.RXNeg: return((byte)(255 - cState.RX));

                case DS4Controls.RYNeg: return((byte)(255 - cState.RY));

                case DS4Controls.LXPos: return(cState.LX);

                case DS4Controls.LYPos: return(cState.LY);

                case DS4Controls.RXPos: return(cState.RX);

                case DS4Controls.RYPos: return(cState.RY);
                }
            }
            return(0);
        }
        public DS4Controls GetActiveInputControl(int ind)
        {
            DS4State        cState = CurrentState[ind];
            DS4StateExposed eState = ExposedState[ind];
            Mouse           tp     = touchPad[ind];
            DS4Controls     result = DS4Controls.None;

            if (DS4Controllers[ind] != null)
            {
                if (Mapping.getBoolButtonMapping(cState.Cross))
                {
                    result = DS4Controls.Cross;
                }
                else if (Mapping.getBoolButtonMapping(cState.Circle))
                {
                    result = DS4Controls.Circle;
                }
                else if (Mapping.getBoolButtonMapping(cState.Triangle))
                {
                    result = DS4Controls.Triangle;
                }
                else if (Mapping.getBoolButtonMapping(cState.Square))
                {
                    result = DS4Controls.Square;
                }
                else if (Mapping.getBoolButtonMapping(cState.L1))
                {
                    result = DS4Controls.L1;
                }
                else if (Mapping.getBoolTriggerMapping(cState.L2))
                {
                    result = DS4Controls.L2;
                }
                else if (Mapping.getBoolButtonMapping(cState.L3))
                {
                    result = DS4Controls.L3;
                }
                else if (Mapping.getBoolButtonMapping(cState.R1))
                {
                    result = DS4Controls.R1;
                }
                else if (Mapping.getBoolTriggerMapping(cState.R2))
                {
                    result = DS4Controls.R2;
                }
                else if (Mapping.getBoolButtonMapping(cState.R3))
                {
                    result = DS4Controls.R3;
                }
                else if (Mapping.getBoolButtonMapping(cState.DpadUp))
                {
                    result = DS4Controls.DpadUp;
                }
                else if (Mapping.getBoolButtonMapping(cState.DpadDown))
                {
                    result = DS4Controls.DpadDown;
                }
                else if (Mapping.getBoolButtonMapping(cState.DpadLeft))
                {
                    result = DS4Controls.DpadLeft;
                }
                else if (Mapping.getBoolButtonMapping(cState.DpadRight))
                {
                    result = DS4Controls.DpadRight;
                }
                else if (Mapping.getBoolButtonMapping(cState.Share))
                {
                    result = DS4Controls.Share;
                }
                else if (Mapping.getBoolButtonMapping(cState.Options))
                {
                    result = DS4Controls.Options;
                }
                else if (Mapping.getBoolButtonMapping(cState.PS))
                {
                    result = DS4Controls.PS;
                }
                else if (Mapping.getBoolAxisDirMapping(cState.LX, true))
                {
                    result = DS4Controls.LXPos;
                }
                else if (Mapping.getBoolAxisDirMapping(cState.LX, false))
                {
                    result = DS4Controls.LXNeg;
                }
                else if (Mapping.getBoolAxisDirMapping(cState.LY, true))
                {
                    result = DS4Controls.LYPos;
                }
                else if (Mapping.getBoolAxisDirMapping(cState.LY, false))
                {
                    result = DS4Controls.LYNeg;
                }
                else if (Mapping.getBoolAxisDirMapping(cState.RX, true))
                {
                    result = DS4Controls.RXPos;
                }
                else if (Mapping.getBoolAxisDirMapping(cState.RX, false))
                {
                    result = DS4Controls.RXNeg;
                }
                else if (Mapping.getBoolAxisDirMapping(cState.RY, true))
                {
                    result = DS4Controls.RYPos;
                }
                else if (Mapping.getBoolAxisDirMapping(cState.RY, false))
                {
                    result = DS4Controls.RYNeg;
                }
                else if (Mapping.getBoolTouchMapping(tp.leftDown))
                {
                    result = DS4Controls.TouchLeft;
                }
                else if (Mapping.getBoolTouchMapping(tp.rightDown))
                {
                    result = DS4Controls.TouchRight;
                }
                else if (Mapping.getBoolTouchMapping(tp.multiDown))
                {
                    result = DS4Controls.TouchMulti;
                }
                else if (Mapping.getBoolTouchMapping(tp.upperDown))
                {
                    result = DS4Controls.TouchUpper;
                }
            }

            return(result);
        }
示例#42
0
 public static X360Controls getCustomButton(DS4Controls controlName)
 {
     return m_Config.GetCustomButton(controlName);
 }