mirror of
https://github.com/dualshock-tools/dualshock-tools.github.io.git
synced 2026-03-01 11:19:54 +03:00
Improve error handling for possible DS4 clones
This commit is contained in:
committed by
dualshock-tools
parent
c295cfa508
commit
e1141b25a7
@@ -304,7 +304,7 @@
|
|||||||
<footer class="fixed-bottom bg-body-tertiary border-top">
|
<footer class="fixed-bottom bg-body-tertiary border-top">
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="d-flex flex-column flex-sm-row justify-content-between py-3" id="footbody">
|
<div class="d-flex flex-column flex-sm-row justify-content-between py-3" id="footbody">
|
||||||
<p class="mb-0"><a target="_blank" href="https://github.com/dualshock-tools/dualshock-tools.github.io/commits/main/"><span class="ds-i18n">Version</span> 2.16 beta 9</a> (2025-09-11) - <a href="#" class="ds-i18n" onclick="show_donate_modal();">Support this project</a> <span id="authorMsg"></span></p>
|
<p class="mb-0"><a target="_blank" href="https://github.com/dualshock-tools/dualshock-tools.github.io/commits/main/"><span class="ds-i18n">Version</span> 2.16 beta 10</a> (2025-09-17) - <a href="#" class="ds-i18n" onclick="show_donate_modal();">Support this project</a> <span id="authorMsg"></span></p>
|
||||||
|
|
||||||
<ul class="list-unstyled d-flex mb-0">
|
<ul class="list-unstyled d-flex mb-0">
|
||||||
<li class="ms-3"><a class="link-body-emphasis" href="mailto:ds4@the.al" target="_blank"><svg class="bi" width="24" height="24"><use xlink:href="#mail"/></svg></a></li>
|
<li class="ms-3"><a class="link-body-emphasis" href="mailto:ds4@the.al" target="_blank"><svg class="bi" width="24" height="24"><use xlink:href="#mail"/></svg></a></li>
|
||||||
|
|||||||
@@ -158,9 +158,8 @@ class ControllerManager {
|
|||||||
* Flash/save changes to the controller
|
* Flash/save changes to the controller
|
||||||
*/
|
*/
|
||||||
async flash(progressCallback = null) {
|
async flash(progressCallback = null) {
|
||||||
const result = await this.currentController.flash(progressCallback);
|
|
||||||
this.setHasChangesToWrite(false);
|
this.setHasChangesToWrite(false);
|
||||||
return result;
|
return this.currentController.flash(progressCallback);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -197,7 +196,7 @@ class ControllerManager {
|
|||||||
async calibrateSticksBegin() {
|
async calibrateSticksBegin() {
|
||||||
const res = await this.currentController.calibrateSticksBegin();
|
const res = await this.currentController.calibrateSticksBegin();
|
||||||
if (!res.ok) {
|
if (!res.ok) {
|
||||||
throw new Error(this.l("Stick calibration failed"), { cause: res.error });
|
throw new Error(`${this.l("Stick calibration failed")}. ${res.error?.message}`, { cause: res.error });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -229,9 +228,9 @@ class ControllerManager {
|
|||||||
* Begin stick range calibration (for UI-driven calibration)
|
* Begin stick range calibration (for UI-driven calibration)
|
||||||
*/
|
*/
|
||||||
async calibrateRangeBegin() {
|
async calibrateRangeBegin() {
|
||||||
const ret = await this.currentController.calibrateRangeBegin();
|
const res = await this.currentController.calibrateRangeBegin();
|
||||||
if (!ret.ok) {
|
if (!res.ok) {
|
||||||
throw new Error(this.l("Range calibration failed"), { cause: ret.error } );
|
throw new Error(`${this.l("Stick calibration failed")}. ${res.error?.message}`, { cause: res.error });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,8 @@ import {
|
|||||||
la
|
la
|
||||||
} from '../utils.js';
|
} from '../utils.js';
|
||||||
|
|
||||||
|
const NOT_GENUINE_SONY_CONTROLLER_MSG = "Your device might not be a genuine Sony controller. If it is not a clone then please report this issue.";
|
||||||
|
|
||||||
// DS4 Button mapping configuration
|
// DS4 Button mapping configuration
|
||||||
const DS4_BUTTON_MAP = [
|
const DS4_BUTTON_MAP = [
|
||||||
{ name: 'up', byte: 4, mask: 0x0 }, // Dpad handled separately
|
{ name: 'up', byte: 4, mask: 0x0 }, // Dpad handled separately
|
||||||
@@ -175,10 +177,14 @@ class DS4Controller extends BaseController {
|
|||||||
// Assert
|
// Assert
|
||||||
const data = await this.receiveFeatureReport(0x91);
|
const data = await this.receiveFeatureReport(0x91);
|
||||||
const data2 = await this.receiveFeatureReport(0x92);
|
const data2 = await this.receiveFeatureReport(0x92);
|
||||||
const [d1, d2] = [data, data2].map(v => v.getUint32(0, false));
|
const [d1, d2] = [data, data2].map(v => v.buffer.byteLength == 4 ? v.getUint32(0, false) : undefined);
|
||||||
if(d1 != 0x91010201 || d2 != 0x920102ff) {
|
if(d1 != 0x91010201 || d2 != 0x920102ff) {
|
||||||
la("ds4_calibrate_range_begin_failed", {"d1": d1, "d2": d2});
|
la("ds4_calibrate_range_begin_failed", {"d1": d1, "d2": d2});
|
||||||
return { ok: false, code: 1, d1, d2 };
|
return {
|
||||||
|
ok: false,
|
||||||
|
error: new Error(this.l(NOT_GENUINE_SONY_CONTROLLER_MSG)),
|
||||||
|
code: 1, d1, d2
|
||||||
|
};
|
||||||
}
|
}
|
||||||
return { ok: true };
|
return { ok: true };
|
||||||
} catch(error) {
|
} catch(error) {
|
||||||
@@ -219,10 +225,14 @@ class DS4Controller extends BaseController {
|
|||||||
// Assert
|
// Assert
|
||||||
const data = await this.receiveFeatureReport(0x91);
|
const data = await this.receiveFeatureReport(0x91);
|
||||||
const data2 = await this.receiveFeatureReport(0x92);
|
const data2 = await this.receiveFeatureReport(0x92);
|
||||||
const [d1, d2] = [data, data2].map(v => v.getUint32(0, false));
|
const [d1, d2] = [data, data2].map(v => v.buffer.byteLength == 4 ? v.getUint32(0, false) : undefined);
|
||||||
if(d1 != 0x91010101 || d2 != 0x920101ff) {
|
if(d1 != 0x91010101 || d2 != 0x920101ff) {
|
||||||
la("ds4_calibrate_sticks_begin_failed", {"d1": d1, "d2": d2});
|
la("ds4_calibrate_sticks_begin_failed", {"d1": d1, "d2": d2});
|
||||||
return { ok: false, code: 1, d1, d2 };
|
return {
|
||||||
|
ok: false,
|
||||||
|
error: new Error(this.l(NOT_GENUINE_SONY_CONTROLLER_MSG)),
|
||||||
|
code: 1, d1, d2,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
return { ok: true };
|
return { ok: true };
|
||||||
|
|||||||
11
js/core.js
11
js/core.js
@@ -298,6 +298,8 @@ async function disconnect() {
|
|||||||
}
|
}
|
||||||
app.gj = 0;
|
app.gj = 0;
|
||||||
app.disable_btn = 0;
|
app.disable_btn = 0;
|
||||||
|
update_disable_btn();
|
||||||
|
|
||||||
await controller.disconnect();
|
await controller.disconnect();
|
||||||
controller = null; // Tear everything down
|
controller = null; // Tear everything down
|
||||||
close_all_modals();
|
close_all_modals();
|
||||||
@@ -724,9 +726,14 @@ function handleNvStatusUpdate(nv) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function flash_all_changes() {
|
async function flash_all_changes() {
|
||||||
// For DS5 Edge controllers, pass the progress callback
|
const isEdge = controller.getModel() == "DS5_Edge";
|
||||||
const progressCallback = controller.getModel() == "DS5_Edge" ? set_edge_progress : null;
|
const progressCallback = isEdge ? set_edge_progress : null;
|
||||||
|
const edgeProgressModal = isEdge ? bootstrap.Modal.getOrCreateInstance('#edgeProgressModal') : null;
|
||||||
|
edgeProgressModal?.show();
|
||||||
|
|
||||||
const result = await controller.flash(progressCallback);
|
const result = await controller.flash(progressCallback);
|
||||||
|
edgeProgressModal?.hide();
|
||||||
|
|
||||||
if (result?.success) {
|
if (result?.success) {
|
||||||
if(result.isHtml) {
|
if(result.isHtml) {
|
||||||
show_popup(result.message, result.isHtml);
|
show_popup(result.message, result.isHtml);
|
||||||
|
|||||||
Reference in New Issue
Block a user