diff --git a/templates/dualsense/template.js b/templates/dualsense/template.js
index 2e34d47..0ece1bc 100644
--- a/templates/dualsense/template.js
+++ b/templates/dualsense/template.js
@@ -19,26 +19,41 @@ window.gamepad.TemplateClass = class DualSenseTemplate {
}
updateButton($button, button) {
- if (!$button.matches('.trigger') || !button) return;
- $button.style.setProperty('opacity', this.gamepad.useMeterTriggers ? 1 : `${button.value * 100}%`);
- $button.style.setProperty('clip-path', this.gamepad.useMeterTriggers ? `inset(${100 - button.value * 100}% 0px 0px 0pc)` : 'none');
+ if (!$button.matches(".trigger") || !button) return;
+ $button.style.setProperty(
+ "opacity",
+ this.gamepad.useMeterTriggers ? 1 : `${button.value * 100}%`,
+ );
+ $button.style.setProperty(
+ "clip-path",
+ this.gamepad.useMeterTriggers
+ ? `inset(${100 - button.value * 100}% 0px 0px 0pc)`
+ : "none",
+ );
}
updateAxis($axis, attribute, axis) {
- if (!$axis.matches('.stick')) return;
- if (attribute === 'data-axis-x') {
- $axis.style.setProperty('margin-left', `${axis * 25}px`);
+ if (!$axis.matches(".stick")) return;
+ if (attribute === "data-axis-x") {
+ $axis.style.setProperty("margin-left", `${axis * 25}px`);
this.updateRotate($axis);
}
- if (attribute === 'data-axis-y') {
- $axis.style.setProperty('margin-top', `${axis * 25}px`);
+ if (attribute === "data-axis-y") {
+ $axis.style.setProperty("margin-top", `${axis * 25}px`);
this.updateRotate($axis);
}
}
updateRotate($axis) {
- const rotateX = Number.parseFloat($axis.getAttribute('data-value-y') * 30);
- const rotateY = -Number.parseFloat($axis.getAttribute('data-value-x') * 30);
- $axis.style.setProperty('transform', `rotateX(${rotateX}deg) rotateY(${rotateY}deg)`);
+ const rotateX = Number.parseFloat(
+ $axis.getAttribute("data-value-y") * 30,
+ );
+ const rotateY = -Number.parseFloat(
+ $axis.getAttribute("data-value-x") * 30,
+ );
+ $axis.style.setProperty(
+ "transform",
+ `rotateX(${rotateX}deg) rotateY(${rotateY}deg)`,
+ );
}
};
diff --git a/templates/telemetry/template.css b/templates/telemetry/template.css
index e8ab925..8c70452 100644
--- a/templates/telemetry/template.css
+++ b/templates/telemetry/template.css
@@ -11,9 +11,9 @@
--white-color: white;
--main-bg-color: black;
--main-component-color: #333;
- --clutch-color: #2D64B9;
- --brake-color: #A52725;
- --throttle-color: #0CA818;
+ --clutch-color: #2d64b9;
+ --brake-color: #a52725;
+ --throttle-color: #0ca818;
}
#gamepad #telemetry:has(#steering:not([style*="display: none"])) {
@@ -26,7 +26,7 @@
box-sizing: border-box;
}
-#gamepad #telemetry>*+* {
+#gamepad #telemetry > * + * {
margin-left: 2px;
}
@@ -53,7 +53,7 @@
width: 30px;
}
-#gamepad #telemetry #meters .meter+.meter {
+#gamepad #telemetry #meters .meter + .meter {
margin-left: 2px;
}
@@ -133,7 +133,6 @@
text-align: center;
}
-
#wizard .wizard-options {
display: flex;
margin: auto;
diff --git a/templates/telemetry/template.js b/templates/telemetry/template.js
index 1eff37f..ee2da1e 100644
--- a/templates/telemetry/template.js
+++ b/templates/telemetry/template.js
@@ -3,7 +3,7 @@ window.gamepad.TemplateClass = class TelemetryTemplate {
* Instanciates a new telemetry template
*/
constructor() {
- this.AXES = ['clutch', 'brake', 'throttle', 'steering'];
+ this.AXES = ["clutch", "brake", "throttle", "steering"];
this.gamepad = window.gamepad;
this.loadSelectors();
@@ -33,7 +33,10 @@ window.gamepad.TemplateClass = class TelemetryTemplate {
* @returns {number}
*/
toPercentage(value, min, max) {
- return Math.max(0, Math.min(100, Math.round((value - min) * (100 / (max - min)))));
+ return Math.max(
+ 0,
+ Math.min(100, Math.round((value - min) * (100 / (max - min)))),
+ );
}
/**
@@ -46,7 +49,7 @@ window.gamepad.TemplateClass = class TelemetryTemplate {
*/
toDegrees(value, min, max) {
const percentage = this.toPercentage(value, min, max);
- return (this.angle) * (percentage - 50) / 100;
+ return (this.angle * (percentage - 50)) / 100;
}
/**
@@ -59,10 +62,11 @@ window.gamepad.TemplateClass = class TelemetryTemplate {
toAxisValue(gamepad, axis) {
const { type, index, min, max } = this[axis];
if (!type || !index) return null;
- const value = type === 'button'
- ? gamepad.buttons[index].value
- : gamepad.axes[index];
- return axis === 'steering'
+ const value =
+ type === "button"
+ ? gamepad.buttons[index].value
+ : gamepad.axes[index];
+ return axis === "steering"
? this.toDegrees(value, min, max)
: this.toPercentage(value, min, max);
}
@@ -71,49 +75,53 @@ window.gamepad.TemplateClass = class TelemetryTemplate {
* Loads the DOM selectors
*/
loadSelectors() {
- this.$telemetry = document.querySelector('#telemetry');
- this.$chart = this.$telemetry.querySelector('#chart');
- this.chartContext = this.$chart.getContext('2d');
- this.$meters = this.$telemetry.querySelector('#meters');
- this.$clutch = this.$telemetry.querySelector('#clutch');
- this.$clutchBar = this.$clutch.querySelector('.bar');
- this.$clutchValue = this.$clutch.querySelector('.value');
- this.$brake = this.$telemetry.querySelector('#brake');
- this.$brakeBar = this.$brake.querySelector('.bar');
- this.$brakeValue = this.$brake.querySelector('.value');
- this.$throttle = this.$telemetry.querySelector('#throttle');
- this.$throttleBar = this.$throttle.querySelector('.bar');
- this.$throttleValue = this.$throttle.querySelector('.value');
- this.$steering = this.$telemetry.querySelector('#steering');
- this.$steeringIndicator = this.$steering.querySelector('.indicator');
- this.$wizard = document.querySelector('#wizard');
- this.$wizardPreview = this.$wizard.querySelector('#wizard-preview');
- this.$wizardInstructions = this.$wizard.querySelector('#wizard-instructions');
+ this.$telemetry = document.querySelector("#telemetry");
+ this.$chart = this.$telemetry.querySelector("#chart");
+ this.chartContext = this.$chart.getContext("2d");
+ this.$meters = this.$telemetry.querySelector("#meters");
+ this.$clutch = this.$telemetry.querySelector("#clutch");
+ this.$clutchBar = this.$clutch.querySelector(".bar");
+ this.$clutchValue = this.$clutch.querySelector(".value");
+ this.$brake = this.$telemetry.querySelector("#brake");
+ this.$brakeBar = this.$brake.querySelector(".bar");
+ this.$brakeValue = this.$brake.querySelector(".value");
+ this.$throttle = this.$telemetry.querySelector("#throttle");
+ this.$throttleBar = this.$throttle.querySelector(".bar");
+ this.$throttleValue = this.$throttle.querySelector(".value");
+ this.$steering = this.$telemetry.querySelector("#steering");
+ this.$steeringIndicator = this.$steering.querySelector(".indicator");
+ this.$wizard = document.querySelector("#wizard");
+ this.$wizardPreview = this.$wizard.querySelector("#wizard-preview");
+ this.$wizardInstructions = this.$wizard.querySelector(
+ "#wizard-instructions",
+ );
}
/**
* Loads the params from the URL
*/
loadParams() {
- this.withChart = gamepad.getUrlParam('chart') !== 'false';
+ this.withChart = gamepad.getUrlParam("chart") !== "false";
this.chartColors = {
- clutch: '#2D64B9',
- brake: '#A52725',
- throttle: '#0CA818',
- }
- this.historyLength = +(gamepad.getUrlParam('history') || 5000);
- this.withMeters = gamepad.getUrlParam('meters') !== 'false';
- this.withSteering = gamepad.getUrlParam('steeringIndex') !== null;
- this.angle = gamepad.getUrlParam('angle') || 360;
- this.frequency = gamepad.getUrlParam('fps') || 60;
- for(const axis of this.AXES) {
+ clutch: "#2D64B9",
+ brake: "#A52725",
+ throttle: "#0CA818",
+ };
+ this.historyLength = +(gamepad.getUrlParam("history") || 5000);
+ this.withMeters = gamepad.getUrlParam("meters") !== "false";
+ this.withSteering = gamepad.getUrlParam("steeringIndex") !== null;
+ this.angle = gamepad.getUrlParam("angle") || 360;
+ this.frequency = gamepad.getUrlParam("fps") || 60;
+ for (const axis of this.AXES) {
this[axis] = {
- type: (gamepad.getUrlParam(`${axis}Type`) || 'axis').replace('axis', 'axe'),
+ type: (gamepad.getUrlParam(`${axis}Type`) || "axis").replace(
+ "axis",
+ "axe",
+ ),
index: gamepad.getUrlParam(`${axis}Index`),
min: gamepad.getUrlParam(`${axis}Min`) || -1,
max: gamepad.getUrlParam(`${axis}Max`) || 1,
};
-
}
}
@@ -131,7 +139,7 @@ window.gamepad.TemplateClass = class TelemetryTemplate {
if (!this.steering.index) {
this.$steering.remove();
} else {
- this.$telemetry.classList.add('with-steering');
+ this.$telemetry.classList.add("with-steering");
}
}
@@ -160,9 +168,16 @@ window.gamepad.TemplateClass = class TelemetryTemplate {
this.scaleChart();
const now = Date.now();
this.chartData = [];
- for (let index = 0; index < this.historyLength / this.interval; index++) {
- const timestamp = now - (this.historyLength - index * this.interval);
- const data = demo ? this.getDemoData() : { clutch: 0, brake: 0, throttle: 0 };
+ for (
+ let index = 0;
+ index < this.historyLength / this.interval;
+ index++
+ ) {
+ const timestamp =
+ now - (this.historyLength - index * this.interval);
+ const data = demo
+ ? this.getDemoData()
+ : { clutch: 0, brake: 0, throttle: 0 };
this.chartData.push({ timestamp, ...data });
}
}
@@ -187,7 +202,9 @@ window.gamepad.TemplateClass = class TelemetryTemplate {
if (!this.running) return;
const gamepad = this.gamepad.getActive();
- const [clutch, brake, throttle, steering] = this.AXES.map((axis) => this.toAxisValue(gamepad, axis));
+ const [clutch, brake, throttle, steering] = this.AXES.map((axis) =>
+ this.toAxisValue(gamepad, axis),
+ );
if (this.withChart) this.drawChart(clutch, brake, throttle);
if (this.withMeters) this.updateMeters(clutch, brake, throttle);
if (this.withSteering) this.updateSteering(steering);
@@ -202,10 +219,38 @@ window.gamepad.TemplateClass = class TelemetryTemplate {
* @returns {object}
*/
getDemoData() {
- const clutch = this.withClutch ? Math.max(0, Math.round(Math.sin(this.demoIndex / (1000 / this.interval)) * 100)) : 0;
- const brake = this.withBrake ? Math.max(0, Math.round(Math.sin(this.demoIndex / (1000 / this.interval) + 1.5) * 100)) : 0;
- const throttle = this.withThrottle ? Math.max(0, Math.round(Math.sin(this.demoIndex / (1000 / this.interval) + 3) * 100)) : 0;
- const steering = this.withSteering ? Math.round(Math.sin(this.demoIndex / (1000 / this.interval) + 3) * this.angle) : 0;
+ const clutch = this.withClutch
+ ? Math.max(
+ 0,
+ Math.round(
+ Math.sin(this.demoIndex / (1000 / this.interval)) * 100,
+ ),
+ )
+ : 0;
+ const brake = this.withBrake
+ ? Math.max(
+ 0,
+ Math.round(
+ Math.sin(this.demoIndex / (1000 / this.interval) + 1.5) *
+ 100,
+ ),
+ )
+ : 0;
+ const throttle = this.withThrottle
+ ? Math.max(
+ 0,
+ Math.round(
+ Math.sin(this.demoIndex / (1000 / this.interval) + 3) *
+ 100,
+ ),
+ )
+ : 0;
+ const steering = this.withSteering
+ ? Math.round(
+ Math.sin(this.demoIndex / (1000 / this.interval) + 3) *
+ this.angle,
+ )
+ : 0;
if (this.demoIndex++ > 10000) this.demoIndex = 0;
return { clutch, brake, throttle, steering };
}
@@ -256,14 +301,17 @@ window.gamepad.TemplateClass = class TelemetryTemplate {
chartContext.clearRect(0, 0, width, height);
for (const axis of this.AXES) {
- if (axis === 'steering') continue;
+ if (axis === "steering") continue;
chartContext.beginPath();
for (let index = 0; index < this.chartData.length; index++) {
const entry = this.chartData[index];
- const x = (entry.timestamp + this.historyLength - now) / this.historyLength * width;
- const y = (101 - (entry[axis] || 0)) * height / 100;
- chartContext[index === 0 ? 'moveTo' : 'lineTo'](x, y);
+ const x =
+ ((entry.timestamp + this.historyLength - now) /
+ this.historyLength) *
+ width;
+ const y = ((101 - (entry[axis] || 0)) * height) / 100;
+ chartContext[index === 0 ? "moveTo" : "lineTo"](x, y);
}
chartContext.strokeStyle = this.chartColors[axis];
@@ -280,10 +328,15 @@ window.gamepad.TemplateClass = class TelemetryTemplate {
* @param {number} steering
*/
updateMeters(clutch, brake, throttle) {
- for (const [axis, value] of Object.entries({ clutch, brake, throttle })) {
+ for (const [axis, value] of Object.entries({
+ clutch,
+ brake,
+ throttle,
+ })) {
if (value === null) continue;
this[`$${axis}Value`].innerHTML = value;
- this[`$${axis}Value`].style.opacity = `${Math.round(33 + (value / 1.5))}%`;
+ this[`$${axis}Value`].style.opacity =
+ `${Math.round(33 + value / 1.5)}%`;
this[`$${axis}Bar`].style.height = `${value}%`;
}
}
@@ -302,7 +355,9 @@ window.gamepad.TemplateClass = class TelemetryTemplate {
*/
setupWizard() {
this.interval = 1000 / 60;
- this.$wizardInstructions.querySelector('#wizard-preview').appendChild(this.$telemetry);
+ this.$wizardInstructions
+ .querySelector("#wizard-preview")
+ .appendChild(this.$telemetry);
this.withChart = true;
this.withMeters = true;
@@ -316,84 +371,107 @@ window.gamepad.TemplateClass = class TelemetryTemplate {
this.updateDemo();
const $inputs = {
- $clutchOption: this.$wizardInstructions.querySelector('#clutch-option'),
- $brakeOption: this.$wizardInstructions.querySelector('#brake-option'),
- $throttleOption: this.$wizardInstructions.querySelector('#throttle-option'),
- $steeringOption: this.$wizardInstructions.querySelector('#steering-option')
+ $clutchOption:
+ this.$wizardInstructions.querySelector("#clutch-option"),
+ $brakeOption:
+ this.$wizardInstructions.querySelector("#brake-option"),
+ $throttleOption:
+ this.$wizardInstructions.querySelector("#throttle-option"),
+ $steeringOption:
+ this.$wizardInstructions.querySelector("#steering-option"),
};
- const $chartOption = this.$wizardInstructions.querySelector('#chart-option');
- const $historyOption = this.$wizardInstructions.querySelector('#history-option');
- const $metersOption = this.$wizardInstructions.querySelector('#meters-option');
- const $steeringAngleOption = this.$wizardInstructions.querySelector('#steering-angle-option');
- const $fpsOption = this.$wizardInstructions.querySelector('[name=fps-option]');
+ const $chartOption =
+ this.$wizardInstructions.querySelector("#chart-option");
+ const $historyOption =
+ this.$wizardInstructions.querySelector("#history-option");
+ const $metersOption =
+ this.$wizardInstructions.querySelector("#meters-option");
+ const $steeringAngleOption = this.$wizardInstructions.querySelector(
+ "#steering-angle-option",
+ );
+ const $fpsOption =
+ this.$wizardInstructions.querySelector("[name=fps-option]");
- $inputs.$clutchOption.addEventListener('change', () => {
+ $inputs.$clutchOption.addEventListener("change", () => {
this.withClutch = $inputs.$clutchOption.checked;
if (this.withClutch) {
- this.$clutch.style.display = '';
+ this.$clutch.style.display = "";
} else {
- this.$clutch.style.display = 'none';
- for (const data of this.chartData) { data.clutch = 0; }
+ this.$clutch.style.display = "none";
+ for (const data of this.chartData) {
+ data.clutch = 0;
+ }
}
});
- $inputs.$brakeOption.addEventListener('change', () => {
+ $inputs.$brakeOption.addEventListener("change", () => {
this.withBrake = $inputs.$brakeOption.checked;
if (this.withBrake) {
- this.$brake.style.display = '';
+ this.$brake.style.display = "";
} else {
- this.$brake.style.display = 'none';
- for (const data of this.chartData) { data.brake = 0; }
+ this.$brake.style.display = "none";
+ for (const data of this.chartData) {
+ data.brake = 0;
+ }
}
});
- $inputs.$throttleOption.addEventListener('change', () => {
+ $inputs.$throttleOption.addEventListener("change", () => {
this.withThrottle = $inputs.$throttleOption.checked;
if (this.withThrottle) {
- this.$throttle.style.display = '';
+ this.$throttle.style.display = "";
} else {
- this.$throttle.style.display = 'none';
- for (const data of this.chartData) { data.throttle = 0; }
+ this.$throttle.style.display = "none";
+ for (const data of this.chartData) {
+ data.throttle = 0;
+ }
}
});
- $inputs.$steeringOption.addEventListener('change', () => {
+ $inputs.$steeringOption.addEventListener("change", () => {
this.withSteering = $inputs.$steeringOption.checked;
if (this.withSteering) {
- this.$steering.style.display = '';
+ this.$steering.style.display = "";
} else {
- this.$steering.style.display = 'none';
+ this.$steering.style.display = "none";
}
});
- $chartOption.addEventListener('change', () => {
+ $chartOption.addEventListener("change", () => {
this.withChart = $chartOption.checked;
if (this.withChart) {
- this.$chart.style.display = '';
+ this.$chart.style.display = "";
} else {
- this.$chart.style.display = 'none';
+ this.$chart.style.display = "none";
}
this.setupChart(true);
});
- $historyOption.addEventListener('change', () => {
+ $historyOption.addEventListener("change", () => {
this.historyLength = Number.parseInt($historyOption.value) * 1000;
this.setupChart(true);
});
- $metersOption.addEventListener('change', () => {
+ $metersOption.addEventListener("change", () => {
this.withMeters = $metersOption.checked;
if (this.withMeters) {
- this.$meters.style.display = '';
+ this.$meters.style.display = "";
} else {
- this.$meters.style.display = 'none';
+ this.$meters.style.display = "none";
}
this.setupChart(true);
});
- $steeringAngleOption.addEventListener('change', () => {
+ $steeringAngleOption.addEventListener("change", () => {
this.angle = $steeringAngleOption.value;
});
- $fpsOption.addEventListener('change', () => {
+ $fpsOption.addEventListener("change", () => {
this.interval = 1000 / Number.parseInt($fpsOption.value);
console.log(this.interval);
this.setupChart(true);
});
- return { $inputs, $chartOption, $historyOption, $metersOption, $steeringAngleOption, $fpsOption };
+ return {
+ $inputs,
+ $chartOption,
+ $historyOption,
+ $metersOption,
+ $steeringAngleOption,
+ $fpsOption,
+ };
}
/**
@@ -406,9 +484,10 @@ window.gamepad.TemplateClass = class TelemetryTemplate {
return new Promise((resolve) => {
const interval = window.setInterval(() => {
const gamepad = this.gamepad.getActive();
- const pressedButton = index !== undefined
- ? gamepad.buttons[index].pressed
- : gamepad.buttons.some((button) => button.pressed);
+ const pressedButton =
+ index !== undefined
+ ? gamepad.buttons[index].pressed
+ : gamepad.buttons.some((button) => button.pressed);
if (pressedButton) return;
window.clearInterval(interval);
resolve();
@@ -425,7 +504,9 @@ window.gamepad.TemplateClass = class TelemetryTemplate {
return new Promise((resolve) => {
const pressInterval = window.setInterval(() => {
const gamepad = this.gamepad.getActive();
- const index = gamepad.buttons.findIndex((button) => button.pressed);
+ const index = gamepad.buttons.findIndex(
+ (button) => button.pressed,
+ );
if (index === -1) return;
window.clearInterval(pressInterval);
const releaseInterval = window.setInterval(() => {
@@ -457,7 +538,10 @@ window.gamepad.TemplateClass = class TelemetryTemplate {
value = gamepad.axes[index];
return;
}
- if (referenceValue !== undefined && Math.abs(gamepad.axes[index] - referenceValue) < 0.5) {
+ if (
+ referenceValue !== undefined &&
+ Math.abs(gamepad.axes[index] - referenceValue) < 0.5
+ ) {
return;
}
if (Math.abs(gamepad.axes[index] - value) > 0.05) {
@@ -556,21 +640,25 @@ window.gamepad.TemplateClass = class TelemetryTemplate {
$historyOption,
$metersOption,
$steeringAngleOption,
- $fpsOption
+ $fpsOption,
} = this.setupWizard();
await this.waitButtonRelease();
await this.waitButtonClick();
return {
- ...this.AXES.reduce((options, axis) => Object.assign(
- options,
- { [`with${this.capitalize(axis)}`]: $inputs[`$${axis}Option`].checked }
- ), {}),
+ ...this.AXES.reduce(
+ (options, axis) =>
+ Object.assign(options, {
+ [`with${this.capitalize(axis)}`]:
+ $inputs[`$${axis}Option`].checked,
+ }),
+ {},
+ ),
chart: $chartOption.checked,
history: Number.parseInt($historyOption.value) * 1000,
meters: $metersOption.checked,
angle: $steeringAngleOption.value,
- fps: Number.parseInt($fpsOption.value)
+ fps: Number.parseInt($fpsOption.value),
};
}
@@ -586,16 +674,25 @@ window.gamepad.TemplateClass = class TelemetryTemplate {
return new Promise((resolve) => {
const interval = window.setInterval(async () => {
const gamepad = this.gamepad.getActive();
- const buttonIndex = ['button', undefined].includes(type)
- ? gamepad.buttons.findIndex((button, index) => button.pressed && Math.abs(button.value - before.buttons[index].value) > distance)
+ const buttonIndex = ["button", undefined].includes(type)
+ ? gamepad.buttons.findIndex(
+ (button, index) =>
+ button.pressed &&
+ Math.abs(
+ button.value - before.buttons[index].value,
+ ) > distance,
+ )
: -1;
- const axisIndex = ['axis', undefined].includes(type)
- ? gamepad.axes.findIndex((axis, index) => Math.abs(axis - before.axes[index]) > distance)
+ const axisIndex = ["axis", undefined].includes(type)
+ ? gamepad.axes.findIndex(
+ (axis, index) =>
+ Math.abs(axis - before.axes[index]) > distance,
+ )
: -1;
if (buttonIndex === -1 && axisIndex === -1) return;
window.clearInterval(interval);
resolve({
- type: buttonIndex === -1 ? 'axis' : 'button',
+ type: buttonIndex === -1 ? "axis" : "button",
index: buttonIndex === -1 ? axisIndex : buttonIndex,
});
}, 100);
@@ -613,7 +710,7 @@ window.gamepad.TemplateClass = class TelemetryTemplate {
Waiting for ${name} activity.
`;
const { type, index } = await this.detectActivity();
- if (type === 'button') {
+ if (type === "button") {
this.$wizardInstructions.innerHTML = `
Release the ${name} button.
`;
@@ -643,7 +740,7 @@ window.gamepad.TemplateClass = class TelemetryTemplate {
this.$wizardInstructions.innerHTML = `
Turn the steering axis all the way to the left.
`;
- const { index } = await this.detectActivity('axis', 0.2);
+ const { index } = await this.detectActivity("axis", 0.2);
const leftValue = await this.getAxisPush(index, 0);
this.$wizardInstructions.innerHTML = `
@@ -664,7 +761,7 @@ window.gamepad.TemplateClass = class TelemetryTemplate {
return Object.entries(options)
.filter(([, value]) => value !== undefined && value !== null)
.map(([key, value]) => `${key}=${value}`)
- .join('&');
+ .join("&");
}
/**
@@ -694,22 +791,35 @@ window.gamepad.TemplateClass = class TelemetryTemplate {
* @returns {Promise}
*/
async wizard() {
- this.$wizard.classList.add('active');
+ this.$wizard.classList.add("active");
const gamepad = this.gamepad.getActive();
- const { withClutch, withBrake, withThrottle, withSteering, chart, history, meters, angle, fps } = await this.askForOptions();
- const clutch = withClutch && await this.calibratePedal('clutch');
- const brake = withBrake && await this.calibratePedal('brake');
- const throttle = withThrottle && await this.calibratePedal('throttle');
- const steering = withSteering && await this.calibrateSteering();
+ const {
+ withClutch,
+ withBrake,
+ withThrottle,
+ withSteering,
+ chart,
+ history,
+ meters,
+ angle,
+ fps,
+ } = await this.askForOptions();
+ const clutch = withClutch && (await this.calibratePedal("clutch"));
+ const brake = withBrake && (await this.calibratePedal("brake"));
+ const throttle =
+ withThrottle && (await this.calibratePedal("throttle"));
+ const steering = withSteering && (await this.calibrateSteering());
window.location.href = [
`?gamepad=${gamepad.id}&type=telemetry`,
this.toOptionsParams({ chart, history, meters, angle, fps }),
- withClutch ? this.toPedalParams('clutch', clutch) : null,
- withBrake ? this.toPedalParams('brake', brake) : null,
- withThrottle ? this.toPedalParams('throttle', throttle) : null,
- withSteering ? this.toSteeringParams(steering) : null
- ].filter(e => e !== null).join('&');
+ withClutch ? this.toPedalParams("clutch", clutch) : null,
+ withBrake ? this.toPedalParams("brake", brake) : null,
+ withThrottle ? this.toPedalParams("throttle", throttle) : null,
+ withSteering ? this.toSteeringParams(steering) : null,
+ ]
+ .filter((e) => e !== null)
+ .join("&");
}
};
diff --git a/templates/xbox-one/template.html b/templates/xbox-one/template.html
index 0231256..3870584 100644
--- a/templates/xbox-one/template.html
+++ b/templates/xbox-one/template.html
@@ -22,8 +22,18 @@