mirror of
https://github.com/LizardByte/Sunshine.git
synced 2024-12-29 12:16:08 +00:00
fix(linux/input): don't pass unknown battery values (#2820)
This commit is contained in:
parent
d57c66fa9c
commit
5f715d66cd
@ -248,9 +248,9 @@ namespace platf::gamepad {
|
||||
if (!gamepad) {
|
||||
return;
|
||||
}
|
||||
// Only the PS5 controller supports motion
|
||||
// Only the PS5 controller supports battery reports
|
||||
if (std::holds_alternative<inputtino::PS5Joypad>(*gamepad->joypad)) {
|
||||
inputtino::PS5Joypad::BATTERY_STATE state = inputtino::PS5Joypad::CHARGHING_ERROR;
|
||||
inputtino::PS5Joypad::BATTERY_STATE state;
|
||||
switch (battery.state) {
|
||||
case LI_BATTERY_STATE_CHARGING:
|
||||
state = inputtino::PS5Joypad::BATTERY_CHARGHING;
|
||||
@ -261,10 +261,14 @@ namespace platf::gamepad {
|
||||
case LI_BATTERY_STATE_FULL:
|
||||
state = inputtino::PS5Joypad::BATTERY_FULL;
|
||||
break;
|
||||
case LI_BATTERY_STATE_UNKNOWN:
|
||||
case LI_BATTERY_STATE_NOT_PRESENT:
|
||||
default:
|
||||
return;
|
||||
}
|
||||
if (battery.percentage != LI_BATTERY_PERCENTAGE_UNKNOWN) {
|
||||
std::get<inputtino::PS5Joypad>(*gamepad->joypad).set_battery(state, battery.percentage);
|
||||
}
|
||||
// Battery values in Moonlight are in the range [0, 0xFF (255)]
|
||||
// Inputtino expects them as a percentage [0, 100]
|
||||
std::get<inputtino::PS5Joypad>(*gamepad->joypad).set_battery(state, battery.percentage / 2.55);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user