Overloaded PS3BT/PS3USB's setRumbleOn to accept custom rumble settings.

This commit is contained in:
Kevin Mark 2013-03-30 00:54:13 -04:00
parent 904f2ff25a
commit adff5d790d
4 changed files with 343 additions and 321 deletions

View file

@ -608,7 +608,13 @@ void PS3BT::setRumbleOn(Rumble mode) {
HID_Command(HIDBuffer, HID_BUFFERSIZE);
}
}
void PS3BT::setRumbleOn(uint8_t rightDuration, uint8_t rightPower, uint8_t leftDuration, uint8_t leftPower) {
HIDBuffer[3] = rightDuration;
HIDBuffer[4] = rightPower;
HIDBuffer[5] = leftDuration;
HIDBuffer[6] = leftPower;
HID_Command(HIDBuffer, HID_BUFFERSIZE);
}
void PS3BT::setLedOff(LED a) {
HIDBuffer[11] &= ~((uint8_t)((pgm_read_byte(&LEDS[(uint8_t)a]) & 0x0f) << 1));
HID_Command(HIDBuffer, HID_BUFFERSIZE);

View file

@ -163,6 +163,14 @@ public:
* @param mode Either ::RumbleHigh or ::RumbleLow.
*/
void setRumbleOn(Rumble mode);
/**
* Turn on ::Rumble using custom duration and power.
* @param rightDuration The duration of the right/low rumble effect.
* @param rightPower The intensity of the right/low rumble effect.
* @param leftDuration The duration of the left/high rumble effect.
* @param leftPower The intensity of the left/high rumble effect.
*/
void setRumbleOn(uint8_t rightDuration, uint8_t rightPower, uint8_t leftDuration, uint8_t leftPower);
/**
* Turn the specific ::LED off.
* @param a The ::LED to turn off.

View file

@ -464,7 +464,13 @@ void PS3USB::setRumbleOn(Rumble mode) {
PS3_Command(writeBuf, PS3_REPORT_BUFFER_SIZE);
}
}
void PS3USB::setRumbleOn(uint8_t rightDuration, uint8_t rightPower, uint8_t leftDuration, uint8_t leftPower) {
writeBuf[1] = rightDuration;
writeBuf[2] = rightPower;
writeBuf[3] = leftDuration;
writeBuf[4] = leftPower;
PS3_Command(writeBuf, PS3_REPORT_BUFFER_SIZE);
}
void PS3USB::setLedOff(LED a) {
writeBuf[9] &= ~((uint8_t)((pgm_read_byte(&LEDS[(uint8_t)a]) & 0x0f) << 1));
PS3_Command(writeBuf, PS3_REPORT_BUFFER_SIZE);

View file

@ -91,22 +91,16 @@ public:
* @return 0 on success.
*/
virtual uint8_t Poll();
/**
* Get 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.
* @return True if it's ready.
*/
virtual bool isReady() {
return bPollEnable;
};
virtual bool isReady() { return bPollEnable; };
/**@}*/
/**
@ -182,6 +176,14 @@ public:
* @param mode Either ::RumbleHigh or ::RumbleLow.
*/
void setRumbleOn(Rumble mode);
/**
* Turn on ::Rumble using custom duration and power.
* @param rightDuration The duration of the right/low rumble effect.
* @param rightPower The intensity of the right/low rumble effect.
* @param leftDuration The duration of the left/high rumble effect.
* @param leftPower The intensity of the left/high rumble effect.
*/
void setRumbleOn(uint8_t rightDuration, uint8_t rightPower, uint8_t leftDuration, uint8_t leftPower);
/**
* Turn the specific ::LED off.
* @param a The ::LED to turn off.