public virtual bool Remap(DsModel Type, int Pad, string Mac, byte[] Input, byte[] Output) { var Mapped = false; try { if (m_Remapping) { switch (Type) { case DsModel.DS3: Mapped = RemapDs3(Find(Mac, Pad), Input, Output); break; case DsModel.DS4: Mapped = RemapDs4(Find(Mac, Pad), Input, Output); break; } } } catch (Exception ex) { Log.ErrorFormat("Unexpected error: {0}", ex); } return(Mapped); }
public virtual bool Remap(DsModel type, int pad, string mac, byte[] input, byte[] output) { var mapped = false; try { if (m_Remapping) { switch (type) { case DsModel.DS3: mapped = RemapDs3(Find(mac, pad), input, output); break; case DsModel.DS4: mapped = RemapDs4(Find(mac, pad), input, output); break; } } } catch (Exception ex) { Log.ErrorFormat("Unexpected error: {0}", ex); } return(mapped); }
public ScpHidReport(DsConnection connectionType, PhysicalAddress padMacAddress, DsModel model, DsPadId padId, DsState padState, HidReport.Core.HidReport hidReport) { ConnectionType = connectionType; _padMacAddress = padMacAddress.GetAddressBytes(); Model = model; PadId = padId; PadState = padState; _hidReport = hidReport; }
internal DsDetail(DsPadId PadId, DsState State, DsModel Model, byte[] Mac, DsConnection Mode, DsBattery Level) { Pad = PadId; this.State = State; this.Model = Model; this.Mode = Mode; Charge = Level; Array.Copy(Mac, m_Local, m_Local.Length); }
internal DsDetail(DsPadId PadId, DsState State, DsModel Model, Byte[] Mac, DsConnection Mode, DsBattery Level) { m_Serial = PadId; m_State = State; m_Model = Model; m_Mode = Mode; m_Charge = Level; Array.Copy(Mac, m_Local, m_Local.Length); }
internal DsDetail(DsPadId padId, DsState state, DsModel model, byte[] mac, DsConnection mode, DsBattery level) { Pad = padId; State = state; Model = model; Mode = mode; Charge = level; Buffer.BlockCopy(mac, 0, _localMac, 0, _localMac.Length); }
public override Int32 Parse(Byte[] Input, Byte[] Output, DsModel Type = DsModel.None) { Byte Serial = Input[0]; for (Int32 Index = 0; Index < 28; Index++) Output[Index] = 0x00; Output[0] = 0x1C; Output[4] = Input[0]; Output[9] = 0x14; if (Input[1] == 0x02) // Pad is active { UInt32 Buttons = (UInt32)((Input[10] << 0) | (Input[11] << 8) | (Input[12] << 16) | (Input[13] << 24)); if ((Buttons & (0x1 << 0)) > 0) Output[10] |= (Byte)(1 << 5); // Back if ((Buttons & (0x1 << 1)) > 0) Output[10] |= (Byte)(1 << 6); // Left Thumb if ((Buttons & (0x1 << 2)) > 0) Output[10] |= (Byte)(1 << 7); // Right Thumb if ((Buttons & (0x1 << 3)) > 0) Output[10] |= (Byte)(1 << 4); // Start if ((Buttons & (0x1 << 4)) > 0) Output[10] |= (Byte)(1 << 0); // Up if ((Buttons & (0x1 << 5)) > 0) Output[10] |= (Byte)(1 << 1); // Down if ((Buttons & (0x1 << 6)) > 0) Output[10] |= (Byte)(1 << 3); // Right if ((Buttons & (0x1 << 7)) > 0) Output[10] |= (Byte)(1 << 2); // Left if ((Buttons & (0x1 << 10)) > 0) Output[11] |= (Byte)(1 << 0); // Left Shoulder if ((Buttons & (0x1 << 11)) > 0) Output[11] |= (Byte)(1 << 1); // Right Shoulder if ((Buttons & (0x1 << 12)) > 0) Output[11] |= (Byte)(1 << 7); // Y if ((Buttons & (0x1 << 13)) > 0) Output[11] |= (Byte)(1 << 5); // B if ((Buttons & (0x1 << 14)) > 0) Output[11] |= (Byte)(1 << 4); // A if ((Buttons & (0x1 << 15)) > 0) Output[11] |= (Byte)(1 << 6); // X if ((Buttons & (0x1 << 16)) > 0) Output[11] |= (Byte)(1 << 2); // Guide Output[12] = Input[26]; // Left Trigger Output[13] = Input[27]; // Right Trigger Output[14] = Input[14]; // LX Output[15] = Input[15]; Output[16] = Input[16]; // LY Output[17] = Input[17]; Output[18] = Input[18]; // RX Output[19] = Input[19]; Output[20] = Input[20]; // RY Output[21] = Input[21]; } return Input[0]; }
public virtual Boolean Remap(DsModel Type, Int32 PadId, String MacAddr, Byte[] Input, Byte[] Output) { Boolean Mapped = false; if (m_Started) { try { Mapped = userMapper.Remap(Type, PadId, MacAddr, Input, Output); } catch { } } return(Mapped); }
public virtual Boolean Remap(DsModel Type, Int32 Pad, String Mac, Byte[] Input, Byte[] Output) { Boolean Mapped = false; try { if (m_Remapping) { switch (Type) { case DsModel.DS3: Mapped = RemapDs3(Find(Mac, Pad), Input, Output); break; } } } catch { } return(Mapped); }
public bool Remap(DsModel Type, int PadId, string MacAddr, byte[] Input, byte[] Output) { var Mapped = false; if (m_Started) { try { Mapped = userMapper.Remap(Type, PadId, MacAddr, Input, Output); } catch (Exception ex) { Log.ErrorFormat("Unexpected error in Remap: {0}", ex); } } return(Mapped); }
protected override void On_Report(object sender, ReportEventArgs e) { Int32 Serial = e.Report[(Int32)DsOffset.Pad]; DsModel Model = (DsModel)e.Report[(Int32)DsOffset.Model]; Byte[] Report = m_Cache[Serial].Report; Byte[] Rumble = m_Cache[Serial].Rumble; Byte[] Mapped = m_Cache[Serial].Mapped; if (scpMap.Remap(Model, Serial, m_Pad[Serial].Local, e.Report, Mapped)) { scpBus.Parse(Mapped, Report, Model); } else { scpBus.Parse(e.Report, Report, Model); } if (scpBus.Report(Report, Rumble) && (DsState)e.Report[1] == DsState.Connected) { Byte Large = (Byte)(Rumble[3]); Byte Small = (Byte)(Rumble[4]); if (Rumble[1] == 0x08 && (Large != m_XInput[Serial][0] || Small != m_XInput[Serial][1])) { m_XInput[Serial][0] = Large; m_XInput[Serial][1] = Small; Pad[Serial].Rumble(Large, Small); } } if ((DsState)e.Report[1] != DsState.Connected) { m_XInput[Serial][0] = m_XInput[Serial][1] = 0; m_Native[Serial][0] = m_Native[Serial][1] = 0; } if (!Global.DisableNative) { m_Client.Send(e.Report, e.Report.Length, m_ClientEp); } }
public override Int32 Parse(Byte[] Input, Byte[] Output, DsModel Type = DsModel.None) { Byte Serial = Input[0]; for (Int32 Index = 0; Index < 28; Index++) { Output[Index] = 0x00; } Output[0] = 0x1C; Output[4] = Input[0]; Output[9] = 0x14; if (Input[1] == 0x02) // Pad is active { UInt32 Buttons = (UInt32)((Input[10] << 0) | (Input[11] << 8) | (Input[12] << 16) | (Input[13] << 24)); if ((Buttons & (0x1 << 0)) > 0) { Output[10] |= (Byte)(1 << 5); // Back } if ((Buttons & (0x1 << 1)) > 0) { Output[10] |= (Byte)(1 << 6); // Left Thumb } if ((Buttons & (0x1 << 2)) > 0) { Output[10] |= (Byte)(1 << 7); // Right Thumb } if ((Buttons & (0x1 << 3)) > 0) { Output[10] |= (Byte)(1 << 4); // Start } if ((Buttons & (0x1 << 4)) > 0) { Output[10] |= (Byte)(1 << 0); // Up } if ((Buttons & (0x1 << 5)) > 0) { Output[10] |= (Byte)(1 << 1); // Down } if ((Buttons & (0x1 << 6)) > 0) { Output[10] |= (Byte)(1 << 3); // Right } if ((Buttons & (0x1 << 7)) > 0) { Output[10] |= (Byte)(1 << 2); // Left } if ((Buttons & (0x1 << 10)) > 0) { Output[11] |= (Byte)(1 << 0); // Left Shoulder } if ((Buttons & (0x1 << 11)) > 0) { Output[11] |= (Byte)(1 << 1); // Right Shoulder } if ((Buttons & (0x1 << 12)) > 0) { Output[11] |= (Byte)(1 << 7); // Y } if ((Buttons & (0x1 << 13)) > 0) { Output[11] |= (Byte)(1 << 5); // B } if ((Buttons & (0x1 << 14)) > 0) { Output[11] |= (Byte)(1 << 4); // A } if ((Buttons & (0x1 << 15)) > 0) { Output[11] |= (Byte)(1 << 6); // X } if ((Buttons & (0x1 << 16)) > 0) { Output[11] |= (Byte)(1 << 2); // Guide } Output[12] = Input[26]; // Left Trigger Output[13] = Input[27]; // Right Trigger Output[14] = Input[14]; // LX Output[15] = Input[15]; Output[16] = Input[16]; // LY Output[17] = Input[17]; Output[18] = Input[18]; // RX Output[19] = Input[19]; Output[20] = Input[20]; // RY Output[21] = Input[21]; } return(Input[0]); }
public virtual bool Remap(DsModel Type, int Pad, string Mac, byte[] Input, byte[] Output) { var Mapped = false; try { if (m_Remapping) { switch (Type) { case DsModel.DS3: Mapped = RemapDs3(Find(Mac, Pad), Input, Output); break; case DsModel.DS4: Mapped = RemapDs4(Find(Mac, Pad), Input, Output); break; } } } catch (Exception ex) { Log.ErrorFormat("Unexpected error: {0}", ex); } return Mapped; }
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 int Parse(ScpHidReport inputReport, byte[] output, DsModel type = DsModel.DS3) { var input = inputReport.RawBytes; var serial = IndexToSerial(input[0]); for (var 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; var xButton = X360Button.None; if (input[1] == 0x02) // Pad is active { switch (type) { case DsModel.DS3: { // select & start if (inputReport[Ds3Button.Select].IsPressed) { xButton |= X360Button.Back; } if (inputReport[Ds3Button.Start].IsPressed) { xButton |= X360Button.Start; } // d-pad if (inputReport[Ds3Button.Up].IsPressed) { xButton |= X360Button.Up; } if (inputReport[Ds3Button.Right].IsPressed) { xButton |= X360Button.Right; } if (inputReport[Ds3Button.Down].IsPressed) { xButton |= X360Button.Down; } if (inputReport[Ds3Button.Left].IsPressed) { xButton |= X360Button.Left; } // shoulders if (inputReport[Ds3Button.L1].IsPressed) { xButton |= X360Button.LB; } if (inputReport[Ds3Button.R1].IsPressed) { xButton |= X360Button.RB; } // face buttons if (inputReport[Ds3Button.Triangle].IsPressed) { xButton |= X360Button.Y; } if (inputReport[Ds3Button.Circle].IsPressed) { xButton |= X360Button.B; } if (inputReport[Ds3Button.Cross].IsPressed) { xButton |= X360Button.A; } if (inputReport[Ds3Button.Square].IsPressed) { xButton |= X360Button.X; } // PS/Guide if (inputReport[Ds3Button.Ps].IsPressed) { xButton |= X360Button.Guide; } // thumbs if (inputReport[Ds3Button.L3].IsPressed) { xButton |= X360Button.LS; } if (inputReport[Ds3Button.R3].IsPressed) { xButton |= X360Button.RS; } output[(uint)X360Axis.BT_Lo] = (byte)((uint)xButton >> 0 & 0xFF); output[(uint)X360Axis.BT_Hi] = (byte)((uint)xButton >> 8 & 0xFF); // trigger output[(uint)X360Axis.LT] = inputReport[Ds3Axis.L2].Value; output[(uint)X360Axis.RT] = inputReport[Ds3Axis.R2].Value; if ( !DeadZone(GlobalConfiguration.Instance.DeadZoneL, inputReport[Ds3Axis.Lx].Value, inputReport[Ds3Axis.Ly].Value)) // Left Stick DeadZone { var thumbLx = +Scale(inputReport[Ds3Axis.Lx].Value, GlobalConfiguration.Instance.FlipLX); var thumbLy = -Scale(inputReport[Ds3Axis.Ly].Value, GlobalConfiguration.Instance.FlipLY); output[(uint)X360Axis.LX_Lo] = (byte)((thumbLx >> 0) & 0xFF); // LX output[(uint)X360Axis.LX_Hi] = (byte)((thumbLx >> 8) & 0xFF); output[(uint)X360Axis.LY_Lo] = (byte)((thumbLy >> 0) & 0xFF); // LY output[(uint)X360Axis.LY_Hi] = (byte)((thumbLy >> 8) & 0xFF); } if ( !DeadZone(GlobalConfiguration.Instance.DeadZoneR, inputReport[Ds3Axis.Rx].Value, inputReport[Ds3Axis.Ry].Value)) // Right Stick DeadZone { var thumbRx = +Scale(inputReport[Ds3Axis.Rx].Value, GlobalConfiguration.Instance.FlipRX); var thumbRy = -Scale(inputReport[Ds3Axis.Ry].Value, GlobalConfiguration.Instance.FlipRY); output[(uint)X360Axis.RX_Lo] = (byte)((thumbRx >> 0) & 0xFF); // RX output[(uint)X360Axis.RX_Hi] = (byte)((thumbRx >> 8) & 0xFF); output[(uint)X360Axis.RY_Lo] = (byte)((thumbRy >> 0) & 0xFF); // RY output[(uint)X360Axis.RY_Hi] = (byte)((thumbRy >> 8) & 0xFF); } } break; case DsModel.DS4: { var 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[(uint)X360Axis.BT_Lo] = (byte)((uint)xButton >> 0 & 0xFF); output[(uint)X360Axis.BT_Hi] = (byte)((uint)xButton >> 8 & 0xFF); output[(uint)X360Axis.LT] = input[(uint)Ds4Axis.L2]; output[(uint)X360Axis.RT] = input[(uint)Ds4Axis.R2]; if ( !DeadZone(GlobalConfiguration.Instance.DeadZoneL, input[(uint)Ds4Axis.LX], input[(uint)Ds4Axis.LY])) // Left Stick DeadZone { var thumbLx = +Scale(input[(uint)Ds4Axis.LX], GlobalConfiguration.Instance.FlipLX); var thumbLy = -Scale(input[(uint)Ds4Axis.LY], GlobalConfiguration.Instance.FlipLY); output[(uint)X360Axis.LX_Lo] = (byte)((thumbLx >> 0) & 0xFF); // LX output[(uint)X360Axis.LX_Hi] = (byte)((thumbLx >> 8) & 0xFF); output[(uint)X360Axis.LY_Lo] = (byte)((thumbLy >> 0) & 0xFF); // LY output[(uint)X360Axis.LY_Hi] = (byte)((thumbLy >> 8) & 0xFF); } if ( !DeadZone(GlobalConfiguration.Instance.DeadZoneR, input[(uint)Ds4Axis.RX], input[(uint)Ds4Axis.RY])) // Right Stick DeadZone { var thumbRx = +Scale(input[(uint)Ds4Axis.RX], GlobalConfiguration.Instance.FlipRX); var thumbRy = -Scale(input[(uint)Ds4Axis.RY], GlobalConfiguration.Instance.FlipRY); output[(uint)X360Axis.RX_Lo] = (byte)((thumbRx >> 0) & 0xFF); // RX output[(uint)X360Axis.RX_Hi] = (byte)((thumbRx >> 8) & 0xFF); output[(uint)X360Axis.RY_Lo] = (byte)((thumbRy >> 0) & 0xFF); // RY output[(uint)X360Axis.RY_Hi] = (byte)((thumbRy >> 8) & 0xFF); } } break; } } return(input[0]); }
public bool Remap(DsModel Type, int PadId, string MacAddr, byte[] Input, byte[] Output) { var Mapped = false; if (m_Started) { try { Mapped = userMapper.Remap(Type, PadId, MacAddr, Input, Output); } catch (Exception ex) { Log.ErrorFormat("Unexpected error in Remap: {0}", ex); } } return Mapped; }
public int Parse(byte[] input, byte[] output, DsModel type = DsModel.DS3) { var serial = IndexToSerial(input[0]); for (var 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; var xButton = X360Button.None; if (input[1] == 0x02) // Pad is active { switch (type) { case DsModel.DS3: { var 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[(uint) X360Axis.BT_Lo] = (byte) ((uint) xButton >> 0 & 0xFF); output[(uint) X360Axis.BT_Hi] = (byte) ((uint) xButton >> 8 & 0xFF); output[(uint) X360Axis.LT] = input[(uint) Ds3Axis.L2]; output[(uint) X360Axis.RT] = input[(uint) Ds3Axis.R2]; if (!DeadZone(GlobalConfiguration.Instance.DeadZoneL, input[(uint)Ds3Axis.LX], input[(uint)Ds3Axis.LY])) // Left Stick DeadZone { var thumbLx = +Scale(input[(uint)Ds3Axis.LX], GlobalConfiguration.Instance.FlipLX); var thumbLy = -Scale(input[(uint)Ds3Axis.LY], GlobalConfiguration.Instance.FlipLY); output[(uint) X360Axis.LX_Lo] = (byte) ((thumbLx >> 0) & 0xFF); // LX output[(uint) X360Axis.LX_Hi] = (byte) ((thumbLx >> 8) & 0xFF); output[(uint) X360Axis.LY_Lo] = (byte) ((thumbLy >> 0) & 0xFF); // LY output[(uint) X360Axis.LY_Hi] = (byte) ((thumbLy >> 8) & 0xFF); } if (!DeadZone(GlobalConfiguration.Instance.DeadZoneR, input[(uint)Ds3Axis.RX], input[(uint)Ds3Axis.RY])) // Right Stick DeadZone { var thumbRx = +Scale(input[(uint)Ds3Axis.RX], GlobalConfiguration.Instance.FlipRX); var thumbRy = -Scale(input[(uint)Ds3Axis.RY], GlobalConfiguration.Instance.FlipRY); output[(uint) X360Axis.RX_Lo] = (byte) ((thumbRx >> 0) & 0xFF); // RX output[(uint) X360Axis.RX_Hi] = (byte) ((thumbRx >> 8) & 0xFF); output[(uint) X360Axis.RY_Lo] = (byte) ((thumbRy >> 0) & 0xFF); // RY output[(uint) X360Axis.RY_Hi] = (byte) ((thumbRy >> 8) & 0xFF); } } break; case DsModel.DS4: { var 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[(uint) X360Axis.BT_Lo] = (byte) ((uint) xButton >> 0 & 0xFF); output[(uint) X360Axis.BT_Hi] = (byte) ((uint) xButton >> 8 & 0xFF); output[(uint) X360Axis.LT] = input[(uint) Ds4Axis.L2]; output[(uint) X360Axis.RT] = input[(uint) Ds4Axis.R2]; if (!DeadZone(GlobalConfiguration.Instance.DeadZoneL, input[(uint)Ds4Axis.LX], input[(uint)Ds4Axis.LY])) // Left Stick DeadZone { var thumbLx = +Scale(input[(uint)Ds4Axis.LX], GlobalConfiguration.Instance.FlipLX); var thumbLy = -Scale(input[(uint)Ds4Axis.LY], GlobalConfiguration.Instance.FlipLY); output[(uint) X360Axis.LX_Lo] = (byte) ((thumbLx >> 0) & 0xFF); // LX output[(uint) X360Axis.LX_Hi] = (byte) ((thumbLx >> 8) & 0xFF); output[(uint) X360Axis.LY_Lo] = (byte) ((thumbLy >> 0) & 0xFF); // LY output[(uint) X360Axis.LY_Hi] = (byte) ((thumbLy >> 8) & 0xFF); } if (!DeadZone(GlobalConfiguration.Instance.DeadZoneR, input[(uint)Ds4Axis.RX], input[(uint)Ds4Axis.RY])) // Right Stick DeadZone { var thumbRx = +Scale(input[(uint)Ds4Axis.RX], GlobalConfiguration.Instance.FlipRX); var thumbRy = -Scale(input[(uint)Ds4Axis.RY], GlobalConfiguration.Instance.FlipRY); output[(uint) X360Axis.RX_Lo] = (byte) ((thumbRx >> 0) & 0xFF); // RX output[(uint) X360Axis.RX_Hi] = (byte) ((thumbRx >> 8) & 0xFF); output[(uint) X360Axis.RY_Lo] = (byte) ((thumbRy >> 0) & 0xFF); // RY output[(uint) X360Axis.RY_Hi] = (byte) ((thumbRy >> 8) & 0xFF); } } break; } } return input[0]; }
public int Parse(byte[] Input, byte[] Output, DsModel Type = DsModel.DS3) { var serial = IndexToSerial(Input[0]); for (var 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; var xButton = X360Button.None; if (Input[1] == 0x02) // Pad is active { switch (Type) { case DsModel.DS3: { var 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[(uint)X360Axis.BT_Lo] = (byte)((uint)xButton >> 0 & 0xFF); Output[(uint)X360Axis.BT_Hi] = (byte)((uint)xButton >> 8 & 0xFF); Output[(uint)X360Axis.LT] = Input[(uint)Ds3Axis.L2]; Output[(uint)X360Axis.RT] = Input[(uint)Ds3Axis.R2]; if (!DeadZone(GlobalConfiguration.Instance.DeadZoneL, Input[(uint)Ds3Axis.LX], Input[(uint)Ds3Axis.LY])) // Left Stick DeadZone { var thumbLx = +Scale(Input[(uint)Ds3Axis.LX], GlobalConfiguration.Instance.FlipLX); var thumbLy = -Scale(Input[(uint)Ds3Axis.LY], GlobalConfiguration.Instance.FlipLY); Output[(uint)X360Axis.LX_Lo] = (byte)((thumbLx >> 0) & 0xFF); // LX Output[(uint)X360Axis.LX_Hi] = (byte)((thumbLx >> 8) & 0xFF); Output[(uint)X360Axis.LY_Lo] = (byte)((thumbLy >> 0) & 0xFF); // LY Output[(uint)X360Axis.LY_Hi] = (byte)((thumbLy >> 8) & 0xFF); } if (!DeadZone(GlobalConfiguration.Instance.DeadZoneR, Input[(uint)Ds3Axis.RX], Input[(uint)Ds3Axis.RY])) // Right Stick DeadZone { var thumbRx = +Scale(Input[(uint)Ds3Axis.RX], GlobalConfiguration.Instance.FlipRX); var thumbRy = -Scale(Input[(uint)Ds3Axis.RY], GlobalConfiguration.Instance.FlipRY); Output[(uint)X360Axis.RX_Lo] = (byte)((thumbRx >> 0) & 0xFF); // RX Output[(uint)X360Axis.RX_Hi] = (byte)((thumbRx >> 8) & 0xFF); Output[(uint)X360Axis.RY_Lo] = (byte)((thumbRy >> 0) & 0xFF); // RY Output[(uint)X360Axis.RY_Hi] = (byte)((thumbRy >> 8) & 0xFF); } } break; case DsModel.DS4: { var 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[(uint)X360Axis.BT_Lo] = (byte)((uint)xButton >> 0 & 0xFF); Output[(uint)X360Axis.BT_Hi] = (byte)((uint)xButton >> 8 & 0xFF); Output[(uint)X360Axis.LT] = Input[(uint)Ds4Axis.L2]; Output[(uint)X360Axis.RT] = Input[(uint)Ds4Axis.R2]; if (!DeadZone(GlobalConfiguration.Instance.DeadZoneL, Input[(uint)Ds4Axis.LX], Input[(uint)Ds4Axis.LY])) // Left Stick DeadZone { var thumbLx = +Scale(Input[(uint)Ds4Axis.LX], GlobalConfiguration.Instance.FlipLX); var thumbLy = -Scale(Input[(uint)Ds4Axis.LY], GlobalConfiguration.Instance.FlipLY); Output[(uint)X360Axis.LX_Lo] = (byte)((thumbLx >> 0) & 0xFF); // LX Output[(uint)X360Axis.LX_Hi] = (byte)((thumbLx >> 8) & 0xFF); Output[(uint)X360Axis.LY_Lo] = (byte)((thumbLy >> 0) & 0xFF); // LY Output[(uint)X360Axis.LY_Hi] = (byte)((thumbLy >> 8) & 0xFF); } if (!DeadZone(GlobalConfiguration.Instance.DeadZoneR, Input[(uint)Ds4Axis.RX], Input[(uint)Ds4Axis.RY])) // Right Stick DeadZone { var thumbRx = +Scale(Input[(uint)Ds4Axis.RX], GlobalConfiguration.Instance.FlipRX); var thumbRy = -Scale(Input[(uint)Ds4Axis.RY], GlobalConfiguration.Instance.FlipRY); Output[(uint)X360Axis.RX_Lo] = (byte)((thumbRx >> 0) & 0xFF); // RX Output[(uint)X360Axis.RX_Hi] = (byte)((thumbRx >> 8) & 0xFF); Output[(uint)X360Axis.RY_Lo] = (byte)((thumbRy >> 0) & 0xFF); // RY Output[(uint)X360Axis.RY_Hi] = (byte)((thumbRy >> 8) & 0xFF); } } break; } } return(Input[0]); }
public virtual bool Remap(DsModel type, int pad, string mac, byte[] input, byte[] output) { var mapped = false; try { if (m_Remapping) { switch (type) { case DsModel.DS3: mapped = RemapDs3(Find(mac, pad), input, output); break; case DsModel.DS4: mapped = RemapDs4(Find(mac, pad), input, output); break; } } } catch (Exception ex) { Log.ErrorFormat("Unexpected error: {0}", ex); } return mapped; }