corsair_test2.js aktualisiert

This commit is contained in:
s-mendyka 2024-08-30 21:08:50 +02:00
parent 2101d23ba3
commit e2e97993e6

View File

@ -4,6 +4,7 @@ export function ProductId() { return Object.keys(CORSAIRdeviceLibrary.PIDLibrary
export function Publisher() { return "WhirlwindFx"; }
export function Documentation(){ return "troubleshooting/corsair"; }
export function Size() { return [1, 1]; }
export function DeviceType(){return "headphones";}
/* global
LightingMode:readonly
forcedColor:readonly
@ -14,11 +15,11 @@ SidetoneAmount:readonly
*/
export function ControllableParameters() {
return [
{"property":"LightingMode", "group":"lighting", "label":"Lighting Mode", "type":"combobox", "values":["Canvas", "Forced"], "default":"Canvas"},
{"property":"forcedColor", "group":"lighting", "label":"Forced Color", "min":"0", "max":"360", "type":"color", "default":"#009bde"},
{"property":"micLedMode", "group":"lighting", "label":"Microphone LED Mode", "type":"combobox", "values":["Canvas", "MuteState"], "default":"Canvas"},
{"property":"micMuteColor", "group":"lighting", "label":"Microphone Mute Color", "min":"0", "max":"360", "type":"color", "default":"#ff0000"},
{"property":"SidetoneAmount", "group":"", "label":"Sidetone", "step":"1", "type":"number", "min":"0", "max":"100", "default":"0"},
{"property":"LightingMode", "group":"lighting", "label":"Lighting Mode", description: "Determines where the device's RGB comes from. Canvas will pull from the active Effect, while Forced will override it to a specific color", "type":"combobox", "values":["Canvas", "Forced"], "default":"Canvas"},
{"property":"forcedColor", "group":"lighting", "label":"Forced Color", description: "The color used when 'Forced' Lighting Mode is enabled", "min":"0", "max":"360", "type":"color", "default":"#009bde"},
{"property":"micLedMode", "group":"lighting", "label":"Microphone LED Mode", description: "Sets the microphone LED behavior", "type":"combobox", "values":["Canvas", "MuteState"], "default":"Canvas"},
{"property":"micMuteColor", "group":"lighting", "label":"Microphone Mute Color", description: "Sets the microphone LED color when on mute while 'Microphone LED Mode' is set to 'MuteState'", "min":"0", "max":"360", "type":"color", "default":"#ff0000"},
{"property":"SidetoneAmount", "group":"", "label":"Sidetone", description: "Sets the sidetone level amount", "step":"1", "type":"number", "min":"0", "max":"100", "default":"0"},
];
}
@ -71,13 +72,19 @@ export class CORSAIR_Device_Protocol {
};
this.chargingStates = Object.freeze({
1: "Charging",
2: "Discharging",
3: "Fully Charged",
});
this.chargingStateDictionary = Object.freeze({
1 : 2,
2 : 1,
3 : 4
});
}
getDeviceProperties(deviceID) { return CORSAIRdeviceLibrary.LEDLibrary[deviceID];};
getDeviceProperties(deviceID) { return CORSAIRdeviceLibrary.PIDLibrary[deviceID];};
getDeviceProductId() { return this.Config.DeviceProductID; }
setDeviceProductId(productID) { this.Config.DeviceProductID = productID; }
@ -203,6 +210,30 @@ export class CORSAIR_Device_Protocol {
device.write([0x02, headsetMode, 0x06, 0x00, 0x09, 0x00, 0x00, 0x00].concat(RGBData), 64);
}
fetchProps(){
if(Date.now() - this.Config.lastMicStatePolling < this.Config.pollingInterval) {
}
const headsetMode = this.getWirelessSupport() === true ? 0x09 : 0x08;
const endpoint = this.getDeviceEndpoint();
device.set_endpoint(endpoint[`interface`], endpoint[`usage`], endpoint[`usage_page`]);
const propsDict = [0x0E, 0x4B, 0x55, 0x5A, 0x66, 0x67, 0x68, 0x78];
for(let i = 0; i < propsDict.length; i++){
const micStatusPacket = [0x02, headsetMode, 0x02, propsDict[i]];
device.pause(100);
device.clearReadBuffer();
device.write(micStatusPacket, 64);
device.pause(50);
console.log(`Result for ${propsDict[i]}: ` + device.read(micStatusPacket, 64));
}
}
fetchMicStatus(){
if(Date.now() - this.Config.lastMicStatePolling < this.Config.pollingInterval) {
@ -243,7 +274,7 @@ export class CORSAIR_Device_Protocol {
const sidetoneValue = Math.round((SidetoneAmount / 100) * 1000);
console.log("Setting Sidetone!");
console.log("Setting Sidetone to: " + SidetoneAmount);
device.write([0x02, headsetMode, 0x01, 0x47, 0x00, sidetoneValue & 0xFF, (sidetoneValue >> 8) & 0xFF], 64);
}
@ -314,7 +345,7 @@ export class CORSAIR_Device_Protocol {
device.log(`Battery Status is [${this.chargingStates[batteryStatus ?? 0]}]`);
battery.setBatteryLevel((batteryLevel ?? 0)/ 10);
battery.setBatteryState(this.chargingStates[batteryStatus ?? 0]);
battery.setBatteryState(this.chargingStateDictionary[batteryStatus ?? 0]);
}
ReadInt32LittleEndian(array){
@ -325,38 +356,18 @@ export class CORSAIR_Device_Protocol {
export class deviceLibrary {
constructor(){
this.PIDLibrary = {
0x0A41: "Virtuoso", // Zayki // mute
0x0A42: "Virtuoso", // Zayki // mute
0x0A43: "Virtuoso", // Need tester
0x0A44: "Virtuoso", // Need tester
0x0A40: "Virtuoso", // Need tester
0x0A4B: "Virtuoso", // Need tester
0x0A4C: "Virtuoso", // Need tester
0x0A5A: "Virtuoso", // Isaki // mute
0x0A5B: "Virtuoso", // Isaki // mute
0x0A5C: "Virtuoso", // Isaki // mute
0x0A3D: "Virtuoso SE", // mute sidetone
0x0A3E: "Virtuoso SE", // Slipstream? // mwbeaster | Shark | lag0matic // mute sidetone
0x0A62: "Virtuoso XT",
0x0A64: "Virtuoso XT",
//0x0A6A: "HS80", // PID for wired WHILE wireless dongle plugged in, doesnt control the headset
0x0A69: "HS80",
0x0A6B: "HS80",
0x0A71: "HS80",
0x0A73: "HS80",
0x0A97: "HS80 MAX" // TehTreeman
};
this.LEDLibrary = {
// Virtuoso Standard
0x0A40: {
name: "Virtuoso Wireless",
size: [3, 3],
LedNames: ["Logo", "Power", "Mic"],
LedPositions: [[1, 0], [0, 2], [2, 2]],
Leds: [0, 1, 2],
wireless: true,
endpoint : { "interface": 4, "usage": 0x0001, "usage_page": 0xFF42, "collection": 0x0004 },
image: "https://assets.signalrgb.com/devices/brands/corsair/audio/virtuoso-standard.png"
},
0x0A41: {
name: "Virtuoso",
size: [3, 3],
@ -395,16 +406,6 @@ export class deviceLibrary {
endpoint : { "interface": 4, "usage": 0x0001, "usage_page": 0xFF42, "collection": 0x0004 },
image: "https://assets.signalrgb.com/devices/brands/corsair/audio/virtuoso-standard.png"
},
0x0A40: {
name: "Virtuoso Wireless",
size: [3, 3],
LedNames: ["Logo", "Power", "Mic"],
LedPositions: [[1, 0], [0, 2], [2, 2]],
Leds: [0, 1, 2],
wireless: true,
endpoint : { "interface": 4, "usage": 0x0001, "usage_page": 0xFF42, "collection": 0x0004 },
image: "https://assets.signalrgb.com/devices/brands/corsair/audio/virtuoso-standard.png"
},
0x0A4B: {
name: "Virtuoso Wireless",
size: [3, 3],
@ -425,16 +426,6 @@ export class deviceLibrary {
endpoint : { "interface": 4, "usage": 0x0001, "usage_page": 0xFF42, "collection": 0x0004 },
image: "https://assets.signalrgb.com/devices/brands/corsair/audio/virtuoso-standard.png"
},
0x0A5C: {
name: "Virtuoso Wireless",
size: [3, 3],
LedNames: ["Logo", "Power", "Mic"],
LedPositions: [[1, 0], [0, 2], [2, 2]],
Leds: [0, 1, 2],
wireless: true,
endpoint : { "interface": 4, "usage": 0x0001, "usage_page": 0xFF42, "collection": 0x0004 },
image: "https://assets.signalrgb.com/devices/brands/corsair/audio/virtuoso-standard.png"
},
0x0A5A: {
name: "Virtuoso",
size: [3, 3],
@ -445,11 +436,21 @@ export class deviceLibrary {
image: "https://assets.signalrgb.com/devices/brands/corsair/audio/virtuoso-standard.png"
},
0x0A5B: {
name: "Virtuoso",
size: [3, 3],
LedNames: ["Logo", "Power", "Mic"],
LedPositions: [[1, 0], [0, 2], [2, 2]],
Leds: [0, 1, 2],
endpoint : { "interface": 4, "usage": 0x0001, "usage_page": 0xFF42, "collection": 0x0004 },
image: "https://assets.signalrgb.com/devices/brands/corsair/audio/virtuoso-standard.png"
},
0x0A5C: {
name: "Virtuoso Wireless",
size: [3, 3],
LedNames: ["Logo", "Power", "Mic"],
LedPositions: [[1, 0], [0, 2], [2, 2]],
Leds: [0, 1, 2],
wireless: true,
endpoint : { "interface": 4, "usage": 0x0001, "usage_page": 0xFF42, "collection": 0x0004 },
image: "https://assets.signalrgb.com/devices/brands/corsair/audio/virtuoso-standard.png"
},
@ -498,7 +499,7 @@ export class deviceLibrary {
// HS80
/*
0x0A6A: { // PID for wired WHILE wireless dongle plugged in
0x0A6A: { // PID for wired WHILE wireless dongle plugged in, doesnt control the headset
name: "HS80 RGB",
size: [3, 3],
LedNames: ["Logo", "Power", "Mic"],
@ -524,7 +525,7 @@ export class deviceLibrary {
LedPositions: [[1, 0], [0, 2], [2, 2]],
Leds: [0, 1, 2],
wireless: true,
endpoint : { "interface": 3, "usage": 0x0001, "usage_page": 0xFF42, "collection": 0x0004 },
endpoint : { "interface": 3, "usage": 0x0001, "usage_page": 0xFF42, "collection": 0x0005 },
image: "https://assets.signalrgb.com/devices/brands/corsair/audio/hs80.png"
},
0x0A71: {
@ -546,16 +547,6 @@ export class deviceLibrary {
endpoint : { "interface": 3, "usage": 0x0001, "usage_page": 0xFF42, "collection": 0x0005 },
image: "https://assets.signalrgb.com/devices/brands/corsair/audio/hs80.png"
},
0x0A97: {
name: "HS80 MAX Wireless",
size: [3, 3],
LedNames: ["Logo", "Power", "Mic"],
LedPositions: [[1, 0], [0, 2], [2, 2]],
Leds: [0, 1, 2],
wireless: true,
endpoint : { "interface": 3, "usage": 0x0001, "usage_page": 0xFF42, "collection": 0x0004 },
image: "https://assets.signalrgb.com/devices/brands/corsair/audio/hs80.png"
},
};
}
}
@ -574,10 +565,9 @@ function hexToRgb(hex) {
}
export function Validate(endpoint) {
return endpoint.interface === 0 || endpoint.interface === 3 || endpoint.interface === 4;
return endpoint.interface === 3 || endpoint.interface === 4;
}
export function ImageUrl() {
return "https://assets.signalrgb.com/devices/default/misc/usb-drive-render.png";
}