protected override void ParseHidReport(byte[] report) { if (report[1] != 0x01) { return; } PacketCounter++; #region HID Report translation // no battery state since the Gamepad is USB-powered m_BatteryStatus = InputReport.SetBatteryStatus(DsBattery.None); // packet counter InputReport.PacketCounter = PacketCounter; // set fake MAC address InputReport.PadMacAddress = PhysicalAddress.Parse(m_Mac.Replace(":", string.Empty)); // reset buttons InputReport.ZeroSelectStartButtonsState(); InputReport.ZeroShoulderButtonsState(); InputReport.Set(Ds3Button.Select, IsBitSet(report[7], 4)); // Select InputReport.Set(Ds3Button.Start, IsBitSet(report[7], 5)); // Start InputReport.Set(Ds3Button.L1, IsBitSet(report[7], 0)); // L1 (button) InputReport.Set(Ds3Button.R1, IsBitSet(report[7], 2)); // R1 (button) InputReport.Set(Ds3Button.Triangle, IsBitSet(report[6], 4)); // Triangle (button) InputReport.Set(Ds3Button.Circle, IsBitSet(report[6], 5)); // Circle (button) InputReport.Set(Ds3Button.Cross, IsBitSet(report[6], 6)); // Cross (button) InputReport.Set(Ds3Button.Square, IsBitSet(report[6], 7)); // Square (button) InputReport.Set(Ds3Button.Right, (report[4] == 0xFF)); // D-Pad right InputReport.Set(Ds3Button.Left, (report[4] == 0x00)); // D-Pad left InputReport.Set(Ds3Button.Up, (report[5] == 0x00)); // D-Pad up InputReport.Set(Ds3Button.Down, (report[5] == 0xFF)); // D-Pad down // This device has no thumb sticks, center axes InputReport.Set(Ds3Axis.Lx, 0x80); InputReport.Set(Ds3Axis.Ly, 0x80); InputReport.Set(Ds3Axis.Rx, 0x80); InputReport.Set(Ds3Axis.Ry, 0x80); #endregion OnHidReportReceived(); }
protected override void ParseHidReport(byte[] report) { if (report[5] != 0x00) { return; } PacketCounter++; #region HID Report translation // no battery state since the Gamepad is USB-powered m_BatteryStatus = InputReport.SetBatteryStatus(DsBattery.None); // packet counter InputReport.PacketCounter = PacketCounter; InputReport.Set(Ds3Button.Triangle, IsBitSet(report[6], 4)); InputReport.Set(Ds3Button.Circle, IsBitSet(report[6], 5)); InputReport.Set(Ds3Button.Cross, IsBitSet(report[6], 6)); InputReport.Set(Ds3Button.Square, IsBitSet(report[6], 7)); InputReport.Set(Ds3Button.Select, IsBitSet(report[7], 4)); InputReport.Set(Ds3Button.Start, IsBitSet(report[7], 5)); InputReport.Set(Ds3Button.Up, (report[4] == 0x00)); InputReport.Set(Ds3Button.Right, (report[3] == 0xFF)); InputReport.Set(Ds3Button.Down, (report[4] == 0xFF)); InputReport.Set(Ds3Button.Left, (report[3] == 0x00)); InputReport.Set(Ds3Button.L1, IsBitSet(report[7], 0)); InputReport.Set(Ds3Button.R1, IsBitSet(report[7], 1)); InputReport.Set(Ds3Button.L2, IsBitSet(report[7], 2)); InputReport.Set(Ds3Button.R2, IsBitSet(report[7], 3)); InputReport.Set(Ds3Button.L3, IsBitSet(report[7], 6)); InputReport.Set(Ds3Button.R3, IsBitSet(report[7], 7)); // TODO: the PS-button is dead according to the report: // http://forums.pcsx2.net/attachment.php?aid=57420 #endregion OnHidReportReceived(); }
protected override void ParseHidReport(byte[] report) { if (report[26] != 0x02) { return; } PacketCounter++; #region HID Report translation // battery m_BatteryStatus = InputReport.BatteryStatus = report[30]; // packet counter InputReport.PacketCounter = PacketCounter; // null button states InputReport.ZeroPsButtonState(); InputReport.ZeroSelectStartButtonsState(); InputReport.ZeroShoulderButtonsState(); // control buttons InputReport.Set(Ds3Button.Ps, IsBitSet(report[1], 4)); InputReport.Set(Ds3Button.Select, IsBitSet(report[1], 0)); InputReport.Set(Ds3Button.Start, IsBitSet(report[1], 1)); // Left shoulder InputReport.Set(Ds3Button.L1, IsBitSet(report[0], 4)); InputReport.Set(Ds3Axis.L1, report[15]); // Right shoulder InputReport.Set(Ds3Button.R1, IsBitSet(report[0], 5)); InputReport.Set(Ds3Axis.R1, report[16]); // Left trigger InputReport.Set(Ds3Button.L2, IsBitSet(report[0], 6)); InputReport.Set(Ds3Axis.L2, report[17]); // Right trigger InputReport.Set(Ds3Button.R2, IsBitSet(report[0], 7)); InputReport.Set(Ds3Axis.R2, report[18]); // Triangle InputReport.Set(Ds3Button.Triangle, IsBitSet(report[0], 3)); InputReport.Set(Ds3Axis.Triangle, report[11]); // Circle InputReport.Set(Ds3Button.Circle, IsBitSet(report[0], 2)); InputReport.Set(Ds3Axis.Circle, report[12]); // Cross InputReport.Set(Ds3Button.Cross, IsBitSet(report[0], 1)); InputReport.Set(Ds3Axis.Cross, report[13]); // Square InputReport.Set(Ds3Button.Square, IsBitSet(report[0], 0)); InputReport.Set(Ds3Axis.Square, report[14]); // Left thumb InputReport.Set(Ds3Button.L3, IsBitSet(report[1], 2)); // Right thumb InputReport.Set(Ds3Button.R3, IsBitSet(report[1], 3)); // D-Pad if (report[2] != 0x0F) { switch (report[2]) { case 0: InputReport.Set(Ds3Button.Up); break; case 1: InputReport.Set(Ds3Button.Up); InputReport.Set(Ds3Button.Right); break; case 2: InputReport.Set(Ds3Button.Right); break; case 3: InputReport.Set(Ds3Button.Right); InputReport.Set(Ds3Button.Down); break; case 4: InputReport.Set(Ds3Button.Down); break; case 5: InputReport.Set(Ds3Button.Down); InputReport.Set(Ds3Button.Left); break; case 6: InputReport.Set(Ds3Button.Left); break; case 7: InputReport.Set(Ds3Button.Left); InputReport.Set(Ds3Button.Up); break; } } // Left thumb stick InputReport.Set(Ds3Axis.Lx, report[3]); InputReport.Set(Ds3Axis.Ly, report[4]); // Right thumb stick InputReport.Set(Ds3Axis.Rx, report[5]); InputReport.Set(Ds3Axis.Ry, report[6]); #endregion OnHidReportReceived(); }
protected override void ParseHidReport(byte[] report) { if (report[8] != 0xC0 && report[8] != 0x40) { return; } PacketCounter++; #region HID Report translation // no battery state since the Gamepad is USB-powered m_BatteryStatus = InputReport.SetBatteryStatus(DsBattery.None); // packet counter InputReport.PacketCounter = PacketCounter; // set fake MAC address InputReport.PadMacAddress = PhysicalAddress.Parse(m_Mac.Replace(":", string.Empty)); // reset buttons InputReport.ZeroSelectStartButtonsState(); InputReport.ZeroShoulderButtonsState(); // buttons equaly reported in both modes InputReport.Set(Ds3Button.Circle, IsBitSet(report[6], 5)); InputReport.Set(Ds3Button.Cross, IsBitSet(report[6], 6)); InputReport.Set(Ds3Button.Triangle, IsBitSet(report[6], 4)); InputReport.Set(Ds3Button.Square, IsBitSet(report[6], 7)); InputReport.Set(Ds3Button.Select, IsBitSet(report[7], 4)); InputReport.Set(Ds3Button.Start, IsBitSet(report[7], 5)); InputReport.Set(Ds3Button.L1, IsBitSet(report[7], 0)); InputReport.Set(Ds3Button.R1, IsBitSet(report[7], 1)); InputReport.Set(Ds3Button.L2, IsBitSet(report[7], 2)); InputReport.Set(Ds3Button.R2, IsBitSet(report[7], 3)); InputReport.Set(Ds3Button.L3, IsBitSet(report[7], 6)); InputReport.Set(Ds3Button.R3, IsBitSet(report[7], 7)); // detect mode it's running in switch (report[8]) { case 0xC0: // mode 1 { InputReport.Set(Ds3Button.Up, (report[2] == 0x00)); InputReport.Set(Ds3Button.Right, (report[1] == 0xFF)); InputReport.Set(Ds3Button.Down, (report[2] == 0xFF)); InputReport.Set(Ds3Button.Left, (report[1] == 0x00)); // mode 1 doesn't report the thumb sticks InputReport.Set(Ds3Axis.Lx, 0x80); InputReport.Set(Ds3Axis.Ly, 0x80); InputReport.Set(Ds3Axis.Rx, 0x80); InputReport.Set(Ds3Axis.Ry, 0x80); } break; case 0x40: // mode 2 { var dPad = (byte)(report[6] & ~0xF0); switch (dPad) { case 0: InputReport.Set(Ds3Button.Up); break; case 1: InputReport.Set(Ds3Button.Up); InputReport.Set(Ds3Button.Right); break; case 2: InputReport.Set(Ds3Button.Right); break; case 3: InputReport.Set(Ds3Button.Right); InputReport.Set(Ds3Button.Down); break; case 4: InputReport.Set(Ds3Button.Down); break; case 5: InputReport.Set(Ds3Button.Down); InputReport.Set(Ds3Button.Left); break; case 6: InputReport.Set(Ds3Button.Left); break; case 7: InputReport.Set(Ds3Button.Left); InputReport.Set(Ds3Button.Up); break; } InputReport.Set(Ds3Axis.Lx, report[1]); InputReport.Set(Ds3Axis.Ly, report[2]); InputReport.Set(Ds3Axis.Rx, report[4]); InputReport.Set(Ds3Axis.Ry, report[5]); } break; } #endregion OnHidReportReceived(); }
protected override void ParseHidReport(byte[] report) { if (report[2] != 0x00) { return; } if (PacketCounter++ + 1 < PacketCounter) { Log.WarnFormat("Packet counter rolled over ({0}), resetting to 0", PacketCounter); PacketCounter = 0; } #region HID Report translation // no battery state since the Gamepad is USB-powered m_BatteryStatus = InputReport.SetBatteryStatus(DsBattery.None); // packet counter InputReport.PacketCounter = PacketCounter; // set fake MAC address InputReport.PadMacAddress = PhysicalAddress.Parse(m_Mac.Replace(":", string.Empty)); // null button states InputReport.ZeroPsButtonState(); InputReport.ZeroSelectStartButtonsState(); InputReport.ZeroShoulderButtonsState(); // control buttons InputReport.Set(Ds3Button.Select, IsBitSet(report[6], 4)); InputReport.Set(Ds3Button.Start, IsBitSet(report[6], 5)); // Left shoulder InputReport.Set(Ds3Button.L1, IsBitSet(report[6], 0)); // Right shoulder InputReport.Set(Ds3Button.R1, IsBitSet(report[6], 1)); // Left trigger InputReport.Set(Ds3Button.L2, IsBitSet(report[6], 2)); // Right trigger InputReport.Set(Ds3Button.R2, IsBitSet(report[6], 3)); // Triangle InputReport.Set(Ds3Button.Triangle, IsBitSet(report[5], 4)); // Circle InputReport.Set(Ds3Button.Circle, IsBitSet(report[5], 5)); // Cross InputReport.Set(Ds3Button.Cross, IsBitSet(report[5], 6)); // Square InputReport.Set(Ds3Button.Square, IsBitSet(report[5], 7)); // Left thumb InputReport.Set(Ds3Button.L3, IsBitSet(report[6], 6)); // Right thumb InputReport.Set(Ds3Button.R3, IsBitSet(report[6], 7)); var dPad = (byte)(report[5] & ~0xF0); // D-Pad switch (dPad) { case 0: InputReport.Set(Ds3Button.Up); break; case 1: InputReport.Set(Ds3Button.Up); InputReport.Set(Ds3Button.Right); break; case 2: InputReport.Set(Ds3Button.Right); break; case 3: InputReport.Set(Ds3Button.Right); InputReport.Set(Ds3Button.Down); break; case 4: InputReport.Set(Ds3Button.Down); break; case 5: InputReport.Set(Ds3Button.Down); InputReport.Set(Ds3Button.Left); break; case 6: InputReport.Set(Ds3Button.Left); break; case 7: InputReport.Set(Ds3Button.Left); InputReport.Set(Ds3Button.Up); break; } // Left thumb stick InputReport.Set(Ds3Axis.Lx, report[0]); InputReport.Set(Ds3Axis.Ly, report[1]); // Right thumb stick InputReport.Set(Ds3Axis.Rx, report[3]); InputReport.Set(Ds3Axis.Ry, report[4]); #endregion OnHidReportReceived(); }