Change To OpenGL
This commit is contained in:
@@ -24,10 +24,10 @@ namespace Firebird2D.KeyMapping
|
||||
private Dictionary<string, Type> eventTypes = [];
|
||||
|
||||
// Maps event names to FirebirdEvent identifiers.
|
||||
private Dictionary<string, FirebirdEvent> inputMapping = [];
|
||||
private Dictionary<string, FirebirdSystemEventIds> inputMapping = [];
|
||||
|
||||
// Caches active pipelines for performance.
|
||||
private Dictionary<FirebirdEvent, IPipelineBase> cachedPipelines = [];
|
||||
private Dictionary<FirebirdSystemEventIds, IPipelineBase> cachedPipelines = [];
|
||||
|
||||
public KeyMapper(IEventBus eventBus)
|
||||
{
|
||||
@@ -38,7 +38,7 @@ namespace Firebird2D.KeyMapping
|
||||
/// <summary>
|
||||
/// Registers an input event with its handler and links it to a FirebirdEvent.
|
||||
/// </summary>
|
||||
public void RegisterEvent<T>(string EventName, EventHandler<T> handler, FirebirdEvent eventNumber) where T : EventArgs
|
||||
public void RegisterEvent<T>(string EventName, EventHandler<T> handler, FirebirdSystemEventIds eventNumber) where T : EventArgs
|
||||
{
|
||||
if (inputEvents.ContainsKey(EventName))
|
||||
throw new ArgumentException($"Event {EventName} already exists.");
|
||||
@@ -51,7 +51,7 @@ namespace Firebird2D.KeyMapping
|
||||
/// <summary>
|
||||
/// Maps an existing input event to a new FirebirdEvent.
|
||||
/// </summary>
|
||||
public void Map(string EventName, FirebirdEvent eventNumber)
|
||||
public void Map(string EventName, FirebirdSystemEventIds eventNumber)
|
||||
{
|
||||
if (inputMapping.ContainsKey(EventName))
|
||||
{
|
||||
@@ -92,7 +92,7 @@ namespace Firebird2D.KeyMapping
|
||||
/// <summary>
|
||||
/// Creates or adjusts a pipeline to reflect current mappings.
|
||||
/// </summary>
|
||||
private void AjustPipeline(string EventName, FirebirdEvent eventNumber)
|
||||
private void AjustPipeline(string EventName, FirebirdSystemEventIds eventNumber)
|
||||
{
|
||||
if (!eventTypes.TryGetValue(EventName, out var type)) return;
|
||||
|
||||
@@ -115,7 +115,7 @@ namespace Firebird2D.KeyMapping
|
||||
public void LoadMapping(string Path)
|
||||
{
|
||||
string json = File.ReadAllText(Path);
|
||||
Dictionary<string, FirebirdEvent>? keyValuePairs = JsonSerializer.Deserialize<Dictionary<string, FirebirdEvent>>(json);
|
||||
Dictionary<string, FirebirdSystemEventIds>? keyValuePairs = JsonSerializer.Deserialize<Dictionary<string, FirebirdSystemEventIds>>(json);
|
||||
if (keyValuePairs == null) throw new FileLoadException("Unable to deserialize input mapping.");
|
||||
|
||||
cachedPipelines.Clear();
|
||||
@@ -139,7 +139,7 @@ namespace Firebird2D.KeyMapping
|
||||
/// <summary>
|
||||
/// Removes a pipeline from the internal cache.
|
||||
/// </summary>
|
||||
public void InvalidatePipelineCache(FirebirdEvent fbEvent)
|
||||
public void InvalidatePipelineCache(FirebirdSystemEventIds fbEvent)
|
||||
{
|
||||
cachedPipelines.Remove(fbEvent);
|
||||
}
|
||||
@@ -148,7 +148,7 @@ namespace Firebird2D.KeyMapping
|
||||
/// Retrieves a cached pipeline or fetches and caches it.
|
||||
/// </summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
private IPipeline<T>? GetOrCachePipeline<T>(FirebirdEvent fbEvent) where T : EventArgs
|
||||
private IPipeline<T>? GetOrCachePipeline<T>(FirebirdSystemEventIds fbEvent) where T : EventArgs
|
||||
{
|
||||
if (cachedPipelines.TryGetValue(fbEvent, out var pipelineObj) && pipelineObj is Pipeline<T> cached)
|
||||
return cached;
|
||||
@@ -166,7 +166,7 @@ namespace Firebird2D.KeyMapping
|
||||
/// </summary>
|
||||
public void HandleKeyboardInput(KeyEvent key, InputEventType type)
|
||||
{
|
||||
var pipeline = GetOrCachePipeline<FirebirdKeyEventArgs>((FirebirdEvent)key.Code);
|
||||
var pipeline = GetOrCachePipeline<FirebirdKeyEventArgs>((FirebirdSystemEventIds)key.Code);
|
||||
pipeline?.SendEvent(this, new FirebirdKeyEventArgs(key, type));
|
||||
}
|
||||
|
||||
@@ -175,7 +175,7 @@ namespace Firebird2D.KeyMapping
|
||||
/// </summary>
|
||||
public void HandleMouseInput(MouseButtonEvent button, InputEventType type)
|
||||
{
|
||||
var pipeline = GetOrCachePipeline<FirebirdMouseButtonEventArgs>((FirebirdEvent)(button.Button + 101));
|
||||
var pipeline = GetOrCachePipeline<FirebirdMouseButtonEventArgs>((FirebirdSystemEventIds)(button.Button + 101));
|
||||
pipeline?.SendEvent(this, new FirebirdMouseButtonEventArgs(button, type));
|
||||
}
|
||||
|
||||
@@ -184,7 +184,7 @@ namespace Firebird2D.KeyMapping
|
||||
/// </summary>
|
||||
public void HandleJoystickButtonInput(JoystickButtonEvent joystickButton, InputEventType type)
|
||||
{
|
||||
var pipeline = GetOrCachePipeline<FirebirdJoystickButtonEventArgs>(FirebirdEvent.JoystickButton);
|
||||
var pipeline = GetOrCachePipeline<FirebirdJoystickButtonEventArgs>(FirebirdSystemEventIds.JoystickButton);
|
||||
pipeline?.SendEvent(this, new FirebirdJoystickButtonEventArgs(joystickButton, type));
|
||||
}
|
||||
|
||||
@@ -193,7 +193,7 @@ namespace Firebird2D.KeyMapping
|
||||
/// </summary>
|
||||
public void HandleMouseMovement(MouseMoveEvent mouseMove)
|
||||
{
|
||||
var pipeline = GetOrCachePipeline<MouseMoveEventArgs>(FirebirdEvent.MouseMove);
|
||||
var pipeline = GetOrCachePipeline<MouseMoveEventArgs>(FirebirdSystemEventIds.MouseMove);
|
||||
pipeline?.SendEvent(this, new MouseMoveEventArgs(mouseMove));
|
||||
}
|
||||
|
||||
@@ -202,7 +202,7 @@ namespace Firebird2D.KeyMapping
|
||||
/// </summary>
|
||||
public void HandleJoytickMove(JoystickMoveEvent joystickMove)
|
||||
{
|
||||
var pipeline = GetOrCachePipeline<JoystickMoveEventArgs>(FirebirdEvent.JoystickMove);
|
||||
var pipeline = GetOrCachePipeline<JoystickMoveEventArgs>(FirebirdSystemEventIds.JoystickMove);
|
||||
pipeline?.SendEvent(this, new JoystickMoveEventArgs(joystickMove));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user