[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] Numeric wireless keyboard



Jake b wrote:
> Hi
> 
>     I'm compiling the code (my first prg with gcc), and doesn't find SDL.h.
>      I have done a find on SDL (find -name "SDL.h"), without success. Where
>     and how can I find this file ?  Do I have to install SDL ? (I'm assuming
>     Python is using it and its there...)
> 
> 
> To search you can try: [ search starting on root, using insensitive case ]
>     $ find / -iname "SDL.h"
> 
> Did you try lsusb?
>     $ lsusb
> 
> To install sdl dev, run synaptic, and do a search for "sdl", it might be
> named "libsdl1.2-dev"
> 
> Ubuntu 9.04 is out.
> 
> To include SDL.h the best way is to: follow this link:
> http://www.libsdl.org/faq.php?action=listentries&category=3#21
> <http://www.libsdl.org/faq.php?action=listentries&category=3#21>
> 
> example:
>     $ gcc -o hiworld hiworld.c `sdl-config --cflags --libs`
> 
> -- 
> Jake

Hi
I have succedded to fix synaptic (and apt-get) and install SDL.
I compile and run the file, but it produce nothing when I move mouse or
type key (it types letter, but not the message printf should output)
But I don't know exactly how I should call the functions...!!!

Anything I should try ?

My target is to debug a keyboard not working with pygames on a ARM
platform.  I was suggested to make this little programe to debug this issue.

bellow is my code

Thanks

#include <stdio.h>
#include <stdlib.h>
#include "/usr/include/SDL/SDL.h"

int MySDL_WaitEvent()
{
    printf("About to call SDL_WaitEvent(&event)\n");
    SDL_Event event;
    SDL_WaitEvent(&event);

    switch (event.type)
    {
        printf("In switch/case of SDL_WaitEvent(&event)\n");
        case SDL_KEYDOWN:
            printf("The %s key was pressed!\n",
                SDL_GetKeyName(event.key.keysym.sym));
            break;
        case SDL_QUIT:
            exit(0);
    }
}


int MySDL_PollEvent()
{
    printf("About to call SDL_PollEvent(&event)\n");
    SDL_Event event;
    while ( SDL_PollEvent(&event) )
    {
        switch (event.type)
        {
            printf("In switch/case of SDL_PollEvent(&event)\n");
            case SDL_MOUSEMOTION:
                printf("Mouse moved by %d,%d to (%d,%d)\n",
                    event.motion.xrel, event.motion.yrel,
                    event.motion.x, event.motion.y);
                break;
            case SDL_MOUSEBUTTONDOWN:
                printf("Mouse button %d pressed at (%d,%d)\n",
                    event.button.button, event.button.x, event.button.y);
                break;
            case SDL_QUIT:
                exit(0);
        }
    }
}

int main(int argc, char *argv[])
{
    printf("About to call SDL_Init()\n");
    if ( SDL_Init(SDL_INIT_AUDIO|SDL_INIT_VIDEO) < 0 )
    {
        //fprintf(stderr, "Unable to init SDL: %s\n", SDL_GetError());
        printf("Unable to init SDL: %s\n", SDL_GetError());
        exit(1);
    }
    while(1)
    {
        printf("About to call MySDL_PollEvent()\n");
        MySDL_PollEvent();
        printf("About to call MySDL_WaitEvent()\n");
        MySDL_WaitEvent();
    }   //  while

    printf("About to call atexit()\n");
    atexit(SDL_Quit);
}

-- 
Pierre Lafrance
--