summaryrefslogtreecommitdiffstats
path: root/src/input_common/drivers
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2022-02-24 20:42:51 +0100
committerGitHub <noreply@github.com>2022-02-24 20:42:51 +0100
commit1079215871cc15452e58aea59630871ea183feeb (patch)
treeac74f8005fc0f98ebdc3206037a83dc55db5ce1b /src/input_common/drivers
parentMerge pull request #7933 from german77/am_update (diff)
parentinput_common: Remove battery duplicated struct and update every button press (diff)
downloadyuzu-1079215871cc15452e58aea59630871ea183feeb.tar
yuzu-1079215871cc15452e58aea59630871ea183feeb.tar.gz
yuzu-1079215871cc15452e58aea59630871ea183feeb.tar.bz2
yuzu-1079215871cc15452e58aea59630871ea183feeb.tar.lz
yuzu-1079215871cc15452e58aea59630871ea183feeb.tar.xz
yuzu-1079215871cc15452e58aea59630871ea183feeb.tar.zst
yuzu-1079215871cc15452e58aea59630871ea183feeb.zip
Diffstat (limited to 'src/input_common/drivers')
-rw-r--r--src/input_common/drivers/sdl_driver.cpp17
-rw-r--r--src/input_common/drivers/udp_client.cpp14
-rw-r--r--src/input_common/drivers/udp_client.h2
3 files changed, 18 insertions, 15 deletions
diff --git a/src/input_common/drivers/sdl_driver.cpp b/src/input_common/drivers/sdl_driver.cpp
index 5cf1987ad..c17ea305e 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;
}
diff --git a/src/input_common/drivers/udp_client.cpp b/src/input_common/drivers/udp_client.cpp
index 64162f431..9780ead10 100644
--- a/src/input_common/drivers/udp_client.cpp
+++ b/src/input_common/drivers/udp_client.cpp
@@ -192,22 +192,22 @@ std::size_t UDPClient::GetClientNumber(std::string_view host, u16 port) const {
return MAX_UDP_CLIENTS;
}
-BatteryLevel UDPClient::GetBatteryLevel(Response::Battery battery) const {
+Common::Input::BatteryLevel UDPClient::GetBatteryLevel(Response::Battery battery) const {
switch (battery) {
case Response::Battery::Dying:
- return BatteryLevel::Empty;
+ return Common::Input::BatteryLevel::Empty;
case Response::Battery::Low:
- return BatteryLevel::Critical;
+ return Common::Input::BatteryLevel::Critical;
case Response::Battery::Medium:
- return BatteryLevel::Low;
+ return Common::Input::BatteryLevel::Low;
case Response::Battery::High:
- return BatteryLevel::Medium;
+ return Common::Input::BatteryLevel::Medium;
case Response::Battery::Full:
case Response::Battery::Charged:
- return BatteryLevel::Full;
+ return Common::Input::BatteryLevel::Full;
case Response::Battery::Charging:
default:
- return BatteryLevel::Charging;
+ return Common::Input::BatteryLevel::Charging;
}
}
diff --git a/src/input_common/drivers/udp_client.h b/src/input_common/drivers/udp_client.h
index 76e32bd04..c7cc7d846 100644
--- a/src/input_common/drivers/udp_client.h
+++ b/src/input_common/drivers/udp_client.h
@@ -141,7 +141,7 @@ private:
std::size_t GetClientNumber(std::string_view host, u16 port) const;
// Translates UDP battery level to input engine battery level
- BatteryLevel GetBatteryLevel(Response::Battery battery) const;
+ Common::Input::BatteryLevel GetBatteryLevel(Response::Battery battery) const;
void OnVersion(Response::Version);
void OnPortInfo(Response::PortInfo);