Detect if the controller is connected via USB

This commit is contained in:
dualshock-tools 2024-05-30 16:04:48 +02:00
parent 9e48207fcc
commit 5f7480e028
14 changed files with 113 additions and 73 deletions

140
core.js
View File

@ -9,15 +9,16 @@ var lang_disabled = true;
var gj = 0; var gj = 0;
var gu = 0; var gu = 0;
// Alphabetical order
var available_langs = { var available_langs = {
"bg_bg": { "name": "Български", "file": "bg_bg.json"}, "bg_bg": { "name": "Български", "file": "bg_bg.json"},
"de_de": { "name": "Deutsch", "file": "de_de.json"}, "de_de": { "name": "Deutsch", "file": "de_de.json"},
"pl_pl": { "name": "Polski", "file": "pl_pl.json"},
"es_es": { "name": "Español", "file": "es_es.json"}, "es_es": { "name": "Español", "file": "es_es.json"},
"fr_fr": { "name": "Français", "file": "fr_fr.json"}, "fr_fr": { "name": "Français", "file": "fr_fr.json"},
"hu_hu": { "name": "Magyar", "file": "hu_hu.json"}, "hu_hu": { "name": "Magyar", "file": "hu_hu.json"},
"it_it": { "name": "Italiano", "file": "it_it.json"}, "it_it": { "name": "Italiano", "file": "it_it.json"},
"jp_jp": { "name": "日本語", "file": "jp_jp.json"}, "jp_jp": { "name": "日本語", "file": "jp_jp.json"},
"pl_pl": { "name": "Polski", "file": "pl_pl.json"},
"pt_br": { "name": "Português do Brasil", "file": "pt_br.json"}, "pt_br": { "name": "Português do Brasil", "file": "pt_br.json"},
"ru_ru": { "name": "Русский", "file": "ru_ru.json"}, "ru_ru": { "name": "Русский", "file": "ru_ru.json"},
"tr_tr": { "name": "Türkçe", "file": "tr_tr.json"}, "tr_tr": { "name": "Türkçe", "file": "tr_tr.json"},
@ -770,6 +771,8 @@ async function disconnect() {
$("#offlinebar").show(); $("#offlinebar").show();
$("#onlinebar").hide(); $("#onlinebar").hide();
$("#mainmenu").hide(); $("#mainmenu").hide();
$("#d-nvstatus").text = l("Unknown");
$("#d-bdaddr").text = l("Unknown");
close_calibrate_window(); close_calibrate_window();
} }
@ -857,6 +860,85 @@ function alloc_req(id, data=[]) {
return out; return out;
} }
async function continue_connection(report) {
try {
device.oninputreport = null;
var reportLen = report.data.byteLength;
var connected = false;
// Detect if the controller is connected via USB
if(reportLen != 63) {
$("#btnconnect").prop("disabled", false);
$("#connectspinner").hide();
show_popup(l("Please connect the device using a USB cable."))
disconnect();
return;
}
if(device.productId == 0x05c4) {
if(await ds4_info()) {
connected = true;
mode = 1;
devname = l("Sony DualShock 4 V1");
}
} else if(device.productId == 0x09cc) {
if(await ds4_info()) {
connected = true;
mode = 1;
devname = l("Sony DualShock 4 V2");
}
} else if(device.productId == 0x0ce6) {
if(await ds5_info()) {
connected = true;
mode = 2;
devname = l("Sony DualSense");
}
} else if(device.productId == 0x0df2) {
if(await ds5_info()) {
connected = true;
mode = 0;
devname = l("Sony DualSense Edge");
disable_btn = true;
}
} else {
$("#btnconnect").prop("disabled", false);
$("#connectspinner").hide();
show_popup(l("Connected invalid device: ") + dec2hex(device.vendorId) + ":" + dec2hex(device.productId))
disconnect();
return;
}
if(connected) {
$("#devname").text(devname + " (" + dec2hex(device.vendorId) + ":" + dec2hex(device.productId) + ")");
$("#offlinebar").hide();
$("#onlinebar").show();
$("#mainmenu").show();
$("#resetBtn").show();
$("#d-nvstatus").text = l("Unknown");
$("#d-bdaddr").text = l("Unknown");
}
if(disable_btn) {
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."));
}
}
$(".ds-btn").prop("disabled", disable_btn);
$("#btnconnect").prop("disabled", false);
$("#connectspinner").hide();
} catch(error) {
$("#btnconnect").prop("disabled", false);
$("#connectspinner").hide();
show_popup(l("Error: ") + error);
return;
}
}
async function connect() { async function connect() {
gj = crypto.randomUUID(); gj = crypto.randomUUID();
la("begin"); la("begin");
@ -894,62 +976,8 @@ async function connect() {
device = devices[0] device = devices[0]
la("connect", {"p": device.productId, "v": device.vendorId}); la("connect", {"p": device.productId, "v": device.vendorId});
var connected = false device.oninputreport = continue_connection
if(device.productId == 0x05c4) {
if(await ds4_info()) {
connected = true
mode = 1;
devname = l("Sony DualShock 4 V1");
}
} else if(device.productId == 0x09cc) {
if(await ds4_info()) {
connected = true
mode = 1;
devname = l("Sony DualShock 4 V2");
}
} else if(device.productId == 0x0ce6) {
if(await ds5_info()) {
connected = true
mode = 2;
devname = l("Sony DualSense");
}
} else if(device.productId == 0x0df2) {
if(await ds5_info()) {
connected = true
mode = 0;
devname = l("Sony DualSense Edge");
disable_btn = true;
}
} else {
$("#btnconnect").prop("disabled", false);
$("#connectspinner").hide();
show_popup(l("Connected invalid device: ") + dec2hex(device.vendorId) + ":" + dec2hex(device.productId))
disconnect();
return;
}
if(connected) {
$("#devname").text(devname + " (" + dec2hex(device.vendorId) + ":" + dec2hex(device.productId) + ")");
$("#offlinebar").hide();
$("#onlinebar").show();
$("#mainmenu").show();
$("#resetBtn").show();
$("#d-nvstatus").text = l("Unknown");
$("#d-bdaddr").text = l("Unknown");
}
if(disable_btn) {
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."));
}
}
$(".ds-btn").prop("disabled", disable_btn);
$("#btnconnect").prop("disabled", false);
$("#connectspinner").hide();
} catch(error) { } catch(error) {
$("#btnconnect").prop("disabled", false); $("#btnconnect").prop("disabled", false);
$("#connectspinner").hide(); $("#connectspinner").hide();

View File

@ -457,7 +457,7 @@
<div class="container"> <div class="container">
<footer> <footer>
<div class="d-flex flex-column flex-sm-row justify-content-between py-4 my-4 border-top" id="footbody"> <div class="d-flex flex-column flex-sm-row justify-content-between py-4 my-4 border-top" id="footbody">
<p><span class="ds-i18n">Version</span> 0.9 (2024-04-25) - <a href="#" class="ds-i18n" onclick="show_donate_modal();">Support this project</a>&nbsp;<span id="authorMsg"></span></p> <p><span class="ds-i18n">Version</span> 1.0 (2024-05-30) - <a href="#" class="ds-i18n" onclick="show_donate_modal();">Support this project</a>&nbsp;<span id="authorMsg"></span></p>
<ul class="list-unstyled d-flex"> <ul class="list-unstyled d-flex">
<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>

View File

@ -154,12 +154,13 @@
"Ship me a controller you would love to add (send me an email for organization).": "Изпратете ми контролер, който бихте искали да добавите (изпратете ми имейл за организация).", "Ship me a controller you would love to add (send me an email for organization).": "Изпратете ми контролер, който бихте искали да добавите (изпратете ми имейл за организация).",
"Translate this website in your language": "Преведете този уебсайт на ваш език", "Translate this website in your language": "Преведете този уебсайт на ваш език",
", to help more people like you!": ", за да помогнете на повече хора като вас!", ", to help more people like you!": ", за да помогнете на повече хора като вас!",
"This website uses analytics to improve the service.": "Този уебсайт използва анализи за подобряване на услугата.",
"Board Model:": "", "Board Model:": "",
"This feature is experimental.": "", "This feature is experimental.": "",
"Please let me know if the board model of your controller is not detected correctly.": "", "Please let me know if the board model of your controller is not detected correctly.": "",
"Board model detection thanks to": "", "Board model detection thanks to": "",
"Please connect the device using a USB cable.": "",
"This website uses analytics to improve the service.": "Този уебсайт използва анализи за подобряване на услугата.",
"": "" "": ""
} }

