summaryrefslogtreecommitdiffstats
path: root/src/input_common/drivers/sdl_driver.cpp
diff options
context:
space:
mode:
authorgerman77 <juangerman-13@hotmail.com>2021-10-19 07:12:24 +0200
committerNarr the Reg <juangerman-13@hotmail.com>2021-11-25 03:30:24 +0100
commit601ac43495904f3f7666d79a800a8b4eda5a8461 (patch)
tree97e49cb22264ceb730ce51babbd3c2dc27d6b36f /src/input_common/drivers/sdl_driver.cpp
parenthid: Fix controller connection/disconnection (diff)
downloadyuzu-601ac43495904f3f7666d79a800a8b4eda5a8461.tar
yuzu-601ac43495904f3f7666d79a800a8b4eda5a8461.tar.gz
yuzu-601ac43495904f3f7666d79a800a8b4eda5a8461.tar.bz2
yuzu-601ac43495904f3f7666d79a800a8b4eda5a8461.tar.lz
yuzu-601ac43495904f3f7666d79a800a8b4eda5a8461.tar.xz
yuzu-601ac43495904f3f7666d79a800a8b4eda5a8461.tar.zst
yuzu-601ac43495904f3f7666d79a800a8b4eda5a8461.zip
Diffstat (limited to 'src/input_common/drivers/sdl_driver.cpp')
-rw-r--r--src/input_common/drivers/sdl_driver.cpp22
1 files changed, 14 insertions, 8 deletions
diff --git a/src/input_common/drivers/sdl_driver.cpp b/src/input_common/drivers/sdl_driver.cpp
index f7f03c5f2..cee2d965f 100644
--- a/src/input_common/drivers/sdl_driver.cpp
+++ b/src/input_common/drivers/sdl_driver.cpp
@@ -305,6 +305,7 @@ void SDLDriver::InitJoystick(int joystick_index) {
if (joystick_map.find(guid) == joystick_map.end()) {
auto joystick = std::make_shared<SDLJoystick>(guid, 0, sdl_joystick, sdl_gamecontroller);
PreSetController(joystick->GetPadIdentifier());
+ SetBattery(joystick->GetPadIdentifier(), joystick->GetBatteryLevel());
joystick_map[guid].emplace_back(std::move(joystick));
return;
}
@@ -322,6 +323,7 @@ void SDLDriver::InitJoystick(int joystick_index) {
const int port = static_cast<int>(joystick_guid_list.size());
auto joystick = std::make_shared<SDLJoystick>(guid, port, sdl_joystick, sdl_gamecontroller);
PreSetController(joystick->GetPadIdentifier());
+ SetBattery(joystick->GetPadIdentifier(), joystick->GetBatteryLevel());
joystick_guid_list.emplace_back(std::move(joystick));
}
@@ -472,7 +474,7 @@ std::vector<Common::ParamPackage> SDLDriver::GetInputDevices() const {
const std::string name =
fmt::format("{} {}", joystick->GetControllerName(), joystick->GetPort());
devices.emplace_back(Common::ParamPackage{
- {"engine", "sdl"},
+ {"engine", GetEngineName()},
{"display", std::move(name)},
{"guid", joystick->GetGUID()},
{"port", std::to_string(joystick->GetPort())},
@@ -495,7 +497,7 @@ std::vector<Common::ParamPackage> SDLDriver::GetInputDevices() const {
const std::string name =
fmt::format("{} {}", "Nintendo Dual Joy-Con", joystick->GetPort());
devices.emplace_back(Common::ParamPackage{
- {"engine", "sdl"},
+ {"engine", GetEngineName()},
{"display", std::move(name)},
{"guid", joystick->GetGUID()},
{"guid2", joystick2->GetGUID()},
@@ -527,7 +529,8 @@ Input::VibrationError SDLDriver::SetRumble(const PadIdentifier& identifier,
}
Common::ParamPackage SDLDriver::BuildAnalogParamPackageForButton(int port, std::string guid,
s32 axis, float value) const {
- Common::ParamPackage params({{"engine", "sdl"}});
+ Common::ParamPackage params{};
+ params.Set("engine", GetEngineName());
params.Set("port", port);
params.Set("guid", std::move(guid));
params.Set("axis", axis);
@@ -538,7 +541,8 @@ Common::ParamPackage SDLDriver::BuildAnalogParamPackageForButton(int port, std::
Common::ParamPackage SDLDriver::BuildButtonParamPackageForButton(int port, std::string guid,
s32 button) const {
- Common::ParamPackage params({{"engine", "sdl"}});
+ Common::ParamPackage params{};
+ params.Set("engine", GetEngineName());
params.Set("port", port);
params.Set("guid", std::move(guid));
params.Set("button", button);
@@ -547,8 +551,8 @@ Common::ParamPackage SDLDriver::BuildButtonParamPackageForButton(int port, std::
Common::ParamPackage SDLDriver::BuildHatParamPackageForButton(int port, std::string guid, s32 hat,
u8 value) const {
- Common::ParamPackage params({{"engine", "sdl"}});
-
+ Common::ParamPackage params{};
+ params.Set("engine", GetEngineName());
params.Set("port", port);
params.Set("guid", std::move(guid));
params.Set("hat", hat);
@@ -557,7 +561,9 @@ Common::ParamPackage SDLDriver::BuildHatParamPackageForButton(int port, std::str
}
Common::ParamPackage SDLDriver::BuildMotionParam(int port, std::string guid) const {
- Common::ParamPackage params({{"engine", "sdl"}, {"motion", "0"}});
+ Common::ParamPackage params{};
+ params.Set("engine", GetEngineName());
+ params.Set("motion", 0);
params.Set("port", port);
params.Set("guid", std::move(guid));
return params;
@@ -583,7 +589,7 @@ Common::ParamPackage SDLDriver::BuildParamPackageForAnalog(PadIdentifier identif
int axis_y, float offset_x,
float offset_y) const {
Common::ParamPackage params;
- params.Set("engine", "sdl");
+ params.Set("engine", GetEngineName());
params.Set("port", static_cast<int>(identifier.port));
params.Set("guid", identifier.guid.Format());
params.Set("axis_x", axis_x);