[gameprogrammer] Re: fast event with standard SDL_KEYDOWN events

  • From: Jaco Briggs <jacob_briggs@xxxxxxxxxxxxxxx>
  • To: "gameprogrammer@xxxxxxxxxxxxx" <gameprogrammer@xxxxxxxxxxxxx>
  • Date: Wed, 21 Apr 2004 22:11:36 +1200 (NZST)

I needed to do this :
        SDL_Surface *screen = NULL;
        char *msg;
...
        /* Set 640x480 16-bits video mode */
        screen = SDL_SetVideoMode (640, 480, 16, SDL_SWSURFACE | SDL_DOUBLEBUF);
        if (screen == NULL) {
                asprintf (&msg, "Couldn't set 640x480x16 video mode: %s\n",
                SDL_GetError ());
                //MessageBox (0, msg, "Error", MB_ICONHAND);
                free (msg);
                exit (2);
        }
        
        SDL_WM_SetCaption ("SDL MultiMedia Application", NULL);
        

I need a screen to capture events.... I have been playing with this problem for
4 hours, the second i ask someone about it, i come up with the answer....

Quoting Jaco Briggs <jacob_briggs@xxxxxxxxxxxxxxx>:

> I have some code below, I cant figure out why it doesnt work. Its a
> hacked up
> version of uc.cpp that can be gotten from the Net2 documentation pages
> (http://www.gameprogrammer.com/net2/net2-1.html)
> Whats wrong with it you ask? Well i cant seem to get it to recognise key
> events,
> such as a SDL_KEYDOWN. In fact it just seems to sit at 
> "while(FE_WaitEvent(&ev)) {" for ever....
> 
> I am a bit confused. Is it possible to use the Fast Events library to
> capture
> both net2 events and standard SDL_KEYDOWN events? It seems to get the
> SDL_QUIT
> event, doing a ctrl-c causes the program to print out SDL_QUIT. I am
> running
> this under linux....
> 
> jake
> 
> #include <string.h>
> #include <stdlib.h>
> #include "SDL.h"
> #include "net2.h"
> #include "fastevents.h"
> #include "SDLUtils.h"
> 
> int main(int argc, char **argv){
>  IPaddress ip; 
>  char buf[100]; 
>  int i; 
>  int limit = 1000; 
>  int count = 0; 
>  SDL_Event ev; 
> 
>  mySDLInitOrQuit(SDL_INIT_EVENTTHREAD | SDL_INIT_VIDEO |
> SDL_INIT_NOPARACHUTE);
>  printf("mySDLInit finished\n");
>  printf("FE_Init returned : %i\n",FE_Init()); 
>  NET2_ResolveHost(&ip, "localhost", 5555); 
> 
>  printf("Host Resovlved\n");
>  while (FE_WaitEvent(&ev)) {
>  //while (SDL_PollEvent (&ev)) {
>  //while (FE_PollEvent (&ev)) {
>  printSDLEvent(&ev);
>               switch (ev.type) { 
>                       case SDL_QUIT: 
>               mySDL_Quit(); 
>                               exit(0); 
>                               break; 
>                       case SDL_KEYDOWN:
>                               printf("SDL_KEYDOWN - %i\n",ev.key.keysym.sym);
>                               break;
>               }
>       }
>  printf("finished"); 
>  mySDL_Quit(); 
> }
> 
>  



this is a signiture....

Other related posts: