listEndpoints etc
This commit is contained in:
parent
33f8f61a14
commit
e0cd593338
12
common.js
12
common.js
|
|
@ -128,7 +128,17 @@ export async function connectDevice() {
|
|||
if (glasses) {
|
||||
return glasses;
|
||||
}
|
||||
return await requestDevice();
|
||||
return await requestDevice({
|
||||
filters: [{
|
||||
vendorId: 0x0486, // ? ASUS Computers Inc. ?
|
||||
}, {
|
||||
vendorId: 0x0483, // STMicroelectronics ?
|
||||
}, {
|
||||
vendorId: 0x0482, // Kyocera Corporation ?
|
||||
}, {
|
||||
vendorId: 0x3318, // Gleaming Reality (Wuxi) Technology Co., LTD ?
|
||||
}]
|
||||
});
|
||||
}
|
||||
|
||||
export async function disconnectDevice() {
|
||||
|
|
|
|||
12
index.html
12
index.html
|
|
@ -51,7 +51,17 @@
|
|||
// Request USB device
|
||||
let device;
|
||||
try {
|
||||
device = await navigator.usb.requestDevice({ filters: [{ vendorId: 0x2341 }] });
|
||||
device = await navigator.usb.requestDevice({
|
||||
filters: [{
|
||||
vendorId: 0x0486, // ? ASUS Computers Inc. ?
|
||||
}, {
|
||||
vendorId: 0x0483, // STMicroelectronics ?
|
||||
}, {
|
||||
vendorId: 0x0482, // Kyocera Corporation ?
|
||||
}, {
|
||||
vendorId: 0x3318, // Gleaming Reality (Wuxi) Technology Co., LTD ?
|
||||
}]
|
||||
});
|
||||
} catch (err) {
|
||||
console.error("No device was selected", err);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -71,6 +71,9 @@
|
|||
</head>
|
||||
<body>
|
||||
<div id="noSupportHid"></div>
|
||||
<div id="listEndpoints">
|
||||
<button onclick="listEndpoints()">list endpoints</button>
|
||||
</div>
|
||||
<div id="connect"><button>connect</button></div>
|
||||
<div id="disconnect" onclick="disconnectDevices()"><button>disconnect</button></div>
|
||||
<div id="startIMU" style="display: none;" onclick="startIMU()"><button>start headtracking</button></div>
|
||||
|
|
@ -320,8 +323,11 @@
|
|||
// });
|
||||
// }
|
||||
|
||||
window.connected_devices = [];
|
||||
|
||||
window.connect = function() {
|
||||
Common.connectDevice().then(async glasses => {
|
||||
connected_devices.push(glasses);
|
||||
if (glasses) {
|
||||
document.getElementById('startIMU').style.display = 'block'
|
||||
document.getElementById('hadConnect').style.display = 'block'
|
||||
|
|
@ -448,6 +454,11 @@
|
|||
});
|
||||
}
|
||||
|
||||
window.listEndpoints = () => {
|
||||
// Manager.listEndpoints(connected_devices[0]);
|
||||
window.listUsbEndpoints();
|
||||
}
|
||||
|
||||
window.disconnectDevices = () => {
|
||||
window.curGlassesArray.map(g=>{
|
||||
g._device.close();
|
||||
|
|
@ -457,10 +468,21 @@
|
|||
|
||||
window.endpoints = [];
|
||||
|
||||
window.listUsbEndpoints = () => {
|
||||
window.listUsbEndpoints = async () => {
|
||||
window.endpoints = [];
|
||||
// list usb endpoints
|
||||
navigator.usb.requestDevice({filters:[]}).then((device)=>{
|
||||
let device = await navigator.usb.requestDevice({
|
||||
filters: [{
|
||||
vendorId: 0x0486, // ? ASUS Computers Inc. ?
|
||||
}, {
|
||||
vendorId: 0x0483, // STMicroelectronics ?
|
||||
}, {
|
||||
vendorId: 0x0482, // Kyocera Corporation ?
|
||||
}, {
|
||||
vendorId: 0x3318, // Gleaming Reality (Wuxi) Technology Co., LTD ?
|
||||
}]
|
||||
})
|
||||
|
||||
window.usb_device = device;
|
||||
|
||||
//usb_device.configurations[0].interfaces[1].alternates[1].endpoints[0]
|
||||
|
|
@ -479,9 +501,11 @@
|
|||
}
|
||||
}
|
||||
|
||||
console.warn('CONNECTED TO DEVICE: ENDPOINTS:')
|
||||
console.table(window.endpoints);
|
||||
})
|
||||
|
||||
// new recursive debug printout:
|
||||
await Manager.listEndpoints(device)
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -134,6 +134,39 @@ export async function getFirmwareVersionInDsp() {
|
|||
});
|
||||
}
|
||||
|
||||
export async function listEndpoints(device) {
|
||||
await device.open();
|
||||
|
||||
// Listing available configurations valid for selection
|
||||
let configurations = device.configurations;
|
||||
for (let i = 0; i < configurations.length; i++) {
|
||||
console.log(`Configuration ${i}: ${configurations[i].configurationValue}`);
|
||||
|
||||
try{
|
||||
// Select the current configuration
|
||||
// Assuming the configuration is 0-based
|
||||
await device.selectConfiguration(i+1);
|
||||
|
||||
// Iterate over all available interfaces for the current configuration and claim them
|
||||
for (let j = 0; j < device.configuration.interfaces.length; j++) {
|
||||
try{
|
||||
await device.claimInterface(j);
|
||||
device.configuration.interfaces[j].alternates.forEach((alternate) => {
|
||||
console.log(`Configuration ${i}, iface ${j} Alternate ${alternate.alternateSetting}`);
|
||||
alternate.endpoints.forEach((endpoint) => {
|
||||
console.log(`Endpoint ${endpoint.endpointNumber} Direction ${endpoint.direction}`);
|
||||
});
|
||||
});
|
||||
}catch(e){
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
}catch(e){
|
||||
console.error(e)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Parameters required for the progress bar
|
||||
// function progress(cur, all) {
|
||||
// current = cur
|
||||
|
|
@ -183,8 +216,19 @@ async function waitBootDevice() {
|
|||
}
|
||||
// await requestDevice()
|
||||
|
||||
// await navigator.hid.requestDevice({
|
||||
// filters: [{ vendorId: Protocol.NREAL_VENDOR_ID, productId: Protocol.NREAL_BOOT_PRODUCT_ID }]
|
||||
// });
|
||||
await navigator.hid.requestDevice({
|
||||
filters: [{ vendorId: Protocol.NREAL_VENDOR_ID, productId: Protocol.NREAL_BOOT_PRODUCT_ID }]
|
||||
filters: [{
|
||||
vendorId: 0x0486, // ? ASUS Computers Inc. ?
|
||||
}, {
|
||||
vendorId: 0x0483, // STMicroelectronics ?
|
||||
}, {
|
||||
vendorId: 0x0482, // Kyocera Corporation ?
|
||||
}, {
|
||||
vendorId: 0x3318, // Gleaming Reality (Wuxi) Technology Co., LTD ?
|
||||
}]
|
||||
});
|
||||
const time = new Date().getTime();
|
||||
while ((new Date().getTime() - time) < 2000) {
|
||||
|
|
@ -489,6 +533,8 @@ async function sendFirmwareInDsp(glasses, data) {
|
|||
}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
// Delay synchronization program execution
|
||||
function sleep(delay) {
|
||||
return new Promise((resolve) => setTimeout(resolve, delay))
|
||||
|
|
@ -542,6 +588,32 @@ export async function stopIMU() {
|
|||
})
|
||||
}
|
||||
|
||||
export async function getDisplayMode(){
|
||||
let glasses = await common.connectDevice();
|
||||
if (!glasses) {
|
||||
return 'not found device';
|
||||
}
|
||||
return glasses.sendReportTimeout(Protocol.MESSAGES.R_DISPLAY_MODE)
|
||||
.then(report => {
|
||||
if (reportSuccess(report)) {
|
||||
return report.payload[0];
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
export async function setDisplayMode(mode){
|
||||
let glasses = await common.connectDevice();
|
||||
if (!glasses) {
|
||||
return 'not found device';
|
||||
}
|
||||
return glasses.sendReportTimeout(Protocol.MESSAGES.W_DISPLAY_MODE, [mode])
|
||||
.then(report => {
|
||||
if (reportSuccess(report)) {
|
||||
return report.payload[0];
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/** read air glassess Brightness */
|
||||
export async function getBrightness() {
|
||||
let glasses = await common.connectDevice();
|
||||
|
|
@ -549,7 +621,7 @@ export async function getBrightness() {
|
|||
return 'not found device';
|
||||
}
|
||||
// what's the chance the getBrightness is the same as setBrightness?
|
||||
return glasses.sendReportTimeout(Protocol.MESSAGES.W_BRIGHTNESS)
|
||||
return glasses.sendReportTimeout(Protocol.MESSAGES.R_BRIGHTNESS)
|
||||
.then(report => {
|
||||
if (reportSuccess(report)) {
|
||||
return report.payload;
|
||||
|
|
|
|||
|
|
@ -73,6 +73,12 @@ export const MESSAGES = {
|
|||
// R_IMU_DATA: 0x80,//IMU data
|
||||
// UNKNOWN_40: 0x40,//Unknown
|
||||
|
||||
R_DISPLAY_MODE: 0x7,//Read display mode
|
||||
W_DISPLAY_MODE: 0x08,//Write display mode
|
||||
|
||||
R_BRIGHTNESS: 0x0,//Read brightness
|
||||
W_BRIGHTNESS: 0x0,//Write brightness
|
||||
|
||||
W_TOGGLE_IMU: 0x19,
|
||||
W_CANCEL_ACTIVATION: 0x19,
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue