From cbd6237ddd5cb4414f7a8530039d9d1209be0781 Mon Sep 17 00:00:00 2001 From: dualshock-tools Date: Sun, 2 Jun 2024 11:02:30 +0200 Subject: [PATCH] Add popup to update DualSense firmware if too old --- core.js | 102 +++++++++++++++++++++++++++++------------------- lang/bg_bg.json | 2 + lang/de_de.json | 2 + lang/es_es.json | 2 + lang/fr_fr.json | 2 + lang/hu_hu.json | 2 + lang/it_it.json | 2 + lang/jp_jp.json | 3 ++ lang/pl_pl.json | 3 ++ lang/pt_br.json | 3 ++ lang/ru_ru.json | 3 ++ lang/tr_tr.json | 3 ++ lang/zh_cn.json | 3 ++ 13 files changed, 91 insertions(+), 41 deletions(-) diff --git a/core.js b/core.js index 7b7a508..934b217 100644 --- a/core.js +++ b/core.js @@ -469,46 +469,59 @@ async function ds4_nvunlock() { } async function ds5_info() { - const view = lf("ds5_info", await device.receiveFeatureReport(0x20)); + try { + const view = lf("ds5_info", await device.receiveFeatureReport(0x20)); - var cmd = view.getUint8(0, true); - if(cmd != 0x20 || view.buffer.byteLength != 64) + var cmd = view.getUint8(0, true); + if(cmd != 0x20 || view.buffer.byteLength != 64) + return false; + + var build_date = new TextDecoder().decode(view.buffer.slice(1, 1+11)); + var build_time = new TextDecoder().decode(view.buffer.slice(12, 20)); + + var fwtype = view.getUint16(20, true); + var swseries = view.getUint16(22, true); + var hwinfo = view.getUint32(24, true); + var fwversion = view.getUint32(28, true); + + var deviceinfo = new TextDecoder().decode(view.buffer.slice(32, 32+12)); + var updversion = view.getUint16(44, true); + var unk = view.getUint16(46, true); + + var fwversion1 = view.getUint32(50, true); + var fwversion2 = view.getUint32(54, true); + var fwversion3 = view.getUint32(58, true); + + clear_info(); + + append_info(l("Build Date:"), build_date + " " + build_time); + append_info(l("Firmware Type:"), "0x" + dec2hex(fwtype)); + append_info(l("SW Series:"), "0x" + dec2hex(swseries)); + append_info(l("HW Info:"), "0x" + dec2hex32(hwinfo)); + append_info(l("SW Version:"), "0x" + dec2hex32(fwversion)); + append_info(l("UPD Version:"), "0x" + dec2hex(updversion)); + append_info(l("FW Version1:"), "0x" + dec2hex32(fwversion1)); + append_info(l("FW Version2:"), "0x" + dec2hex32(fwversion2)); + append_info(l("FW Version3:"), "0x" + dec2hex32(fwversion3)); + + b_info = ' ' + + ''; + append_info(l("Board Model:"), ds5_hw_to_bm(hwinfo) + b_info); + + old_controller = build_date.search(/ 2020| 2021/); + if(old_controller != -1) { + la("ds5_info_error", {"r": "old"}) + disable_btn = true; + return true; + } + + await ds5_nvstatus(); + await ds5_getbdaddr(); + } catch(e) { + la("ds5_info_error", {"r": e}) + show_popup(l("Cannot read controller information")); return false; - - var build_date = new TextDecoder().decode(view.buffer.slice(1, 1+11)); - var build_time = new TextDecoder().decode(view.buffer.slice(12, 20)); - - var fwtype = view.getUint16(20, true); - var swseries = view.getUint16(22, true); - var hwinfo = view.getUint32(24, true); - var fwversion = view.getUint32(28, true); - - var deviceinfo = new TextDecoder().decode(view.buffer.slice(32, 32+12)); - var updversion = view.getUint16(44, true); - var unk = view.getUint16(46, true); - - var fwversion1 = view.getUint32(50, true); - var fwversion2 = view.getUint32(54, true); - var fwversion3 = view.getUint32(58, true); - - clear_info(); - - append_info(l("Build Date:"), build_date + " " + build_time); - append_info(l("Firmware Type:"), "0x" + dec2hex(fwtype)); - append_info(l("SW Series:"), "0x" + dec2hex(swseries)); - append_info(l("HW Info:"), "0x" + dec2hex32(hwinfo)); - append_info(l("SW Version:"), "0x" + dec2hex32(fwversion)); - append_info(l("UPD Version:"), "0x" + dec2hex(updversion)); - append_info(l("FW Version1:"), "0x" + dec2hex32(fwversion1)); - append_info(l("FW Version2:"), "0x" + dec2hex32(fwversion2)); - append_info(l("FW Version3:"), "0x" + dec2hex32(fwversion3)); - - b_info = ' ' + - ''; - append_info(l("Board Model:"), ds5_hw_to_bm(hwinfo) + b_info); - - await ds5_nvstatus(); - await ds5_getbdaddr(); + } return true; } @@ -871,8 +884,8 @@ async function continue_connection(report) { if(reportLen != 63) { $("#btnconnect").prop("disabled", false); $("#connectspinner").hide(); - show_popup(l("Please connect the device using a USB cable.")) disconnect(); + show_popup(l("Please connect the device using a USB cable.")) return; } @@ -917,10 +930,18 @@ async function continue_connection(report) { $("#resetBtn").show(); $("#d-nvstatus").text = l("Unknown"); $("#d-bdaddr").text = l("Unknown"); + } else { + show_popup(l("Connected invalid device: ") + l("Error 1")); + $("#btnconnect").prop("disabled", false); + $("#connectspinner").hide(); + disconnect(); + return; } if(disable_btn) { - if(device.productId == 0x0df2) { + if(device.productId == 0x0ce6) { + show_popup(l("This DualSense controller has outdated firmware.") + "
" + l("Please update the firmware and try again."), true); + } else if(device.productId == 0x0df2) { show_popup(l("Calibration of the DualSense Edge is not currently supported.")); } else { show_popup(l("The device appears to be a DS4 clone. All functionalities are disabled.")); @@ -1370,5 +1391,4 @@ function lang_translate(target_file, target_lang) { } $("#curLang").html(available_langs[target_lang]["name"]); }); - } diff --git a/lang/bg_bg.json b/lang/bg_bg.json index b6ccb52..7c420a8 100644 --- a/lang/bg_bg.json +++ b/lang/bg_bg.json @@ -161,6 +161,8 @@ "Please let me know if the board model of your controller is not detected correctly.": "", "Board model detection thanks to": "", "Please connect the device using a USB cable.": "", + "This DualSense controller has outdated firmware.": "", + "Please update the firmware and try again.": "", "": "" } diff --git a/lang/de_de.json b/lang/de_de.json index ee6020b..a33661f 100644 --- a/lang/de_de.json +++ b/lang/de_de.json @@ -161,6 +161,8 @@ "Please let me know if the board model of your controller is not detected correctly.": "", "Board model detection thanks to": "", "Please connect the device using a USB cable.": "", + "This DualSense controller has outdated firmware.": "", + "Please update the firmware and try again.": "", "": "" } diff --git a/lang/es_es.json b/lang/es_es.json index 66ffae8..a5ea723 100644 --- a/lang/es_es.json +++ b/lang/es_es.json @@ -161,6 +161,8 @@ "Please let me know if the board model of your controller is not detected correctly.": "", "Board model detection thanks to": "", "Please connect the device using a USB cable.": "", + "This DualSense controller has outdated firmware.": "", + "Please update the firmware and try again.": "", "": "" } diff --git a/lang/fr_fr.json b/lang/fr_fr.json index 367789a..30129c0 100644 --- a/lang/fr_fr.json +++ b/lang/fr_fr.json @@ -161,6 +161,8 @@ "Please let me know if the board model of your controller is not detected correctly.": "", "Board model detection thanks to": "", "Please connect the device using a USB cable.": "", + "This DualSense controller has outdated firmware.": "", + "Please update the firmware and try again.": "", "": "" } diff --git a/lang/hu_hu.json b/lang/hu_hu.json index ad34767..0a11bfc 100644 --- a/lang/hu_hu.json +++ b/lang/hu_hu.json @@ -162,5 +162,7 @@ "Board model detection thanks to": "Az alaplapfelismerési funkciőért köszönet neki:", "Please connect the device using a USB cable.": "", + "This DualSense controller has outdated firmware.": "", + "Please update the firmware and try again.": "", "": "" } diff --git a/lang/it_it.json b/lang/it_it.json index a89d0fc..b06b08b 100644 --- a/lang/it_it.json +++ b/lang/it_it.json @@ -161,6 +161,8 @@ "Please let me know if the board model of your controller is not detected correctly.": "Scrivimi se il modello della scheda del tuo controller non viene riconosciuto correttamente.", "Board model detection thanks to": "Rilevamento del modello della scheda grazie a", "Please connect the device using a USB cable.": "Connetti il controller usando un cavo USB.", + "This DualSense controller has outdated firmware.": "Questo controller DualSense ha un firmware non aggiornato.", + "Please update the firmware and try again.": "Aggiorna il firmware e riprova.", "": "" } diff --git a/lang/jp_jp.json b/lang/jp_jp.json index a8a5a4a..1cbd3d7 100644 --- a/lang/jp_jp.json +++ b/lang/jp_jp.json @@ -161,6 +161,9 @@ "Please let me know if the board model of your controller is not detected correctly.": "", "Board model detection thanks to": "", "Please connect the device using a USB cable.": "", + "This DualSense controller has outdated firmware.": "", + "Please update the firmware and try again.": "", + "": "" } diff --git a/lang/pl_pl.json b/lang/pl_pl.json index 69ded57..9d3a218 100644 --- a/lang/pl_pl.json +++ b/lang/pl_pl.json @@ -162,5 +162,8 @@ "Board model detection thanks to": "Podziękowania dla osoby która wykryła model płytki", "Please connect the device using a USB cable.": "", + "This DualSense controller has outdated firmware.": "", + "Please update the firmware and try again.": "", + "": "" } diff --git a/lang/pt_br.json b/lang/pt_br.json index 8b09cb4..2713cff 100644 --- a/lang/pt_br.json +++ b/lang/pt_br.json @@ -161,6 +161,9 @@ "Please let me know if the board model of your controller is not detected correctly.": "", "Board model detection thanks to": "", "Please connect the device using a USB cable.": "", + "This DualSense controller has outdated firmware.": "", + "Please update the firmware and try again.": "", + "": "" } diff --git a/lang/ru_ru.json b/lang/ru_ru.json index ceef67c..10c9d2b 100644 --- a/lang/ru_ru.json +++ b/lang/ru_ru.json @@ -161,6 +161,9 @@ "Please let me know if the board model of your controller is not detected correctly.": "", "Board model detection thanks to": "", "Please connect the device using a USB cable.": "", + "This DualSense controller has outdated firmware.": "", + "Please update the firmware and try again.": "", + "": "" } diff --git a/lang/tr_tr.json b/lang/tr_tr.json index 4b71de5..be7aed9 100644 --- a/lang/tr_tr.json +++ b/lang/tr_tr.json @@ -161,6 +161,9 @@ "Please let me know if the board model of your controller is not detected correctly.": "", "Board model detection thanks to": "", "Please connect the device using a USB cable.": "", + "This DualSense controller has outdated firmware.": "", + "Please update the firmware and try again.": "", + "": "" } diff --git a/lang/zh_cn.json b/lang/zh_cn.json index 454581b..e35b10a 100644 --- a/lang/zh_cn.json +++ b/lang/zh_cn.json @@ -162,5 +162,8 @@ "Board model detection thanks to": "主板型号检测功能需要感谢", "Please connect the device using a USB cable.": "", + "This DualSense controller has outdated firmware.": "", + "Please update the firmware and try again.": "", + "": "" }