Castagne Engine

Documentation

Castagne Engine

Getting Started

Editor

Gametypes

Intermediate

Making a Game

Pushing Castagne

Advanced

Modules

Castagne Input

Castagne's input system is quite intricate, as it is one of the core entry points of the engine. It is also one of the few parts that must be usable from outside of fights. This page will detail some of the key concepts, how to use it, and how it works internally.

As of the time of writing (v0.53), the input system is implemented, but buffering and motion inputs are not. Button press and release events are active for up to three frames by default. This part of the input will be revisited for v0.7-v0.8, with the aim of being able to handle high-frequency polling and be robust to online.

At the moment, analog input is not supported, although that is a future goal.

Definitions: Physical Inputs and Game Inputs

Castagne Input is handled through two main types of inputs:

In addition to that, Castagne holds these inputs in a few different structures for use:

Input Types

Physical Inputs can have one of many types depending on their use:

Game inputs can instead have one of three types:

Layout Configuration

The user must specify an Input Layout. This should be done through the Castagne Editor's Input Manager. The game inputs will be created automatically from there.

The editor allows users to create and organize physical inputs of various types. For each of them, they can also change:

At the moment (v0.53), to use the Base Casp files correctly, the main movement stick must keep its default names. The attack buttons shouldn't be changed, although this might change in Castagne v0.54.

Menu input may have a different layout specified, although that will be for v0.55.

Device-Player Association

The association between an Input Device and a player is done outside the loop. Indeed, the main step function only takes the actual inputs in, and doesn't care about where they might come from. This enables mid-match controller changes, or hopping between replays, player control, and AI.

This may be specified in the BID to handle the basic association.

That part of the behavior is managed by CastagneEngine.gd, which provides some functions to change devices.

Input Manipulation and Transformation

Inputs may be changed during the engine loop, as they might depend on the actual game state. This has two main cases: derived inputs, and fake inputs.

Fake Inputs are literally fake button presses and releases that can be made by the engine. This is mainly meant for AIs to be able to react based on what the game state is. This is limited to Direct and Combination inputs, and must happen before the Input Phase.

Derived Inputs are inputs dependent on other inputs (press and release events) and/or state (forward/back). They may come from various modules, and must be done in the Input Phase.

Accessing Inputs from Outside the Engine

It is possible to access and poll inputs by accessing CastagneInput directly. This should be done from a Config Data handle.

While it is technically possible to use several CastagneInputs at the same time, they may interfere with each other.

Rebindings

This is still in progress and will be implemented in v0.55.

Standard In-Game Input Flow

Here is the full path of an input in the engine, in the standard case of two players fighting each other:

Alternative In-Game Input Flows

Other cases may happen, which can change input flow slightly. Here are some other examples:

Internal Structure

This part describes in more detail how the input works at a technical level.

This part will be written later.