summaryrefslogtreecommitdiff
path: root/src/input_common/drivers/sdl_driver.cpp
diff options
context:
space:
mode:
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) {
305 if (joystick_map.find(guid) == joystick_map.end()) { 305 if (joystick_map.find(guid) == joystick_map.end()) {
306 auto joystick = std::make_shared<SDLJoystick>(guid, 0, sdl_joystick, sdl_gamecontroller); 306 auto joystick = std::make_shared<SDLJoystick>(guid, 0, sdl_joystick, sdl_gamecontroller);
307 PreSetController(joystick->GetPadIdentifier()); 307 PreSetController(joystick->GetPadIdentifier());
308 SetBattery(joystick->GetPadIdentifier(), joystick->GetBatteryLevel());
308 joystick_map[guid].emplace_back(std::move(joystick)); 309 joystick_map[guid].emplace_back(std::move(joystick));
309 return; 310 return;
310 } 311 }
@@ -322,6 +323,7 @@ void SDLDriver::InitJoystick(int joystick_index) {
322 const int port = static_cast<int>(joystick_guid_list.size()); 323 const int port = static_cast<int>(joystick_guid_list.size());
323 auto joystick = std::make_shared<SDLJoystick>(guid, port, sdl_joystick, sdl_gamecontroller); 324 auto joystick = std::make_shared<SDLJoystick>(guid, port, sdl_joystick, sdl_gamecontroller);
324 PreSetController(joystick->GetPadIdentifier()); 325 PreSetController(joystick->GetPadIdentifier());
326 SetBattery(joystick->GetPadIdentifier(), joystick->GetBatteryLevel());
325 joystick_guid_list.emplace_back(std::move(joystick)); 327 joystick_guid_list.emplace_back(std::move(joystick));
326} 328}
327 329
@@ -472,7 +474,7 @@ std::vector<Common::ParamPackage> SDLDriver::GetInputDevices() const {
472 const std::string name = 474 const std::string name =
473 fmt::format("{} {}", joystick->GetControllerName(), joystick->GetPort()); 475 fmt::format("{} {}", joystick->GetControllerName(), joystick->GetPort());
474 devices.emplace_back(Common::ParamPackage{ 476 devices.emplace_back(Common::ParamPackage{
475 {"engine", "sdl"}, 477 {"engine", GetEngineName()},
476 {"display", std::move(name)}, 478 {"display", std::move(name)},
477 {"guid", joystick->GetGUID()}, 479 {"guid", joystick->GetGUID()},
478 {"port", std::to_string(joystick->GetPort())}, 480 {"port", std::to_string(joystick->GetPort())},
@@ -495,7 +497,7 @@ std::vector<Common::ParamPackage> SDLDriver::GetInputDevices() const {
495 const std::string name = 497 const std::string name =
496 fmt::format("{} {}", "Nintendo Dual Joy-Con", joystick->GetPort()); 498 fmt::format("{} {}", "Nintendo Dual Joy-Con", joystick->GetPort());
497 devices.emplace_back(Common::ParamPackage{ 499 devices.emplace_back(Common::ParamPackage{
498 {"engine", "sdl"}, 500 {"engine", GetEngineName()},
499 {"display", std::move(name)}, 501 {"display", std::move(name)},
500 {"guid", joystick->GetGUID()}, 502 {"guid", joystick->GetGUID()},
501 {"guid2", joystick2->GetGUID()}, 503 {"guid2", joystick2->GetGUID()},
@@ -527,7 +529,8 @@ Input::VibrationError SDLDriver::SetRumble(const PadIdentifier& identifier,
527} 529}
528Common::ParamPackage SDLDriver::BuildAnalogParamPackageForButton(int port, std::string guid, 530Common::ParamPackage SDLDriver::BuildAnalogParamPackageForButton(int port, std::string guid,
529 s32 axis, float value) const { 531 s32 axis, float value) const {
530 Common::ParamPackage params({{"engine", "sdl"}}); 532 Common::ParamPackage params{};
533 params.Set("engine", GetEngineName());
531 params.Set("port", port); 534 params.Set("port", port);
532 params.Set("guid", std::move(guid)); 535 params.Set("guid", std::move(guid));
533 params.Set("axis", axis); 536 params.Set("axis", axis);
@@ -538,7 +541,8 @@ Common::ParamPackage SDLDriver::BuildAnalogParamPackageForButton(int port, std::
538 541
539Common::ParamPackage SDLDriver::BuildButtonParamPackageForButton(int port, std::string guid, 542Common::ParamPackage SDLDriver::BuildButtonParamPackageForButton(int port, std::string guid,
540 s32 button) const { 543 s32 button) const {
541 Common::ParamPackage params({{"engine", "sdl"}}); 544 Common::ParamPackage params{};
545 params.Set("engine", GetEngineName());
542 params.Set("port", port); 546 params.Set("port", port);
543 params.Set("guid", std::move(guid)); 547 params.Set("guid", std::move(guid));
544 params.Set("button", button); 548 params.Set("button", button);
@@ -547,8 +551,8 @@ Common::ParamPackage SDLDriver::BuildButtonParamPackageForButton(int port, std::
547 551
548Common::ParamPackage SDLDriver::BuildHatParamPackageForButton(int port, std::string guid, s32 hat, 552Common::ParamPackage SDLDriver::BuildHatParamPackageForButton(int port, std::string guid, s32 hat,
549 u8 value) const { 553 u8 value) const {
550 Common::ParamPackage params({{"engine", "sdl"}}); 554 Common::ParamPackage params{};
551 555 params.Set("engine", GetEngineName());
552 params.Set("port", port); 556 params.Set("port", port);
553 params.Set("guid", std::move(guid)); 557 params.Set("guid", std::move(guid));
554 params.Set("hat", hat); 558 params.Set("hat", hat);
@@ -557,7 +561,9 @@ Common::ParamPackage SDLDriver::BuildHatParamPackageForButton(int port, std::str
557} 561}
558 562
559Common::ParamPackage SDLDriver::BuildMotionParam(int port, std::string guid) const { 563Common::ParamPackage SDLDriver::BuildMotionParam(int port, std::string guid) const {
560 Common::ParamPackage params({{"engine", "sdl"}, {"motion", "0"}}); 564 Common::ParamPackage params{};
565 params.Set("engine", GetEngineName());
566 params.Set("motion", 0);
561 params.Set("port", port); 567 params.Set("port", port);
562 params.Set("guid", std::move(guid)); 568 params.Set("guid", std::move(guid));
563 return params; 569 return params;
@@ -583,7 +589,7 @@ Common::ParamPackage SDLDriver::BuildParamPackageForAnalog(PadIdentifier identif
583 int axis_y, float offset_x, 589 int axis_y, float offset_x,
584 float offset_y) const { 590 float offset_y) const {
585 Common::ParamPackage params; 591 Common::ParamPackage params;
586 params.Set("engine", "sdl"); 592 params.Set("engine", GetEngineName());
587 params.Set("port", static_cast<int>(identifier.port)); 593 params.Set("port", static_cast<int>(identifier.port));
588 params.Set("guid", identifier.guid.Format()); 594 params.Set("guid", identifier.guid.Format());
589 params.Set("axis_x", axis_x); 595 params.Set("axis_x", axis_x);