v0.5.0

Syncromesh routes SDL3 input through the Helix/Event system. Register listeners with Event.on(name, callback) in your bootstrap script. Mouse events include both screen-space and world-space coordinates (projected through the camera). You can also dispatch your own in-script events with Event.emit(name, payload) for local UI/action buses.

Import #

import * as Event from 'Helix/Event';

Custom events #

import * as Event from 'Helix/Event';

Event.on('ui:action', (payload) => {
    if (payload.type === 'burst') {
        // route to board-specific behavior
    }
});

Event.emit('ui:action', { type: 'burst', source: 'button' });

Mouse events #

These are global input events. UI elements can handle pointer input first via Helix/UserInterface callbacks such as onMouseDown, onMouseUp, and onMouseScroll; when an element-level handler consumes a button or scroll event, the corresponding global mouse event is not emitted.

mouseMove #

MouseMoveEvent
Fired on pointer movement.
  • event Point — Screen-space position { x, y }.
  • world Point optional — World-space position (if a window is active).

mouseDown #

MouseDownEvent
Fired on mouse button press.
  • event Point — Screen-space position { x, y }.
  • button number — Mouse button index.
  • world Point optional — World-space position.

mouseUp #

MouseUpEvent
Fired on mouse button release.
  • event Point — Screen-space position { x, y }.
  • button number — Mouse button index.
  • world Point optional — World-space position.

mouseScroll #

MouseScrollEvent
Fired on scroll wheel input.
  • event Point — Screen-space position { x, y }.
  • delta number — Scroll delta (positive = up/forward).
  • world Point optional — World-space position.

Keyboard events #

keyDown / keyUp #

KeyEvent
Fired on key press (keyDown) and release (keyUp).
  • code number — SDL scancode.
  • alt boolean — Whether Alt is held.
  • control boolean — Whether Control is held.
  • shift boolean — Whether Shift is held.

Window events #

closed #

Fired when a window close is requested. No event payload.

ready #

Fired after the engine has initialised and the bootstrap script has completed. Also fired after a RELOAD.

preRender #

Fired from the render pipeline when render_begin is reached. This event is coalesced behind a fence: it is only dispatched when the previous preRender callback is idle, and intermediate frames may be skipped.

PreRenderEvent
Render-begin callback payload.
  • windowId number — Window id currently rendering.
  • time number — Engine time in seconds for this render pass.
  • integration number — Render interpolation alpha supplied by the engine.

Examples #

import * as Event from 'Helix/Event';

Event.on('ready', () => {
    console.log('Engine ready');
});

Event.on('mouseDown', (e) => {
    console.log(`Click at screen ${e.event.x},${e.event.y}`);
    if (e.world) console.log(`World ${e.world.x},${e.world.y}`);
});

Event.on('keyDown', (e) => {
    if (e.code === 41) { // Escape
        // handle escape
    }
});

Event.on('closed', () => {
    Simulation.quit();
});