From a8f3b1739d03dfc2781fb40e9011fcdaf9423f45 Mon Sep 17 00:00:00 2001 From: Daniel Stuart Baxter Date: Sun, 31 May 2015 11:11:14 -0500 Subject: [PATCH] Review Changes 10 --- src/common/logging/log.h | 1 + src/core/system.cpp | 2 +- src/input_common/input_common.cpp | 13 +++++++------ src/input_common/input_common.h | 10 +++++----- src/input_common/sdl_input/sdl_input.h | 2 +- 5 files changed, 15 insertions(+), 13 deletions(-) diff --git a/src/common/logging/log.h b/src/common/logging/log.h index d720d7fe0..ff49a2e8f 100644 --- a/src/common/logging/log.h +++ b/src/common/logging/log.h @@ -75,6 +75,7 @@ enum class Class : ClassType { Render_Software, ///< Software renderer backend Render_OpenGL, ///< OpenGL backend Loader, ///< ROM loader + Input, ///< User input system Count ///< Total number of logging classes }; diff --git a/src/core/system.cpp b/src/core/system.cpp index ce6e1ca01..1b4cca42f 100644 --- a/src/core/system.cpp +++ b/src/core/system.cpp @@ -24,7 +24,7 @@ void Init(EmuWindow* emu_window) { Kernel::Init(); HLE::Init(); VideoCore::Init(emu_window); - InputCommon::Init(InputCommon::SDL2); + InputCommon::Init(InputCommon::ControllerBackends::SDL2); } void Shutdown() { diff --git a/src/input_common/input_common.cpp b/src/input_common/input_common.cpp index 2afe9fe6b..03bead9a4 100644 --- a/src/input_common/input_common.cpp +++ b/src/input_common/input_common.cpp @@ -14,7 +14,7 @@ namespace InputCommon { // Set to nullptr until initialized by a backend -ControllerBase* g_user_input = nullptr; +InputBase* g_user_input = nullptr; // Event id for CoreTiming static int input_event; @@ -32,11 +32,11 @@ static void InputCallback(u64 userdata, int cycles_late) { CoreTiming::ScheduleEvent(frame_ticks - cycles_late, input_event); } -std::string ControllerBase::GetDeviceName() const { +std::string InputBase::GetDeviceName() const { return device_name; } -Service::HID::PadState ControllerBase::GetPadState() const { +Service::HID::PadState InputBase::GetPadState() const { return controller.pad_state; } @@ -44,17 +44,18 @@ void Init(ControllerBackends backend) { switch (backend) { #ifdef HAS_SDL // SDL2 backend selected - case SDL2: + case ControllerBackends::SDL2: g_user_input = new SDLController(); break; #endif // No backend selected - case NONE: + case ControllerBackends::NONE: break; - // What? + // If no backend whatsoever inits, launch a critical log default: + LOG_CRITICAL(Input, "Input backend initialization failed!"); break; } diff --git a/src/input_common/input_common.h b/src/input_common/input_common.h index 7c690f3eb..503a34a60 100644 --- a/src/input_common/input_common.h +++ b/src/input_common/input_common.h @@ -10,15 +10,15 @@ namespace InputCommon { /// Enum defining available backends -enum ControllerBackends { +enum class ControllerBackends { NONE, SDL2 }; -class ControllerBase { +class InputBase { public: - ControllerBase() {} - virtual ~ControllerBase() {} + InputBase() {} + virtual ~InputBase() {} /// Initializes input based on specific backends virtual bool Init() = 0; @@ -55,6 +55,6 @@ void Init(ControllerBackends backend); void Shutdown(); /// InputCommon 'plugin' -extern ControllerBase* g_user_input; +extern InputBase* g_user_input; } // namespace diff --git a/src/input_common/sdl_input/sdl_input.h b/src/input_common/sdl_input/sdl_input.h index 4e78404f0..b05670833 100644 --- a/src/input_common/sdl_input/sdl_input.h +++ b/src/input_common/sdl_input/sdl_input.h @@ -10,7 +10,7 @@ namespace InputCommon { -class SDLController final : public ControllerBase { +class SDLController final : public InputBase { public: SDLController(); ~SDLController();