mirror of
https://github.com/citra-emu/citra.git
synced 2024-11-24 16:31:05 +00:00
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:
parent
1703988f00
commit
f87056289a
@ -28,7 +28,7 @@ void Init(EmuWindow* emu_window) {
|
||||
}
|
||||
|
||||
void Shutdown() {
|
||||
//InputCommon::Shutdown();
|
||||
InputCommon::Shutdown();
|
||||
VideoCore::Shutdown();
|
||||
HLE::Shutdown();
|
||||
Kernel::Shutdown();
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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
|
||||
|
||||
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user