-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8fdaee2
commit 242109c
Showing
9 changed files
with
132 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
using Hypercube.EventBus.Events; | ||
using JetBrains.Annotations; | ||
|
||
namespace Hypercube.Client.Input.Events; | ||
|
||
[PublicAPI] | ||
public sealed class CharHandledEvent : IEventArgs | ||
{ | ||
public readonly uint Code; | ||
|
||
public char Char => (char) Code; | ||
public string String => Code.ToString(); | ||
|
||
public CharHandledEvent(uint code) | ||
{ | ||
Code = code; | ||
} | ||
|
||
public static implicit operator uint(CharHandledEvent @event) | ||
{ | ||
return @event.Code; | ||
} | ||
|
||
public static implicit operator char(CharHandledEvent @event) | ||
{ | ||
return @event.Char; | ||
} | ||
|
||
public static implicit operator string(CharHandledEvent @event) | ||
{ | ||
return @event.String; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using Hypercube.EventBus.Events; | ||
using Hypercube.Math.Vectors; | ||
using JetBrains.Annotations; | ||
|
||
namespace Hypercube.Client.Input.Events; | ||
|
||
[PublicAPI] | ||
public class ScrollHandledEvent : IEventArgs | ||
{ | ||
public readonly Vector2 Offset; | ||
|
||
public ScrollHandledEvent(Vector2 offset) | ||
{ | ||
Offset = offset; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 10 additions & 1 deletion
11
Hypercube.Client/Input/Events/Windowing/WindowingScrollHandledEvent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,14 @@ | ||
using Hypercube.EventBus.Events; | ||
using Hypercube.Math.Vectors; | ||
|
||
namespace Hypercube.Client.Input.Events.Windowing; | ||
|
||
public readonly record struct WindowingScrollHandledEvent : IEventArgs; | ||
public class WindowingScrollHandledEvent : IEventArgs | ||
{ | ||
public readonly Vector2 Offset; | ||
|
||
public WindowingScrollHandledEvent(Vector2 offset) | ||
{ | ||
Offset = offset; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,61 @@ | ||
using Hypercube.Client.Graphics.Windows; | ||
using Hypercube.Client.Input.Events; | ||
using Hypercube.EventBus; | ||
using Hypercube.Input; | ||
using JetBrains.Annotations; | ||
|
||
namespace Hypercube.Client.Input.Handler; | ||
|
||
/// <summary> | ||
/// Receives requests from user input, via <see cref="IWindowManager"/>, | ||
/// and submits them for further work via events. | ||
/// </summary> | ||
[PublicAPI] | ||
public interface IInputHandler : IEventSubscriber | ||
{ | ||
bool IsKeyState(Key key, KeyState state); | ||
|
||
/// <summary> | ||
/// Checks the state <see cref="Key"/> is <see cref="KeyState.Held"/> or <see cref="KeyState.Pressed"/>. | ||
/// </summary> | ||
bool IsKeyHeld(Key key); | ||
|
||
/// <summary> | ||
/// Checks the state <see cref="Key"/> is <see cref="KeyState.Pressed"/>. | ||
/// </summary> | ||
bool IsKeyPressed(Key key); | ||
|
||
/// <summary> | ||
/// Checks the state <see cref="Key"/> is <see cref="KeyState.Released"/>. | ||
/// </summary> | ||
bool IsKeyReleased(Key key); | ||
|
||
/// <summary> | ||
/// Clears all received <see cref="KeyState"/> of <see cref="Key"/>, | ||
/// and can abort all checks and <see cref="KeyHandledEvent"/> (<see cref="KeyState.Held"/>) events. | ||
/// </summary> | ||
void KeyClear(); | ||
|
||
bool IsMouseButtonState(MouseButton button, KeyState state); | ||
|
||
/// <summary> | ||
/// Checks the state <see cref="MouseButton"/> is <see cref="KeyState.Held"/> or <see cref="KeyState.Pressed"/>. | ||
/// </summary> | ||
bool IsMouseButtonHeld(MouseButton button); | ||
|
||
/// <summary> | ||
/// Checks the state <see cref="MouseButton"/> is <see cref="KeyState.Pressed"/>. | ||
/// </summary> | ||
bool IsMouseButtonPressed(MouseButton button); | ||
|
||
/// <summary> | ||
/// Checks the state <see cref="MouseButton"/> is <see cref="KeyState.Released"/>. | ||
/// </summary> | ||
bool IsMouseButtonReleased(MouseButton button); | ||
|
||
/// <summary> | ||
/// Clears all received <see cref="KeyState"/> of <see cref="MouseButton"/>, | ||
/// and can abort all checks and <see cref="MouseButtonHandledEvent"/> (<see cref="KeyState.Held"/>) events. | ||
/// </summary> | ||
void MouseButtonClear(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
|
||
public enum KeyState | ||
{ | ||
Release, | ||
Released, | ||
Pressed, | ||
Held | ||
} |