mirror of
https://github.com/ndeadly/MissionControl
synced 2024-11-26 22:30:21 +00:00
bluetooth-mitm: refactor mocute 050 handler for yet another input report variation
This commit is contained in:
parent
bb7a0865ee
commit
ad46ee78e1
2 changed files with 32 additions and 61 deletions
|
@ -30,17 +30,16 @@ namespace ams::controller {
|
|||
|
||||
switch(mocute_report->id) {
|
||||
case 0x01:
|
||||
this->HandleInputReport0x01(mocute_report);
|
||||
break;
|
||||
case 0x04:
|
||||
this->HandleInputReport0x04(mocute_report);
|
||||
case 0x06:
|
||||
this->HandleInputReport(mocute_report);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void MocuteController::HandleInputReport0x01(const MocuteReportData *src) {
|
||||
void MocuteController::HandleInputReport(const MocuteReportData *src) {
|
||||
m_left_stick = this->PackStickData(
|
||||
static_cast<uint16_t>(stick_scale_factor * src->input0x01.left_stick.x) & 0xfff,
|
||||
static_cast<uint16_t>(stick_scale_factor * (UINT8_MAX - src->input0x01.left_stick.y)) & 0xfff
|
||||
|
@ -50,6 +49,7 @@ namespace ams::controller {
|
|||
static_cast<uint16_t>(stick_scale_factor * (UINT8_MAX - src->input0x01.right_stick.y)) & 0xfff
|
||||
);
|
||||
|
||||
if (src->id == 0x01) {
|
||||
m_buttons.dpad_down = (src->input0x01.buttons.dpad == MocuteDPad2_S) ||
|
||||
(src->input0x01.buttons.dpad == MocuteDPad2_SE) ||
|
||||
(src->input0x01.buttons.dpad == MocuteDPad2_SW);
|
||||
|
@ -62,6 +62,21 @@ namespace ams::controller {
|
|||
m_buttons.dpad_left = (src->input0x01.buttons.dpad == MocuteDPad2_W) ||
|
||||
(src->input0x01.buttons.dpad == MocuteDPad2_NW) ||
|
||||
(src->input0x01.buttons.dpad == MocuteDPad2_SW);
|
||||
}
|
||||
else {
|
||||
m_buttons.dpad_down = (src->input0x01.buttons.dpad == MocuteDPad_S) ||
|
||||
(src->input0x01.buttons.dpad == MocuteDPad_SE) ||
|
||||
(src->input0x01.buttons.dpad == MocuteDPad_SW);
|
||||
m_buttons.dpad_up = (src->input0x01.buttons.dpad == MocuteDPad_N) ||
|
||||
(src->input0x01.buttons.dpad == MocuteDPad_NE) ||
|
||||
(src->input0x01.buttons.dpad == MocuteDPad_NW);
|
||||
m_buttons.dpad_right = (src->input0x01.buttons.dpad == MocuteDPad_E) ||
|
||||
(src->input0x01.buttons.dpad == MocuteDPad_NE) ||
|
||||
(src->input0x01.buttons.dpad == MocuteDPad_SE);
|
||||
m_buttons.dpad_left = (src->input0x01.buttons.dpad == MocuteDPad_W) ||
|
||||
(src->input0x01.buttons.dpad == MocuteDPad_NW) ||
|
||||
(src->input0x01.buttons.dpad == MocuteDPad_SW);
|
||||
}
|
||||
|
||||
m_buttons.A = src->input0x01.buttons.B;
|
||||
m_buttons.B = src->input0x01.buttons.A;
|
||||
|
@ -80,44 +95,4 @@ namespace ams::controller {
|
|||
m_buttons.rstick_press = src->input0x01.buttons.R3;
|
||||
}
|
||||
|
||||
void MocuteController::HandleInputReport0x04(const MocuteReportData *src) {
|
||||
m_left_stick = this->PackStickData(
|
||||
static_cast<uint16_t>(stick_scale_factor * src->input0x04.left_stick.x) & 0xfff,
|
||||
static_cast<uint16_t>(stick_scale_factor * (UINT8_MAX - src->input0x04.left_stick.y)) & 0xfff
|
||||
);
|
||||
m_right_stick = this->PackStickData(
|
||||
static_cast<uint16_t>(stick_scale_factor * src->input0x04.right_stick.x) & 0xfff,
|
||||
static_cast<uint16_t>(stick_scale_factor * (UINT8_MAX - src->input0x04.right_stick.y)) & 0xfff
|
||||
);
|
||||
|
||||
m_buttons.dpad_down = (src->input0x04.buttons.dpad == MocuteDPad_S) ||
|
||||
(src->input0x04.buttons.dpad == MocuteDPad_SE) ||
|
||||
(src->input0x04.buttons.dpad == MocuteDPad_SW);
|
||||
m_buttons.dpad_up = (src->input0x04.buttons.dpad == MocuteDPad_N) ||
|
||||
(src->input0x04.buttons.dpad == MocuteDPad_NE) ||
|
||||
(src->input0x04.buttons.dpad == MocuteDPad_NW);
|
||||
m_buttons.dpad_right = (src->input0x04.buttons.dpad == MocuteDPad_E) ||
|
||||
(src->input0x04.buttons.dpad == MocuteDPad_NE) ||
|
||||
(src->input0x04.buttons.dpad == MocuteDPad_SE);
|
||||
m_buttons.dpad_left = (src->input0x04.buttons.dpad == MocuteDPad_W) ||
|
||||
(src->input0x04.buttons.dpad == MocuteDPad_NW) ||
|
||||
(src->input0x04.buttons.dpad == MocuteDPad_SW);
|
||||
|
||||
m_buttons.A = src->input0x04.buttons.B;
|
||||
m_buttons.B = src->input0x04.buttons.A;
|
||||
m_buttons.X = src->input0x04.buttons.Y;
|
||||
m_buttons.Y = src->input0x04.buttons.X;
|
||||
|
||||
m_buttons.R = src->input0x04.buttons.R1;
|
||||
m_buttons.ZR = src->input0x04.buttons.R2;
|
||||
m_buttons.L = src->input0x04.buttons.L1;
|
||||
m_buttons.ZL = src->input0x04.buttons.L2;
|
||||
|
||||
m_buttons.minus = src->input0x04.buttons.select;
|
||||
m_buttons.plus = src->input0x04.buttons.start;
|
||||
|
||||
m_buttons.lstick_press = src->input0x04.buttons.L3;
|
||||
m_buttons.rstick_press = src->input0x04.buttons.R3;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -73,13 +73,10 @@ namespace ams::controller {
|
|||
uint8_t right_trigger;
|
||||
} __attribute__ ((__packed__));
|
||||
|
||||
typedef MocuteInputReport0x01 MocuteInputReport0x04;
|
||||
|
||||
struct MocuteReportData {
|
||||
uint8_t id;
|
||||
union {
|
||||
MocuteInputReport0x01 input0x01;
|
||||
MocuteInputReport0x04 input0x04;
|
||||
};
|
||||
} __attribute__((packed));
|
||||
|
||||
|
@ -96,8 +93,7 @@ namespace ams::controller {
|
|||
void UpdateControllerState(const bluetooth::HidReport *report);
|
||||
|
||||
private:
|
||||
void HandleInputReport0x01(const MocuteReportData *src);
|
||||
void HandleInputReport0x04(const MocuteReportData *src);
|
||||
void HandleInputReport(const MocuteReportData *src);
|
||||
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue