1 /* Copyright (C) 2017 Wildfire Games.
3 * Permission is hereby granted, free of charge, to any person obtaining
4 * a copy of this software and associated documentation files (the
5 * "Software"), to deal in the Software without restriction, including
6 * without limitation the rights to use, copy, modify, merge, publish,
7 * distribute, sublicense, and/or sell copies of the Software, and to
8 * permit persons to whom the Software is furnished to do so, subject to
9 * the following conditions:
11 * The above copyright notice and this permission notice shall be included
12 * in all copies or substantial portions of the Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
18 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
19 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
20 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 * SDL input redirector; dispatches to multiple handlers.
27 #ifndef INCLUDED_INPUT
28 #define INCLUDED_INPUT
31 #include "lib/external_libraries/libsdl_fwd.h"
33 // input handler return values.
36 // (the handlers' return values are checked and these
37 // 'strange' values might bring errors to light)
39 // pass the event to the next handler in the chain
42 // we've handled it; no other handlers will receive this event.
46 typedef InReaction (*InHandler
)(const SDL_Event_
*);
48 // register an input handler, which will receive all subsequent events first.
49 // events are passed to other handlers if handler returns IN_PASS.
50 extern void in_add_handler(InHandler handler
);
52 // remove all registered input handlers
53 extern void in_reset_handlers();
55 // send event to each handler (newest first) until one returns true
56 extern void in_dispatch_event(const SDL_Event_
* event
);
58 // push an event onto the back of a high-priority queue - the new event will
59 // be returned by in_poll_event before any standard SDL events
60 extern void in_push_priority_event(const SDL_Event_
* event
);
62 // reads events that were pushed by in_push_priority_event
63 // returns 1 if an event was read, 0 otherwise.
64 extern int in_poll_priority_event(SDL_Event_
* event
);
66 // reads events that were pushed by in_push_priority_event, or, if there are
67 // no high-priority events) reads from the SDL event queue with SDL_PollEvent.
68 // returns 1 if an event was read, 0 otherwise.
69 extern int in_poll_event(SDL_Event_
* event
);
71 #endif // #ifndef INCLUDED_INPUT