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

@ -72,7 +72,7 @@ public:
* Pass your dongles Bluetooth address into the constructor, * Pass your dongles Bluetooth address into the constructor,
* This will set BTD#my_bdaddr, so you don't have to plug in the dongle before pairing with your controller. * This will set BTD#my_bdaddr, so you don't have to plug in the dongle before pairing with your controller.
*/ */
PS3BT(BTD *pBtd, uint8_t btadr5=0, uint8_t btadr4=0, uint8_t btadr3=0, uint8_t btadr2=0, uint8_t btadr1=0, uint8_t btadr0=0); PS3BT(BTD *pBtd, uint8_t btadr5 = 0, uint8_t btadr4 = 0, uint8_t btadr3 = 0, uint8_t btadr2 = 0, uint8_t btadr1 = 0, uint8_t btadr0 = 0);
/** @name BluetoothService implementation */ /** @name BluetoothService implementation */
/** /**

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

@ -70,7 +70,7 @@ public:
* Pass your dongles Bluetooth address into the constructor, * Pass your dongles Bluetooth address into the constructor,
* so you are able to pair the controller with a Bluetooth dongle. * so you are able to pair the controller with a Bluetooth dongle.
*/ */
PS3USB(USB *pUsb, uint8_t btadr5=0, uint8_t btadr4=0, uint8_t btadr3=0, uint8_t btadr2=0, uint8_t btadr1=0, uint8_t btadr0=0); PS3USB(USB *pUsb, uint8_t btadr5 = 0, uint8_t btadr4 = 0, uint8_t btadr3 = 0, uint8_t btadr2 = 0, uint8_t btadr1 = 0, uint8_t btadr0 = 0);
/** @name USBDeviceConfig implementation */ /** @name USBDeviceConfig implementation */
/** /**
@ -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;
};
/**@}*/ /**@}*/
/** /**