Skip to content

Commit

Permalink
Never report NOT_PRESENT or other unknown status values to inputino
Browse files Browse the repository at this point in the history
  • Loading branch information
cgutman authored and ReenigneArcher committed Jul 14, 2024
1 parent 7d30bdf commit a006100
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/platform/linux/input/inputtino_gamepad.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Check warning on line 253 in src/platform/linux/input/inputtino_gamepad.cpp

View check run for this annotation

Codecov / codecov/patch

src/platform/linux/input/inputtino_gamepad.cpp#L253

Added line #L253 was not covered by tests
switch (battery.state) {
case LI_BATTERY_STATE_CHARGING:
state = inputtino::PS5Joypad::BATTERY_CHARGHING;
Expand All @@ -262,6 +262,8 @@ namespace platf::gamepad {
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) {
Expand Down

0 comments on commit a006100

Please sign in to comment.