public XInputButtonAssignment(X360Button button, ScpDirector.XInput_Device device = ScpDirector.XInput_Device.Device_A) { Button = button; Device = device; }
public virtual Int32 Parse(Byte[] Input, Byte[] Output, DsModel Type = DsModel.DS3) { Int32 Serial = IndexToSerial(Input[0]); for (Int32 Index = 0; Index < ReportSize; Index++) { Output[Index] = 0x00; } Output[0] = 0x1C; Output[4] = (Byte)((Serial >> 0) & 0xFF); Output[5] = (Byte)((Serial >> 8) & 0xFF); Output[6] = (Byte)((Serial >> 16) & 0xFF); Output[7] = (Byte)((Serial >> 24) & 0xFF); Output[9] = 0x14; X360Button XButton = X360Button.None; if (Input[1] == 0x02) // Pad is active { switch (Type) { case DsModel.DS3: { Ds3Button Buttons = (Ds3Button)((Input[10] << 0) | (Input[11] << 8) | (Input[12] << 16) | (Input[13] << 24)); if (Buttons.HasFlag(Ds3Button.Select)) { XButton |= X360Button.Back; } if (Buttons.HasFlag(Ds3Button.Start)) { XButton |= X360Button.Start; } if (Buttons.HasFlag(Ds3Button.Up)) { XButton |= X360Button.Up; } if (Buttons.HasFlag(Ds3Button.Right)) { XButton |= X360Button.Right; } if (Buttons.HasFlag(Ds3Button.Down)) { XButton |= X360Button.Down; } if (Buttons.HasFlag(Ds3Button.Left)) { XButton |= X360Button.Left; } if (Buttons.HasFlag(Ds3Button.L1)) { XButton |= X360Button.LB; } if (Buttons.HasFlag(Ds3Button.R1)) { XButton |= X360Button.RB; } if (Buttons.HasFlag(Ds3Button.Triangle)) { XButton |= X360Button.Y; } if (Buttons.HasFlag(Ds3Button.Circle)) { XButton |= X360Button.B; } if (Buttons.HasFlag(Ds3Button.Cross)) { XButton |= X360Button.A; } if (Buttons.HasFlag(Ds3Button.Square)) { XButton |= X360Button.X; } if (Buttons.HasFlag(Ds3Button.PS)) { XButton |= X360Button.Guide; } if (Buttons.HasFlag(Ds3Button.L3)) { XButton |= X360Button.LS; } if (Buttons.HasFlag(Ds3Button.R3)) { XButton |= X360Button.RS; } Output[(UInt32)X360Axis.BT_Lo] = (Byte)((UInt32)XButton >> 0 & 0xFF); Output[(UInt32)X360Axis.BT_Hi] = (Byte)((UInt32)XButton >> 8 & 0xFF); Output[(UInt32)X360Axis.LT] = Input[(UInt32)Ds3Axis.L2]; Output[(UInt32)X360Axis.RT] = Input[(UInt32)Ds3Axis.R2]; if (!DeadZone(Global.DeadZoneL, Input[(UInt32)Ds3Axis.LX], Input[(UInt32)Ds3Axis.LY])) // Left Stick DeadZone { Int32 ThumbLX = +Scale(Input[(UInt32)Ds3Axis.LX], Global.FlipLX); Int32 ThumbLY = -Scale(Input[(UInt32)Ds3Axis.LY], Global.FlipLY); Output[(UInt32)X360Axis.LX_Lo] = (Byte)((ThumbLX >> 0) & 0xFF); // LX Output[(UInt32)X360Axis.LX_Hi] = (Byte)((ThumbLX >> 8) & 0xFF); Output[(UInt32)X360Axis.LY_Lo] = (Byte)((ThumbLY >> 0) & 0xFF); // LY Output[(UInt32)X360Axis.LY_Hi] = (Byte)((ThumbLY >> 8) & 0xFF); } if (!DeadZone(Global.DeadZoneR, Input[(UInt32)Ds3Axis.RX], Input[(UInt32)Ds3Axis.RY])) // Right Stick DeadZone { Int32 ThumbRX = +Scale(Input[(UInt32)Ds3Axis.RX], Global.FlipRX); Int32 ThumbRY = -Scale(Input[(UInt32)Ds3Axis.RY], Global.FlipRY); Output[(UInt32)X360Axis.RX_Lo] = (Byte)((ThumbRX >> 0) & 0xFF); // RX Output[(UInt32)X360Axis.RX_Hi] = (Byte)((ThumbRX >> 8) & 0xFF); Output[(UInt32)X360Axis.RY_Lo] = (Byte)((ThumbRY >> 0) & 0xFF); // RY Output[(UInt32)X360Axis.RY_Hi] = (Byte)((ThumbRY >> 8) & 0xFF); } } break; case DsModel.DS4: { Ds4Button Buttons = (Ds4Button)((Input[13] << 0) | (Input[14] << 8) | (Input[15] << 16)); if (Buttons.HasFlag(Ds4Button.Share)) { XButton |= X360Button.Back; } if (Buttons.HasFlag(Ds4Button.Options)) { XButton |= X360Button.Start; } if (Buttons.HasFlag(Ds4Button.Up)) { XButton |= X360Button.Up; } if (Buttons.HasFlag(Ds4Button.Right)) { XButton |= X360Button.Right; } if (Buttons.HasFlag(Ds4Button.Down)) { XButton |= X360Button.Down; } if (Buttons.HasFlag(Ds4Button.Left)) { XButton |= X360Button.Left; } if (Buttons.HasFlag(Ds4Button.L1)) { XButton |= X360Button.LB; } if (Buttons.HasFlag(Ds4Button.R1)) { XButton |= X360Button.RB; } if (Buttons.HasFlag(Ds4Button.Triangle)) { XButton |= X360Button.Y; } if (Buttons.HasFlag(Ds4Button.Circle)) { XButton |= X360Button.B; } if (Buttons.HasFlag(Ds4Button.Cross)) { XButton |= X360Button.A; } if (Buttons.HasFlag(Ds4Button.Square)) { XButton |= X360Button.X; } if (Buttons.HasFlag(Ds4Button.PS)) { XButton |= X360Button.Guide; } if (Buttons.HasFlag(Ds4Button.L3)) { XButton |= X360Button.LS; } if (Buttons.HasFlag(Ds4Button.R3)) { XButton |= X360Button.RS; } Output[(UInt32)X360Axis.BT_Lo] = (Byte)((UInt32)XButton >> 0 & 0xFF); Output[(UInt32)X360Axis.BT_Hi] = (Byte)((UInt32)XButton >> 8 & 0xFF); Output[(UInt32)X360Axis.LT] = Input[(UInt32)Ds4Axis.L2]; Output[(UInt32)X360Axis.RT] = Input[(UInt32)Ds4Axis.R2]; if (!DeadZone(Global.DeadZoneL, Input[(UInt32)Ds4Axis.LX], Input[(UInt32)Ds4Axis.LY])) // Left Stick DeadZone { Int32 ThumbLX = +Scale(Input[(UInt32)Ds4Axis.LX], Global.FlipLX); Int32 ThumbLY = -Scale(Input[(UInt32)Ds4Axis.LY], Global.FlipLY); Output[(UInt32)X360Axis.LX_Lo] = (Byte)((ThumbLX >> 0) & 0xFF); // LX Output[(UInt32)X360Axis.LX_Hi] = (Byte)((ThumbLX >> 8) & 0xFF); Output[(UInt32)X360Axis.LY_Lo] = (Byte)((ThumbLY >> 0) & 0xFF); // LY Output[(UInt32)X360Axis.LY_Hi] = (Byte)((ThumbLY >> 8) & 0xFF); } if (!DeadZone(Global.DeadZoneR, Input[(UInt32)Ds4Axis.RX], Input[(UInt32)Ds4Axis.RY])) // Right Stick DeadZone { Int32 ThumbRX = +Scale(Input[(UInt32)Ds4Axis.RX], Global.FlipRX); Int32 ThumbRY = -Scale(Input[(UInt32)Ds4Axis.RY], Global.FlipRY); Output[(UInt32)X360Axis.RX_Lo] = (Byte)((ThumbRX >> 0) & 0xFF); // RX Output[(UInt32)X360Axis.RX_Hi] = (Byte)((ThumbRX >> 8) & 0xFF); Output[(UInt32)X360Axis.RY_Lo] = (Byte)((ThumbRY >> 0) & 0xFF); // RY Output[(UInt32)X360Axis.RY_Hi] = (Byte)((ThumbRY >> 8) & 0xFF); } } break; } } return(Input[0]); }
public void SetButton(X360Button button, bool pressed, XInput_Device device) { //this[(int)device].SetInput(button, pressed); _xInstances[(int)device - 1].SetInput(button, pressed); }
public void SetButton(X360Button button, bool pressed) { SetButton(button, pressed, XInput_Device.Device_A); }
public void SetInput(X360Button button, bool state) { inputs[button] = state;// || inputs[button]; }
public bool this[X360Button btn] { set { switch (btn) { case X360Button.A: A = value; break; case X360Button.B: B = value; break; case X360Button.X: X = value; break; case X360Button.Y: Y = value; break; case X360Button.LB: LB = value; break; case X360Button.RB: RB = value; break; case X360Button.LS: LS = value; break; case X360Button.RS: RS = value; break; case X360Button.Up: Up = value; break; case X360Button.Down: Down = value; break; case X360Button.Left: Left = value; break; case X360Button.Right: Right = value; break; case X360Button.Start: Start = value; break; case X360Button.Back: Back = value; break; case X360Button.Guide: Guide = value; break; default: break; } } get { switch (btn) { case X360Button.A: return(A); case X360Button.B: return(B); case X360Button.X: return(X); case X360Button.Y: return(Y); case X360Button.LB: return(LB); case X360Button.RB: return(RB); case X360Button.LS: return(LS); case X360Button.RS: return(RS); case X360Button.Up: return(Up); case X360Button.Down: return(Down); case X360Button.Left: return(Left); case X360Button.Right: return(Right); case X360Button.Start: return(Start); case X360Button.Back: return(Back); case X360Button.Guide: return(Back); default: return(false); } } }