mirror of
https://github.com/yuzu-mirror/yuzu.git
synced 2024-09-09 14:39:07 +01:00
input_common: Report battery for UDP controllers
This commit is contained in:
parent
480b03b645
commit
36144a5690
2 changed files with 25 additions and 0 deletions
|
@ -192,6 +192,25 @@ std::size_t UDPClient::GetClientNumber(std::string_view host, u16 port) const {
|
||||||
return MAX_UDP_CLIENTS;
|
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) {
|
void UDPClient::OnVersion([[maybe_unused]] Response::Version data) {
|
||||||
LOG_TRACE(Input, "Version packet received: {}", data.version);
|
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]);
|
const int button = static_cast<int>(buttons[i]);
|
||||||
SetButton(identifier, button, button_status);
|
SetButton(identifier, button, button_status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SetBattery(identifier, GetBatteryLevel(data.info.battery));
|
||||||
}
|
}
|
||||||
|
|
||||||
void UDPClient::StartCommunication(std::size_t client, const std::string& host, u16 port) {
|
void UDPClient::StartCommunication(std::size_t client, const std::string& host, u16 port) {
|
||||||
|
|
|
@ -15,6 +15,7 @@ namespace InputCommon::CemuhookUDP {
|
||||||
class Socket;
|
class Socket;
|
||||||
|
|
||||||
namespace Response {
|
namespace Response {
|
||||||
|
enum class Battery : u8;
|
||||||
struct PadData;
|
struct PadData;
|
||||||
struct PortInfo;
|
struct PortInfo;
|
||||||
struct TouchPad;
|
struct TouchPad;
|
||||||
|
@ -137,6 +138,9 @@ private:
|
||||||
// Translates configuration to client number
|
// Translates configuration to client number
|
||||||
std::size_t GetClientNumber(std::string_view host, u16 port) const;
|
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 OnVersion(Response::Version);
|
||||||
void OnPortInfo(Response::PortInfo);
|
void OnPortInfo(Response::PortInfo);
|
||||||
void OnPadData(Response::PadData, std::size_t client);
|
void OnPadData(Response::PadData, std::size_t client);
|
||||||
|
|
Loading…
Reference in a new issue