-
Notifications
You must be signed in to change notification settings - Fork 155
Expand file tree
/
Copy pathmouse.c
More file actions
29 lines (27 loc) · 692 Bytes
/
mouse.c
File metadata and controls
29 lines (27 loc) · 692 Bytes
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
/* Print mouse position to stdout. */
#include "common.h"
int main(void) {
SDL_Event event;
SDL_Window *window;
int x, y, last_x, last_y;
window = SDL_CreateWindow(__FILE__, 0, 0, 500, 500, SDL_WINDOW_OPENGL);
x = 0;
y = 0;
last_x = 0;
last_y = 0;
common_fps_init();
while (1) {
if (SDL_PollEvent(&event) && event.type == SDL_QUIT)
break;
SDL_GetMouseState(&x, &y);
if (x != last_x || y != last_y) {
printf("%d %d\n", x, y);
last_x = x;
last_y = y;
}
common_fps_update_and_print();
}
SDL_DestroyWindow(window);
SDL_Quit();
return EXIT_SUCCESS;
}