User:Monster Iestyn/Source Code Documentation/d_event.h

From SRB2 Wiki
Jump to navigation Jump to search
Online link GitHub entry
File type C header file
#include guard __D_EVENT__

This header file declares the basic typedefs and variables needed for event handling.

Includes

Typedefs

Name Type Description
evtype_t enum Event types
event_t struct Event structure

evtype_t

Value Name Description Uses data1? Uses data2? Uses data3?
0 ev_keydown Key or mouse/joystick button pressed Yes No No
1 ev_keyup Key or mouse/joystick button released Yes No No
2 ev_console Key pressed in console window1 Yes No No
3 ev_mouse Mouse motion No Yes Yes
4 ev_joystick Joystick axis motion Yes Yes Yes
5 ev_mouse2 Mouse 2 motion No Yes Yes
6 ev_joystick2 Joystick 2 axis motion Yes Yes Yes

1 The console window seen when running SRB2 under dedicated mode, or with the command line parameter -console. In the latter case the console window exists alongside the main SRB2 window (rather than being the only window), though the SRB2 window will still have a console of its own. Note that ev_keyup is used for key release events from the console window.

event_t

Data name Data type Description
type evtype_t The event type.
data1 INT32 Stores keyboard or mouse/joystick button input, as a key code. For ev_joystick or ev_joystick2, this instead stores the id of the axis that was moved
data2 INT32 Stores mouse/joystick X-axis movement
data3 INT32 Stores mouse/joystick Y-axis movement

Macros

Macro Defined as Description
MAXEVENTS 128 The maximum number of events allowed to be stored in the events array at the same time.

Externs

Data name Data type Non-extern location(s) Description
events[MAXEVENTS] event_t d_main.c The events array. New events are written to this using D_PostEvent.
eventhead
eventtail
INT32 d_main.c The "head" and "tail" event IDs not yet processed by D_ProcessEvent. eventhead's value is increased whenever new events are added by D_PostEvent, while eventtail's value is increased by D_ProcessEvent until it matches eventhead's value. If these two values are equal when D_ProcessEvent is called, then there are no unprocessed events for D_ProcessEvent to handle currently.