summaryrefslogtreecommitdiffstats
path: root/src/input_common/drivers
diff options
context:
space:
mode:
authorNarr the Reg <juangerman-13@hotmail.com>2022-01-17 17:44:13 +0100
committerNarr the Reg <juangerman-13@hotmail.com>2022-01-17 20:30:15 +0100
commit36144a56905046d0dee1fd369f9eb4e130e18c35 (patch)
treecb86bc935041681906403c6e227372a300f7643b /src/input_common/drivers
parentMerge pull request #7713 from gidoly/patch-3 (diff)
downloadyuzu-36144a56905046d0dee1fd369f9eb4e130e18c35.tar
yuzu-36144a56905046d0dee1fd369f9eb4e130e18c35.tar.gz
yuzu-36144a56905046d0dee1fd369f9eb4e130e18c35.tar.bz2
yuzu-36144a56905046d0dee1fd369f9eb4e130e18c35.tar.lz
yuzu-36144a56905046d0dee1fd369f9eb4e130e18c35.tar.xz
yuzu-36144a56905046d0dee1fd369f9eb4e130e18c35.tar.zst
yuzu-36144a56905046d0dee1fd369f9eb4e130e18c35.zip
Diffstat (limited to '')
-rw-r--r--src/input_common/drivers/udp_client.cpp21
-rw-r--r--src/input_common/drivers/udp_client.h4
2 files changed, 25 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 {
return MAX_UDP_CLIENTS;
}
+BatteryLevel UDPClient::GetBatteryLevel(Response::Battery battery) const {
+ switch (battery) {
+ case Response::Battery::Dying:
+ return BatteryLevel::Empty;
+ case Response::Battery::Low:
+ return BatteryLevel::Critical;
+ case Response::Battery::Medium:
+ return BatteryLevel::Low;
+ case Response::Battery::High:
+ return BatteryLevel::Medium;
+ case Response::Battery::Full:
+ case Response::Battery::Charged:
+ return BatteryLevel::Full;
+ case Response::Battery::Charging:
+ default:
+ return BatteryLevel::Charging;
+ }
+}
+
void UDPClient::OnVersion([[maybe_unused]] Response::Version data) {
LOG_TRACE(Input, "Version packet received: {}", data.version);
}
@@ -299,6 +318,8 @@ void UDPClient::OnPadData(Response::PadData data, std::size_t client) {
const int button = static_cast<int>(buttons[i]);
SetButton(identifier, button, button_status);
}
+
+ SetBattery(identifier, GetBatteryLevel(data.info.battery));
}
void UDPClient::StartCommunication(std::size_t client, const std::string& host, u16 port) {
diff --git a/src/input_common/drivers/udp_client.h b/src/input_common/drivers/udp_client.h
index 1adc947c4..61a1fff37 100644
--- a/src/input_common/drivers/udp_client.h
+++ b/src/input_common/drivers/udp_client.h
@@ -15,6 +15,7 @@ namespace InputCommon::CemuhookUDP {
class Socket;
namespace Response {
+enum class Battery : u8;
struct PadData;
struct PortInfo;
struct TouchPad;
@@ -137,6 +138,9 @@ private:
// Translates configuration to client number
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;
+
void OnVersion(Response::Version);
void OnPortInfo(Response::PortInfo);
void OnPadData(Response::PadData, std::size_t client);