-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclikey.c
52 lines (51 loc) · 1.59 KB
/
clikey.c
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
#include <SDL2/SDL.h>
#include "keysdown.h"
int handlekey(SDL_Event event,struct keysdown* keys){
int multiplier = 0;
switch(event.type){
case SDL_KEYDOWN:
multiplier=1;
case SDL_KEYUP:
switch(event.key.keysym.sym){
case SDLK_RIGHT:
case SDLK_d:
keys->rightd=multiplier;
break;
case SDLK_DOWN:
case SDLK_s:
keys->downs=multiplier;
break;
case SDLK_LEFT:
case SDLK_a:
keys->lefta=multiplier;
break;
case SDLK_UP:
case SDLK_w:
keys->upw=multiplier;
break;
case SDLK_z:
case SDLK_j:
if(multiplier==1)
keys->zj=1;
break;
case SDLK_x:
case SDLK_k:
if(multiplier==1)
keys->xk=1;
break;
case SDLK_c:
case SDLK_l:
if(multiplier==1)
keys->cl=1;
break;
}
break;
case SDL_QUIT:
keys->quit=1;
default:
break;
}
}
void printkeys(struct keysdown* keys){
printf("left %d right %d up %d down %d zj %d xk %d cl %d\n",keys->lefta,keys->rightd,keys->upw,keys->downs,keys->zj,keys->xk,keys->cl);
}