cmdfx 0.1.0
Lightweight game engine for your terminal
Loading...
Searching...
No Matches
events.h
Go to the documentation of this file.
1
10
11#pragma once
12
13#ifdef __cplusplus
14extern "C" {
15#endif
16
28#define EVENT_TICK 10
29
30#pragma region Events
31
37#define CMDFX_EVENT_RESIZE 0
38
60
66#define CMDFX_EVENT_KEY 1
67
81
87#define CMDFX_EVENT_MOUSE 2
88
89#pragma endregion
90
91struct CmdFX_Event;
92
96typedef int (*EventCallback)(struct CmdFX_Event* event);
97
104typedef struct CmdFX_Event {
108 unsigned int id;
112 unsigned long long time;
116 void* data;
118
128int addCmdFXEventListener(unsigned int id, EventCallback callback);
129
136EventCallback* getCmdFXEventListener(unsigned int eventId, unsigned int listenerId);
137
144int removeCmdFXEventListener(unsigned int eventId, unsigned int listenerId);
145
152
160
166
167#ifdef __cplusplus
168}
169#endif
EventCallback * getCmdFXEventListener(unsigned int eventId, unsigned int listenerId)
Gets an event listener.
int beginCmdFXEventLoop()
Starts the event loop for CmdFX.
int removeCmdFXEventListener(unsigned int eventId, unsigned int listenerId)
Removes an event listener.
int endCmdFXEventLoop()
Ends the event loop for CmdFX.
const EventCallback ** dispatchCmdFXEvent(CmdFX_Event *event)
Dispatches an event.
int(* EventCallback)(struct CmdFX_Event *event)
Represents an event callback.
Definition events.h:96
int addCmdFXEventListener(unsigned int id, EventCallback callback)
Adds an event listener.
The main event structure for CmdFX.
Definition events.h:104
unsigned int id
The event ID.
Definition events.h:108
void * data
A pointer to the data associated with the event.
Definition events.h:116
unsigned long long time
The time the event was created, in milliseconds.
Definition events.h:112
The payload for the CMDFX_EVENT_KEY event.
Definition events.h:71
char keyChar
The character representation of the key.
Definition events.h:79
int keyCode
The key code.
Definition events.h:75
The payload for the CMDFX_EVENT_RESIZE event.
Definition events.h:42
int newWidth
The new width of the terminal.
Definition events.h:54
int prevHeight
The previous height of the terminal.
Definition events.h:50
int prevWidth
The previous width of the terminal.
Definition events.h:46
int newHeight
The new height of the terminal.
Definition events.h:58