mirror of
https://github.com/citra-emu/citra.git
synced 2024-11-24 16:21:05 +00:00
Review Changes 12 - unique_ptr for InputBase
This commit is contained in:
parent
5dbd3c53f7
commit
1be629b345
@ -13,8 +13,8 @@
|
||||
|
||||
namespace InputCommon {
|
||||
|
||||
// Set to nullptr until initialized by a backend
|
||||
InputBase* g_user_input = nullptr;
|
||||
// User input system
|
||||
std::unique_ptr<InputBase> g_user_input;
|
||||
|
||||
// Event id for CoreTiming
|
||||
static int input_event;
|
||||
@ -26,7 +26,7 @@ static u64 frame_ticks;
|
||||
static void InputCallback(u64 userdata, int cycles_late) {
|
||||
|
||||
// Call user input plugin Poll()
|
||||
if (g_user_input != nullptr) g_user_input->Poll();
|
||||
if (g_user_input) g_user_input->Poll();
|
||||
|
||||
// Reschedule recurrent event
|
||||
CoreTiming::ScheduleEvent(frame_ticks - cycles_late, input_event);
|
||||
@ -45,7 +45,7 @@ void Init(InputBackends backend) {
|
||||
#ifdef HAS_SDL
|
||||
// SDL2 backend selected
|
||||
case InputBackends::SDL2:
|
||||
g_user_input = new SDLController();
|
||||
g_user_input.reset(new SDLController);
|
||||
break;
|
||||
#endif
|
||||
|
||||
@ -60,7 +60,7 @@ void Init(InputBackends backend) {
|
||||
}
|
||||
|
||||
// Shutdown immediately if backend failed to initialize
|
||||
if (g_user_input != nullptr && !g_user_input->activated) {
|
||||
if (!g_user_input && !g_user_input->activated) {
|
||||
Shutdown();
|
||||
return;
|
||||
}
|
||||
@ -73,10 +73,7 @@ void Init(InputBackends backend) {
|
||||
}
|
||||
|
||||
void Shutdown() {
|
||||
if (g_user_input != nullptr) {
|
||||
delete g_user_input;
|
||||
g_user_input = nullptr;
|
||||
}
|
||||
if (g_user_input) g_user_input.release();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
@ -55,6 +55,6 @@ void Init(InputBackends backend);
|
||||
void Shutdown();
|
||||
|
||||
/// InputCommon 'plugin'
|
||||
extern InputBase* g_user_input;
|
||||
extern std::unique_ptr<InputBase> g_user_input;
|
||||
|
||||
} // namespace
|
||||
|
Loading…
Reference in New Issue
Block a user