mc.mitm: add support for steelseries stratus xl controller

This commit is contained in:
ndeadly 2022-07-27 10:47:04 +02:00
parent fe31665695
commit badbbbd61e
3 changed files with 83 additions and 22 deletions

View file

@ -48,6 +48,7 @@ Use controllers from other consoles natively on your Nintendo Switch via Bluetoo
* __Steelseries Free__
* __Steelseries Nimbus__
* __Steelseries Stratus Duo__
* __Steelseries Stratus XL__
* __GameSir G3s__
* __GameSir G4s__
* __GameSir T1s__

View file

@ -29,7 +29,14 @@ namespace ams::controller {
switch(steelseries_report->id) {
case 0x01:
this->MapInputReport0x01(steelseries_report); break;
if (report->size == sizeof(SteelseriesInputReport0x01_v2) + 1) {
this->MapInputReport0x01_v2(steelseries_report);
} else {
this->MapInputReport0x01(steelseries_report);
}
break;
case 0x02:
this->MapInputReport0x02(steelseries_report); break;
case 0x12:
this->MapInputReport0x12(steelseries_report); break;
case 0xc4:
@ -69,15 +76,59 @@ namespace ams::controller {
m_buttons.X = src->input0x01.buttons.Y;
m_buttons.Y = src->input0x01.buttons.X;
m_buttons.R = src->input0x01.buttons.R;
m_buttons.L = src->input0x01.buttons.L;
m_buttons.R = src->input0x01.buttons.R1;
m_buttons.L = src->input0x01.buttons.L1;
m_buttons.minus = src->input0x01.buttons.select;
m_buttons.plus = src->input0x01.buttons.start;
}
void SteelseriesController::MapInputReport0x01_v2(const SteelseriesReportData *src) {
m_left_stick.SetData(
static_cast<u16>( src->input0x01_v2.left_stick.x + 0x7ff) & UINT12_MAX,
static_cast<u16>(-src->input0x01_v2.left_stick.y + 0x7ff) & UINT12_MAX
);
m_right_stick.SetData(
static_cast<u16>( src->input0x01_v2.right_stick.x + 0x7ff) & UINT12_MAX,
static_cast<u16>(-src->input0x01_v2.right_stick.y + 0x7ff) & UINT12_MAX
);
m_buttons.dpad_down = (src->input0x01_v2.dpad == SteelseriesDPad_S) ||
(src->input0x01_v2.dpad == SteelseriesDPad_SE) ||
(src->input0x01_v2.dpad == SteelseriesDPad_SW);
m_buttons.dpad_up = (src->input0x01_v2.dpad == SteelseriesDPad_N) ||
(src->input0x01_v2.dpad == SteelseriesDPad_NE) ||
(src->input0x01_v2.dpad == SteelseriesDPad_NW);
m_buttons.dpad_right = (src->input0x01_v2.dpad == SteelseriesDPad_E) ||
(src->input0x01_v2.dpad == SteelseriesDPad_NE) ||
(src->input0x01_v2.dpad == SteelseriesDPad_SE);
m_buttons.dpad_left = (src->input0x01_v2.dpad == SteelseriesDPad_W) ||
(src->input0x01_v2.dpad == SteelseriesDPad_NW) ||
(src->input0x01_v2.dpad == SteelseriesDPad_SW);
m_buttons.A = src->input0x01_v2.buttons.B;
m_buttons.B = src->input0x01_v2.buttons.A;
m_buttons.X = src->input0x01_v2.buttons.Y;
m_buttons.Y = src->input0x01_v2.buttons.X;
m_buttons.R = src->input0x01_v2.buttons.R1;
m_buttons.ZR = src->input0x01_v2.right_trigger > 0x7ff;
m_buttons.L = src->input0x01_v2.buttons.L1;
m_buttons.ZL = src->input0x01_v2.left_trigger > 0x7ff;
m_buttons.rstick_press = src->input0x01_v2.buttons.R3;
m_buttons.lstick_press = src->input0x01_v2.buttons.L3;
m_buttons.plus = src->input0x01_v2.buttons.start;
}
void SteelseriesController::MapInputReport0x02(const SteelseriesReportData *src) {
m_buttons.minus = src->input0x02.select;
m_buttons.home = src->input0x02.home;
}
void SteelseriesController::MapInputReport0x12(const SteelseriesReportData *src) {
m_buttons.home = src->input0x12.home;
m_buttons.home = src->input0x12.home;
}
void SteelseriesController::MapInputReport0xc4(const SteelseriesReportData *src) {

View file

@ -47,23 +47,12 @@ namespace ams::controller {
u8 y;
} PACKED;
struct SteelseriesButtonData {
u8 A : 1;
u8 B : 1;
u8 : 1;
u8 X : 1;
u8 Y : 1;
u8 : 1;
u8 L : 1;
u8 R : 1;
u8 : 3;
u8 start : 1;
u8 select : 1;
u8 : 0;
struct SteelseriesStickData2 {
s16 x;
s16 y;
} PACKED;
struct SteelseriesButtonData2 {
struct SteelseriesButtonData {
u8 A : 1;
u8 B : 1;
u8 : 1;
@ -75,9 +64,9 @@ namespace ams::controller {
u8 L2 : 1;
u8 R2 : 1;
u8 : 1;
u8 start : 1;
u8 select : 1;
u8 : 1;
u8 L3 : 1;
u8 R3 : 1;
u8 : 0;
@ -114,6 +103,21 @@ namespace ams::controller {
SteelseriesButtonData buttons;
} PACKED;
struct SteelseriesInputReport0x01_v2 {
u8 dpad;
SteelseriesButtonData buttons;
SteelseriesStickData2 left_stick;
SteelseriesStickData2 right_stick;
u16 right_trigger;
u16 left_trigger;
} PACKED;
struct SteelseriesInputReport0x02 {
u8 select : 1;
u8 home : 1;
u8 : 0;
} PACKED;
struct SteelseriesInputReport0x12 {
u8 : 3;
u8 home : 1;
@ -130,7 +134,7 @@ namespace ams::controller {
SteelseriesStickData right_stick;
u8 left_trigger;
u8 right_trigger;
SteelseriesButtonData2 buttons;
SteelseriesButtonData buttons;
u8 dpad;
u8 _unk[2];
} PACKED;
@ -141,6 +145,8 @@ namespace ams::controller {
u8 id;
union {
SteelseriesInputReport0x01 input0x01;
SteelseriesInputReport0x01_v2 input0x01_v2;
SteelseriesInputReport0x02 input0x02;
SteelseriesInputReport0x12 input0x12;
SteelseriesInputReport0xc4 input0xc4;
};
@ -156,7 +162,8 @@ namespace ams::controller {
static constexpr const HardwareID hardware_ids[] = {
{0x1038, 0x1412}, // Steelseries Free
{0x0111, 0x1420}, // Steelseries Nimbus
{0x0111, 0x1431} // Steelseries Stratus Duo
{0x0111, 0x1431}, // Steelseries Stratus Duo
{0x0111, 0x1419} // Steelseries Stratus XL
};
SteelseriesController(const bluetooth::Address *address, HardwareID id)
@ -166,6 +173,8 @@ namespace ams::controller {
private:
void MapInputReport0x01(const SteelseriesReportData *src);
void MapInputReport0x01_v2(const SteelseriesReportData *src);
void MapInputReport0x02(const SteelseriesReportData *src);
void MapInputReport0x12(const SteelseriesReportData *src);
void MapInputReport0xc4(const SteelseriesReportData *src);
void MapMfiInputReport(const SteelseriesReportData *src);