new input system

This commit is contained in:
Jorijn van der Graaf 2026-05-12 00:24:48 +02:00
commit ac2eb7fb0a
31 changed files with 3292 additions and 781 deletions

View file

@ -5,18 +5,35 @@ using namespace Crafter;
extern "C" Configuration CrafterBuildProject(std::span<const std::string_view> args) {
std::vector<std::string> depArgs(args.begin(), args.end());
Configuration* event = GitProject({
.source = { .url = "https://forgejo.catcrafts.net/Catcrafts/Crafter.Event.git" },
.args = depArgs,
});
Configuration* math = GitProject({
.source = { .url = "https://forgejo.catcrafts.net/Catcrafts/Crafter.Math.git" },
.args = depArgs,
});
Configuration* asset = GitProject({
.source = { .url = "https://forgejo.catcrafts.net/Catcrafts/Crafter.Asset.git" },
.args = depArgs,
});
// --local resolves Crafter.* deps from sibling working trees instead of
// fetching them from forgejo. Use during cross-repo development so edits
// in ../Crafter.Asset are picked up without commit-and-pull. Add to
// depArgs too so transitive deps inherit the same mode.
bool useLocal = false;
for (std::string_view a : args) {
if (a == "--local") { useLocal = true; break; }
}
if (useLocal && std::find(depArgs.begin(), depArgs.end(), std::string("--local")) == depArgs.end()) {
depArgs.push_back("--local");
}
auto resolveDep = [&](std::string_view name, std::string_view gitUrl) -> Configuration* {
if (useLocal) {
return LocalProject({
.projectFile = fs::path("../") / name / "project.cpp",
.args = depArgs,
});
}
return GitProject({
.source = { .url = std::string(gitUrl) },
.args = depArgs,
});
};
Configuration* event = resolveDep("Crafter.Event", "https://forgejo.catcrafts.net/Catcrafts/Crafter.Event.git");
Configuration* math = resolveDep("Crafter.Math", "https://forgejo.catcrafts.net/Catcrafts/Crafter.Math.git");
Configuration* asset = resolveDep("Crafter.Asset", "https://forgejo.catcrafts.net/Catcrafts/Crafter.Asset.git");
Configuration cfg;
cfg.path = "./";
@ -37,10 +54,20 @@ extern "C" Configuration CrafterBuildProject(std::span<const std::string_view> a
cfg.linkFlags.push_back("-lkernel32");
cfg.linkFlags.push_back("-luser32");
cfg.linkFlags.push_back("-lgdi32");
// Windows.Gaming.Input (WGI) needs the WinRT activation runtime
// and combase for HSTRING / RoGetActivationFactory.
cfg.linkFlags.push_back("-lruntimeobject");
cfg.linkFlags.push_back("-lcombase");
} else {
cfg.defines.push_back({"CRAFTER_GRAPHICS_WINDOW_WAYLAND", ""});
cfg.linkFlags.push_back("-lwayland-client");
cfg.linkFlags.push_back("-lxkbcommon");
// Gamepad: libudev for hot-plug + device enumeration; libevdev
// for event parsing + axis calibration. libevdev ships its headers
// under a versioned dir (libevdev-1.0/) so the -I is mandatory.
cfg.linkFlags.push_back("-ludev");
cfg.linkFlags.push_back("-levdev");
cfg.compileFlags.push_back("-I/usr/include/libevdev-1.0");
cfg.cFiles.push_back("lib/xdg-shell-protocol");
cfg.cFiles.push_back("lib/wayland-xdg-decoration-unstable-v1-client-protocol");
cfg.cFiles.push_back("lib/fractional-scale-v1");
@ -63,17 +90,22 @@ extern "C" Configuration CrafterBuildProject(std::span<const std::string_view> a
if (opts.Has("--timing")) cfg.defines.push_back({"CRAFTER_TIMING", ""});
std::array<fs::path, 24> ifaces = {
std::array<fs::path, 29> ifaces = {
"interfaces/Crafter.Graphics",
"interfaces/Crafter.Graphics-Animation",
"interfaces/Crafter.Graphics-Clipboard",
"interfaces/Crafter.Graphics-ComputeShader",
"interfaces/Crafter.Graphics-Decompress",
"interfaces/Crafter.Graphics-DescriptorHeapVulkan",
"interfaces/Crafter.Graphics-Device",
"interfaces/Crafter.Graphics-Font",
"interfaces/Crafter.Graphics-FontAtlas",
"interfaces/Crafter.Graphics-ForwardDeclarations",
"interfaces/Crafter.Graphics-Gamepad",
"interfaces/Crafter.Graphics-ImageVulkan",
"interfaces/Crafter.Graphics-Input",
"interfaces/Crafter.Graphics-InputField",
"interfaces/Crafter.Graphics-Keys",
"interfaces/Crafter.Graphics-Mesh",
"interfaces/Crafter.Graphics-PipelineRTVulkan",
"interfaces/Crafter.Graphics-RenderingElement3D",
@ -89,11 +121,14 @@ extern "C" Configuration CrafterBuildProject(std::span<const std::string_view> a
"interfaces/Crafter.Graphics-VulkanTransition",
"interfaces/Crafter.Graphics-Window",
};
std::array<fs::path, 10> impls = {
std::array<fs::path, 13> impls = {
"implementations/Crafter.Graphics-Clipboard",
"implementations/Crafter.Graphics-ComputeShader",
"implementations/Crafter.Graphics-Device",
"implementations/Crafter.Graphics-Font",
"implementations/Crafter.Graphics-FontAtlas",
"implementations/Crafter.Graphics-Gamepad",
"implementations/Crafter.Graphics-Input",
"implementations/Crafter.Graphics-InputField",
"implementations/Crafter.Graphics-Mesh",
"implementations/Crafter.Graphics-RenderingElement3D",