View File

@ -154,12 +154,13 @@
"Ship me a controller you would love to add (send me an email for organization).": "Schicken Sie mir einen Controller, den Sie gerne hinzufügen möchten (senden Sie mir eine E-Mail zur Organisation).", "Ship me a controller you would love to add (send me an email for organization).": "Schicken Sie mir einen Controller, den Sie gerne hinzufügen möchten (senden Sie mir eine E-Mail zur Organisation).",
"Translate this website in your language": "Übersetzen Sie diese Website in Ihre Sprache", "Translate this website in your language": "Übersetzen Sie diese Website in Ihre Sprache",
", to help more people like you!": ", um mehr Menschen wie Sie zu helfen!", ", to help more people like you!": ", um mehr Menschen wie Sie zu helfen!",
"This website uses analytics to improve the service.": "Diese Website verwendet Analytics, um den Service zu verbessern.",
"Board Model:": "", "Board Model:": "",
"This feature is experimental.": "", "This feature is experimental.": "",
"Please let me know if the board model of your controller is not detected correctly.": "", "Please let me know if the board model of your controller is not detected correctly.": "",
"Board model detection thanks to": "", "Board model detection thanks to": "",
"Please connect the device using a USB cable.": "",
"This website uses analytics to improve the service.": "Diese Website verwendet Analytics, um den Service zu verbessern.",
"": "" "": ""
} }

