diff --git a/btdrv-mitm/source/controllers/dualshock4.cpp b/btdrv-mitm/source/controllers/dualshock4.cpp index 25e5444..da8f2e6 100644 --- a/btdrv-mitm/source/controllers/dualshock4.cpp +++ b/btdrv-mitm/source/controllers/dualshock4.cpp @@ -65,10 +65,10 @@ namespace controller { } void Dualshock4Controller::handleInputReport0x01(const Dualshock4ReportData *src, SwitchReportData *dst) { - dst->report0x30.left_stick.x = static_cast(src->report0x01.left_stick.x * scale_factor) & 0xfff; - dst->report0x30.left_stick.y = static_cast((UINT8_MAX - src->report0x01.left_stick.y) * scale_factor) & 0xfff; - dst->report0x30.right_stick.x = static_cast(src->report0x01.right_stick.x * scale_factor) & 0xfff; - dst->report0x30.right_stick.y = static_cast((UINT8_MAX - src->report0x01.right_stick.y) * scale_factor) & 0xfff; + dst->report0x30.left_stick.x = static_cast(scale_factor * src->report0x01.left_stick.x) & 0xfff; + dst->report0x30.left_stick.y = static_cast(scale_factor * (UINT8_MAX - src->report0x01.left_stick.y)) & 0xfff; + dst->report0x30.right_stick.x = static_cast(scale_factor * src->report0x01.right_stick.x) & 0xfff; + dst->report0x30.right_stick.y = static_cast(scale_factor * (UINT8_MAX - src->report0x01.right_stick.y)) & 0xfff; dst->report0x30.buttons.dpad_down = (src->report0x01.buttons.dpad == Dualshock4DPad_S) || (src->report0x01.buttons.dpad == Dualshock4DPad_SE) || @@ -104,10 +104,10 @@ namespace controller { } void Dualshock4Controller::handleInputReport0x11(const Dualshock4ReportData *src, SwitchReportData *dst) { - dst->report0x30.left_stick.x = static_cast(src->report0x11.left_stick.x * scale_factor) & 0xfff; - dst->report0x30.left_stick.y = static_cast((UINT8_MAX - src->report0x11.left_stick.y) * scale_factor) & 0xfff; - dst->report0x30.right_stick.x = static_cast(src->report0x11.right_stick.x * scale_factor) & 0xfff; - dst->report0x30.right_stick.y = static_cast((UINT8_MAX - src->report0x11.right_stick.y) * scale_factor) & 0xfff; + dst->report0x30.left_stick.x = static_cast(scale_factor * src->report0x11.left_stick.x) & 0xfff; + dst->report0x30.left_stick.y = static_cast(scale_factor * (UINT8_MAX - src->report0x11.left_stick.y)) & 0xfff; + dst->report0x30.right_stick.x = static_cast(scale_factor * src->report0x11.right_stick.x) & 0xfff; + dst->report0x30.right_stick.y = static_cast(scale_factor * (UINT8_MAX - src->report0x11.right_stick.y)) & 0xfff; dst->report0x30.buttons.dpad_down = (src->report0x11.buttons.dpad == Dualshock4DPad_S) || (src->report0x11.buttons.dpad == Dualshock4DPad_SE) || diff --git a/btdrv-mitm/source/controllers/xboxone.cpp b/btdrv-mitm/source/controllers/xboxone.cpp index 01c1ec5..1833097 100644 --- a/btdrv-mitm/source/controllers/xboxone.cpp +++ b/btdrv-mitm/source/controllers/xboxone.cpp @@ -41,12 +41,11 @@ namespace controller { } void XboxOneController::handleInputReport0x01(const XboxOneReportData *src, SwitchReportData *dst) { - dst->report0x30.left_stick.x = static_cast(src->report0x01.left_stick.x * scale_factor) & 0xfff; - dst->report0x30.left_stick.y = static_cast((UINT16_MAX - src->report0x01.left_stick.y) * scale_factor) & 0xfff; - dst->report0x30.right_stick.x = static_cast(src->report0x01.right_stick.x * scale_factor) & 0xfff; - dst->report0x30.right_stick.y = static_cast((UINT16_MAX - src->report0x01.right_stick.y) * scale_factor) & 0xfff; + dst->report0x30.left_stick.x = static_cast(scale_factor * src->report0x01.left_stick.x) & 0xfff; + dst->report0x30.left_stick.y = static_cast(scale_factor * (UINT16_MAX - src->report0x01.left_stick.y)) & 0xfff; + dst->report0x30.right_stick.x = static_cast(scale_factor * src->report0x01.right_stick.x) & 0xfff; + dst->report0x30.right_stick.y = static_cast(scale_factor * (UINT16_MAX - src->report0x01.right_stick.y)) & 0xfff; - dst->report0x30.buttons.dpad_down = (src->report0x01.buttons.dpad == XboxOneDPad_S) || (src->report0x01.buttons.dpad == XboxOneDPad_SE) || (src->report0x01.buttons.dpad == XboxOneDPad_SW);