FinalEngine.Input 2023.4.0-pre

This is a prerelease version of FinalEngine.Input.
dotnet add package FinalEngine.Input --version 2023.4.0-pre
NuGet\Install-Package FinalEngine.Input -Version 2023.4.0-pre
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="FinalEngine.Input" Version="2023.4.0-pre" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add FinalEngine.Input --version 2023.4.0-pre
#r "nuget: FinalEngine.Input, 2023.4.0-pre"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install FinalEngine.Input as a Cake Addin
#addin nuget:?package=FinalEngine.Input&version=2023.4.0-pre&prerelease

// Install FinalEngine.Input as a Cake Tool
#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 or IMouseDevice classes as the current platform back-end only supports OpenTK.
  • Remember to call keyboard.Update() and mouse.Update() after polling for input changes.
  • Keyboard and Mosue implement IDisposable 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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • 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 102 7/11/2023