core: hid: Remove service callbacks on game close
This commit is contained in:
@@ -1207,4 +1207,12 @@ void EmulatedController::DeleteCallback(int key) {
|
|||||||
}
|
}
|
||||||
callback_list.erase(iterator);
|
callback_list.erase(iterator);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EmulatedController::RemoveServiceCallbacks() {
|
||||||
|
std::lock_guard lock{mutex};
|
||||||
|
const auto count = std::erase_if(
|
||||||
|
callback_list, [](const auto& callback) { return callback.second.is_npad_service; });
|
||||||
|
LOG_DEBUG(Input, "Elements deleted {}", count);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Core::HID
|
} // namespace Core::HID
|
||||||
|
|||||||
@@ -335,6 +335,9 @@ public:
|
|||||||
*/
|
*/
|
||||||
void DeleteCallback(int key);
|
void DeleteCallback(int key);
|
||||||
|
|
||||||
|
/// Removes all callbacks created from npad services
|
||||||
|
void RemoveServiceCallbacks();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/// creates input devices from params
|
/// creates input devices from params
|
||||||
void LoadDevices();
|
void LoadDevices();
|
||||||
|
|||||||
@@ -211,4 +211,17 @@ void HIDCore::UnloadInputDevices() {
|
|||||||
devices->UnloadInput();
|
devices->UnloadInput();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void HIDCore::RemoveServiceCallbacks() {
|
||||||
|
player_1->RemoveServiceCallbacks();
|
||||||
|
player_2->RemoveServiceCallbacks();
|
||||||
|
player_3->RemoveServiceCallbacks();
|
||||||
|
player_4->RemoveServiceCallbacks();
|
||||||
|
player_5->RemoveServiceCallbacks();
|
||||||
|
player_6->RemoveServiceCallbacks();
|
||||||
|
player_7->RemoveServiceCallbacks();
|
||||||
|
player_8->RemoveServiceCallbacks();
|
||||||
|
other->RemoveServiceCallbacks();
|
||||||
|
handheld->RemoveServiceCallbacks();
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Core::HID
|
} // namespace Core::HID
|
||||||
|
|||||||
@@ -61,6 +61,9 @@ public:
|
|||||||
/// Removes all callbacks from input common
|
/// Removes all callbacks from input common
|
||||||
void UnloadInputDevices();
|
void UnloadInputDevices();
|
||||||
|
|
||||||
|
/// Removes all callbacks from npad services
|
||||||
|
void RemoveServiceCallbacks();
|
||||||
|
|
||||||
/// Number of emulated controllers
|
/// Number of emulated controllers
|
||||||
static constexpr std::size_t available_controllers{10};
|
static constexpr std::size_t available_controllers{10};
|
||||||
|
|
||||||
|
|||||||
+2
-1
@@ -1533,8 +1533,9 @@ void GMainWindow::ShutdownGame() {
|
|||||||
input_subsystem->GetTas()->Stop();
|
input_subsystem->GetTas()->Stop();
|
||||||
OnTasStateChanged();
|
OnTasStateChanged();
|
||||||
|
|
||||||
// Enable all controllers
|
// Enable all controllers types and remove all service callbacks
|
||||||
system->HIDCore().SetSupportedStyleTag({Core::HID::NpadStyleSet::All});
|
system->HIDCore().SetSupportedStyleTag({Core::HID::NpadStyleSet::All});
|
||||||
|
system->HIDCore().RemoveServiceCallbacks();
|
||||||
|
|
||||||
render_window->removeEventFilter(render_window);
|
render_window->removeEventFilter(render_window);
|
||||||
render_window->setAttribute(Qt::WA_Hover, false);
|
render_window->setAttribute(Qt::WA_Hover, false);
|
||||||
|
|||||||
Reference in New Issue
Block a user