feat: implement keyboard and mouse input - #7
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds keyboard and mouse input support to VectorJS by exporting Raylib input enums into the JS module and exposing input-query helpers on the per-frame UpdateContext, with an example updated to demonstrate keyboard-driven control.
Changes:
- Export
Keyboard,MouseButton, andMouseCursorconstants from thevectorjsmodule. - Implement keyboard/mouse query functions on the runtime
UpdateContextobject (isKeyPressed,getMousePosition, etc.). - Update the
solar2dexample to toggle/reset the simulation via keyboard input.
Reviewed changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/vectorjs.d.ts | Adds TS declarations for input enums and UpdateContext input methods. |
| src/api/js_utils.hpp | Updates object-property helpers to support enums in exported objects. |
| src/api/hostapi.hpp | Adds module exports for new input enum objects. |
| src/api/api_enums.cpp | Exports Raylib keyboard/mouse enums into JS as objects. |
| src/api/api_context.cpp | Builds an UpdateContext object with keyboard/mouse query functions. |
| examples/2d/solar2d.js | Demonstrates new keyboard input API to control simulation state. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
183
to
185
| template <typename T> | ||
| void set_object_property(JSContext* ctx, JSValueConst obj, const char* name, const T& val) { | ||
| void set_object_property(JSContext* ctx, JSValueConst obj, const char* name, const T& val) { | ||
| constexpr int flags = JS_PROP_ENUMERABLE | JS_PROP_CONFIGURABLE; |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
No description provided.