> For the complete documentation index, see [llms.txt](https://dante-3.gitbook.io/dante-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://dante-3.gitbook.io/dante-docs/modular-input-system/c++-api.md).

# C++ API

Headers are relative to `Plugins/ModularInputSystem/Source/<Module>/Public/`. Include them by folder, e.g. `#include "Runtime/MIPS_InputComponent.h"`.

***

## Classes

### ModularInputSystem module

| Class                                    | Header                                                        | Parent                         | Role                                                                           |
| ---------------------------------------- | ------------------------------------------------------------- | ------------------------------ | ------------------------------------------------------------------------------ |
| `UMIPS_InputComponent`                   | `Runtime/MIPS_InputComponent.h`                               | `UActorComponent`              | Binds configs, runs the pipeline, owns the mode stack and the buffer.          |
| `UMIPS_InputConfig`                      | `Config/MIPS_InputConfig.h`                                   | `UPrimaryDataAsset`            | Tag-to-action rows, mapping contexts, buffer windows.                          |
| `UMIPS_InputMode`                        | `Runtime/MIPS_InputMode.h`                                    | `UPrimaryDataAsset`            | Bypass inputs, gates, buffer policies, processors, dispatch policy.            |
| `UMIPS_InputStep`                        | `Runtime/MIPS_InputStep.h`                                    | `UObject` *(abstract)*         | Shared base of gates and processors: filter, world access, labels.             |
| `UMIPS_InputGate`                        | `Gates/MIPS_InputGate.h`                                      | `UMIPS_InputStep` *(abstract)* | Base gate.                                                                     |
| `UMIPS_InputGate_TagQuery`               | `Gates/MIPS_InputGate_TagQuery.h`                             | `UMIPS_InputGate`              | **Tag Query** gate.                                                            |
| `UMIPS_InputGate_InputFilter`            | `Gates/MIPS_InputGate_InputFilter.h`                          | `UMIPS_InputGate`              | **Input Filter** gate.                                                         |
| `UMIPS_InputGate_Cooldown`               | `Gates/MIPS_InputGate_Cooldown.h`                             | `UMIPS_InputGate`              | **Cooldown** gate.                                                             |
| `UMIPS_InputProcessor`                   | `Processors/MIPS_InputProcessor.h`                            | `UMIPS_InputStep` *(abstract)* | Base processor.                                                                |
| `UMIPS_InputProcessor_BroadcastTagEvent` | `Processors/MIPS_InputProcessor_BroadcastTagEvent.h`          | `UMIPS_InputProcessor`         | **Broadcast Tag Event**.                                                       |
| `UMIPS_InputProcessor_PushMode`          | `Processors/MIPS_InputProcessor_PushMode.h`                   | `UMIPS_InputProcessor`         | **Push Mode**.                                                                 |
| `UMIPS_InputProcessor_PopMode`           | `Processors/MIPS_InputProcessor_PopMode.h`                    | `UMIPS_InputProcessor`         | **Pop Mode**.                                                                  |
| `UMIPS_InputProcessor_OpenBufferWindow`  | `Processors/MIPS_InputProcessor_OpenBufferWindow.h`           | `UMIPS_InputProcessor`         | **Open Buffer Window**.                                                        |
| `UMIPS_InputProcessor_Move`              | `Processors/Gameplay/MIPS_InputProcessor_Move.h`              | `UMIPS_InputProcessor`         | **Move**.                                                                      |
| `UMIPS_InputProcessor_Look`              | `Processors/Gameplay/MIPS_InputProcessor_Look.h`              | `UMIPS_InputProcessor`         | **Look**.                                                                      |
| `UMIPS_InputProcessor_Jump`              | `Processors/Gameplay/MIPS_InputProcessor_Jump.h`              | `UMIPS_InputProcessor`         | **Jump**.                                                                      |
| `UMIPS_InputProcessor_Crouch`            | `Processors/Gameplay/MIPS_InputProcessor_Crouch.h`            | `UMIPS_InputProcessor`         | **Crouch**. Also declares `EMIPS_ActivationMode`.                              |
| `UMIPS_InputProcessor_Sprint`            | `Processors/Gameplay/MIPS_InputProcessor_Sprint.h`            | `UMIPS_InputProcessor`         | **Sprint**.                                                                    |
| `UMIPS_InputProcessor_CallInputReceiver` | `Processors/Gameplay/MIPS_InputProcessor_CallInputReceiver.h` | `UMIPS_InputProcessor`         | **Call Input Receiver**.                                                       |
| `UMIPS_InputProcessor_DebugString`       | `Processors/Gameplay/MIPS_InputProcessor_DebugString.h`       | `UMIPS_InputProcessor`         | **Debug String**.                                                              |
| `UMIPS_InputLibrary`                     | `BP/MIPS_InputLibrary.h`                                      | `UBlueprintFunctionLibrary`    | Blueprint helpers and actor shortcuts.                                         |
| `UMIPS_AsyncAction_WaitForInput`         | `BP/MIPS_AsyncAction_WaitForInput.h`                          | `UBlueprintAsyncActionBase`    | **Wait For Input** node.                                                       |
| `UMIPS_AnimNotifyState_BufferWindow`     | `Animation/MIPS_AnimNotifyState_BufferWindow.h`               | `UAnimNotifyState`             | **Input Buffer Window** notify state.                                          |
| `UMIPS_InputUserSettings`                | `Settings/MIPS_InputUserSettings.h`                           | `UEnhancedInputUserSettings`   | Invert and sensitivity look settings.                                          |
| `UMIPS_InputModifier_InvertLook`         | `Settings/MIPS_InputModifiers.h`                              | `UInputModifier`               | **Invert Look (User Settings)**.                                               |
| `UMIPS_InputModifier_LookSensitivity`    | `Settings/MIPS_InputModifiers.h`                              | `UInputModifier`               | **Look Sensitivity (User Settings)**. Also declares `EMIPS_SensitivitySource`. |

### Interfaces

| Interface                  | Header                           | Function                                                                                             |
| -------------------------- | -------------------------------- | ---------------------------------------------------------------------------------------------------- |
| `IMIPS_TagProvider`        | `Core/MIPS_TagProvider.h`        | `FGameplayTagContainer GetInputGateTags() const`                                                     |
| `IMIPS_InputReceiver`      | `Core/MIPS_InputReceiver.h`      | `bool HandleInputEvent(FGameplayTag EventTag, const FMIPS_InputContext& Context)`                    |
| `IMIPS_InputSetupProvider` | `Core/MIPS_InputSetupProvider.h` | `TArray<UMIPS_InputConfig*> GetInputConfigs() const`, `UMIPS_InputMode* GetDefaultInputMode() const` |

All three are `BlueprintNativeEvent`s: implement `<Function>_Implementation` in C++ and call them through `IMIPS_X::Execute_<Function>(Object, ...)`.

### ModularInputSystemUI module

| Class                           | Header                                      | Parent               |
| ------------------------------- | ------------------------------------------- | -------------------- |
| `UMIPS_InputSettingsViewModel`  | `ViewModels/MIPS_InputSettingsViewModel.h`  | `UMVVMViewModelBase` |
| `UMIPS_KeyMappingListViewModel` | `ViewModels/MIPS_KeyMappingListViewModel.h` | `UMVVMViewModelBase` |
| `UMIPS_KeyMappingViewModel`     | `ViewModels/MIPS_KeyMappingViewModel.h`     | `UMVVMViewModelBase` |

***

## Structs and Enums

| Type                                                                                                     | Header                                           | Description                                                                                             |
| -------------------------------------------------------------------------------------------------------- | ------------------------------------------------ | ------------------------------------------------------------------------------------------------------- |
| `FMIPS_InputEvent`                                                                                       | `Core/MIPS_InputTypes.h`                         | One input event.                                                                                        |
| `FMIPS_InputContext`                                                                                     | `Core/MIPS_InputTypes.h`                         | What gates and processors see.                                                                          |
| `FMIPS_GateResult`                                                                                       | `Core/MIPS_InputTypes.h`                         | Verdict, reason tag, debug detail. Static `Allow()`, `Block(Reason, Detail)`, `Buffer(Reason, Detail)`. |
| `EMIPS_Verdict`, `EMIPS_HandleResult`, `EMIPS_DispatchPolicy`, `EMIPS_Resolution`, `EMIPS_BufferOnBlock` | `Core/MIPS_InputTypes.h`                         | See [Input Events & Context](/dante-docs/modular-input-system/core-concepts/input-events.md).           |
| `FMIPS_InputActionBinding`, `FMIPS_MappingContextEntry`, `FMIPS_BufferWindowDefinition`                  | `Config/MIPS_InputConfig.h`                      | Config rows.                                                                                            |
| `FMIPS_ModeHandle`, `FMIPS_ModeStackEntry`                                                               | `Runtime/MIPS_InputMode.h`                       | Mode stack entries.                                                                                     |
| `FMIPS_DispatchResult`                                                                                   | `Runtime/MIPS_InputMode.h`                       | *(C++ only)* Result, first handler, consumer.                                                           |
| `FMIPS_OpenBufferWindow`                                                                                 | `Runtime/MIPS_InputComponent.h`                  | An open window: definition copy, open and close times.                                                  |
| `FMIPS_AcceptedInput`                                                                                    | `Runtime/MIPS_InputBuffer.h`                     | Tag, trigger event mask, priority.                                                                      |
| `FMIPS_BufferQuery`                                                                                      | `Runtime/MIPS_InputBuffer.h`                     | *(C++ only)* Accepted inputs, resolution, age limits.                                                   |
| `FMIPS_InputBuffer`                                                                                      | `Runtime/MIPS_InputBuffer.h`                     | The ring of held events. Plain data, testable on its own.                                               |
| `EMIPS_MoveSpace`                                                                                        | `Processors/Gameplay/MIPS_InputProcessor_Move.h` | Movement reference frame.                                                                               |
| `FMIPS_TraceRecord`, `FMIPS_TraceWindowRecord`, `FMIPS_InputTrace`                                       | `Debug/MIPS_InputTrace.h`                        | Trace data (development builds).                                                                        |

***

## Helpers

```cpp
namespace MIPS
{
    // Trigger event masks
    constexpr int32 TriggerEventBit(ETriggerEvent Event);
    constexpr bool  MaskHasTriggerEvent(int32 Mask, ETriggerEvent Event);
    inline constexpr int32 AllTriggerEvents;
    inline constexpr ETriggerEvent BindableTriggerEvents[];   // Started, Ongoing, Triggered, Canceled, Completed

    // Device tag for a hardware device type
    FGameplayTag DeviceTagForType(EHardwareDevicePrimaryType DeviceType);

    // World direction for a 2D movement value (X right, Y forward), keeping its magnitude
    FVector ComputeMoveDirection(EMIPS_MoveSpace Space, const FRotator& ControlRotation,
                                 const FRotator& PawnRotation, const FVector2D& AxisValue);
}
```

### Native gameplay tags

Declared in `Core/MIPS_InputTags.h` with `UE_DECLARE_GAMEPLAY_TAG_EXTERN`:

```cpp
MIPS::Tags::Reason_TagQuery        // ModularInput.Reason.TagQuery
MIPS::Tags::Reason_InputFilter     // ModularInput.Reason.InputFilter
MIPS::Tags::Reason_Cooldown        // ModularInput.Reason.Cooldown
MIPS::Tags::Reason_BufferWindow    // ModularInput.Reason.BufferWindow
MIPS::Tags::Reason_Unspecified     // ModularInput.Reason.Unspecified

MIPS::Tags::Device_KeyboardAndMouse
MIPS::Tags::Device_Gamepad
MIPS::Tags::Device_Touch
MIPS::Tags::Device_Other
```

### Logging

```cpp
#include "Core/MIPS_Log.h"

// LogModularInput, with the calling function as a prefix. Pass the format in TEXT().
MIPS_LOG(Warning, TEXT("%s has no stamina component."), *GetNameSafe(Pawn));
MIPS_CLOG(bVerbose, Log, TEXT("Dodging towards %s"), *Direction.ToString());
```

`MIPS_WITH_TRACE` (in `Debug/MIPS_InputTrace.h`) is 1 outside Shipping and Test builds. Wrap trace access in `#if MIPS_WITH_TRACE`.

***

## Extension Points

| Class                     | Member                                                     | Purpose                                                                         |
| ------------------------- | ---------------------------------------------------------- | ------------------------------------------------------------------------------- |
| `UMIPS_InputGate`         | `Evaluate_Implementation(const FMIPS_InputContext&) const` | Your gate's decision. Use `MakeFailResult(Reason, Detail)`.                     |
| `UMIPS_InputProcessor`    | `ShouldHandle_Implementation`, `Handle_Implementation`     | Your processor's check and work. Use `MakeHandledResult()`.                     |
| `UMIPS_InputStep`         | `GetDebugLabel() const`                                    | Name in the monitor, debugger and log.                                          |
| `UMIPS_InputStep`         | `BuildEditorTitle() const` *(editor)*                      | Entry title in a mode's lists.                                                  |
| `UMIPS_InputStep`         | `IsDataValid(FDataValidationContext&) const` *(editor)*    | Report configuration errors; called by the owning mode.                         |
| `UMIPS_InputComponent`    | `ProcessInputEvent(const FMIPS_InputEvent&)`               | Pre-process every captured event. Call the parent to keep the pipeline.         |
| `UMIPS_InputComponent`    | `GatherOwnerTags(FGameplayTagContainer&) const`            | Add owner tags from elsewhere.                                                  |
| `UMIPS_InputUserSettings` | subclass                                                   | Add your own saved input settings; set the subclass as the user settings class. |

***

## Working with the Buffer Directly

`FMIPS_InputBuffer` has no UObject or world behind it, which makes it easy to use in tests or custom systems:

```cpp
FMIPS_InputBuffer Buffer(8);                  // capacity
Buffer.Push(Event);                           // drops the oldest when full
Buffer.ExpireOlderThan(Now, /*MaxAge=*/1.0);

FMIPS_InputEvent Out;
if (Buffer.TryConsume(AttackTag, ETriggerEvent::Started, Now, /*MaxAge=*/0.2, Out)) { ... }

FMIPS_BufferQuery Query;
Query.Accepted = AcceptedInputs;              // TConstArrayView<FMIPS_AcceptedInput>
Query.Resolution = EMIPS_Resolution::HighestPriority;
Query.NowSeconds = Now;
Query.NotBeforeSeconds = WindowOpenedAt - LeadTime;
Buffer.TryConsume(Query, Out);
Buffer.RemoveAll(Query);
```

An empty `Accepted` list accepts every entry. `ETriggerEvent::None` in `TryConsume(Tag, ...)` matches any trigger event.

***

## Step World Scope

Steps are shared between players, so their world cannot live on the instance. While the pipeline runs an event, it opens an `FMIPS_ScopedStepWorld` that makes `UMIPS_InputStep::GetWorld()` return the component's world. If you call gates or processors yourself outside the pipeline, open one around the call:

```cpp
const FMIPS_ScopedStepWorld StepWorld(GetWorld());
const FMIPS_GateResult Result = Gate->Evaluate(Context);
```

***

## Next Steps
