diff options
Diffstat (limited to 'src/input_common/drivers')
| -rw-r--r-- | src/input_common/drivers/sdl_driver.cpp | 17 | ||||
| -rw-r--r-- | src/input_common/drivers/udp_client.cpp | 14 | ||||
| -rw-r--r-- | src/input_common/drivers/udp_client.h | 2 |
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: | |||
| 175 | return false; | 175 | return false; |
| 176 | } | 176 | } |
| 177 | 177 | ||
| 178 | BatteryLevel GetBatteryLevel() { | 178 | Common::Input::BatteryLevel GetBatteryLevel() { |
| 179 | const auto level = SDL_JoystickCurrentPowerLevel(sdl_joystick.get()); | 179 | const auto level = SDL_JoystickCurrentPowerLevel(sdl_joystick.get()); |
| 180 | switch (level) { | 180 | switch (level) { |
| 181 | case SDL_JOYSTICK_POWER_EMPTY: | 181 | case SDL_JOYSTICK_POWER_EMPTY: |
| 182 | return BatteryLevel::Empty; | 182 | return Common::Input::BatteryLevel::Empty; |
| 183 | case SDL_JOYSTICK_POWER_LOW: | 183 | case SDL_JOYSTICK_POWER_LOW: |
| 184 | return BatteryLevel::Low; | 184 | return Common::Input::BatteryLevel::Low; |
| 185 | case SDL_JOYSTICK_POWER_MEDIUM: | 185 | case SDL_JOYSTICK_POWER_MEDIUM: |
| 186 | return BatteryLevel::Medium; | 186 | return Common::Input::BatteryLevel::Medium; |
| 187 | case SDL_JOYSTICK_POWER_FULL: | 187 | case SDL_JOYSTICK_POWER_FULL: |
| 188 | case SDL_JOYSTICK_POWER_MAX: | 188 | case SDL_JOYSTICK_POWER_MAX: |
| 189 | return BatteryLevel::Full; | 189 | return Common::Input::BatteryLevel::Full; |
| 190 | case SDL_JOYSTICK_POWER_UNKNOWN: | ||
| 191 | case SDL_JOYSTICK_POWER_WIRED: | 190 | case SDL_JOYSTICK_POWER_WIRED: |
| 191 | return Common::Input::BatteryLevel::Charging; | ||
| 192 | case SDL_JOYSTICK_POWER_UNKNOWN: | ||
| 192 | default: | 193 | default: |
| 193 | return BatteryLevel::Charging; | 194 | return Common::Input::BatteryLevel::None; |
| 194 | } | 195 | } |
| 195 | } | 196 | } |
| 196 | 197 | ||
| @@ -351,6 +352,8 @@ void SDLDriver::HandleGameControllerEvent(const SDL_Event& event) { | |||
| 351 | if (const auto joystick = GetSDLJoystickBySDLID(event.jbutton.which)) { | 352 | if (const auto joystick = GetSDLJoystickBySDLID(event.jbutton.which)) { |
| 352 | const PadIdentifier identifier = joystick->GetPadIdentifier(); | 353 | const PadIdentifier identifier = joystick->GetPadIdentifier(); |
| 353 | SetButton(identifier, event.jbutton.button, true); | 354 | SetButton(identifier, event.jbutton.button, true); |
| 355 | // Battery doesn't trigger an event so just update every button press | ||
| 356 | SetBattery(identifier, joystick->GetBatteryLevel()); | ||
| 354 | } | 357 | } |
| 355 | break; | 358 | break; |
| 356 | } | 359 | } |
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 { | |||
| 192 | return MAX_UDP_CLIENTS; | 192 | return MAX_UDP_CLIENTS; |
| 193 | } | 193 | } |
| 194 | 194 | ||
| 195 | BatteryLevel UDPClient::GetBatteryLevel(Response::Battery battery) const { | 195 | Common::Input::BatteryLevel UDPClient::GetBatteryLevel(Response::Battery battery) const { |
| 196 | switch (battery) { | 196 | switch (battery) { |
| 197 | case Response::Battery::Dying: | 197 | case Response::Battery::Dying: |
| 198 | return BatteryLevel::Empty; | 198 | return Common::Input::BatteryLevel::Empty; |
| 199 | case Response::Battery::Low: | 199 | case Response::Battery::Low: |
| 200 | return BatteryLevel::Critical; | 200 | return Common::Input::BatteryLevel::Critical; |
| 201 | case Response::Battery::Medium: | 201 | case Response::Battery::Medium: |
| 202 | return BatteryLevel::Low; | 202 | return Common::Input::BatteryLevel::Low; |
| 203 | case Response::Battery::High: | 203 | case Response::Battery::High: |
| 204 | return BatteryLevel::Medium; | 204 | return Common::Input::BatteryLevel::Medium; |
| 205 | case Response::Battery::Full: | 205 | case Response::Battery::Full: |
| 206 | case Response::Battery::Charged: | 206 | case Response::Battery::Charged: |
| 207 | return BatteryLevel::Full; | 207 | return Common::Input::BatteryLevel::Full; |
| 208 | case Response::Battery::Charging: | 208 | case Response::Battery::Charging: |
| 209 | default: | 209 | default: |
| 210 | return BatteryLevel::Charging; | 210 | return Common::Input::BatteryLevel::Charging; |
| 211 | } | 211 | } |
| 212 | } | 212 | } |
| 213 | 213 | ||
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: | |||
| 141 | std::size_t GetClientNumber(std::string_view host, u16 port) const; | 141 | std::size_t GetClientNumber(std::string_view host, u16 port) const; |
| 142 | 142 | ||
| 143 | // Translates UDP battery level to input engine battery level | 143 | // Translates UDP battery level to input engine battery level |
| 144 | BatteryLevel GetBatteryLevel(Response::Battery battery) const; | 144 | Common::Input::BatteryLevel GetBatteryLevel(Response::Battery battery) const; |
| 145 | 145 | ||
| 146 | void OnVersion(Response::Version); | 146 | void OnVersion(Response::Version); |
| 147 | void OnPortInfo(Response::PortInfo); | 147 | void OnPortInfo(Response::PortInfo); |