how to detect button presses using SDL?

  • Thread starter Thread starter JPisaBrony
  • Start date Start date
  • Views Views 540
  • Replies Replies 0

JPisaBrony

New Member
Newbie
Joined
Sep 17, 2019
Messages
1
Reaction score
0
Trophies
0
Age
33
XP
97
Country
United States
does anyone know how to detect button presses (like A,B,X,Y) using SDL?

I used a certain method (code below) to detect those buttons before but I tried to use the same method recently and it just doesn't do anything anymore. no button presses are being detected, and I'm not sure why button press detection is broken.

the code snippet in question:
Code:
int running = 1;
SDL_Event event;

while(running) {
    while(SDL_PollEvent(&event)) {
        switch(event.key.keysym.sym) {
            case 'a':
                running = 0;
                break;
           case 'b':
                running = 0;
                break;
    }
}

the code above should detect if either A or B is pressed and exit the loop but nothing is being detected. any help would be appreciated.
 

Site & Scene News

Popular threads in this forum