-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathKeyInputModule.cs
48 lines (42 loc) · 1.71 KB
/
KeyInputModule.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
using AltV.Atlas.KeyInputs.Client.Events;
using AltV.Net.Client.Elements.Data;
using Microsoft.Extensions.DependencyInjection;
namespace AltV.Atlas.KeyInputs.Client;
/// <summary>
/// Main entry point to client-side key input module
/// </summary>
public static class KeyInputModule
{
/// <summary>
/// The keys you want to listen for
/// </summary>
public static List<Key> Keys { get; private set; } = new( );
/// <summary>
/// Registers the key input module and it's classes/interfaces
/// </summary>
/// <param name="serviceCollection">A service collection</param>
/// <returns>The service collection</returns>
public static IServiceCollection RegisterKeyInputModule( this IServiceCollection serviceCollection )
{
Console.WriteLine( "[ATLAS] KeyInput Module Registered!" );
serviceCollection.AddSingleton<AtlasKeyInputEvents>( );
serviceCollection.AddSingleton<KeyDownEvent>( );
serviceCollection.AddSingleton<KeyUpEvent>( );
return serviceCollection;
}
/// <summary>
/// Initializes the key input module
/// </summary>
/// <param name="serviceProvider">A service provider</param>
/// <param name="keys">The keys the module should listen for</param>
/// <returns></returns>
public static IServiceProvider InitializeKeyInputModule( this IServiceProvider serviceProvider, List<Key> keys )
{
Console.WriteLine( "[ATLAS] KeyInput Module Initialized!" );
_ = serviceProvider.GetService<KeyDownEvent>( );
_ = serviceProvider.GetService<KeyUpEvent>( );
Keys = keys;
Console.WriteLine( $" [ATLAS] KeyInput Module is listening for {Keys.Count} keys!" );
return serviceProvider;
}
}