mirror of
https://github.com/felis/USB_Host_Shield_2.0.git
synced 2024-03-22 11:31:26 +01:00
Added setLedRaw
This commit is contained in:
parent
712ed057e5
commit
831d18016e
6 changed files with 38 additions and 11 deletions
20
PS3BT.cpp
20
PS3BT.cpp
|
@ -581,22 +581,20 @@ void PS3BT::setAllOff() {
|
|||
|
||||
void PS3BT::setRumbleOff() {
|
||||
HIDBuffer[3] = 0x00;
|
||||
HIDBuffer[4] = 0x00; //low mode off
|
||||
HIDBuffer[4] = 0x00;
|
||||
HIDBuffer[5] = 0x00;
|
||||
HIDBuffer[6] = 0x00; //high mode off
|
||||
HIDBuffer[6] = 0x00;
|
||||
|
||||
HID_Command(HIDBuffer, HID_BUFFERSIZE);
|
||||
}
|
||||
|
||||
void PS3BT::setRumbleOn(Rumble mode) {
|
||||
if ((mode & 0x30) > 0x00) {
|
||||
uint8_t power[2] = { 0xff, 0x00 }; // Defaults to RumbleLow
|
||||
if (mode == RumbleHigh) {
|
||||
power[0] = 0x00;
|
||||
power[1] = 0xff;
|
||||
}
|
||||
setRumbleOn(0xfe, power[0], 0xfe, power[1]);
|
||||
uint8_t power[2] = { 0xff, 0x00 }; // Defaults to RumbleLow
|
||||
if (mode == RumbleHigh) {
|
||||
power[0] = 0x00;
|
||||
power[1] = 0xff;
|
||||
}
|
||||
setRumbleOn(0xfe, power[0], 0xfe, power[1]);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
void PS3BT::setLedRaw(uint8_t value) {
|
||||
HIDBuffer[11] = value;
|
||||
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);
|
||||
|
|
6
PS3BT.h
6
PS3BT.h
|
@ -171,6 +171,12 @@ public:
|
|||
* @param leftPower The intensity of the left/high rumble effect.
|
||||
*/
|
||||
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.
|
||||
* @param a The ::LED to turn off.
|
||||
|
|
|
@ -454,16 +454,18 @@ void PS3USB::setRumbleOn(uint8_t rightDuration, uint8_t rightPower, uint8_t left
|
|||
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) {
|
||||
writeBuf[9] &= ~((uint8_t)((pgm_read_byte(&LEDS[(uint8_t)a]) & 0x0f) << 1));
|
||||
PS3_Command(writeBuf, PS3_REPORT_BUFFER_SIZE);
|
||||
}
|
||||
|
||||
void PS3USB::setLedOn(LED a) {
|
||||
writeBuf[9] |= (uint8_t)((pgm_read_byte(&LEDS[(uint8_t)a]) & 0x0f) << 1);
|
||||
PS3_Command(writeBuf, PS3_REPORT_BUFFER_SIZE);
|
||||
}
|
||||
|
||||
void PS3USB::setLedToggle(LED a) {
|
||||
writeBuf[9] ^= (uint8_t)((pgm_read_byte(&LEDS[(uint8_t)a]) & 0x0f) << 1);
|
||||
PS3_Command(writeBuf, PS3_REPORT_BUFFER_SIZE);
|
||||
|
|
6
PS3USB.h
6
PS3USB.h
|
@ -190,6 +190,12 @@ public:
|
|||
* @param leftPower The intensity of the left/high rumble effect.
|
||||
*/
|
||||
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.
|
||||
* @param a The ::LED to turn off.
|
||||
|
|
5
Wii.cpp
5
Wii.cpp
|
@ -869,6 +869,11 @@ void WII::setRumbleToggle() {
|
|||
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) {
|
||||
HIDBuffer[1] = 0x11;
|
||||
HIDBuffer[2] &= ~(pgm_read_byte(&LEDS[(uint8_t)a]));
|
||||
|
|
6
Wii.h
6
Wii.h
|
@ -178,6 +178,12 @@ public:
|
|||
void setRumbleOn();
|
||||
/** Toggle rumble. */
|
||||
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.
|
||||
* @param a The ::LED to turn off.
|
||||
|
|
Loading…
Reference in a new issue