View File

@ -154,12 +154,13 @@
"Ship me a controller you would love to add (send me an email for organization).": "Enviame un mando que te gustaria añadir (envia el email para organizar).", "Ship me a controller you would love to add (send me an email for organization).": "Enviame un mando que te gustaria añadir (envia el email para organizar).",
"Translate this website in your language": "Traduz esta web en tu idioma", "Translate this website in your language": "Traduz esta web en tu idioma",
", to help more people like you!": ", para que ayude mas personas como tu!", ", to help more people like you!": ", para que ayude mas personas como tu!",
"This website uses analytics to improve the service.": "Este sitio web utiliza análisis para mejorar el servicio.",
"Board Model:": "", "Board Model:": "",
"This feature is experimental.": "", "This feature is experimental.": "",
"Please let me know if the board model of your controller is not detected correctly.": "", "Please let me know if the board model of your controller is not detected correctly.": "",
"Board model detection thanks to": "", "Board model detection thanks to": "",
"Please connect the device using a USB cable.": "",
"This website uses analytics to improve the service.": "Este sitio web utiliza análisis para mejorar el servicio.",
"": "" "": ""
} }

View File

@ -154,12 +154,13 @@
"Ship me a controller you would love to add (send me an email for organization).": "", "Ship me a controller you would love to add (send me an email for organization).": "",
"Translate this website in your language": "", "Translate this website in your language": "",
", to help more people like you!": "", ", to help more people like you!": "",
"This website uses analytics to improve the service.": "Ce site utilise des analyses pour améliorer le service.",
"Board Model:": "", "Board Model:": "",
"This feature is experimental.": "", "This feature is experimental.": "",
"Please let me know if the board model of your controller is not detected correctly.": "", "Please let me know if the board model of your controller is not detected correctly.": "",
"Board model detection thanks to": "", "Board model detection thanks to": "",
"Please connect the device using a USB cable.": "",
"This website uses analytics to improve the service.": "Ce site utilise des analyses pour améliorer le service.",
"": "" "": ""
} }

View File

@ -154,12 +154,13 @@
"Ship me a controller you would love to add (send me an email for organization).": "Küldj a fejlesztőnek egy kontrollert, amelyet szívesen látnál a támogatott kontrollerek listájában (küldj e-mailt a fejlesztőnek).", "Ship me a controller you would love to add (send me an email for organization).": "Küldj a fejlesztőnek egy kontrollert, amelyet szívesen látnál a támogatott kontrollerek listájában (küldj e-mailt a fejlesztőnek).",
"Translate this website in your language": "Fordítsd le ezt a webhelyet a saját nyelvedre", "Translate this website in your language": "Fordítsd le ezt a webhelyet a saját nyelvedre",
", to help more people like you!": ", hogy több hozzád hasonló embernek segítsen!", ", to help more people like you!": ", hogy több hozzád hasonló embernek segítsen!",
"This website uses analytics to improve the service.": "Ez a weboldal analitikát használ a szolgáltatás javításához.",
"Board Model:": "Alaplap verzió", "Board Model:": "Alaplap verzió",
"This feature is experimental.": "Ez egy kisérleti funkció", "This feature is experimental.": "Ez egy kisérleti funkció",
"Please let me know if the board model of your controller is not detected correctly.": "Kérlek értesítsd a fejlesztőt, ha az alaplap verziója nem egyezik meg a felimert verzióval!", "Please let me know if the board model of your controller is not detected correctly.": "Kérlek értesítsd a fejlesztőt, ha az alaplap verziója nem egyezik meg a felimert verzióval!",
"Board model detection thanks to": "Az alaplapfelismerési funkciőért köszönet neki:", "Board model detection thanks to": "Az alaplapfelismerési funkciőért köszönet neki:",
"This website uses analytics to improve the service.": "Ez a weboldal analitikát használ a szolgáltatás javításához.", "Please connect the device using a USB cable.": "",
"": "" "": ""
} }

