Pyrogenesis
trunk
source
lib
input.h
Go to the documentation of this file.
1
/* Copyright (C) 2017 Wildfire Games.
2
*
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:
10
*
11
* The above copyright notice and this permission notice shall be included
12
* in all copies or substantial portions of the Software.
13
*
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.
21
*/
22
23
/*
24
* SDL input redirector; dispatches to multiple handlers.
25
*/
26
27
#ifndef INCLUDED_INPUT
28
#define INCLUDED_INPUT
29
30
31
#include "
lib/external_libraries/libsdl_fwd.h
"
32
33
// input handler return values.
34
enum
InReaction
35
{
36
// (the handlers' return values are checked and these
37
// 'strange' values might bring errors to light)
38
39
// pass the event to the next handler in the chain
40
IN_PASS
= 4,
41
42
// we've handled it; no other handlers will receive this event.
43
IN_HANDLED
= 2
44
};
45
46
typedef
InReaction
(*
InHandler
)(
const
SDL_Event_
*);
47
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
);
51
52
// remove all registered input handlers
53
extern
void
in_reset_handlers
();
54
55
// send event to each handler (newest first) until one returns true
56
extern
void
in_dispatch_event
(
const
SDL_Event_
* event);
57
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);
61
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);
65
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);
70
71
#endif
// #ifndef INCLUDED_INPUT
in_reset_handlers
void in_reset_handlers()
Definition:
input.cpp:52
in_add_handler
void in_add_handler(InHandler handler)
Definition:
input.cpp:42
InHandler
InReaction(* InHandler)(const SDL_Event_ *)
Definition:
input.h:46
in_push_priority_event
void in_push_priority_event(const SDL_Event_ *event)
Definition:
input.cpp:76
in_dispatch_event
void in_dispatch_event(const SDL_Event_ *event)
Definition:
input.cpp:58
in_poll_event
int in_poll_event(SDL_Event_ *event)
Definition:
input.cpp:91
InReaction
InReaction
Definition:
input.h:35
IN_PASS
@ IN_PASS
Definition:
input.h:40
IN_HANDLED
@ IN_HANDLED
Definition:
input.h:43
in_poll_priority_event
int in_poll_priority_event(SDL_Event_ *event)
Definition:
input.cpp:81
libsdl_fwd.h
vm::handler
static PVOID handler
Definition:
wvm.cpp:450
SDL_Event_
Definition:
libsdl.h:53
Generated by
1.9.4