Removed duplicate code from PS3BT/PS3USB's setRumbleOn

This commit is contained in:
Kevin Mark 2013-03-30 01:18:43 -04:00
parent adff5d790d
commit 67a8989cef
2 changed files with 14 additions and 34 deletions

View file

@ -589,23 +589,13 @@ void PS3BT::setRumbleOff() {
} }
void PS3BT::setRumbleOn(Rumble mode) { 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) { if ((mode & 0x30) > 0) {
HIDBuffer[3] = 0xfe; uint8_t power[2] = { 0xff, 0 }; // Defaults to RumbleLow
HIDBuffer[5] = 0xfe;
if (mode == RumbleHigh) { if (mode == RumbleHigh) {
HIDBuffer[4] = 0; //low mode off power[0] = 0;
HIDBuffer[6] = 0xff; //high mode on power[1] = 0xff;
} else {
HIDBuffer[4] = 0xff; //low mode on
HIDBuffer[6] = 0; //high mode off
} }
HID_Command(HIDBuffer, HID_BUFFERSIZE); setRumbleOn(0xfe, power[0], 0xfe, power[1]);
} }
} }
void PS3BT::setRumbleOn(uint8_t rightDuration, uint8_t rightPower, uint8_t leftDuration, uint8_t leftPower) { void PS3BT::setRumbleOn(uint8_t rightDuration, uint8_t rightPower, uint8_t leftDuration, uint8_t leftPower) {

View file

@ -445,23 +445,13 @@ void PS3USB::setRumbleOff() {
} }
void PS3USB::setRumbleOn(Rumble mode) { 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) { if ((mode & 0x30) > 0) {
writeBuf[1] = 0xfe; uint8_t power[2] = { 0xff, 0 }; // Defaults to RumbleLow
writeBuf[3] = 0xfe;
if (mode == RumbleHigh) { if (mode == RumbleHigh) {
writeBuf[2] = 0; //low mode off power[0] = 0;
writeBuf[4] = 0xff; //high mode on power[1] = 0xff;
} else {
writeBuf[2] = 0xff; //low mode on
writeBuf[4] = 0; //high mode off
} }
PS3_Command(writeBuf, PS3_REPORT_BUFFER_SIZE); setRumbleOn(0xfe, power[0], 0xfe, power[1]);
} }
} }
void PS3USB::setRumbleOn(uint8_t rightDuration, uint8_t rightPower, uint8_t leftDuration, uint8_t leftPower) { void PS3USB::setRumbleOn(uint8_t rightDuration, uint8_t rightPower, uint8_t leftDuration, uint8_t leftPower) {