The Battle for Wesnoth  1.19.5+dev
input.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2022 - 2024
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 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 current mouse location in draw space. */
40 
41 /**
42  * Returns a bitmask of active modifier keys (ctrl, shift, alt, gui).
43  *
44  * Unused modifier keys (caps lock, scroll lock, num lock, AltGr) are
45  * filtered out and will always be unset.
46  *
47  * Left and right keys are not distinguished. If either is detected, both
48  * will be set. For example if only left shift is down, both KMOD_LSHIFT
49  * and KMOD_RSHIFT will be set in the returned bitmask.
50  *
51  * @returns A bitmask of SDL_Keymod values representing the active state.
52  */
53 unsigned get_mods();
54 
55 } // namespace sdl
uint32_t get_mouse_button_mask()
Returns the current mouse button mask.
Definition: input.cpp:49
uint32_t get_mouse_state(int *x, int *y)
A wrapper for SDL_GetMouseState that gives coordinates in draw space.
Definition: input.cpp:27
unsigned get_mods()
Returns a bitmask of active modifier keys (ctrl, shift, alt, gui).
Definition: input.cpp:61
point get_mouse_location()
Returns the current mouse location in draw space.
Definition: input.cpp:54
Holds a 2D point.
Definition: point.hpp:25