Hello, everyone.
I’m trying to build my first SDL2 game, and as I’m setting up player input through a game controller, I’m getting the strangest issue. The values of the x and y axes for both the left and right joystick are being stored under SDL_CONTROLLER_AXIS_RIGHTX and SDL_CONTROLLER_AXIS_RIGHTY. Also, the left analog stick overwrites the values for the right analog stick.
I just need to know why it seems SDL2 is storing the left stick’s data in the right stick’s memory, and if there is a way to correct the issue.
Specs:
OS: Windows 10
SDL: 2.28.4
Controller: Logitech F310
The following is my routine code:
while ( !boolQuitGame && rEvent->type != SDL_QUIT ) { //Run while the user doesn't want to quit
while ( SDL_PollEvent( rEvent ) ) { //Listen for events
switch ( rEvent->type ) { //Check if user wants to quit
case SDL_QUIT:
boolQuitGame = true; //The user wants to quit :(
break;
}
}
//Logic goes here
system("cls");
std::cout << (int) SDL_GameControllerGetAxis( rGameController, SDL_CONTROLLER_AXIS_RIGHTX ) << " " << (int) SDL_GameControllerGetAxis( rGameController, SDL_CONTROLLER_AXIS_RIGHTY ) << std::endl;
imageManager.Draw();
}
Thank you for taking time to read my post.