-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSDL3Module.cpp
More file actions
145 lines (116 loc) · 3.95 KB
/
Copy pathSDL3Module.cpp
File metadata and controls
145 lines (116 loc) · 3.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
/**
* @file SDL3Module.cpp
* @brief Module entry point for deki-sdl3 DLL
*
* This file exports the standard Deki plugin interface so the editor
* can load deki-sdl3.dll and discover available SDL3 components.
*
* Display and input are set up by their SetupComponents; the SDL3 time provider
* is registered in SDL3Display.cpp. The desktop program entry (main) and the
* memory/filesystem HAL live in the deki-desktop-integration module.
*/
#include "SDL3Module.h"
#include "interop/DekiPlugin.h"
#include "DekiModuleFeatureMeta.h"
#include "DekiTime.h"
#include "providers/ITimeProvider.h"
#include "reflection/ComponentRegistry.h"
#include "reflection/ComponentFactory.h"
#ifdef DEKI_EDITOR
// Auto-generated registration helpers
extern void DekiSDL3_RegisterComponents();
extern int DekiSDL3_GetAutoComponentCount();
extern const DekiComponentMeta* DekiSDL3_GetAutoComponentMeta(int index);
// Track if already registered to avoid duplicates
static bool s_SDL3Registered = false;
extern "C" {
/**
* @brief Ensure deki-sdl3 module is loaded and components are registered
*/
DEKI_SDL3_API int DekiSDL3_EnsureRegistered(void)
{
if (s_SDL3Registered)
return DekiSDL3_GetAutoComponentCount();
s_SDL3Registered = true;
// Auto-generated: registers all SDL3 components with ComponentRegistry + ComponentFactory
DekiSDL3_RegisterComponents();
return DekiSDL3_GetAutoComponentCount();
}
// =============================================================================
// Plugin metadata (for dynamic loading compatibility)
// =============================================================================
DEKI_PLUGIN_API const char* DekiPlugin_GetName(void)
{
return "Deki SDL3 Module";
}
DEKI_PLUGIN_API const char* DekiPlugin_GetVersion(void)
{
#ifdef DEKI_MODULE_VERSION
return DEKI_MODULE_VERSION;
#else
return "0.0.0-dev";
#endif
}
DEKI_PLUGIN_API const char* DekiPlugin_GetReflectionJson(void)
{
return "{}";
}
DEKI_PLUGIN_API int DekiPlugin_Init(void)
{
return 0;
}
DEKI_PLUGIN_API void DekiPlugin_Shutdown(void)
{
s_SDL3Registered = false;
DekiTime::SetTimeProvider(nullptr);
}
DEKI_PLUGIN_API int DekiPlugin_GetComponentCount(void)
{
return DekiSDL3_GetAutoComponentCount();
}
DEKI_PLUGIN_API const DekiComponentMeta* DekiPlugin_GetComponentMeta(int index)
{
return DekiSDL3_GetAutoComponentMeta(index);
}
DEKI_PLUGIN_API void DekiPlugin_RegisterComponents(void)
{
DekiSDL3_EnsureRegistered();
}
// =============================================================================
// Module Feature API
// =============================================================================
static const DekiModuleFeatureInfo s_Features[] = {
{"display", "Display", "SDL3 window display", false},
{"input", "Input", "SDL3 keyboard/mouse input", false},
};
DEKI_PLUGIN_API int DekiPlugin_GetFeatureCount(void)
{
return sizeof(s_Features) / sizeof(s_Features[0]);
}
DEKI_PLUGIN_API const DekiModuleFeatureInfo* DekiPlugin_GetFeature(int index)
{
if (index < 0 || index >= DekiPlugin_GetFeatureCount())
return nullptr;
return &s_Features[index];
}
// =============================================================================
// Module-specific feature API (for linked DLL access without name conflicts)
// =============================================================================
DEKI_SDL3_API const char* DekiSDL3_GetName(void)
{
return "SDL3";
}
DEKI_SDL3_API int DekiSDL3_GetFeatureCount(void)
{
return DekiPlugin_GetFeatureCount();
}
DEKI_SDL3_API const DekiModuleFeatureInfo* DekiSDL3_GetFeature(int index)
{
return DekiPlugin_GetFeature(index);
}
} // extern "C"
#else // !DEKI_EDITOR - Runtime registration
// Component registration happens via the auto-generated DekiSDL3_RegisterComponents(),
// called from deki_register_project_modules(). Display/input run as boot SetupComponents,
// and the SDL3 time provider is registered by a static initializer in SDL3Display.cpp.
#endif // DEKI_EDITOR