Build Argo V2 control mappings and telemetry dashboard
Add configurable Xbox motion and action bindings, frame-aware six-axis MAVLink controls, sensor logging, camera viewing and recording, and a faster startup path. Synchronize both app copies and document companion hardware setup and verification limits.
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
/* Synthetic Xbox input: no device, serial port, or browser is opened. */
|
||||
const assert=require('node:assert/strict');
|
||||
const input=require('../web/controller-input.js');
|
||||
const pad=()=>({connected:true,mapping:'standard',axes:[0,0,0,0],buttons:Array.from({length:17},()=>({value:0,pressed:false}))});
|
||||
const press=(pad,index,value=1)=>{pad.buttons[index]={value,pressed:value>.5};return pad};
|
||||
const three=input.preset(),six=input.preset('sixaxis');
|
||||
assert(input.validProfile(three));assert(input.validProfile(six));
|
||||
assert.deepEqual(input.read(pad(),three),Object.fromEntries(input.names.map(name=>[name,0])));
|
||||
assert.equal(input.read(press(pad(),1),three).vertical,1);
|
||||
assert.equal(input.read(press(pad(),0),three).vertical,-1);
|
||||
assert.equal(input.read(press(press(pad(),0),1),three).vertical,0);
|
||||
assert.equal(input.read(press(pad(),7),three).forward,1);
|
||||
assert.equal(input.read(press(pad(),6),three).forward,-1);
|
||||
assert.equal(input.read(press(press(pad(),6),7),three).forward,0);
|
||||
assert(input.read(press(pad(),7,.5),three).forward>0);
|
||||
assert(input.read(press(pad(),7,.5),three).forward<.5);
|
||||
let p=pad();p.axes[0]=1;p.axes[1]=-1;p.axes[2]=1;press(p,4);
|
||||
assert.deepEqual(input.read(p,six),{forward:0,lateral:1,vertical:0,turn:1,pitch:-1,roll:-1});
|
||||
let custom=structuredClone(six);custom.bindings.vertical={negative:'button:12',positive:'button:13',scale:.25};
|
||||
assert.equal(input.read(press(pad(),13),custom).vertical,.25);
|
||||
custom.bindings.turn.scale=0;assert.equal(input.read(p,custom).turn,0);
|
||||
custom.bindings.pitch.negative='axis:90:-';assert.equal(input.read(p,custom),null);
|
||||
assert.equal(input.read({...pad(),connected:false},three),null);
|
||||
p=pad();p.axes[0]=NaN;assert.equal(input.read(p,three),null);
|
||||
p=pad();p.buttons=[];assert.equal(input.read(p,three),null);
|
||||
assert.equal(input.actions(press(pad(),2),three).lights,true);
|
||||
assert.equal(input.migrate({turn:0,forward:1,vertical:3,invertForward:true,invertVertical:true,deadZone:.1}).bindings.forward.positive,'axis:1:-');
|
||||
const duplicate=structuredClone(three);duplicate.bindings.forward.negative='button:7';assert.equal(input.validProfile(duplicate),false);
|
||||
console.log('PASS: Xbox triggers, B/A, cancellation, six axes, custom buttons, limits, invalid devices, migration and actions.');
|
||||
Reference in New Issue
Block a user