-
-
Couldn't load subscription status.
- Fork 441
Enhanced Input Events #402
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
9a57a7a
Created Propostal - Enhanced Input Events.md
ThomasMiz 9fa2a1d
Update Proposal - Enhanced Input Events.md
ThomasMiz 1c4712c
Update Proposal - Enhanced Input Events.md
ThomasMiz 34d258d
Added ctors - Enhanced Input Events.md
ThomasMiz baa3518
Applied suggestions - Enhanced Input Events.md
ThomasMiz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
169 changes: 169 additions & 0 deletions
169
documentation/proposals/Proposal - Enhanced Input Events.md
This file contains hidden or 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,169 @@ | ||
| # Summary | ||
| Proposal for adding important missing functionality to input, as well as other enhancements. | ||
|
|
||
| # Contributors | ||
| - ThomasMiz | ||
|
|
||
| # Current Status | ||
| - [x] Proposed | ||
| - [x] Discussed with API Review Board (ARB) | ||
| - [ ] Approved | ||
| - [ ] Implemented | ||
|
|
||
| # Design Decisions | ||
| - Event parameters will be turned into readonly structures to prevent long parameter lists in some cases and allow more parameters (such as deltas) to be added in the future without breaking. | ||
|
|
||
| # Proposed API | ||
| The only API changes will be to the events presented by IMouse, IKeyboard and possibly other device interfaces. | ||
|
|
||
| ## Enums | ||
|
|
||
| #### KeyModifiers | ||
| Based on [the modifier keys flag from GLFW](https://www.glfw.org/docs/latest/group__mods.html). | ||
| ```cs | ||
| [Flags] | ||
| public enum KeyModifiers | ||
| { | ||
| Shift = 1 << 1, | ||
| Control = 1 << 2, | ||
| Alt = 1 << 3, | ||
| Super = 1 << 4, | ||
| CapsLock = 1 << 5, | ||
| NumLock = 1 << 6 | ||
| } | ||
| ``` | ||
|
|
||
| ## Structs | ||
|
|
||
| #### KeyDownEvent | ||
| ```cs | ||
| public readonly struct KeyDownEvent | ||
| { | ||
| public IKeyboard Keyboard { get; } | ||
| public Key Key { get; } | ||
| public int KeyCode { get; } | ||
| public KeyModifiers Modifiers { get; } | ||
| public bool IsRepeat { get; } | ||
|
|
||
| public KeyDownEvent(IKeyboard keyboard, Key key, int keyCode, KeyModifiers modifiers, bool isRepeat) | ||
ThomasMiz marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
| ``` | ||
|
|
||
| #### KeyUpEvent | ||
| ```cs | ||
| public readonly struct KeyUpEvent | ||
| { | ||
Perksey marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| public IKeyboard Keyboard { get; } | ||
| public Key Key { get; } | ||
| public int KeyCode { get; } | ||
| public KeyModifiers Modifiers { get; } | ||
|
|
||
| public KeyUpEvent(IKeyboard keyboard, Key key, int keyCode, KeyModifiers modifiers) | ||
ThomasMiz marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
| ``` | ||
|
|
||
| #### KeyCharEvent | ||
| ```cs | ||
| public readonly struct KeyCharEvent | ||
| { | ||
| public IKeyboard Keyboard { get; } | ||
| public char Character { get; } | ||
| public int KeyCode { get; } | ||
|
|
||
| public KeyCharEvent(IKeyboard keyboard, char character, int keyCode) | ||
ThomasMiz marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
| ``` | ||
|
|
||
| #### MouseMoveEvent | ||
| ```cs | ||
| public readonly struct MouseMoveEvent | ||
| { | ||
| public IMouse Mouse { get; } | ||
| public Vector2 Position { get; } | ||
| public Vector2 Delta { get; } | ||
|
|
||
| public MouseMoveEvent(IMouse mouse, Vector2 position, Vector2 delta) | ||
ThomasMiz marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
| ``` | ||
|
|
||
| #### MouseButtonEvent | ||
| ```cs | ||
| public readonly struct MouseButtonEvent | ||
| { | ||
| public IMouse Mouse { get; } | ||
| public Vector2 Position { get; } | ||
| public MouseButton Button { get; } | ||
| public KeyModifiers Modifiers { get; } | ||
|
|
||
| public MouseButtonEvent(IMouse mouse, Vector2 position, MouseButton button, KeyModifiers modifiers) | ||
ThomasMiz marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
| ``` | ||
|
|
||
| #### MouseScrollEvent | ||
| This would replace the current ScrollWheel struct. | ||
ThomasMiz marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ```cs | ||
| public readonly struct MouseScrollEvent | ||
| { | ||
| public IMouse Mouse { get; } | ||
| public Vector2 Position { get; } | ||
| public Vector2 WheelPosition { get; } | ||
| public Vector2 Delta { get; } | ||
|
|
||
| public MouseScrollEvent(IMouse mouse, Vector2 position, Vector2 wheelPosition, Vector2 delta) | ||
ThomasMiz marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
| ``` | ||
|
|
||
| #### MouseClickEvent | ||
| ```cs | ||
| public readonly struct MouseClickEvent | ||
| { | ||
| public IMouse Mouse { get; } | ||
| public Vector2 Position { get; } | ||
| public MouseButton Button { get; } | ||
| public KeyModifiers Modifiers { get; } | ||
|
|
||
| public MouseClickEvent(IMouse mouse, Vector2 position, MouseButton button, KeyModifiers modifiers) | ||
| } | ||
| ``` | ||
|
|
||
| ## Interface changes | ||
|
|
||
| #### IKeyboard | ||
| ```cs | ||
| public interface IKeyboard : IInputDevice | ||
| { | ||
| // The old events get removed: | ||
| // event Action<IKeyboard, Key> KeyDown; | ||
| // event Action<IKeyboard, Key> KeyUp; | ||
| // event Action<IKeyboard, char> KeyChar; | ||
|
|
||
| // KeyDown reports key down and key repeats | ||
| event Action<KeyDownEvent> KeyDown; | ||
| event Action<KeyUpEvent> KeyUp; | ||
|
|
||
| event Action<KeyCharEvent> KeyChar; | ||
| } | ||
| ``` | ||
|
|
||
| #### IMouse | ||
| ```cs | ||
| public interface IMouse : IInputDevice | ||
| { | ||
| // The old events get removed: | ||
| // event Action<IMouse, Vector2> MouseMove; | ||
| // event Action<IMouse, MouseButton> MouseDown; | ||
| // event Action<IMouse, MouseButton> MouseUp; | ||
| // event Action<IMouse, ScrollWheel> Scroll; | ||
| // event Action<IMouse, MouseButton, Vector2> Click; | ||
| // event Action<IMouse, MouseButton, Vector2> DoubleClick; | ||
|
|
||
| event Action<MouseMoveEvent> MouseMove; | ||
| event Action<MouseButtonEvent> MouseDown; | ||
| event Action<MouseButtonEvent> MouseUp; | ||
| event Action<MouseScrollEvent> Scroll; | ||
| event Action<MouseClickEvent> Click; | ||
| event Action<MouseClickEvent> DoubleClick; | ||
| } | ||
| ``` | ||
|
|
||
| These changes can also be applied to other IDevices to keep consistency across our API. | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.