Common: Make HookableEvent use non-static data.
This makes Common::HookableEvent into a normal object rather than each event being a unique type with static storage.
The video events for now exist inside a struct accessible from System::GetVideoEvents().
I've also, for now, added a global GetVideoEvents() function for places that don't have a system reference readily available.
I'm open to suggestions on doing it differently.
Register and Trigger calls are unfortunately much more verbose, but that's how removing globals goes.
In future PRs I plan to rectify all of our duplicate "callback" implementations, replacing them with HookableEvent.
HookableEvent's EventHook handle has automatic callback removal on destruction, which these others do not.
e.g. ControllerInterface::RegisterDevicesChangedCallback, Config::AddConfigChangedCallback, Core::AddOnStateChangedCallback, are there more?
I'm also thinking there might be some future situations more cleanly implemented with additional HookableEvents rather than having unrelated subsystems talk to each other.
This now also eliminates the usage of Common/StringLiteral.h
I think freebsd/macos build bots were having struggles with that, but maybe OatmealDome knows more?
Edit: whelp, freebsd/macos builds are still struggling..
This looks reasonable to me and I always appreciate less global state.
Are the event and hook names used for anything in Release mode? I'm only seeing the debug log prints. Not tragic but maybe ifdef the members out then?
Are the event and hook names used for anything in Release mode? I'm only seeing the debug log prints. Not tragic but maybe ifdef the members out then?
Good point. I've now disabled those members in non-debug builds.
If you add e3e0b0ab6477c6b4018e46c6cba2ce1a9c6d6fa4 to this PR the macos/freebsd builds don't fail anymore: #13199.
I've added f1410314bdde6cd7be8bb62faf2e3c2c4858be30 to https://github.com/dolphin-emu/dolphin/pull/13199 which converts the new HookableEvents added to AchievementManager since this PR was made.
I have an upcoming PR that crashes when Dolphin exits due to static deinitialization issues in HookableEvent. That crash is fixed by cherry-picking this PR, so let me know if there's anything else I can do to help with this.
I've added f141031 to #13199 which converts the new HookableEvents added to AchievementManager since this PR was made.
I have an upcoming PR that crashes when Dolphin exits due to static deinitialization issues in HookableEvent. That crash is fixed by cherry-picking this PR, so let me know if there's anything else I can do to help with this.
Okie, thanks, I'll get this PR cleaned up.