Skip to content

Commit

Permalink
docs(engine): loading input bindings
Browse files Browse the repository at this point in the history
  • Loading branch information
roby2014 committed Oct 17, 2023
1 parent d443d9a commit 6922f26
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions engine/samples/input/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ static void update(Read<Input> input, Read<Window> window, Write<State> state, W
}
}

/// [Loading the bindings]
static void config(Write<Settings> settings)
{
settings->setString("assets.io.path", SAMPLE_ASSETS_FOLDER);
Expand All @@ -186,6 +187,7 @@ static void init(Read<Assets> assets, Write<Input> input)
input->bind(*bindings);
CUBOS_INFO("Loaded bindings: {}", Debug(input->bindings().at(0)));
}
/// [Loading the bindings]

int main()
{
Expand All @@ -197,8 +199,10 @@ int main()

cubos.addResource<State>();

/// [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");

Expand Down
6 changes: 6 additions & 0 deletions engine/samples/input/page.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 6922f26

Please sign in to comment.