View File

@ -154,12 +154,13 @@
"Ship me a controller you would love to add (send me an email for organization).": "Spediscimi un controller che vorresti aggiungere (mandami un'email per l'organizzazione).", "Ship me a controller you would love to add (send me an email for organization).": "Spediscimi un controller che vorresti aggiungere (mandami un'email per l'organizzazione).",
"Translate this website in your language": "Traduci questo sito web nella tua lingua", "Translate this website in your language": "Traduci questo sito web nella tua lingua",
", to help more people like you!": ", per aiutare più persone come te!", ", to help more people like you!": ", per aiutare più persone come te!",
"This website uses analytics to improve the service.": "Questo sito web utilizza analytics per migliorare il servizio.",
"Board Model:": "Modello scheda:", "Board Model:": "Modello scheda:",
"This feature is experimental.": "Questa funzionalità è sperimentale.", "This feature is experimental.": "Questa funzionalità è sperimentale.",
"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.", "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", "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 website uses analytics to improve the service.": "Questo sito web utilizza analytics per migliorare il servizio.",
"": "" "": ""
} }

View File

@ -154,12 +154,13 @@
"Ship me a controller you would love to add (send me an email for organization).": "追加したいコントローラーを送ってください(組織のためにメールを送ってください)。", "Ship me a controller you would love to add (send me an email for organization).": "追加したいコントローラーを送ってください(組織のためにメールを送ってください)。",
"Translate this website in your language": "このウェブサイトをあなたの言語に翻訳する", "Translate this website in your language": "このウェブサイトをあなたの言語に翻訳する",
", to help more people like you!": "、あなたのような多くの人々を助けるために!", ", to help more people like you!": "、あなたのような多くの人々を助けるために!",
"This website uses analytics to improve the service.": "このウェブサイトはサービスを向上させるためにアナリティクスを使用しています。",
"Board Model:": "", "Board Model:": "",
"This feature is experimental.": "", "This feature is experimental.": "",
"Please let me know if the board model of your controller is not detected correctly.": "", "Please let me know if the board model of your controller is not detected correctly.": "",
"Board model detection thanks to": "", "Board model detection thanks to": "",
"Please connect the device using a USB cable.": "",
"This website uses analytics to improve the service.": "このウェブサイトはサービスを向上させるためにアナリティクスを使用しています。",
"": "" "": ""
} }

View File

@ -154,12 +154,13 @@
"Ship me a controller you would love to add (send me an email for organization).": "Wyślij mi kontroler, który chciałbyś dodać (wyślij mi e-mail do organizacji).", "Ship me a controller you would love to add (send me an email for organization).": "Wyślij mi kontroler, który chciałbyś dodać (wyślij mi e-mail do organizacji).",
"Translate this website in your language": "Przetłumacz tę stronę na swój język", "Translate this website in your language": "Przetłumacz tę stronę na swój język",
", to help more people like you!": ", aby pomóc większej ilości osób takich jak ty!", ", to help more people like you!": ", aby pomóc większej ilości osób takich jak ty!",
"This website uses analytics to improve the service.": "Ta strona korzysta z analiz w celu ulepszenia usług.",
"Board Model:": "Model płytki:", "Board Model:": "Model płytki:",
"This feature is experimental.": "Ta funkcja jest eksperymentalna.", "This feature is experimental.": "Ta funkcja jest eksperymentalna.",
"Please let me know if the board model of your controller is not detected correctly.": "Proszę daj mi znać jaki model płytki kontrolera nie został wykryty poprawnie", "Please let me know if the board model of your controller is not detected correctly.": "Proszę daj mi znać jaki model płytki kontrolera nie został wykryty poprawnie",
"Board model detection thanks to": "Podziękowania dla osoby która wykryła model płytki", "Board model detection thanks to": "Podziękowania dla osoby która wykryła model płytki",
"This website uses analytics to improve the service.": "Ta strona korzysta z analiz w celu ulepszenia usług.", "Please connect the device using a USB cable.": "",
"": "" "": ""
} }

View File

