-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinput.c
51 lines (30 loc) · 822 Bytes
/
input.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
#include "input.h"
const Uint8 *keyState;
// checks if key is pressed
bool decaf_key_pressed(Uint32 key) {
if(keyState[key]) {
return true;
} else {
return false;
}
}
// sets the current keystate
void decaf_set_KeyboardState(void) {
keyState = SDL_GetKeyboardState(NULL);
}
// returns the current mouse position x
int decaf_fetch_mouse_x(void) {
int x, y;
float log_x, log_y;
SDL_GetMouseState( &x, &y );
SDL_RenderWindowToLogical(decaf_get_renderer(), x, y, &log_x, &log_y);
return log_x;
}
// returns the current mouse position y
int decaf_fetch_mouse_y(void) {
int x, y;
float log_x, log_y;
SDL_GetMouseState( &x, &y );
SDL_RenderWindowToLogical(decaf_get_renderer(), x, y, &log_x, &log_y);
return log_y;
}