[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: [pygame] Numeric wireless keyboard
Hi
> I think you probably can't get those messages without creating a
> window, so try creating a window before getting events.
You were right all the way, it works now.
Thanks, I'm ready to verify my ARM platform
--
Pierre Lafrance
--
Brian Fisher wrote:
> I think you probably can't get those messages without creating a window,
> so try creating a window before getting events.
>
> Also, you don't want to have a separate poll and wait func, which are
> both called and both check for different messages. Both those functions
> remove messages from the queue, so if a your poll function gets a
> SDL_KEYDOWN message, it would end up throwing out the message and then
> your wait function would never receive it. Just do the Poll thing, and
> make it's switch statement do the prints for SDL_KEYDOWN as well.
>
> Anyways, once your test program works for your normal keyboard, then you
> can try it out with the wireless in order to learn how SDL is or is not
> reading that things key data, which will help you understand where the
> problem lies and how to solve it.
>
> On Thu, Sep 3, 2009 at 2:05 PM, PierreLafrance1@xxxxxxxxxxxx
> <mailto:PierreLafrance1@xxxxxxxxxxxx> <PierreLafrance1@xxxxxxxxxxxx
> <mailto:PierreLafrance1@xxxxxxxxxxxx>> wrote:
>
> #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
> --
>
>