Namespace OmegaEngine.Input
OmegaEngine provides a flexible input system that processes low-level input events into higher-level navigational commands.
The input system uses a provider-receiver pattern:
- InputProvider - Captures raw input from devices (keyboard, mouse, touch) and translates it into semantic commands
- IInputReceiver - Receives and responds to input commands
Input providers
Keyboard
KeyboardInputProvider processes keyboard input for navigation and interaction.
The KeyBindings property maps keyboard keys to translation and rotation commands. Default bindings include:
- WASD - Forward/backward and strafe left/right
- QE - Roll left/right
- Arrow keys - Pitch and yaw
You can customize the key bindings by modifying this dictionary.
Mouse
MouseInputProvider processes mouse input for Camera control and selection.
The Scheme property controls which mouse button does what using MouseInputScheme. Pre-defined schemes include:
- Scene - Full 6DOF navigation (left: pan XY, right: rotate, middle: roll/zoom)
- Orbit - Rotation around a fixed target. (left: rotate, right: roll/zoom)
- Planar - Top-down navigation (left: area select, right: pan XY, middle: rotate/zoom)
- FreeLook - First-person style (left: look, right: move)
Each scheme maps mouse buttons to InputActions like Navigation or AreaSelection.
Touch
TouchInputProvider processes touch input for gesture-based control.
The Scheme property controls which touch gesture does what using TouchInputScheme. Pre-defined schemes include:
- Scene - Pan translates XY, pinch zooms, twist rolls
- Orbit - Pan rotates around a fixed target, pinch zooms, twist rolls
- Planar - Top-down navigation (pan translates XY, pinch zooms, twist yaws)
Each scheme maps the pan, pinch and twist gestures to NavigationAxises.
Input receivers
Classes that want to respond to input commands implement the IInputReceiver interface.
Built-in receivers
All Cameras implement the interface. This allows you to connect an input provider for direct movement control:
var camera = new FreeFlyCamera();
inputProvider.AddReceiver(camera);
PresenterBase<TUniverse> implements the interface. It passes Navigate() calls through to the Camera.
Custom receivers
For custom input handling, you can implement IInputReceiver in your own code.
You can use the abstract base class InputReceiverBase to simplify the implementation. It allows you to override only the methods you wish to handle rather than implementing all of the interface methods.
public class MyGameController : InputReceiverBase
{
public override void Navigate(DoubleVector3 translation, DoubleVector3 rotation)
{
// Handle player movement
player.Move(translation.X, translation.Z);
}
// ...
}
var controller = new MyGameController();
inputProvider.AddReceiver(controller);
Usage with Hosting classes
RenderHost and RenderPanel automatically set up all built-in input providers.
You can register an input receiver with all of the providers with a single call to AddInputReceiver(IRenderHost, IInputReceiver)
Overview
flowchart TD
subgraph Providers["Input providers"]
KeyboardInputProvider
MouseInputProvider
TouchInputProvider
end
subgraph Receivers["Input receivers"]
Camera
Presenter
CustomReceiver["Custom receiver"]
end
RenderHost --> KeyboardInputProvider
RenderHost --> MouseInputProvider
RenderHost --> TouchInputProvider
KeyboardInputProvider --> IInputReceiver
MouseInputProvider --> IInputReceiver
TouchInputProvider --> IInputReceiver
IInputReceiver --> Camera
IInputReceiver --> Presenter --> Camera
IInputReceiver --> CustomReceiver
API
Classes
- ActionReceiver
Calls a callback delegate whenever any kind of input is received.
- AreaSelection
A rectangular selection action bound to a mouse input.
- InputAction
An action bound to an input.
- InputProvider
Processes events from an input device into higher-level navigational commands.
- InputReceiverBase
Base class to simplify implementing IInputReceiver
- KeyboardInputProvider
Processes keyboard events into higher-level navigational commands.
- MouseInputProvider
Processes mouse events into higher-level navigational commands.
- MouseInputScheme
Controls which mouse button does what.
- Navigation
A navigation action mapping two input axes to degrees-of-freedom.
- TouchInputProvider
Processes touch events into higher-level navigational commands.
- TouchInputScheme
Controls which touch gesture does what.
Interfaces
- IInputReceiver
An object that receives input from an InputProvider.
Enums
- NavigationAxis
An axis / degree-of-freedom manipulatable by input.