https://github.com/rsptim1/Ctrl
Input system wrapper built on Stride's native input system
https://github.com/rsptim1/Ctrl
csharp stride3d
Last synced: 4 days ago
JSON representation
Input system wrapper built on Stride's native input system
- Host: GitHub
- URL: https://github.com/rsptim1/Ctrl
- Owner: rsptim1
- License: mit
- Created: 2020-08-15T19:37:07.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2020-10-30T00:24:00.000Z (over 4 years ago)
- Last Synced: 2024-11-13T18:43:30.560Z (6 months ago)
- Topics: csharp, stride3d
- Language: C#
- Homepage:
- Size: 8.79 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- Awesome-Stride - Control - Input Manager
README
# Ctrl
*Ctrl* is a programmer-oriented wrapper for Stride's native input system. The goal is to make grabbing player inputs at runtime more standardized and configurable, and to allow easy rebinding of controls.## Roadmap:
- [x] Basic binding controls for buttons and axes
- [ ] Advanced mouse controls and utilities
- [ ] Easy runtime rebinding
- [ ] Savable and loadable controller binding layouts# Using Ctrl
The most configurable way to utilize *Ctrl* is by implementing the `PlayerActionSet` class and having `PlayerAction` fields to be read from.
```cs
public class InputController : PlayerActionSet
{
private readonly TwoAxisPlayerAction exampleAxis;
public TwoPlayerAxisAction => ExampleAxis;private readonly PlayerAction exampleButton;
public PlayerAction => ExampleButton;public InputController() : base()
{
// Setup the axis action
// Note: each PlayerAction must be assigned a unique name
exampleAxis = CreateTwoAxisPlayerAction("Axis");
exampleAxis.AddBinding(MouseAxis.X, MouseAxis.Y);// Setup the button action
exampleAxis = CreatePlayerAction("Button");
exampleAxis.AddBinding(Keys.Space);
}
}
```These player actions can now be read for input values.
```cs
var controller = new InputController();bool isPressed = controller.ExampleButton.IsPressed;
Vector2 axisInput = controller.ExampleAxis.Vector;
```Yes, the name is a pun.