bluetooth-mitm: map controls for steelseries nimbus

This commit is contained in:
ndeadly 2020-10-11 12:17:30 +02:00
parent c4cd9d5cdd
commit 825e675e60
4 changed files with 69 additions and 9 deletions

@ -1 +1 @@
Subproject commit 2c3ccef17e9b267a5d9d232f1aba689f2c591b95
Subproject commit 48dbf4808f4f2042de8c45e9ec471a8f60d5d621

View file

@ -33,6 +33,8 @@ namespace ams::controller {
this->HandleInputReport0x01(steelseries_report);
break;
default:
// Todo: handle this properly
this->HandleMfiInputReport(steelseries_report);
break;
}
}
@ -65,11 +67,39 @@ 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.R;
m_buttons.L = src->input0x01.buttons.L;
m_buttons.minus = src->input0x01.buttons.select;
m_buttons.plus = src->input0x01.buttons.start;
m_buttons.minus = src->input0x01.buttons.select;
m_buttons.plus = src->input0x01.buttons.start;
}
void SteelseriesController::HandleMfiInputReport(const SteelseriesReportData *src) {
m_left_stick = this->PackStickData(
static_cast<uint16_t>(stick_scale_factor * -static_cast<int8_t>(~src->input_mfi.left_stick.x + 1) + 0x7ff) & 0xfff,
static_cast<uint16_t>(stick_scale_factor * (-static_cast<int8_t>(~src->input_mfi.left_stick.y + 1)) + 0x7ff) & 0xfff
);
m_right_stick = this->PackStickData(
static_cast<uint16_t>(stick_scale_factor * -static_cast<int8_t>(~src->input_mfi.right_stick.x + 1) + 0x7ff) & 0xfff,
static_cast<uint16_t>(stick_scale_factor * (-static_cast<int8_t>(~src->input_mfi.right_stick.y + 1)) + 0x7ff) & 0xfff
);
m_buttons.dpad_up = src->input_mfi.buttons.dpad_up > 0;
m_buttons.dpad_right = src->input_mfi.buttons.dpad_right > 0;
m_buttons.dpad_down = src->input_mfi.buttons.dpad_down > 0;
m_buttons.dpad_left = src->input_mfi.buttons.dpad_left > 0;
m_buttons.A = src->input_mfi.buttons.A > 0;
m_buttons.B = src->input_mfi.buttons.B > 0;
m_buttons.X = src->input_mfi.buttons.X > 0;
m_buttons.Y = src->input_mfi.buttons.Y > 0;
m_buttons.R = src->input_mfi.buttons.R1 > 0;
m_buttons.L = src->input_mfi.buttons.L1 > 0;
m_buttons.ZR = src->input_mfi.buttons.R2 > 0;
m_buttons.ZL = src->input_mfi.buttons.L2 > 0;
m_buttons.home = src->input_mfi.buttons.menu;
}
}

View file

@ -51,6 +51,30 @@ namespace ams::controller {
uint8_t select : 1;
uint8_t : 0;
} __attribute__ ((__packed__));
struct SteelseriesMfiButtonData {
uint8_t dpad_up;
uint8_t dpad_right;
uint8_t dpad_down;
uint8_t dpad_left;
uint8_t A;
uint8_t B;
uint8_t X;
uint8_t Y;
uint8_t L1;
uint8_t R1;
uint8_t L2;
uint8_t R2;
uint8_t menu : 1;
uint8_t : 0;
} __attribute__ ((__packed__));
struct SteelseriesMfiInputReport {
SteelseriesMfiButtonData buttons;
SteelseriesStickData left_stick;
SteelseriesStickData right_stick;
} __attribute__((packed));
struct SteelseriesInputReport0x01 {
uint8_t dpad;
@ -60,9 +84,15 @@ namespace ams::controller {
} __attribute__((packed));
struct SteelseriesReportData {
uint8_t id;
union {
SteelseriesInputReport0x01 input0x01;
struct {
uint8_t id;
union {
SteelseriesInputReport0x01 input0x01;
};
};
SteelseriesMfiInputReport input_mfi;
};
} __attribute__((packed));
@ -81,7 +111,7 @@ namespace ams::controller {
private:
void HandleInputReport0x01(const SteelseriesReportData *src);
void HandleMfiInputReport(const SteelseriesReportData *src);
};
}

2
libnx

@ -1 +1 @@
Subproject commit 9d939bcd7e821cef3cb8ef2529b409252b883041
Subproject commit ffde37ae3d0be30269f5aa5d0c1986e6d7dcdb10