‹›
Utility Scripts · Physical Controls

Values and Output Mapping

Separate a mechanism's physical position from the value range your game needs.

ItemMeaning / default
get_value()Button, Lever, Pedal, Slider, Knob, Pull Handle: 0..1. Wheel/Crank: phase [0,1).
get_value(axis) / get_values()Joystick: axis 0=X, 1=Y; pair {x,y} in the unit disc.
get_output_value(axis=undefined)One value after mapping and inversion; Joystick requires an axis.
get_output_values()Joystick only: mapped pair {x,y}.

Scalar mapping uses u=get_value(); joystick first converts each component with u=(value+1)/2. With inverted:true, u becomes 1−u and the result corresponds to min+(max−min)×u. Min/max may be negative, equal or reversed, but must be finite. The implementation also handles finite endpoints whose direct difference would overflow.

Example#

GML
knob = jolt_control_knob({output: {min: 0, max: 100}});
knob.set_output_range(20, 80);
knob.set_inverted(true);
var mapped = knob.get_output_value();
var mapping = knob.get_output_config();
var inverted = knob.is_inverted();

stick = jolt_control_joystick();
stick.set_output_range(-100, 100, 0);
stick.set_inverted(true, 1);
var xy = stick.get_output_values();

get_output_config() returns a fresh copy of {min,max,inverted}, or {x:{…},y:{…}} for joystick. The factory accepts shared output:{min,max,inverted} as the fallback for axes without their own struct. If output.x or output.y is supplied, its omitted fields use the standard −1, 1, false defaults.

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 / ownerSignatureOperation contract
JoltControl.get_output_configJoltControl.get_output_config()Finite min/max may be reversed or equal; inverted strict Boolean. Joystick axis0/1. Setters Boolean; is_inverted also false on error; config copies min/max/inverted (joystick x/y), undefined on error.
JoltControl.get_output_valueJoltControl.get_output_value(axis=undefined)Gameplay mapping into output min/max with optional inversion. Joystick requires axis or get_output_values {x, y}; errors undefined. Does not change physical targets or ranges.
JoltControl.get_output_valuesJoltControl.get_output_values()Gameplay mapping into output min/max with optional inversion. Joystick requires axis or get_output_values {x, y}; errors undefined. Does not change physical targets or ranges.
JoltControl.get_valueJoltControl.get_value(axis=undefined)Ordinary control normalized0..1; Wheel/Crank phase; Joystick -1..1 with required axis0(X)/1(Y). get_values joystick only → {x, y}; errors undefined.
JoltControl.get_valuesJoltControl.get_values()Ordinary control normalized0..1; Wheel/Crank phase; Joystick -1..1 with required axis0(X)/1(Y). get_values joystick only → {x, y}; errors undefined.
JoltControl.is_invertedJoltControl.is_inverted(axis=undefined)Finite min/max may be reversed or equal; inverted strict Boolean. Joystick axis0/1. Setters Boolean; is_inverted also false on error; config copies min/max/inverted (joystick x/y), undefined on error.
JoltControl.set_invertedJoltControl.set_inverted(enabled,axis=undefined)Finite min/max may be reversed or equal; inverted strict Boolean. Joystick axis0/1. Setters Boolean; is_inverted also false on error; config copies min/max/inverted (joystick x/y), undefined on error.
JoltControl.set_output_rangeJoltControl.set_output_range(minimum,maximum,axis=undefined)Finite min/max may be reversed or equal; inverted strict Boolean. Joystick axis0/1. Setters Boolean; is_inverted also false on error; config copies min/max/inverted (joystick x/y), undefined on error.