Added setLedRaw

This commit is contained in:
Kristian Sloth Lauszus 2013-04-01 15:38:15 +02:00
parent 712ed057e5
commit 831d18016e
6 changed files with 38 additions and 11 deletions

View file

@ -581,22 +581,20 @@ void PS3BT::setAllOff() {
void PS3BT::setRumbleOff() { void PS3BT::setRumbleOff() {
HIDBuffer[3] = 0x00; HIDBuffer[3] = 0x00;
HIDBuffer[4] = 0x00; //low mode off HIDBuffer[4] = 0x00;
HIDBuffer[5] = 0x00; HIDBuffer[5] = 0x00;
HIDBuffer[6] = 0x00; //high mode off HIDBuffer[6] = 0x00;
HID_Command(HIDBuffer, HID_BUFFERSIZE); HID_Command(HIDBuffer, HID_BUFFERSIZE);
} }
void PS3BT::setRumbleOn(Rumble mode) { void PS3BT::setRumbleOn(Rumble mode) {
if ((mode & 0x30) > 0x00) { uint8_t power[2] = { 0xff, 0x00 }; // Defaults to RumbleLow
uint8_t power[2] = { 0xff, 0x00 }; // Defaults to RumbleLow if (mode == RumbleHigh) {
if (mode == RumbleHigh) { power[0] = 0x00;
power[0] = 0x00; power[1] = 0xff;
power[1] = 0xff;
}
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) {
@ -607,6 +605,10 @@ void PS3BT::setRumbleOn(uint8_t rightDuration, uint8_t rightPower, uint8_t leftD
HID_Command(HIDBuffer, HID_BUFFERSIZE); HID_Command(HIDBuffer, HID_BUFFERSIZE);
} }
void PS3BT::setLedRaw(uint8_t value) {
HIDBuffer[11] = value;
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

@ -171,6 +171,12 @@ public:
* @param leftPower The intensity 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); void setRumbleOn(uint8_t rightDuration, uint8_t rightPower, uint8_t leftDuration, uint8_t leftPower);
/**
* Set LED value without using the ::LED enum.
* @param value See: ::LED enum.
*/
void setLedRaw(uint8_t value);
/** /**
* Turn the specific ::LED off. * Turn the specific ::LED off.
* @param a The ::LED to turn off. * @param a The ::LED to turn off.

View file

@ -454,16 +454,18 @@ void PS3USB::setRumbleOn(uint8_t rightDuration, uint8_t rightPower, uint8_t left
PS3_Command(writeBuf, PS3_REPORT_BUFFER_SIZE); PS3_Command(writeBuf, PS3_REPORT_BUFFER_SIZE);
} }
void PS3USB::setLedRaw(uint8_t value) {
writeBuf[9] = value;
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);
} }
void PS3USB::setLedOn(LED a) { void PS3USB::setLedOn(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);
} }
void PS3USB::setLedToggle(LED a) { void PS3USB::setLedToggle(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

@ -190,6 +190,12 @@ public:
* @param leftPower The intensity 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); void setRumbleOn(uint8_t rightDuration, uint8_t rightPower, uint8_t leftDuration, uint8_t leftPower);
/**
* Set LED value without using the ::LED enum.
* @param value See: ::LED enum.
*/
void setLedRaw(uint8_t value);
/** /**
* Turn the specific ::LED off. * Turn the specific ::LED off.
* @param a The ::LED to turn off. * @param a The ::LED to turn off.

View file

@ -869,6 +869,11 @@ void WII::setRumbleToggle() {
HID_Command(HIDBuffer, 3); HID_Command(HIDBuffer, 3);
} }
void WII::setLedRaw(uint8_t value) {
HIDBuffer[1] = 0x11;
HIDBuffer[2] = value | (HIDBuffer[2] & 0x01); // Keep the rumble bit
HID_Command(HIDBuffer, 3);
}
void WII::setLedOff(LED a) { void WII::setLedOff(LED a) {
HIDBuffer[1] = 0x11; HIDBuffer[1] = 0x11;
HIDBuffer[2] &= ~(pgm_read_byte(&LEDS[(uint8_t)a])); HIDBuffer[2] &= ~(pgm_read_byte(&LEDS[(uint8_t)a]));

6
Wii.h
View file

@ -178,6 +178,12 @@ public:
void setRumbleOn(); void setRumbleOn();
/** Toggle rumble. */ /** Toggle rumble. */
void setRumbleToggle(); void setRumbleToggle();
/**
* Set LED value without using the ::LED enum.
* @param value See: ::LED enum.
*/
void setLedRaw(uint8_t value);
/** /**
* Turn the specific ::LED off. * Turn the specific ::LED off.
* @param a The ::LED to turn off. * @param a The ::LED to turn off.