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) {
// 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);

View File

@ -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

View File

@ -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() {