Change folder structure, add solution to the root.
This commit is contained in:
87
DaggerFramework/Source/RaylibInputHandler.cs
Executable file
87
DaggerFramework/Source/RaylibInputHandler.cs
Executable file
@@ -0,0 +1,87 @@
|
||||
using System.Numerics;
|
||||
using Raylib_cs;
|
||||
|
||||
namespace DaggerFramework
|
||||
{
|
||||
public class RaylibInputHandler : InputHandler
|
||||
{
|
||||
public override int GetCharPressed()
|
||||
{
|
||||
return Raylib.GetCharPressed();
|
||||
}
|
||||
|
||||
public override Vector2 GetInputDirection(KeyboardKey leftKey, KeyboardKey rightKey, KeyboardKey upKey, KeyboardKey downKey)
|
||||
{
|
||||
Vector2 dir = Vector2.Zero;
|
||||
|
||||
if (IsKeyboardKeyDown(leftKey))
|
||||
dir += new Vector2(-1, 0);
|
||||
if (IsKeyboardKeyDown(rightKey))
|
||||
dir += new Vector2(1, 0);
|
||||
if (IsKeyboardKeyDown(upKey))
|
||||
dir += new Vector2(0, -1);
|
||||
if (IsKeyboardKeyDown(downKey))
|
||||
dir += new Vector2(0, 1);
|
||||
|
||||
return dir == Vector2.Zero ? Vector2.Zero : Vector2.Normalize(dir);
|
||||
}
|
||||
|
||||
public override Vector2 GetMousePosition()
|
||||
{
|
||||
return Raylib.GetMousePosition();
|
||||
}
|
||||
|
||||
public override float GetMouseWheelMovement()
|
||||
{
|
||||
return Raylib.GetMouseWheelMove();
|
||||
}
|
||||
|
||||
public override void HideCursor()
|
||||
{
|
||||
Raylib.HideCursor();
|
||||
}
|
||||
|
||||
public override bool IsActionDown(string action)
|
||||
{
|
||||
// throw new NotImplementedException();
|
||||
// return inputMappings[action].IsPressed();
|
||||
foreach (InputAction inputAction in inputMappings[action])
|
||||
if (inputAction.IsDown(this)) return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public override bool IsActionJustPressed(string action)
|
||||
{
|
||||
foreach (InputAction inputAction in inputMappings[action])
|
||||
if (inputAction.IsPressed(this)) return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public override bool IsKeyboardKeyDown(DaggerFramework.KeyboardKey key)
|
||||
{
|
||||
Raylib_cs.KeyboardKey rayKey = (Raylib_cs.KeyboardKey)key;
|
||||
OnInput?.Invoke();
|
||||
return Raylib.IsKeyDown(rayKey);
|
||||
}
|
||||
|
||||
public override bool IsMouseButtonDown(MouseButton button)
|
||||
{
|
||||
return Raylib.IsMouseButtonDown((Raylib_cs.MouseButton)button);
|
||||
}
|
||||
|
||||
public override bool KeyboardKeyJustPressed(KeyboardKey key)
|
||||
{
|
||||
Raylib_cs.KeyboardKey rayKey = (Raylib_cs.KeyboardKey)key;
|
||||
return Raylib.IsKeyPressed(rayKey);
|
||||
}
|
||||
|
||||
public override void SetMousePosition(Vector2 position)
|
||||
{
|
||||
Raylib.SetMousePosition((int)position.X, (int)position.Y);
|
||||
}
|
||||
public override void ShowCursor() => Raylib.ShowCursor();
|
||||
public override bool IsCursorHidden() => Raylib.IsCursorHidden();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user