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)
- 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 MouseActions like navigation or area selection.
Touch
TouchInputProvider processes touch input for gesture-based control.
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.
- 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.
- MouseAction
An action bound to a mouse input.
- MouseAreaSelection
A rectangular selection action bound to a mouse input.
- MouseInputProvider
Processes mouse events into higher-level navigational commands.
- MouseInputScheme
Controls which mouse button does what.
- MouseNavigation
A navigation action bound to a mouse input.
- TouchInputProvider
Processes touch events into higher-level navigational commands.
Interfaces
- IInputReceiver
An object that receives input from an InputProvider.
Enums
- MouseNavigationAxis
An axis / degree-of-freedom manipulatable by mouse.