summaryrefslogtreecommitdiffstats
path: root/src/input_common/drivers/sdl_driver.cpp
diff options
context:
space:
mode:
authorgerman77 <juangerman-13@hotmail.com>2022-02-07 01:20:12 +0100
committergerman77 <juangerman-13@hotmail.com>2022-02-07 01:33:55 +0100
commit21742f00961308fedb35cf38261afba3c1682853 (patch)
treea130ab5b3d1a214e546227edf448a14e0be01081 /src/input_common/drivers/sdl_driver.cpp
parentMerge pull request #7847 from tech-ticks/master (diff)
downloadyuzu-21742f00961308fedb35cf38261afba3c1682853.tar
yuzu-21742f00961308fedb35cf38261afba3c1682853.tar.gz
yuzu-21742f00961308fedb35cf38261afba3c1682853.tar.bz2
yuzu-21742f00961308fedb35cf38261afba3c1682853.tar.lz
yuzu-21742f00961308fedb35cf38261afba3c1682853.tar.xz
yuzu-21742f00961308fedb35cf38261afba3c1682853.tar.zst
yuzu-21742f00961308fedb35cf38261afba3c1682853.zip
Diffstat (limited to '')
-rw-r--r--src/input_common/drivers/sdl_driver.cpp17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/input_common/drivers/sdl_driver.cpp b/src/input_common/drivers/sdl_driver.cpp
index b031a8523..4ed10aba9 100644
--- a/src/input_common/drivers/sdl_driver.cpp
+++ b/src/input_common/drivers/sdl_driver.cpp
@@ -175,22 +175,23 @@ public:
return false;
}
- BatteryLevel GetBatteryLevel() {
+ Common::Input::BatteryLevel GetBatteryLevel() {
const auto level = SDL_JoystickCurrentPowerLevel(sdl_joystick.get());
switch (level) {
case SDL_JOYSTICK_POWER_EMPTY:
- return BatteryLevel::Empty;
+ return Common::Input::BatteryLevel::Empty;
case SDL_JOYSTICK_POWER_LOW:
- return BatteryLevel::Low;
+ return Common::Input::BatteryLevel::Low;
case SDL_JOYSTICK_POWER_MEDIUM:
- return BatteryLevel::Medium;
+ return Common::Input::BatteryLevel::Medium;
case SDL_JOYSTICK_POWER_FULL:
case SDL_JOYSTICK_POWER_MAX:
- return BatteryLevel::Full;
- case SDL_JOYSTICK_POWER_UNKNOWN:
+ return Common::Input::BatteryLevel::Full;
case SDL_JOYSTICK_POWER_WIRED:
+ return Common::Input::BatteryLevel::Charging;
+ case SDL_JOYSTICK_POWER_UNKNOWN:
default:
- return BatteryLevel::Charging;
+ return Common::Input::BatteryLevel::None;
}
}
@@ -351,6 +352,8 @@ void SDLDriver::HandleGameControllerEvent(const SDL_Event& event) {
if (const auto joystick = GetSDLJoystickBySDLID(event.jbutton.which)) {
const PadIdentifier identifier = joystick->GetPadIdentifier();
SetButton(identifier, event.jbutton.button, true);
+ // Battery doesn't trigger an event so just update every button press
+ SetBattery(identifier, joystick->GetBatteryLevel());
}
break;
}