Review Changes 9

This commit is contained in:
Daniel Stuart Baxter 2015-05-31 10:59:17 -05:00
parent 61ead16c48
commit ae7c967941
3 changed files with 10 additions and 10 deletions

View File

@ -26,9 +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) { if (g_user_input != nullptr) g_user_input->Poll();
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);

View File

@ -55,6 +55,6 @@ void Init(ControllerBackends backend);
void Shutdown(); void Shutdown();
/// InputCommon 'plugin' /// InputCommon 'plugin'
extern std::unique_ptr<ControllerBase> g_user_input; extern ControllerBase* g_user_input;
} // namespace } // namespace

View File

@ -9,7 +9,7 @@
namespace InputCommon { namespace InputCommon {
SDLController::SDLController() { SDLController::SDLController() {
device_name = "SDL2::NONE"; device_name = "SDL2::";
jpad = nullptr; jpad = nullptr;
index = 0; index = 0;
@ -29,6 +29,7 @@ bool SDLController::Init() {
// Attempt to initialize SDL with joystick only // Attempt to initialize SDL with joystick only
if (SDL_Init(SDL_INIT_JOYSTICK) != 0) { if (SDL_Init(SDL_INIT_JOYSTICK) != 0) {
Shutdown();
return false; return false;
} }
@ -37,10 +38,12 @@ bool SDLController::Init() {
jpad = SDL_JoystickOpen(index); jpad = SDL_JoystickOpen(index);
if (jpad == nullptr) { if (jpad == nullptr) {
Shutdown();
return false; 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 // If joystick successfully opened, load up keymap from input configuration
// TODO - Make it NOT hardcoded // TODO - Make it NOT hardcoded
@ -57,9 +60,8 @@ 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); SDL_Quit();
}
} }
void SDLController::Poll() { void SDLController::Poll() {
@ -233,4 +235,4 @@ bool SDLController::CheckDeadZone(int range) const {
return false; return false;
} }
}// namespace } // namespace