Simple DirectMedia Layer



SDL_WaitEvent().

:

SDL , UNICODE event.key.keysym.unicode. , SDL_EnableUNICODE().

:

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

SDL_PollEvent().

:

, SDL_PEEKEVENT SDL_PeepEvents().

:

 { SDL_Event event;  while ( SDL_PollEvent(&event) ) { switch (event.type) { 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); } }}

, , . , SDL_EventState() SDL_PumpEvents() .

:

SDL_ShowCursor().

:

 { SDL_EventState(SDL_MOUSEMOTION, SDL_IGNORE);} void CheckMouseHover(void){ int mouse_x, mouse_y;  SDL_PumpEvents();  SDL_GetMouseState(&mouse_x, &mouse_y); if ( (mouse_x < 32) && (mouse_y < 32) ) { printf("Mouse in upper left hand corner!\n"); }}

<