Corsair_Virtuoso_XT_Headset.js.bad aktualisiert
This commit is contained in:
parent
c29910d2e0
commit
816f94ffc5
@ -3,7 +3,7 @@ export function VendorId() { return 0x1b1c; }
|
|||||||
export function ProductId() { return 0x0A64; }
|
export function ProductId() { return 0x0A64; }
|
||||||
export function Publisher() { return "WhirlwindFX"; }
|
export function Publisher() { return "WhirlwindFX"; }
|
||||||
export function Documentation(){ return "troubleshooting/corsair"; }
|
export function Documentation(){ return "troubleshooting/corsair"; }
|
||||||
export function Size() { return [1, 1]; }
|
export function Size() { return [1, 2]; }
|
||||||
export function DefaultPosition(){return [145, 85];}
|
export function DefaultPosition(){return [145, 85];}
|
||||||
export function DefaultScale(){return 10.0;}
|
export function DefaultScale(){return 10.0;}
|
||||||
/* global
|
/* global
|
||||||
@ -18,7 +18,7 @@ export function ControllableParameters() {
|
|||||||
{"property":"LightingMode", "group":"lighting", "label":"Lighting Mode", "type":"combobox", "values":["Canvas", "Forced"], "default":"Canvas"},
|
{"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":"forcedColor", "group":"lighting", "label":"Forced Color", "min":"0", "max":"360", "type":"color", "default":"#009bde"},
|
||||||
{"property":"idleTimeout", "group":"", "label":"Enable Device Sleep", "type":"boolean", "default":"true"},
|
{"property":"idleTimeout", "group":"", "label":"Enable Device Sleep", "type":"boolean", "default":"true"},
|
||||||
{"property":"idleTimeoutLength", "group":"", "label":"Device Sleep Timeout (Minutes)", "type":"combobox", "values":["1","2","3","4","5","10","15","20","25","30"], "default":"10"},
|
{"property":"idleTimeoutLength", "group":"", "label":"Device Sleep Timeout (Minutes)", "type":"combobox", "values":["1", "2", "3", "4", "5", "10", "15", "20", "25", "30"], "default":"10"},
|
||||||
{"property":"SidetoneAmount", "group":"", "label":"Sidetone", "step":"1", "type":"number", "min":"0", "max":"100", "default":"0"},
|
{"property":"SidetoneAmount", "group":"", "label":"Sidetone", "step":"1", "type":"number", "min":"0", "max":"100", "default":"0"},
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
@ -28,7 +28,7 @@ let device_status;
|
|||||||
let previousBatteryLevel = -1;
|
let previousBatteryLevel = -1;
|
||||||
let batteryPercentage = -1;
|
let batteryPercentage = -1;
|
||||||
|
|
||||||
const vLeds = [ 0, 1 ]
|
const vLeds = [ 0, 1 ];
|
||||||
|
|
||||||
const vLedNames = [
|
const vLedNames = [
|
||||||
"Logo", "Mic"
|
"Logo", "Mic"
|
||||||
@ -51,7 +51,7 @@ export function Initialize() {
|
|||||||
headsetMode = (ProductId() == 0x0a6b || ProductId() == 0x0a64) ? 0x09 : 0x08;
|
headsetMode = (ProductId() == 0x0a6b || ProductId() == 0x0a64) ? 0x09 : 0x08;
|
||||||
device.addFeature("battery");
|
device.addFeature("battery");
|
||||||
setSoftwareMode();
|
setSoftwareMode();
|
||||||
setMicOn()
|
setMicOn();
|
||||||
setSidetone();
|
setSidetone();
|
||||||
setIdleTimeout(idleTimeoutLength);
|
setIdleTimeout(idleTimeoutLength);
|
||||||
}
|
}
|
||||||
@ -76,8 +76,8 @@ export function onSidetoneAmountChanged() {
|
|||||||
|
|
||||||
export function onidleTimeoutLengthChanged() {
|
export function onidleTimeoutLengthChanged() {
|
||||||
if (idleTimeout){
|
if (idleTimeout){
|
||||||
console.log ("Set Idle Timeout to: " + idleTimeoutLength + "Minutes")
|
console.log ("Set Idle Timeout to: " + idleTimeoutLength + "Minutes");
|
||||||
setIdleTimeout(idleTimeoutLength)
|
setIdleTimeout(idleTimeoutLength);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -110,11 +110,12 @@ function sendColors(overrideColor) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
device.set_endpoint(3, 0x0001, 0xFF42);
|
device.set_endpoint(3, 0x0001, 0xFF42);
|
||||||
device.write(packet, 64);
|
device.write(packet.concat(RGBData), 64);
|
||||||
}
|
}
|
||||||
|
|
||||||
function setSidetone() {
|
function setSidetone() {
|
||||||
device.set_endpoint(3, 0x0001, 0xFF42);
|
device.set_endpoint(3, 0x0001, 0xFF42);
|
||||||
|
|
||||||
const packet = [];
|
const packet = [];
|
||||||
// Header
|
// Header
|
||||||
packet[0] = 0x02;
|
packet[0] = 0x02;
|
||||||
@ -122,7 +123,7 @@ function setSidetone() {
|
|||||||
packet[2] = 0x01;
|
packet[2] = 0x01;
|
||||||
packet[3] = 0x47;
|
packet[3] = 0x47;
|
||||||
|
|
||||||
let sidetoneValue = Math.round((SidetoneAmount / 100) * 1000);
|
const sidetoneValue = Math.round((SidetoneAmount / 100) * 1000);
|
||||||
|
|
||||||
packet[0x05] = sidetoneValue & 0xFF;
|
packet[0x05] = sidetoneValue & 0xFF;
|
||||||
packet[0x06] = (sidetoneValue >> 8) & 0xFF;
|
packet[0x06] = (sidetoneValue >> 8) & 0xFF;
|
||||||
@ -134,7 +135,7 @@ export function onidleTimeoutChanged() {
|
|||||||
device.set_endpoint(3, 0x0001, 0xFF42);
|
device.set_endpoint(3, 0x0001, 0xFF42);
|
||||||
device.write([0x02, headsetMode, 0x01, 0x0d, 0x01], 128);
|
device.write([0x02, headsetMode, 0x01, 0x0d, 0x01], 128);
|
||||||
device.pause(1);
|
device.pause(1);
|
||||||
setIdleTimeout(idleTimeoutLength)
|
setIdleTimeout(idleTimeoutLength);
|
||||||
}else{
|
}else{
|
||||||
device.set_endpoint(3, 0x0001, 0xFF42);
|
device.set_endpoint(3, 0x0001, 0xFF42);
|
||||||
device.write([0x02, headsetMode, 0x01, 0x0d], 128);
|
device.write([0x02, headsetMode, 0x01, 0x0d], 128);
|
||||||
@ -154,6 +155,7 @@ function setSoftwareMode() {
|
|||||||
|
|
||||||
function readDevice() {
|
function readDevice() {
|
||||||
device.set_endpoint(3, 0x0002, 0xFF42);
|
device.set_endpoint(3, 0x0002, 0xFF42);
|
||||||
|
|
||||||
const packet = device.read([0x00], 16, 15);
|
const packet = device.read([0x00], 16, 15);
|
||||||
|
|
||||||
if(packet[0] == 0x03 && packet[1] == 0x01 && packet[2] == 0x01 && packet[3] == 0x10 && packet[4] == 0x00 && packet[5] == 0x02) {
|
if(packet[0] == 0x03 && packet[1] == 0x01 && packet[2] == 0x01 && packet[3] == 0x10 && packet[4] == 0x00 && packet[5] == 0x02) {
|
||||||
@ -161,24 +163,27 @@ function readDevice() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(packet[0] == 0x03 && packet[2] == 0x01 && packet[3] == 0x46 && packet[4] == 0x00 && packet[5] == 0x00) {
|
if(packet[0] == 0x03 && packet[2] == 0x01 && packet[3] == 0x46 && packet[4] == 0x00 && packet[5] == 0x00) {
|
||||||
console.log("Microphone: ON")
|
console.log("Microphone: ON");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(packet[0] == 0x03 && packet[2] == 0x01 && packet[3] == 0x46 && packet[4] == 0x00 && packet[5] == 0x01) {
|
if(packet[0] == 0x03 && packet[2] == 0x01 && packet[3] == 0x46 && packet[4] == 0x00 && packet[5] == 0x01) {
|
||||||
console.log("Microphone: OFF")
|
console.log("Microphone: OFF");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(packet[0] == 0x03 && packet[2] == 0x01 && packet[3] == 0x10 && packet[4] == 0x00 && packet[5] == 0x01) {
|
if(packet[0] == 0x03 && packet[2] == 0x01 && packet[3] == 0x10 && packet[4] == 0x00 && packet[5] == 0x01) {
|
||||||
battery.setBatteryState(2)
|
battery.setBatteryState(2);
|
||||||
console.log("Headset is charging")
|
console.log("Headset is charging");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(packet[0] == 0x03 && packet[2] == 0x01 && packet[3] == 0x10 && packet[4] == 0x00 && packet[5] == 0x02) {
|
if(packet[0] == 0x03 && packet[2] == 0x01 && packet[3] == 0x10 && packet[4] == 0x00 && packet[5] == 0x02) {
|
||||||
battery.setBatteryState(1)
|
battery.setBatteryState(1);
|
||||||
console.log("Headset is draining")
|
console.log("Headset is draining");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (packet[0] == 0x03 && packet[1] == 0x01 && packet[2] == 0x01 && packet[3] == 0x0f && packet[4] == 0x00) {
|
if (packet[0] == 0x03 && packet[1] == 0x01 && packet[2] == 0x01 && packet[3] == 0x0f && packet[4] == 0x00) {
|
||||||
|
|
||||||
let batteryValue = (packet[5] & 0xFF) | ((packet[6] & 0xFF) << 8);
|
const batteryValue = (packet[5] & 0xFF) | ((packet[6] & 0xFF) << 8);
|
||||||
let maxBatteryValue = 1023; // 0xff03 in Dezimal
|
const maxBatteryValue = 1023; // 0xff03 in Dezimal
|
||||||
|
|
||||||
batteryPercentage = Math.round((batteryValue / maxBatteryValue) * 100);
|
batteryPercentage = Math.round((batteryValue / maxBatteryValue) * 100);
|
||||||
|
|
||||||
@ -194,6 +199,7 @@ function readDevice() {
|
|||||||
battery.setBatteryState(2);
|
battery.setBatteryState(2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
previousBatteryLevel = batteryPercentage;
|
previousBatteryLevel = batteryPercentage;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -205,8 +211,8 @@ function setMicOn() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function setIdleTimeout(idleTimeoutLength) {
|
function setIdleTimeout(idleTimeoutLength) {
|
||||||
applyPreConfig()
|
applyPreConfig();
|
||||||
applyIdleTimeout(idleTimeoutLength)
|
applyIdleTimeout(idleTimeoutLength);
|
||||||
}
|
}
|
||||||
|
|
||||||
function applyIdleTimeout(idleTimeoutLength) {
|
function applyIdleTimeout(idleTimeoutLength) {
|
||||||
@ -225,7 +231,7 @@ function applyIdleTimeout(idleTimeoutLength) {
|
|||||||
packet[5] = parseInt(littleEndianHex[0], 16);
|
packet[5] = parseInt(littleEndianHex[0], 16);
|
||||||
packet[6] = parseInt(littleEndianHex[1], 16);
|
packet[6] = parseInt(littleEndianHex[1], 16);
|
||||||
packet[7] = parseInt(littleEndianHex[2], 16);
|
packet[7] = parseInt(littleEndianHex[2], 16);
|
||||||
console.log ("Idle Timeout: " + idleTimeoutLength + "Min")
|
console.log ("Idle Timeout: " + idleTimeoutLength + "Min");
|
||||||
device.write(packet, 128);
|
device.write(packet, 128);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user