Code cleanup

This commit is contained in:
Kevin Mark 2013-03-30 04:15:25 -04:00
parent 67a8989cef
commit f3342aa589
4 changed files with 366 additions and 356 deletions

View file

@ -598,6 +598,7 @@ void PS3BT::setRumbleOn(Rumble mode) {
setRumbleOn(0xfe, power[0], 0xfe, power[1]); 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) {
HIDBuffer[3] = rightDuration; HIDBuffer[3] = rightDuration;
HIDBuffer[4] = rightPower; HIDBuffer[4] = rightPower;
@ -605,6 +606,7 @@ void PS3BT::setRumbleOn(uint8_t rightDuration, uint8_t rightPower, uint8_t leftD
HIDBuffer[6] = leftPower; HIDBuffer[6] = leftPower;
HID_Command(HIDBuffer, HID_BUFFERSIZE); HID_Command(HIDBuffer, HID_BUFFERSIZE);
} }
void PS3BT::setLedOff(LED a) { void PS3BT::setLedOff(LED a) {
HIDBuffer[11] &= ~((uint8_t)((pgm_read_byte(&LEDS[(uint8_t)a]) & 0x0f) << 1)); HIDBuffer[11] &= ~((uint8_t)((pgm_read_byte(&LEDS[(uint8_t)a]) & 0x0f) << 1));
HID_Command(HIDBuffer, HID_BUFFERSIZE); HID_Command(HIDBuffer, HID_BUFFERSIZE);

View file

@ -445,15 +445,16 @@ void PS3USB::setRumbleOff() {
} }
void PS3USB::setRumbleOn(Rumble mode) { void PS3USB::setRumbleOn(Rumble mode) {
if ((mode & 0x30) > 0) { if ((mode & 0x30) > 0x00) {
uint8_t power[2] = { 0xff, 0 }; // Defaults to RumbleLow uint8_t power[2] = { 0xff, 0x00 }; // Defaults to RumbleLow
if (mode == RumbleHigh) { if (mode == RumbleHigh) {
power[0] = 0; power[0] = 0x00;
power[1] = 0xff; power[1] = 0xff;
} }
setRumbleOn(0xfe, power[0], 0xfe, power[1]); 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) {
writeBuf[1] = rightDuration; writeBuf[1] = rightDuration;
writeBuf[2] = rightPower; writeBuf[2] = rightPower;
@ -461,6 +462,7 @@ void PS3USB::setRumbleOn(uint8_t rightDuration, uint8_t rightPower, uint8_t left
writeBuf[4] = leftPower; writeBuf[4] = leftPower;
PS3_Command(writeBuf, PS3_REPORT_BUFFER_SIZE); PS3_Command(writeBuf, PS3_REPORT_BUFFER_SIZE);
} }
void PS3USB::setLedOff(LED a) { void PS3USB::setLedOff(LED a) {
writeBuf[9] &= ~((uint8_t)((pgm_read_byte(&LEDS[(uint8_t)a]) & 0x0f) << 1)); writeBuf[9] &= ~((uint8_t)((pgm_read_byte(&LEDS[(uint8_t)a]) & 0x0f) << 1));
PS3_Command(writeBuf, PS3_REPORT_BUFFER_SIZE); PS3_Command(writeBuf, PS3_REPORT_BUFFER_SIZE);

View file

@ -91,16 +91,22 @@ public:
* @return 0 on success. * @return 0 on success.
*/ */
virtual uint8_t Poll(); virtual uint8_t Poll();
/** /**
* Get the device address. * Get the device address.
* @return The device address. * @return The device address.
*/ */
virtual uint8_t GetAddress() { return bAddress; }; virtual uint8_t GetAddress() {
return bAddress;
};
/** /**
* Used to check if the controller has been initialized. * Used to check if the controller has been initialized.
* @return True if it's ready. * @return True if it's ready.
*/ */
virtual bool isReady() { return bPollEnable; }; virtual bool isReady() {
return bPollEnable;
};
/**@}*/ /**@}*/
/** /**