A portable way of accessing HID devices cross-platform
This project is still in development!
- Windows
- OpenTK
- Mouse
- Keyboard
- TouchDevice
- GamePad
OpenInput is designed for loc libraries, which makes it easy for numerous reasons when implementation and handling crossplatform code.
In this example I am going to show how to use Nine.Injection which is a lightwight loc library.
First you have to map the devices you wish to use.
// You can read more on how to map object on Nine.Injection's page.
var container = new Container();
container
.Map<IMouse>(new RawInput.Mouse(this.Handle))
.Map<IKeyboard>(new RawInput.Keyboard(this.Handle))
.Map<IGamePad>(new RawInput.GamePad(this.Handle));
Now when you have mapped the devices you can start using them.
var keyboardState = container.Get<IKeyboard>().GetCurrentState();
if (keyboardState.IsKeyDown(Keys.Space))
{
/// Executed if Space is down.
}