Review Changes 9
This commit is contained in:
parent
61ead16c48
commit
ae7c967941
3 changed files with 10 additions and 10 deletions
|
@ -26,9 +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 != nullptr) g_user_input->Poll();
|
||||
|
||||
// Reschedule recurrent event
|
||||
CoreTiming::ScheduleEvent(frame_ticks - cycles_late, input_event);
|
||||
|
|
|
@ -55,6 +55,6 @@ void Init(ControllerBackends backend);
|
|||
void Shutdown();
|
||||
|
||||
/// InputCommon 'plugin'
|
||||
extern std::unique_ptr<ControllerBase> g_user_input;
|
||||
extern ControllerBase* g_user_input;
|
||||
|
||||
} // namespace
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
namespace InputCommon {
|
||||
|
||||
SDLController::SDLController() {
|
||||
device_name = "SDL2::NONE";
|
||||
device_name = "SDL2::";
|
||||
jpad = nullptr;
|
||||
index = 0;
|
||||
|
||||
|
@ -29,6 +29,7 @@ bool SDLController::Init() {
|
|||
|
||||
// Attempt to initialize SDL with joystick only
|
||||
if (SDL_Init(SDL_INIT_JOYSTICK) != 0) {
|
||||
Shutdown();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -37,10 +38,12 @@ bool SDLController::Init() {
|
|||
jpad = SDL_JoystickOpen(index);
|
||||
|
||||
if (jpad == nullptr) {
|
||||
Shutdown();
|
||||
return false;
|
||||
}
|
||||
|
||||
device_name = SDL_JoystickNameForIndex(index);
|
||||
std::string index_name = SDL_JoystickNameForIndex(index);
|
||||
device_name += index_name;
|
||||
|
||||
// If joystick successfully opened, load up keymap from input configuration
|
||||
// TODO - Make it NOT hardcoded
|
||||
|
@ -57,9 +60,8 @@ void SDLController::DiscoverDevices() {}
|
|||
|
||||
void SDLController::Shutdown() {
|
||||
// Attempt to close joystick with SDL
|
||||
if (jpad != nullptr) {
|
||||
SDL_JoystickClose(jpad);
|
||||
}
|
||||
if (jpad != nullptr) SDL_JoystickClose(jpad);
|
||||
SDL_Quit();
|
||||
}
|
||||
|
||||
void SDLController::Poll() {
|
||||
|
|
Loading…
Reference in a new issue