BerylliumInputBinder 1.2.3

dotnet add package BerylliumInputBinder --version 1.2.3
                    
NuGet\Install-Package BerylliumInputBinder -Version 1.2.3
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="BerylliumInputBinder" Version="1.2.3" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="BerylliumInputBinder" Version="1.2.3" />
                    
Directory.Packages.props
<PackageReference Include="BerylliumInputBinder" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add BerylliumInputBinder --version 1.2.3
                    
#r "nuget: BerylliumInputBinder, 1.2.3"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package BerylliumInputBinder@1.2.3
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=BerylliumInputBinder&version=1.2.3
                    
Install as a Cake Addin
#tool nuget:?package=BerylliumInputBinder&version=1.2.3
                    
Install as a Cake Tool

Beryllium Input Binder

Class library for managing various types of input binding to game actions.

Actions come in three shapes — button, one-axis and two-axes — and each action can hold several input bindings (2 by default). Registration and binding are separate on purpose: a game first registers its actions (by name/description), then the player binds inputs to them later in a settings menu.

Quick start

var binder = new InputBinder(inputBindingsPerAction: 2);

// 1. Register actions once at startup. Each call returns a handle you can keep or look up later.
var jump = binder.RegisterButton("Jump", (state, player) => Player.Jump(),
                                 description: "Jump over obstacles")
                 .WithDefaultBinding(0, Input.Key(32))          // keyboard Space
                 .WithDefaultBinding(1, Input.GamePadButton(0)); // gamepad A

var look = binder.RegisterTwoAxes("Look", (delta, player) => Camera.Rotate(delta))
                 .WithDefaultBinding(0, Input.MouseAxes(0));

// Batch-register pre-built actions if you prefer defining them elsewhere:
binder.RegisterRange(
    new OneAxisAction("Throttle", (v, p) => Ship.SetThrottle(v)),
    new ButtonAction("Fire", (s, p) => Ship.Fire()));

// 2. Drive the binder each frame with the inputs you polled.
//    Update takes IReadOnlyList (arrays or List<T>) and is O(1) per input with zero allocations,
//    so it is safe to call every frame. Any list may be null.
binder.Update(buttonInputs, oneAxisInputs, twoAxesInputs,
              withShift: shiftHeld, withCtrl: ctrlHeld, withAlt: altHeld);

Rebinding menu

Enumerate binder.Actions (or binder.GetAction(name)) to build a settings screen, then bind through the handle. Bind reports a conflict instead of silently stealing the input:

foreach (var action in binder.Actions)
    Console.WriteLine($"{action.Name} ({action.Type}): {action.Description}");

var result = jump.Bind(0, Input.Key(newKeyCode));

if (result.Result == InputBinderResults.InputBoundToOtherAction)
{
    // The input is already bound to result.ConflictingAction — ask the player, then override:
    jump.Bind(0, Input.Key(newKeyCode), forceMap: true);
}

jump.Unbind(1); // clear a slot

Each handle exposes Name, Description, Type, Representation and its current Inputs (one slot per binding; a slot is null when unbound), so you can render the current mapping.

Input factories

Input provides terse factories for binding:

Kind Factories
Button Input.Key(code, modifier?), Input.MouseButton(n), Input.GamePadButton(n), Input.MidiButton(n)
One axis Input.MouseAxis(id), Input.GamePadAxis(id), Input.MidiAxis(id), Input.Axis(source, id)
Two axes Input.MouseAxes(id), Input.GamePadAxes(id), Input.Axes(source, id)

Keyboard button bindings may carry a ButtonModifiers value (Shift/Ctrl/Alt); the Update flags tell the binder which modifiers are currently held so the right binding fires.

When polling inputs for Update, construct them directly so you can set the live state:

new ButtonInput(InputSources.Keyboard, 32) { State = ButtonStates.Pressed, PlayerNumber = 0 }
Product Compatible and additional computed target framework versions.
.NET net10.0-windows7.0 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net10.0-windows7.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.2.3 91 7/13/2026
1.2.2 88 7/13/2026
1.2.1 91 7/12/2026
1.2.0 109 7/12/2026
1.1.0 114 4/11/2026
1.0.0 233 10/23/2025