The Battle for Wesnoth 1.21.0-dev
 
Loading...
Searching...
No Matches
userevent.hpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2017 - 2025
3 Part of the Battle for Wesnoth Project https://www.wesnoth.org/
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY.
11
12 See the COPYING file for more details.
13*/
14
15#pragma once
16
17#include <SDL3/SDL_events.h>
18
19#include <cstring>
20
21namespace sdl
22{
23
25{
26public:
28 {
29 std::memset(&event_, 0, sizeof(event_));
30 }
31
32 UserEvent(int type) : UserEvent()
33 {
34 event_.type = type;
35 }
36
37 UserEvent(int type, int code) : UserEvent(type)
38 {
39 event_.code = code;
40 }
41
42 UserEvent(int type, int code, std::size_t data1, std::size_t data2) : UserEvent(type)
43 {
44 event_.code = code;
45 event_.data1 = reinterpret_cast<void*>(data1);
46 event_.data2 = reinterpret_cast<void*>(data2);
47 }
48
49 UserEvent(int type, void* data1) : UserEvent(type)
50 {
51 event_.data1 = data1;
52 }
53
54 operator SDL_UserEvent()
55 {
56 return event_;
57 }
58
59private:
60 SDL_UserEvent event_;
61};
62
63}
UserEvent(int type, int code, std::size_t data1, std::size_t data2)
Definition userevent.hpp:42
UserEvent(int type, int code)
Definition userevent.hpp:37
UserEvent(int type, void *data1)
Definition userevent.hpp:49
SDL_UserEvent event_
Definition userevent.hpp:60
UserEvent(int type)
Definition userevent.hpp:32