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
|
struct Structure_Evenement
{
int clavier[SDLK_LAST];
int boutons_souris[6];
int position_sourisX, position_precedente_sourisX, position_sourisY, position_precedente_sourisY,
position_relative_sourisX, position_relative_sourisY;
int quit;
};
void maj_evenements (struct Structure_Evenement *Input)
{
Input->position_precedente_sourisX = Input->position_sourisX;
Input->position_precedente_sourisY = Input->position_sourisY;
SDL_Event event;
while(SDL_PollEvent(&event))
{
switch(event.type)
{
case SDL_KEYDOWN:
Input->clavier[event.key.keysym.sym] = 1;
break;
case SDL_KEYUP:
Input->clavier[event.key.keysym.sym] = 0;
break;
case SDL_MOUSEMOTION:
Input->position_sourisX = event.motion.x;
Input->position_sourisY = event.motion.y;
Input->position_relative_sourisX = event.motion.xrel;
Input->position_relative_sourisY = event.motion.yrel;
break;
case SDL_MOUSEBUTTONDOWN:
Input->boutons_souris[event.button.button - 1] = 1;
break;
case SDL_MOUSEBUTTONUP:
Input->boutons_souris[event.button.button - 1] = 0;
break;
case SDL_QUIT:
Input->quit = 1;
break;
default:
break;
}
}
} |