8 control_t
*control_new(SDLKey arg_up
, SDLKey arg_right
, SDLKey arg_left
,
9 SDLKey arg_down
, SDLKey arg_shot
, SDLKey arg_switch
)
13 tmp
= malloc(sizeof(control_t
));
14 memset(tmp
, 0, sizeof(control_t
));
15 tmp
->key
[CONTROL_UP
] = arg_up
;
16 tmp
->key
[CONTROL_RIGHT
] = arg_right
;
17 tmp
->key
[CONTROL_LEFT
] = arg_left
;
18 tmp
->key
[CONTROL_DOWN
] = arg_down
;
19 tmp
->key
[CONTROL_SHOT
] = arg_shot
;
20 tmp
->key
[CONTROL_SWITCH
] = arg_switch
;
25 int control_get_key_route(control_t
*my_control
)
32 assert(my_control
!= NULL
);
34 ret_key
= CONTROL_NONE
;
36 map
= SDL_GetKeyState(NULL
);
38 for (i
= 0; i
< CONTROL_KEY_COUNT_ROUTE
; i
++) {
39 if (map
[my_control
->key
[i
]] == SDL_PRESSED
) {
40 my_control
->count
[i
]++;
42 my_control
->count
[i
] = 0;
48 for (i
= 0; i
< CONTROL_KEY_COUNT_ROUTE
; i
++) {
49 if (my_control
->count
[i
] > 0 &&
50 my_control
->count
[i
] < z
&&
51 map
[my_control
->key
[i
]] == SDL_PRESSED
) {
52 z
= my_control
->count
[i
];
60 int control_get_key_action(control_t
*my_control
)
64 assert(my_control
!= NULL
);
66 map
= SDL_GetKeyState(NULL
);
68 if (map
[my_control
->key
[CONTROL_SHOT
]] == SDL_PRESSED
) {
72 if (map
[my_control
->key
[CONTROL_SWITCH
]] == SDL_PRESSED
) {
73 return CONTROL_SWITCH
;
79 void control_destroy(control_t
*my_control
)
81 assert(my_control
!= NULL
);