diff --git a/src/gamepad.cpp b/src/gamepad.cpp index 20c03caa..69df03a6 100644 --- a/src/gamepad.cpp +++ b/src/gamepad.cpp @@ -33,9 +33,9 @@ void gamepad_update(){ ds5_count = 0; switch_count = 0; bitdo_count = 0; - logi_count = 0; for (auto &p : fs::directory_iterator(path)) { string fileName = p.path().filename(); +//Gamepads //CHECK XONE AND XPADNEO DEVICES for (string n : xbox_paths ) { if (fileName.find(n) != std::string::npos) { @@ -67,11 +67,11 @@ void gamepad_update(){ gamepad_found = true; bitdo_count += 1; } +// Mice and Keyboards //CHECK LOGITECH DEVICES if (fileName.find("hidpp_battery") != std::string::npos) { list.push_back(p.path()); gamepad_found = true; - logi_count += 1; } } } @@ -80,21 +80,23 @@ void gamepad_update(){ void gamepad_info () { gamepad_count = 0; gamepad_data.clear(); + //gamepad counters int xbox_counter = 0; int ds4_counter = 0; int ds5_counter = 0; int switch_counter = 0; int bitdo_counter = 0; - int logi_counter = 0; for (auto &path : list ) { //Set devices paths std::string capacity = path + "/capacity"; std::string capacity_level = path + "/capacity_level"; std::string status = path + "/status"; + std::string model = path + "/model_name"; std::ifstream input_capacity(capacity); std::ifstream input_capacity_level(capacity_level); std::ifstream input_status(status); + std::ifstream device_name(model); std::string line; gamepad_data.push_back(gamepad()); @@ -142,11 +144,9 @@ void gamepad_info () { } //Logitech Devices if (path.find("hidpp_battery") != std::string::npos) { - if (logi_count == 1) - gamepad_data[gamepad_count].name = "LOGI DEVICE"; - else - gamepad_data[gamepad_count].name = "LOGI DEVICE-" + to_string(logi_counter + 1); - logi_counter++; + if (std::getline(device_name, line)) { + gamepad_data[gamepad_count].name = line; + } } //Get device charging status if (std::getline(input_status, line)) {