> 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/core-concepts/input-component.md).

# Input Component

| Class                  | Header                          | Parent            | Create from                                                                                                                              |
| ---------------------- | ------------------------------- | ----------------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
| `UMIPS_InputComponent` | `Runtime/MIPS_InputComponent.h` | `UActorComponent` | **Add Component > Modular Input Component**, or **Modular Input System > Components > Modular Input Component** for a Blueprint subclass |

***

## Overview

The Modular Input Component turns Enhanced Input into tagged input events and runs them through the active mode. Add it to a **Pawn** or a **PlayerController**; on any other actor it logs an error and does nothing.

Whenever the owner is driven by a local player, the component:

{% stepper %}
{% step %}

## Push an input component

Pushes an input component of its own onto that player controller.
{% endstep %}

{% step %}

## Add mapping contexts

Adds the mapping contexts from its input configs.
{% endstep %}

{% step %}

## Bind actions and trigger events

Binds every configured action and trigger event.
{% endstep %}
{% endstepper %}

Because it owns its input component instead of borrowing the pawn's, its bindings stay apart from anything the pawn sets up itself, and it works whatever input component class the pawn uses.

***

## Properties

| Property                          | Default | Description                                                                                                                                                                                                                                  |
| --------------------------------- | ------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Input Configs**                 |         | Configs bound when a local player takes control, in order.                                                                                                                                                                                   |
| **Default Mode**                  |         | The mode used while nothing is pushed onto the mode stack. Without any mode, events are only broadcast.                                                                                                                                      |
| **Use Setup From Owner Chain**    | On      | Asks the possessed pawn (and the rest of the owner chain) for configs and a default mode through `IMIPS_InputSetupProvider`. See [Input on the Player Controller](/dante-docs/modular-input-system/core-concepts/controller-owned-input.md). |
| **Buffer Capacity**               | 16      | Most events the buffer holds. When full, the oldest is dropped.                                                                                                                                                                              |
| **Max Buffer Age**                | 1.0 s   | Held events older than this are dropped. Keep it longer than your longest buffer window. Zero keeps events until they are pushed out.                                                                                                        |
| **Log Input Events** *(advanced)* | Off     | Writes every captured event and its outcome to the log.                                                                                                                                                                                      |

***

## Where the Component Lives

{% tabs %}
{% tab title="On the Pawn" %}
The simplest setup. The component follows possession by itself:

* When a local player possesses the pawn, it binds.
* When the pawn is unpossessed, or possessed by an AI or a remote player, it unbinds.
* When the pawn restarts with the same controller, it keeps its bindings and re-adds any mapping context another system removed in the meantime.

Every pawn class carries its own configs and modes.
{% endtab %}

{% tab title="On the Player Controller" %}
The component survives pawn changes, so the mode stack, the buffer and your listeners stay in place when the player respawns or enters a vehicle.

* On every possession change it rebinds, because a new pawn may bring different configs.
* A pawn that implements `IMIPS_InputSetupProvider` contributes its own configs and default mode while it is possessed; they are taken back when the pawn changes.
* A player controller is spawned before it is handed its local player and nothing is broadcast when that happens, so the component ticks until the player arrives, then binds and stops ticking. On a dedicated server it never waits.

See [Input on the Player Controller](/dante-docs/modular-input-system/core-concepts/controller-owned-input.md).
{% endtab %}
{% endtabs %}

**Find Input Component** (static, pure) finds the component on an actor, its controller or its pawn, so callers do not need to know which one carries it. Every actor shortcut in the Blueprint library uses it.

***

## Modes

The component holds a **mode stack**. The highest-priority entry is active; among equal priorities the latest push wins. When the stack is empty, the **Default Mode** is active.

| Function                       | Description                                                                                                        |
| ------------------------------ | ------------------------------------------------------------------------------------------------------------------ |
| `PushMode(Mode, Priority = 0)` | Pushes a mode and returns an `FMIPS_ModeHandle`. Pushing the same mode twice gives two handles and needs two pops. |
| `PopMode(Handle)`              | Removes the entry the handle refers to and resets the handle. False if it was not on the stack.                    |
| `PopModeByAsset(Mode)`         | Removes the most recently pushed entry of a mode.                                                                  |
| `GetActiveMode()`              | The top of the stack, or the default mode.                                                                         |
| `IsModeOnStack(Mode)`          | True if the mode has at least one entry.                                                                           |
| `SetDefaultMode(Mode)`         | Changes the default mode.                                                                                          |
| `GetModeStack()`               | *(C++)* The entries, lowest priority first.                                                                        |

**On Active Mode Changed** `(NewMode, PreviousMode)` fires whenever the active mode becomes a different asset. See [Input Modes & the Mode Stack](/dante-docs/modular-input-system/core-concepts/input-modes.md).

***

## Configs

| Function                    | Description                                                                              |
| --------------------------- | ---------------------------------------------------------------------------------------- |
| `AddInputConfig(Config)`    | Adds a config and rebinds if currently bound. Adding the same config twice does nothing. |
| `RemoveInputConfig(Config)` | Removes a config and rebinds if currently bound.                                         |

***

## Binding State and Processing

| Function                              | Description                                                                                                                                                                                                     |
| ------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `IsInputBound()`                      | True while bindings are live on a local player controller.                                                                                                                                                      |
| `GetBoundController()`                | The player controller the bindings live on.                                                                                                                                                                     |
| `SetInputProcessingEnabled(bEnabled)` | Stops or resumes the whole pipeline in one call, for cutscenes, death screens or anything where the player should not be driving. Bindings and mapping contexts stay as they are, so nothing has to be rebuilt. |
| `IsInputProcessingEnabled()`          | Current state of the switch above.                                                                                                                                                                              |

