eventloop as a function

I was trying to make a event loop into a function that will simple toggle globe variables. The reason I am trying to do this is that I don't know what input the final product will use, so I am trying to tie it into SDL as little as possible.
Here is the function so far; needless to say it is not working right.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
 void updateinput()
{

    SDL_Event event;
        while(SDL_PollEvent(&event))
        {
            switch(event.type)
            {
            case SDL_QUIT:
            running = false;
            break;
            case SDL_KEYDOWN:
            switch(event.key.keysym.sym)
               {
               case SDLK_RIGHT:
                pad[0] = 1;
                break;

                case SDLK_UP:
                pad[1] = 1;
                break;

                case SDLK_LEFT:
                pad[2] = 1;
                break;

                case SDLK_DOWN:
                pad[3] = 1;
                break;
               }

              case SDL_KEYUP:
            switch(event.key.keysym.sym)
               {
               case SDLK_RIGHT:
                pad[0] = 0;
                break;

                case SDLK_UP:
                pad[1] = 0;
                break;

                case SDLK_LEFT:
                pad[2] = 0;
                break;

                case SDLK_DOWN:
                pad[3] = 0;
                break;
               }


            }


       }
}


any verbal not make in the function is globe.
Do you know what the problem is, but just now how to solve it? Hint: Did you expect code to run after you called the function?

Nevermind, I don't know my SDL.
Last edited on
the idea is

while(running) {
updateinput();
do stuff
}

The problem is that the globe variables are not updating like no keys are being pressed.
Hold on; it seems the problem is in the keyup part of the function; it appears to be setting everything back to 0 before the function ends. Any ideas on what is wrong?
You're missing a break after line 30.
Thinks ^_^
Sorry for the bad English; I should have been asleep hours ago.
Topic archived. No new replies allowed.