Joystick
Joystick provides two tilt axes with a circular limit and locked twist.
jolt_control_joystick(options=undefined)Call jolt_start() before creation. Every factory accepts one optional options struct and returns JoltControl, or undefined on error. Common options: parent, position/rotation or local_position/local_rotation, mass, resistance and output. Dimensions are full lengths in metres, mass is in kg; this API uses degrees for angles. See Mounting, Size and Rendering for shared configuration.
| Item | Meaning / default |
|---|---|
| size | {radius:0.06, length:0.6} |
| mass / max_angle | 1 kg / 25° |
| auto_return / target | true / {x:0, y:0} |
| drive | {max_torque:10, frequency:5, damping:1} |
| detents / output | [] / {x:{min:-1,max:1,inverted:false}, y:{min:-1,max:1,inverted:false}} |
The rod extends from the pivot along +Z, right tilt is +X and forward tilt is +Y. max_angle must be strictly between 0 and 90°. get_values() returns {x,y}, get_value(0) reads X and get_value(1) reads Y. Both components are in −1..1 and vector length cannot exceed 1; diagonal {1,1} is therefore not a valid target or detent.
Example#
stick = jolt_control_joystick({
max_angle: 20,
output: {x: {min: -1, max: 1}, y: {min: -1, max: 1, inverted: true}}
});
var input = stick.get_output_values();
var steering = input.x;
var forward = input.y;set_target(x,y) uses the physical disc regardless of output. Automatic return is enabled by default and targets the centre. For a detented joystick, use auto_return:false and detents:[{x:0,y:0}, …]; detent zones are distances in this disc.
Current project integrations#
New related workflows#
Verified operation contracts#
These contracts distinguish units, return values, errors and lifetime according to the current implementation. Check results: false, 0 and undefined can mean different things for different methods.
| Symbol / owner | Signature | Operation contract |
|---|---|---|
| jolt_control_joystick | jolt_control_joystick(options=undefined) | Requires managed world, optional options, returns owning JoltControl or undefined. Without parent world position/rotation; with parent local_position/local_rotation, do not mix. Joystick: radius.06, length.6 m, mass1kg, max_angle25° in (0, 90), auto_return true, target{0, 0}, drive10N·m/5Hz/1; no pressed thresholds. |