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