19 #include <SDL2/SDL_mouse.h> 22 SDL_Point drawing_surface_size;
23 SDL_Point window_size;
31 uint32_t buttons = SDL_GetMouseState(x, y);
32 if (window_size.x == 0 || window_size.y == 0) {
36 if (window_size.x != drawing_surface_size.x) {
37 *x = (*x * drawing_surface_size.x) / window_size.x;
39 if (window_size.y != drawing_surface_size.y) {
40 *y = (*y * drawing_surface_size.y) / window_size.y;
47 return SDL_GetMouseState(
nullptr,
nullptr);
58 int draw_width,
int draw_height,
59 int input_width,
int input_height
61 drawing_surface_size.x = draw_width;
62 drawing_surface_size.y = draw_height;
63 window_size.x = input_width;
64 window_size.y = input_height;
69 drawing_surface_size = draw_size;
70 window_size = input_size;
void update_input_dimensions(int draw_width, int draw_height, int input_width, int input_height)
Update the cached drawing area and input area sizes.
SDL_Point get_mouse_location()
Returns the currnet mouse location in draw space.
uint32_t get_mouse_button_mask()
Returns the current mouse button mask.
uint32_t get_mouse_state(int *x, int *y)
A wrapper for SDL_GetMouseState that gives coordinates in draw space.