FinalEngine.Input
2023.4.0-pre
dotnet add package FinalEngine.Input --version 2023.4.0-pre
NuGet\Install-Package FinalEngine.Input -Version 2023.4.0-pre
<PackageReference Include="FinalEngine.Input" Version="2023.4.0-pre" />
<PackageVersion Include="FinalEngine.Input" Version="2023.4.0-pre" />
<PackageReference Include="FinalEngine.Input" />
paket add FinalEngine.Input --version 2023.4.0-pre
#r "nuget: FinalEngine.Input, 2023.4.0-pre"
#addin nuget:?package=FinalEngine.Input&version=2023.4.0-pre&prerelease
#tool nuget:?package=FinalEngine.Input&version=2023.4.0-pre&prerelease
FinalEngine.Input
FinalEngine.Input is a core library that provides keyboard and mouse control to Final Engine games. It also provides interfaces that can be implemented to add support to a different platform back-end (currently Final Engine used OpenTK.
Getting started
Below you'll find instructions on how to take advantage of this package. Please note that Final Engine is in active development and a full release is still underway.
Prerequisites
If you haven't already, you'll need to reference a package that provides back-end input support to Final Engine. Currently, the only one available and maintained is FinalEngine.Platform.Desktop. Install the package to access concrete implementations of interfaces defined in this package.
Alternatively, you can provide your own implementations of IKeyboardDevice
and IMouseDevice
. This README won't go into further detail on how this can be accomplished but upon the first release the source documentation will likely provide some more insight. For now, it's omitted as it's outside the scope of this packages' prerequisites.
Usage
Once all dependencies have been resolved you can create the required input devices.
// Natvie window refers to INativeWindowInvoker, which can be accessed by creating a NativeWindowInvoker object.
var keyboardDevice = new OpenTKKeyboardDevice(nativeWindow);
// Do the same for the mouse.
var mouseDevice = new OpenTKMouseDevice(nativeWindow);
// Note that these classes allow you to hook onto specific events.
keyboardDevice.KeyUp += On_KeyUp;
mouseDevice.Scroll += On_Scroll;
Okay, so that's not very interesting. You can now create a Keyboard
and Mouse
object which can be used in your games update loop.
// In initialization.
var keyboard = new Keyboard(keyboardDevice);
var mouse = new Mouse(mouseDevice);
// In game loop.
while (isRunning)
{
if (keyboard.IsKeyDown(Key.Escape))
{
ExitGame();
}
if (mouse.IsButtonReleased(MouseButton.Left))
{
ShootBullet();
}
// Always call Update methods AFTER checking input.
mouse.Update();
keyboard.Update();
}
Additional documentation
- Generally speaking, you should not need to implement your own
IKeyboardDevice
orIMouseDevice
classes as the current platform back-end only supports OpenTK. - Remember to call
keyboard.Update()
andmouse.Update()
after polling for input changes. Keyboard
andMosue
implementIDisposable
and are not managed by the engines resource manager.
Feedback
Want to provide feedback? Perhaps you have a found a bug or wish to provide a feature request? Look no further!
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. |
-
net7.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 |
---|---|---|
2023.4.0-pre | 134 | 7/11/2023 |