The Battle for Wesnoth  1.17.4+dev
input.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2022
3  by Thomas Iorns <mesilliac@tomanui.nz>
4  Part of the Battle for Wesnoth Project https://www.wesnoth.org/
5 
6  This program is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation; either version 2 of the License, or
9  (at your option) any later version.
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY.
12 
13  See the COPYING file for more details.
14 */
15 
16 #include <cstdint>
17 
18 #pragma once
19 
20 /**
21  * @file
22  * Contains functions for cleanly handling SDL input.
23  */
24 
25 struct SDL_Point;
26 
27 namespace sdl
28 {
29 
30 /**
31  * A wrapper for SDL_GetMouseState that gives coordinates in draw space.
32  */
33 uint32_t get_mouse_state(int *x, int *y);
34 
35 /** Returns the current mouse button mask */
36 uint32_t get_mouse_button_mask();
37 
38 /** Returns the currnet mouse location in draw space. */
39 SDL_Point get_mouse_location();
40 
41 /**
42  * Update the cached drawing area and input area sizes. These correspond to
43  * the size of the drawing surface in pixels, and the size of the window in
44  * display coordinates.
45  *
46  * This should be called every time the window is resized, or the pixel scale
47  * multiplier changes.
48  *
49  * @param draw_width The width of the drawing surface, in pixels
50  * @param draw_height The height of the drawing surface, in pixels
51  * @param input_width The width of the input surface, in display coordinates
52  * @param input_height The height of the input surface, in display coordinates
53  */
55  int draw_width, int draw_height,
56  int input_width, int input_height
57 );
58 void update_input_dimensions(SDL_Point draw_size, SDL_Point input_size);
59 
60 
61 } // namespace sdl
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.
Definition: input.cpp:57
SDL_Point get_mouse_location()
Returns the currnet mouse location in draw space.
Definition: input.cpp:50
uint32_t get_mouse_button_mask()
Returns the current mouse button mask.
Definition: input.cpp:45
uint32_t get_mouse_state(int *x, int *y)
A wrapper for SDL_GetMouseState that gives coordinates in draw space.
Definition: input.cpp:29