From 67a8989cefb9c123100fb568e4b3b1816280dc77 Mon Sep 17 00:00:00 2001 From: Kevin Mark Date: Sat, 30 Mar 2013 01:18:43 -0400 Subject: [PATCH] Removed duplicate code from PS3BT/PS3USB's setRumbleOn --- PS3BT.cpp | 24 +++++++----------------- PS3USB.cpp | 24 +++++++----------------- 2 files changed, 14 insertions(+), 34 deletions(-) diff --git a/PS3BT.cpp b/PS3BT.cpp index d957a666..e72a60ce 100644 --- a/PS3BT.cpp +++ b/PS3BT.cpp @@ -589,24 +589,14 @@ void PS3BT::setRumbleOff() { } void PS3BT::setRumbleOn(Rumble mode) { - /* Still not totally sure how it works, maybe something like this instead? - * 3 - duration_right - * 4 - power_right - * 5 - duration_left - * 6 - power_left - */ - if ((mode & 0x30) > 0) { - HIDBuffer[3] = 0xfe; - HIDBuffer[5] = 0xfe; - if (mode == RumbleHigh) { - HIDBuffer[4] = 0; //low mode off - HIDBuffer[6] = 0xff; //high mode on - } else { - HIDBuffer[4] = 0xff; //low mode on - HIDBuffer[6] = 0; //high mode off - } - HID_Command(HIDBuffer, HID_BUFFERSIZE); + if ((mode & 0x30) > 0) { + uint8_t power[2] = { 0xff, 0 }; // Defaults to RumbleLow + if (mode == RumbleHigh) { + power[0] = 0; + power[1] = 0xff; } + setRumbleOn(0xfe, power[0], 0xfe, power[1]); + } } void PS3BT::setRumbleOn(uint8_t rightDuration, uint8_t rightPower, uint8_t leftDuration, uint8_t leftPower) { HIDBuffer[3] = rightDuration; diff --git a/PS3USB.cpp b/PS3USB.cpp index b329e174..6e58286a 100644 --- a/PS3USB.cpp +++ b/PS3USB.cpp @@ -445,24 +445,14 @@ void PS3USB::setRumbleOff() { } void PS3USB::setRumbleOn(Rumble mode) { - /* Still not totally sure how it works, maybe something like this instead? - * 3 - duration_right - * 4 - power_right - * 5 - duration_left - * 6 - power_left - */ - if ((mode & 0x30) > 0) { - writeBuf[1] = 0xfe; - writeBuf[3] = 0xfe; - if (mode == RumbleHigh) { - writeBuf[2] = 0; //low mode off - writeBuf[4] = 0xff; //high mode on - } else { - writeBuf[2] = 0xff; //low mode on - writeBuf[4] = 0; //high mode off - } - PS3_Command(writeBuf, PS3_REPORT_BUFFER_SIZE); + if ((mode & 0x30) > 0) { + uint8_t power[2] = { 0xff, 0 }; // Defaults to RumbleLow + if (mode == RumbleHigh) { + power[0] = 0; + power[1] = 0xff; } + setRumbleOn(0xfe, power[0], 0xfe, power[1]); + } } void PS3USB::setRumbleOn(uint8_t rightDuration, uint8_t rightPower, uint8_t leftDuration, uint8_t leftPower) { writeBuf[1] = rightDuration;