From 6922f2673b2e94cbb7d9a5f00e3c7dae5b9d95f0 Mon Sep 17 00:00:00 2001 From: roby2014 Date: Tue, 17 Oct 2023 03:28:13 +0100 Subject: [PATCH] docs(engine): loading input bindings --- engine/samples/input/main.cpp | 4 ++++ engine/samples/input/page.md | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/engine/samples/input/main.cpp b/engine/samples/input/main.cpp index 5e0a8c321..eb7acbb00 100644 --- a/engine/samples/input/main.cpp +++ b/engine/samples/input/main.cpp @@ -175,6 +175,7 @@ static void update(Read input, Read window, Write state, W } } +/// [Loading the bindings] static void config(Write settings) { settings->setString("assets.io.path", SAMPLE_ASSETS_FOLDER); @@ -186,6 +187,7 @@ static void init(Read assets, Write input) input->bind(*bindings); CUBOS_INFO("Loaded bindings: {}", Debug(input->bindings().at(0))); } +/// [Loading the bindings] int main() { @@ -197,8 +199,10 @@ int main() cubos.addResource(); + /// [Systems to load bindings] cubos.startupSystem(config).tagged("cubos.settings"); cubos.startupSystem(init).tagged("cubos.assets"); + /// [Systems to load bindings] cubos.system(update).after("cubos.input.update"); diff --git a/engine/samples/input/page.md b/engine/samples/input/page.md index 4c27c937e..c02602504 100644 --- a/engine/samples/input/page.md +++ b/engine/samples/input/page.md @@ -33,6 +33,12 @@ For the purposes of this sample we can simply use an hardcoded reference to the @snippet input/main.cpp Setting the Bindings +To utilize the bindings, loading them is essential. This can be accomplished by establishing two startup systems: one to configure the `assets.io.path` path and the other to read from the asset and establish the required bindings. + +@snippet input/main.cpp Systems to load bindings + +@snippet input/main.cpp Loading the bindings + Getting the input is done through the @ref cubos::engine::Input resource. What this sample does is show in order, a series of prompt to showcase the different functionalities of the Input plugin. For this, it keeps a `state` integer that indicates the current prompt.