mirror of
https://github.com/felis/USB_Host_Shield_2.0.git
synced 2024-03-22 11:31:26 +01:00
Overloaded PS3BT/PS3USB's setRumbleOn to accept custom rumble settings.
This commit is contained in:
parent
904f2ff25a
commit
adff5d790d
4 changed files with 343 additions and 321 deletions
|
@ -608,7 +608,13 @@ void PS3BT::setRumbleOn(Rumble mode) {
|
||||||
HID_Command(HIDBuffer, HID_BUFFERSIZE);
|
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) {
|
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);
|
||||||
|
|
10
PS3BT.h
10
PS3BT.h
|
@ -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 */
|
||||||
/**
|
/**
|
||||||
|
@ -163,6 +163,14 @@ public:
|
||||||
* @param mode Either ::RumbleHigh or ::RumbleLow.
|
* @param mode Either ::RumbleHigh or ::RumbleLow.
|
||||||
*/
|
*/
|
||||||
void setRumbleOn(Rumble mode);
|
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.
|
* Turn the specific ::LED off.
|
||||||
* @param a The ::LED to turn off.
|
* @param a The ::LED to turn off.
|
||||||
|
|
|
@ -464,7 +464,13 @@ void PS3USB::setRumbleOn(Rumble mode) {
|
||||||
PS3_Command(writeBuf, PS3_REPORT_BUFFER_SIZE);
|
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) {
|
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);
|
||||||
|
|
20
PS3USB.h
20
PS3USB.h
|
@ -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,22 +91,16 @@ 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() {
|
virtual uint8_t GetAddress() { return bAddress; };
|
||||||
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() {
|
virtual bool isReady() { return bPollEnable; };
|
||||||
return bPollEnable;
|
|
||||||
};
|
|
||||||
/**@}*/
|
/**@}*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -182,6 +176,14 @@ public:
|
||||||
* @param mode Either ::RumbleHigh or ::RumbleLow.
|
* @param mode Either ::RumbleHigh or ::RumbleLow.
|
||||||
*/
|
*/
|
||||||
void setRumbleOn(Rumble mode);
|
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.
|
* Turn the specific ::LED off.
|
||||||
* @param a The ::LED to turn off.
|
* @param a The ::LED to turn off.
|
||||||
|
|
Loading…
Reference in a new issue