diff options
| author | 2022-01-17 10:44:13 -0600 | |
|---|---|---|
| committer | 2022-01-17 13:30:15 -0600 | |
| commit | 36144a56905046d0dee1fd369f9eb4e130e18c35 (patch) | |
| tree | cb86bc935041681906403c6e227372a300f7643b /src/input_common/drivers/udp_client.cpp | |
| parent | Merge pull request #7713 from gidoly/patch-3 (diff) | |
| download | yuzu-36144a56905046d0dee1fd369f9eb4e130e18c35.tar.gz yuzu-36144a56905046d0dee1fd369f9eb4e130e18c35.tar.xz yuzu-36144a56905046d0dee1fd369f9eb4e130e18c35.zip | |
input_common: Report battery for UDP controllers
Diffstat (limited to '')
| -rw-r--r-- | src/input_common/drivers/udp_client.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/input_common/drivers/udp_client.cpp b/src/input_common/drivers/udp_client.cpp index c8a12c7d5..9aaeb91be 100644 --- a/src/input_common/drivers/udp_client.cpp +++ b/src/input_common/drivers/udp_client.cpp | |||
| @@ -192,6 +192,25 @@ std::size_t UDPClient::GetClientNumber(std::string_view host, u16 port) const { | |||
| 192 | return MAX_UDP_CLIENTS; | 192 | return MAX_UDP_CLIENTS; |
| 193 | } | 193 | } |
| 194 | 194 | ||
| 195 | BatteryLevel UDPClient::GetBatteryLevel(Response::Battery battery) const { | ||
| 196 | switch (battery) { | ||
| 197 | case Response::Battery::Dying: | ||
| 198 | return BatteryLevel::Empty; | ||
| 199 | case Response::Battery::Low: | ||
| 200 | return BatteryLevel::Critical; | ||
| 201 | case Response::Battery::Medium: | ||
| 202 | return BatteryLevel::Low; | ||
| 203 | case Response::Battery::High: | ||
| 204 | return BatteryLevel::Medium; | ||
| 205 | case Response::Battery::Full: | ||
| 206 | case Response::Battery::Charged: | ||
| 207 | return BatteryLevel::Full; | ||
| 208 | case Response::Battery::Charging: | ||
| 209 | default: | ||
| 210 | return BatteryLevel::Charging; | ||
| 211 | } | ||
| 212 | } | ||
| 213 | |||
| 195 | void UDPClient::OnVersion([[maybe_unused]] Response::Version data) { | 214 | void UDPClient::OnVersion([[maybe_unused]] Response::Version data) { |
| 196 | LOG_TRACE(Input, "Version packet received: {}", data.version); | 215 | LOG_TRACE(Input, "Version packet received: {}", data.version); |
| 197 | } | 216 | } |
| @@ -299,6 +318,8 @@ void UDPClient::OnPadData(Response::PadData data, std::size_t client) { | |||
| 299 | const int button = static_cast<int>(buttons[i]); | 318 | const int button = static_cast<int>(buttons[i]); |
| 300 | SetButton(identifier, button, button_status); | 319 | SetButton(identifier, button, button_status); |
| 301 | } | 320 | } |
| 321 | |||
| 322 | SetBattery(identifier, GetBatteryLevel(data.info.battery)); | ||
| 302 | } | 323 | } |
| 303 | 324 | ||
| 304 | void UDPClient::StartCommunication(std::size_t client, const std::string& host, u16 port) { | 325 | void UDPClient::StartCommunication(std::size_t client, const std::string& host, u16 port) { |