|
Nebula
|
The mirror of the engine's default keyboard and mouse handlers.
The engine has authority over the state, and this holds what the last sync saw, so a read is a field read rather than a call through the api.
The mirror is only as good as the frame it was read in. The engine clears the per-frame flags at the start of the input frame and sets them again from the events that arrive during the pump, so the sync has to happen after the pump and before the end of the frame. NebulaApp.OnBeginFrame is that point: the render feature unit pumps the window events at the start of its OnBeginFrame, and the script feature unit is attached after it.
What is here is what the input server received. ImGui gets the keys first and the window drops the events it consumes, so a key typed into a text field never reaches the handlers. HasFocus and the two capture flags are what tell a caller that a key is missing because the UI took it rather than because nobody pressed it.
Classes | |
| struct | KeyWords |
| One key as three words: held through the frame, pressed during it, released during it. More... | |
| struct | Snapshot |
| The layout the engine writes with. More... | |
Static Public Member Functions | |
| static void | Sync () |
| Refresh the mirror from the engine. | |
| static bool | IsKeyHeld (Key key) |
| Held at the time of the sync. | |
| static bool | IsKeyPressed (Key key) |
| Went down during this frame. | |
| static bool | IsKeyReleased (Key key) |
| Went up during this frame. | |
| static bool | IsMouseHeld (MouseButton button) |
| Held at the time of the sync. | |
| static bool | IsMousePressed (MouseButton button) |
| static bool | IsMouseReleased (MouseButton button) |
| static bool | IsMouseDoubleClicked (MouseButton button) |
| static string | CharInput () |
| The text the keyboard produced during this frame. | |
Properties | |
| static int | SnapshotSize [get] |
| The size of the layout on this side. | |
| static int | Wheel [get] |
| The wheel as the net movement for the frame: 1 forward, -1 backward, 0 when it did not move. | |
| static Vector2 | PixelPosition [get] |
| static Vector2 | ScreenPosition [get] |
| The same position as 0.0 through 1.0. | |
| static Vector2 | Movement [get] |
| The movement since the frame started. | |
| static bool | HasFocus [get] |
| static bool | MouseCaptured [get] |
| Whether a handler holds the mouse. | |
| static bool | KeyCaptured [get] |
Private Member Functions | |
| static int | SyncCall (IntPtr buffer, int bufferSize) |
| static int | CharInputCall (IntPtr outBuffer, int outLen) |
Static Private Member Functions | |
| static KeyWords | Words (Key key) |
| The word a key code falls in. | |
| static ulong | Bit (Key key) |
Static Private Attributes | |
| const int | MaxCharInput = 256 |
| static readonly Snapshot[] | buffer = new Snapshot[1] |
| static readonly GCHandle | handle = GCHandle.Alloc(buffer, GCHandleType.Pinned) |
| static readonly byte[] | charBuffer = new byte[MaxCharInput] |
| static readonly GCHandle | charHandle = GCHandle.Alloc(charBuffer, GCHandleType.Pinned) |
|
inlinestatic |
The text the keyboard produced during this frame.
Text only crosses through a buffer this side owns, so this is the call that reads it. Empty when nothing was typed.
|
private |
|
inlinestatic |
Held at the time of the sync.
A key that was pressed and released inside one frame is held for that frame, because the engine keeps the pressed state until the frame after the release.
|
inlinestatic |
Went down during this frame.
This is the edge, so it is true for one frame only.
|
inlinestatic |
Went up during this frame.
Also an edge, and also true for one frame only.
|
inlinestatic |
|
inlinestatic |
Held at the time of the sync.
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
Refresh the mirror from the engine.
Called once per frame at the beginning of the frame, after the events have been pumped. A run with no window has no input server, and the mirror is cleared for it rather than left with the state the previous frame had.
|
private |
The word a key code falls in.
A code outside the codes the engine has is not in any word, so the answer is no bit rather than a read outside the buffer.
|
staticprivate |
|
staticprivate |
|
staticprivate |
|
staticprivate |
|
staticget |
|
staticget |
|
staticget |
Whether a handler holds the mouse.
The handler that holds the capture is the one the events go to, so this is what tells a caller that the mouse is somewhere else.
|
staticget |
The movement since the frame started.
The engine builds it as the position the frame started at minus the position the event carried, which is the negative of the delta, and the raw move path assigns the delta itself. See ISSUES.md.
|
staticget |
|
staticget |
The same position as 0.0 through 1.0.
|
staticget |
The size of the layout on this side.
The engine asserts the same number, and the test compares the two, because the field order is the only thing the contract has.
|
staticget |
The wheel as the net movement for the frame: 1 forward, -1 backward, 0 when it did not move.