{% hint style="info" %}
The component's input component sits on the controller's input stack, so the engine's **Disable Input** on the owner would not reach it on its own. The component checks it anyway: while the owning pawn or controller has input disabled, events are ignored.
{% endhint %}

***

## Device

The component tracks which kind of device the bound player used last, as a gameplay tag.

| Function / Event                                             | Description                                                                                                                  |
| ------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------- |
| `GetInputDeviceTag()`                                        | `ModularInput.Device.KeyboardAndMouse`, `.Gamepad`, `.Touch` or `.Other`. Racing wheels and flight sticks count as gamepads. |
| `IsUsingGamepad()`                                           | True when the device tag is Gamepad.                                                                                         |
| `IsUsingKeyboardAndMouse()`                                  | True when the device tag is KeyboardAndMouse.                                                                                |
| **On Input Device Changed** `(DeviceTag, PreviousDeviceTag)` | Fires when the player picks up a different kind of device. Key prompt widgets listen to this.                                |

Only changes for the player this component is bound to are reported, so split-screen players each get their own. See [Settings Screens & Key Prompts](/dante-docs/modular-input-system/core-concepts/settings-and-rebinding.md).

***

## Values

| Function                                                  | Description                                                                                              |
| --------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- |
| `GetInputValue(InputTag)`                                 | The live value of the action behind the tag. Only tracked for rows with **Track Value** on.              |
| `GetLastInputValue(InputTag)`                             | The value carried by the most recent event for the tag, whatever its trigger event.                      |
| `TryGetLastAcceptedTime(InputTag, TriggerEvent, OutTime)` | *(C++)* World time the input last got past the gates with that trigger event. The Cooldown gate uses it. |

***

## Buffer and Buffer Windows

| Function                                                                | Description                                                                                      |
| ----------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------ |
| `ConsumeBufferedInput(Tag, MaxAge, OutEvent, TriggerEvent = Started)`   | Takes the newest held event for the tag (or a child tag).                                        |
| `ConsumeAnyBufferedInput(AcceptedInputs, Resolution, MaxAge, OutEvent)` | Takes the event the resolution picks among several accepted inputs.                              |
| `PeekBufferedInput(Tag, MaxAge, OutEvent, TriggerEvent = Started)`      | Like consume, but leaves the event in the buffer.                                                |
| `WasPressedRecently(Tag, WithinSeconds)`                                | Press history: true if the exact tag raised Started recently, whatever the pipeline did with it. |
| `WasTriggerEventRecent(Tag, TriggerEvent, WithinSeconds)`               | The same for any trigger event.                                                                  |
| `GetBufferedInputs()`                                                   | Held events, oldest first.                                                                       |
| `ClearBuffer()` / `SetBufferCapacity(N)`                                | Empties the buffer / resizes it, keeping the newest events.                                      |
| `OpenBufferWindow(Tag)` / `OpenBufferWindowForDuration(Tag, Seconds)`   | Opens a window defined in one of the configs.                                                    |
| `CloseBufferWindow(Tag)`                                                | Closes the window, picks the winning input and replays it if the window says so.                 |
| `CancelBufferWindow(Tag)`                                               | Closes the window without picking or replaying anything.                                         |
| `IsBufferWindowOpen(Tag)`                                               | True while the window is open.                                                                   |

Events: **On Buffer Window Opened** `(WindowTag)` and **On Buffer Window Closed** `(WindowTag, bResolved, ResolvedEvent)`. See [Input Buffer & Buffer Windows](/dante-docs/modular-input-system/core-concepts/input-buffer.md).

***

## Events and Injection

| Member                                | Description                                                                                                                                                                                                                                               |
| ------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **On Input Event** `(Event, Verdict)` | Every captured or replayed event, once the pipeline has decided on it.                                                                                                                                                                                    |
| **On Tag Event** `(EventTag, Event)`  | Tags sent by processors such as **Broadcast Tag Event**.                                                                                                                                                                                                  |
| `BroadcastTagEvent(EventTag, Event)`  | Fires On Tag Event yourself.                                                                                                                                                                                                                              |
| `InjectInputEvent(Event)`             | Runs an event through the pipeline as if the player had produced it: on-screen buttons, tutorials, AI driving a player pawn, automated tests. Time and frame are filled in when left at zero. Needs a valid input tag and respects the processing switch. |

***

## Extending in C++

| Member                                                       | Description                                                                                                            |
| ------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------- |
| `virtual void ProcessInputEvent(const FMIPS_InputEvent&)`    | Runs one captured event through the active mode. Override to pre-process events; call the parent to keep the pipeline. |
| `virtual void GatherOwnerTags(FGameplayTagContainer&) const` | Collects the tags gates test against. Override to add tags from elsewhere.                                             |
| `void GetOwnerChain(TArray<AActor*>&) const`                 | The owner chain, nearest first.                                                                                        |
| `static void GetActorChain(AActor*, TArray<AActor*>&)`       | The same chain starting from any actor.                                                                                |
| `const FMIPS_InputBuffer& GetBuffer() const`                 | Direct read access to the buffer.                                                                                      |
| `const FMIPS_InputTrace& GetTrace() const`                   | Recent decisions and windows (development builds only, `MIPS_WITH_TRACE`).                                             |

***

## Lifecycle

```
OnRegister   ─ game worlds only: follow possession
               (pawn: Restarted + ControllerChanged, controller: OnPossessedPawnChanged)
BeginPlay    ─ size the buffer, listen for device changes, bind if a local player drives the owner
               └─ player controller without its player yet: tick until it arrives
Possession   ─ refresh setup from the owner chain, then bind / rebind / unbind
EndPlay      ─ unbind, clear the mode stack, press history, open windows and buffer,
               give back configs and mode contributed by a setup provider
```

***

## Next Steps
