Finalize input shutdown in the core

Eliminate trailing whitespace

Review changes 1

Review changes 2

Review changes 3

Review change 4

Review changes 5
This commit is contained in:
Daniel Stuart Baxter 2015-05-30 15:24:09 -05:00
parent 1703988f00
commit f87056289a
5 changed files with 70 additions and 70 deletions

View File

@ -28,7 +28,7 @@ void Init(EmuWindow* emu_window) {
}
void Shutdown() {
//InputCommon::Shutdown();
InputCommon::Shutdown();
VideoCore::Shutdown();
HLE::Shutdown();
Kernel::Shutdown();

View File

@ -3,7 +3,10 @@
// Refer to the license.txt file included.
#include "input_common/input_common.h"
#ifdef _SDL_H
#include "input_common/sdl_input/sdl_input.h"
#endif
#include "core/core_timing.h"
#include "core/settings.h"
@ -35,17 +38,18 @@ std::string ControllerBase::GetDeviceName() const {
return device_name;
}
const Service::HID::PadState ControllerBase::GetPadState() const {
return controller.pad_state;
}
void Init(ControllerBackends backend) {
switch (backend) {
#ifdef _SDL_H
//SDL2 backend selected
case SDL2_JOY:
g_user_input = new SDLController();
break;
#endif
//No backend selected
case NO_JOY:
@ -57,8 +61,8 @@ void Init(ControllerBackends backend) {
}
//Shutdown immediately if backend failed to initialize
if((g_user_input != nullptr) && (!g_user_input->activated)) {
ShutDown();
if (g_user_input != nullptr && !g_user_input->activated) {
Shutdown();
return;
}
@ -69,8 +73,8 @@ void Init(ControllerBackends backend) {
CoreTiming::ScheduleEvent(frame_ticks, input_event);
}
void ShutDown() {
if((g_user_input != nullptr)
void Shutdown() {
if (g_user_input != nullptr) {
delete g_user_input;
g_user_input = nullptr;
}

View File

@ -30,7 +30,7 @@ public:
virtual void Poll() = 0;
/// Shuts down all backend related data
virtual void ShutDown() = 0;
virtual void Shutdown() = 0;
/// Returns internal name of currently selected device. Expose this to the UI
std::string GetDeviceName() const;
@ -52,11 +52,9 @@ protected:
void Init(ControllerBackends backend);
/// Deactive the user input system
void ShutDown();
void Shutdown();
/// InputCommon 'plugin'
extern ControllerBase* g_user_input;
} // namespace

View File

@ -22,7 +22,7 @@ SDLController::SDLController() {
}
SDLController::~SDLController() {
ShutDown();
Shutdown();
}
bool SDLController::Init() {
@ -55,7 +55,7 @@ bool SDLController::Init() {
void SDLController::DiscoverDevices() {}
void SDLController::ShutDown() {
void SDLController::Shutdown() {
//Attempt to close joystick with SDL
if (jpad != nullptr) {
SDL_JoystickClose(jpad);
@ -64,8 +64,8 @@ void SDLController::ShutDown() {
void SDLController::Poll() {
if (SDL_PollEvent(&input_event)) {
if((input_event.type == SDL_JOYBUTTONDOWN) || (input_event.type == SDL_JOYBUTTONUP)
|| (input_event.type == SDL_JOYAXISMOTION) || (input_event.type == SDL_JOYHATMOTION)) {
if (input_event.type == SDL_JOYBUTTONDOWN || input_event.type == SDL_JOYBUTTONUP
|| input_event.type == SDL_JOYAXISMOTION || input_event.type == SDL_JOYHATMOTION) {
ProcessInput();
}
}

View File

@ -10,22 +10,22 @@
namespace InputCommon {
class SDLController : virtual public ControllerBase {
class SDLController final : public ControllerBase {
public:
SDLController();
~SDLController();
/// Initializes input via SDL2
bool Init();
bool Init() override;
/// Grabs a list of devices supported by the backend
void DiscoverDevices();
void DiscoverDevices() override;
/// Grab and process input via SDL2
void Poll();
void Poll() override;
/// Shuts down all joysticks opened by SDL2
void ShutDown();
void Shutdown() override;
/// Processes input when polling
void ProcessInput();
@ -55,5 +55,3 @@ private:
};
} //namespace