input_common: Eliminate most global state

Abstracts most of the input mechanisms under an InputSubsystem class
that is managed by the frontends, eliminating any static constructors
and destructors. This gets rid of global accessor functions and also
allows the frontends to have a more fine-grained control over the
lifecycle of the input subsystem.

This also makes it explicit which interfaces rely on the input subsystem
instead of making it opaque in the interface functions. All that remains
to migrate over is the factories, which can be done in a separate
change.
This commit is contained in:
Lioncash 2020-08-27 15:16:47 -04:00
parent 3db9a25977
commit 9e1b0af259
25 changed files with 397 additions and 243 deletions

View file

@ -13,7 +13,6 @@
#include <glad/glad.h>
#include "common/assert.h"
#include "common/logging/log.h"
#include "common/scm_rev.h"
#include "core/settings.h"
@ -53,7 +52,7 @@ EmuWindow_SDL2_Hide::EmuWindow_SDL2_Hide() {
exit(1);
}
InputCommon::Init();
input_subsystem->Initialize();
SDL_SetMainReady();
@ -105,7 +104,7 @@ EmuWindow_SDL2_Hide::EmuWindow_SDL2_Hide() {
}
EmuWindow_SDL2_Hide::~EmuWindow_SDL2_Hide() {
InputCommon::Shutdown();
input_subsystem->Shutdown();
SDL_GL_DeleteContext(gl_context);
SDL_Quit();
}

View file

@ -8,6 +8,10 @@
struct SDL_Window;
namespace InputCommon {
class InputSubsystem;
}
class EmuWindow_SDL2_Hide : public Core::Frontend::EmuWindow {
public:
explicit EmuWindow_SDL2_Hide();
@ -25,6 +29,8 @@ private:
/// Whether the GPU and driver supports the OpenGL extension required
bool SupportsRequiredGLExtensions();
std::unique_ptr<InputCommon::InputSubsystem> input_subsystem;
/// Internal SDL2 render window
SDL_Window* render_window;