@ -154,12 +154,13 @@
"Ship me a controller you would love to add (send me an email for organization).": "Envie-me um controle que você adoraria adicionar (envie-me um e-mail para organização).", "Ship me a controller you would love to add (send me an email for organization).": "Envie-me um controle que você adoraria adicionar (envie-me um e-mail para organização).",
"Translate this website in your language": "Traduza este site para o seu idioma", "Translate this website in your language": "Traduza este site para o seu idioma",
", to help more people like you!": ", para ajudar mais pessoas como você!", ", to help more people like you!": ", para ajudar mais pessoas como você!",
"This website uses analytics to improve the service.": "Este site utiliza análises para melhorar o serviço.",
":": "", "Board Model:": "",
"This feature is experimental.": "", "This feature is experimental.": "",
"Please let me know if the board model of your controller is not detected correctly.": "", "Please let me know if the board model of your controller is not detected correctly.": "",
"Board model detection thanks to": "", "Board model detection thanks to": "",
"Please connect the device using a USB cable.": "",
"This website uses analytics to improve the service.": "Este site utiliza análises para melhorar o serviço.",
"": "" "": ""
} }

View File

@ -154,12 +154,13 @@
"Ship me a controller you would love to add (send me an email for organization).": "Отправьте мне контроллер, который вы хотели бы добавить (отправьте мне электронное письмо для организации).", "Ship me a controller you would love to add (send me an email for organization).": "Отправьте мне контроллер, который вы хотели бы добавить (отправьте мне электронное письмо для организации).",
"Translate this website in your language": "Переведите этот сайт на свой язык", "Translate this website in your language": "Переведите этот сайт на свой язык",
", to help more people like you!": ", чтобы помочь большему числу людей, подобных вам!", ", to help more people like you!": ", чтобы помочь большему числу людей, подобных вам!",
"This website uses analytics to improve the service.": "Этот сайт использует аналитику для улучшения сервиса.",
"Board Model:": "", "Board Model:": "",
"This feature is experimental.": "", "This feature is experimental.": "",
"Please let me know if the board model of your controller is not detected correctly.": "", "Please let me know if the board model of your controller is not detected correctly.": "",
"Board model detection thanks to": "", "Board model detection thanks to": "",
"Please connect the device using a USB cable.": "",
"This website uses analytics to improve the service.": "Этот сайт использует аналитику для улучшения сервиса.",
"": "" "": ""
} }

View File

@ -154,12 +154,13 @@
"Ship me a controller you would love to add (send me an email for organization).": "Eklemek istediğiniz bir denetleyiciyi var ise bana gönderin (organizasyon için bana bir e-posta gönderin).", "Ship me a controller you would love to add (send me an email for organization).": "Eklemek istediğiniz bir denetleyiciyi var ise bana gönderin (organizasyon için bana bir e-posta gönderin).",
"Translate this website in your language": "Bu web sitesini kendi dilinize çevirin", "Translate this website in your language": "Bu web sitesini kendi dilinize çevirin",
", to help more people like you!": ", sizin gibi daha fazla insanın faydalanması için!", ", to help more people like you!": ", sizin gibi daha fazla insanın faydalanması için!",
"This website uses analytics to improve the service.": "Bu web sitesi hizmeti iyileştirmek için analiz kullanıyor.",
"Board Model:": "", "Board Model:": "",
"This feature is experimental.": "", "This feature is experimental.": "",
"Please let me know if the board model of your controller is not detected correctly.": "", "Please let me know if the board model of your controller is not detected correctly.": "",
"Board model detection thanks to": "", "Board model detection thanks to": "",
"Please connect the device using a USB cable.": "",
"This website uses analytics to improve the service.": "Bu web sitesi hizmeti iyileştirmek için analiz kullanıyor.",
"": "" "": ""
} }

View File

@ -154,12 +154,13 @@
"Ship me a controller you would love to add (send me an email for organization).": "给我寄送一个您想添加的手柄(发送电子邮件给我进行安排)。", "Ship me a controller you would love to add (send me an email for organization).": "给我寄送一个您想添加的手柄(发送电子邮件给我进行安排)。",
"Translate this website in your language": "将这个网站翻译成您的语言", "Translate this website in your language": "将这个网站翻译成您的语言",
", to help more people like you!": "以帮助更多像您一样的人!", ", to help more people like you!": "以帮助更多像您一样的人!",
"This website uses analytics to improve the service.": "该网站使用分析工具来改善服务。",
"Board Model:": "主板型号", "Board Model:": "主板型号",
"This feature is experimental.": "此功能为实验性质。", "This feature is experimental.": "此功能为实验性质。",
"Please let me know if the board model of your controller is not detected correctly.": "如果您的手柄的主板型号没有被正确检测,请告诉我。", "Please let me know if the board model of your controller is not detected correctly.": "如果您的手柄的主板型号没有被正确检测,请告诉我。",
"Board model detection thanks to": "主板型号检测功能需要感谢", "Board model detection thanks to": "主板型号检测功能需要感谢",
"This website uses analytics to improve the service.": "该网站使用分析工具来改善服务。", "Please connect the device using a USB cable.": "",
"": "" "": ""
} }