mirror of
https://github.com/citra-emu/citra.git
synced 2024-11-24 18:21: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() {
|
void Shutdown() {
|
||||||
//InputCommon::Shutdown();
|
InputCommon::Shutdown();
|
||||||
VideoCore::Shutdown();
|
VideoCore::Shutdown();
|
||||||
HLE::Shutdown();
|
HLE::Shutdown();
|
||||||
Kernel::Shutdown();
|
Kernel::Shutdown();
|
||||||
|
@ -3,7 +3,10 @@
|
|||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
#include "input_common/input_common.h"
|
#include "input_common/input_common.h"
|
||||||
|
|
||||||
|
#ifdef _SDL_H
|
||||||
#include "input_common/sdl_input/sdl_input.h"
|
#include "input_common/sdl_input/sdl_input.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "core/core_timing.h"
|
#include "core/core_timing.h"
|
||||||
#include "core/settings.h"
|
#include "core/settings.h"
|
||||||
@ -35,17 +38,18 @@ std::string ControllerBase::GetDeviceName() const {
|
|||||||
return device_name;
|
return device_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const Service::HID::PadState ControllerBase::GetPadState() const {
|
const Service::HID::PadState ControllerBase::GetPadState() const {
|
||||||
return controller.pad_state;
|
return controller.pad_state;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Init(ControllerBackends backend) {
|
void Init(ControllerBackends backend) {
|
||||||
switch (backend) {
|
switch (backend) {
|
||||||
|
#ifdef _SDL_H
|
||||||
//SDL2 backend selected
|
//SDL2 backend selected
|
||||||
case SDL2_JOY:
|
case SDL2_JOY:
|
||||||
g_user_input = new SDLController();
|
g_user_input = new SDLController();
|
||||||
break;
|
break;
|
||||||
|
#endif
|
||||||
|
|
||||||
//No backend selected
|
//No backend selected
|
||||||
case NO_JOY:
|
case NO_JOY:
|
||||||
@ -57,8 +61,8 @@ void Init(ControllerBackends backend) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Shutdown immediately if backend failed to initialize
|
//Shutdown immediately if backend failed to initialize
|
||||||
if((g_user_input != nullptr) && (!g_user_input->activated)) {
|
if (g_user_input != nullptr && !g_user_input->activated) {
|
||||||
ShutDown();
|
Shutdown();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -69,8 +73,8 @@ void Init(ControllerBackends backend) {
|
|||||||
CoreTiming::ScheduleEvent(frame_ticks, input_event);
|
CoreTiming::ScheduleEvent(frame_ticks, input_event);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShutDown() {
|
void Shutdown() {
|
||||||
if((g_user_input != nullptr)
|
if (g_user_input != nullptr) {
|
||||||
delete g_user_input;
|
delete g_user_input;
|
||||||
g_user_input = nullptr;
|
g_user_input = nullptr;
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ public:
|
|||||||
virtual void Poll() = 0;
|
virtual void Poll() = 0;
|
||||||
|
|
||||||
/// Shuts down all backend related data
|
/// 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
|
/// Returns internal name of currently selected device. Expose this to the UI
|
||||||
std::string GetDeviceName() const;
|
std::string GetDeviceName() const;
|
||||||
@ -52,11 +52,9 @@ protected:
|
|||||||
void Init(ControllerBackends backend);
|
void Init(ControllerBackends backend);
|
||||||
|
|
||||||
/// Deactive the user input system
|
/// Deactive the user input system
|
||||||
void ShutDown();
|
void Shutdown();
|
||||||
|
|
||||||
/// InputCommon 'plugin'
|
/// InputCommon 'plugin'
|
||||||
extern ControllerBase* g_user_input;
|
extern ControllerBase* g_user_input;
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ SDLController::SDLController() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
SDLController::~SDLController() {
|
SDLController::~SDLController() {
|
||||||
ShutDown();
|
Shutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SDLController::Init() {
|
bool SDLController::Init() {
|
||||||
@ -55,7 +55,7 @@ bool SDLController::Init() {
|
|||||||
|
|
||||||
void SDLController::DiscoverDevices() {}
|
void SDLController::DiscoverDevices() {}
|
||||||
|
|
||||||
void SDLController::ShutDown() {
|
void SDLController::Shutdown() {
|
||||||
//Attempt to close joystick with SDL
|
//Attempt to close joystick with SDL
|
||||||
if (jpad != nullptr) {
|
if (jpad != nullptr) {
|
||||||
SDL_JoystickClose(jpad);
|
SDL_JoystickClose(jpad);
|
||||||
@ -64,8 +64,8 @@ void SDLController::ShutDown() {
|
|||||||
|
|
||||||
void SDLController::Poll() {
|
void SDLController::Poll() {
|
||||||
if (SDL_PollEvent(&input_event)) {
|
if (SDL_PollEvent(&input_event)) {
|
||||||
if((input_event.type == SDL_JOYBUTTONDOWN) || (input_event.type == SDL_JOYBUTTONUP)
|
if (input_event.type == SDL_JOYBUTTONDOWN || input_event.type == SDL_JOYBUTTONUP
|
||||||
|| (input_event.type == SDL_JOYAXISMOTION) || (input_event.type == SDL_JOYHATMOTION)) {
|
|| input_event.type == SDL_JOYAXISMOTION || input_event.type == SDL_JOYHATMOTION) {
|
||||||
ProcessInput();
|
ProcessInput();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,22 +10,22 @@
|
|||||||
|
|
||||||
namespace InputCommon {
|
namespace InputCommon {
|
||||||
|
|
||||||
class SDLController : virtual public ControllerBase {
|
class SDLController final : public ControllerBase {
|
||||||
public:
|
public:
|
||||||
SDLController();
|
SDLController();
|
||||||
~SDLController();
|
~SDLController();
|
||||||
|
|
||||||
/// Initializes input via SDL2
|
/// Initializes input via SDL2
|
||||||
bool Init();
|
bool Init() override;
|
||||||
|
|
||||||
/// Grabs a list of devices supported by the backend
|
/// Grabs a list of devices supported by the backend
|
||||||
void DiscoverDevices();
|
void DiscoverDevices() override;
|
||||||
|
|
||||||
/// Grab and process input via SDL2
|
/// Grab and process input via SDL2
|
||||||
void Poll();
|
void Poll() override;
|
||||||
|
|
||||||
/// Shuts down all joysticks opened by SDL2
|
/// Shuts down all joysticks opened by SDL2
|
||||||
void ShutDown();
|
void Shutdown() override;
|
||||||
|
|
||||||
/// Processes input when polling
|
/// Processes input when polling
|
||||||
void ProcessInput();
|
void ProcessInput();
|
||||||
@ -55,5 +55,3 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
} //namespace
|
} //namespace
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user