mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-07 15:31:26 +12:00
dualsense: implement battery level
This commit is contained in:
parent
b836d2497d
commit
cdffaa1598
6 changed files with 109 additions and 19 deletions
|
@ -203,6 +203,21 @@ std::shared_ptr<PadDevice> hid_pad_handler<Device>::get_device(const std::string
|
|||
return get_hid_device(device);
|
||||
}
|
||||
|
||||
template <class Device>
|
||||
u32 hid_pad_handler<Device>::get_battery_color(u8 battery_level, int brightness) const
|
||||
{
|
||||
static const std::array<u32, 12> battery_level_clr = {0xff00, 0xff33, 0xff66, 0xff99, 0xffcc, 0xffff, 0xccff, 0x99ff, 0x66ff, 0x33ff, 0x00ff, 0x00ff};
|
||||
u32 combined_color = battery_level_clr[0];
|
||||
// Check if we got a weird value
|
||||
if (battery_level < battery_level_clr.size())
|
||||
{
|
||||
combined_color = battery_level_clr[battery_level];
|
||||
}
|
||||
const u32 red = (combined_color >> 8) * brightness / 100;
|
||||
const u32 green = (combined_color & 0xff) * brightness / 100;
|
||||
return ((red << 8) | green);
|
||||
}
|
||||
|
||||
template class hid_pad_handler<ds3_device>;
|
||||
template class hid_pad_handler<DS4Device>;
|
||||
template class hid_pad_handler<DualSenseDevice>;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue