logi-fix.js aktualisiert
This commit is contained in:
parent
f49e5a8ee2
commit
356208e068
284
logi-fix.js
284
logi-fix.js
@ -16,51 +16,39 @@ export function ControllableParameters(){
|
|||||||
{"property":"shutdownColor", "group":"lighting", "label":"Shutdown Color", "min":"0", "max":"360", "type":"color", "default":"#009bde"},
|
{"property":"shutdownColor", "group":"lighting", "label":"Shutdown Color", "min":"0", "max":"360", "type":"color", "default":"#009bde"},
|
||||||
{"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"},
|
||||||
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
const vLedNames = [
|
const vLedNames = [
|
||||||
|
"Logo", "Brightness",
|
||||||
"Esc", "F1", "F2", "F3", "F4", "F5", "F6", "F7", "F8", "F9", "F10", "F11", "F12", "Print Screen", "Scroll Lock", "Pause Break",
|
"Esc", "F1", "F2", "F3", "F4", "F5", "F6", "F7", "F8", "F9", "F10", "F11", "F12", "Print Screen", "Scroll Lock", "Pause Break", "MediaRewind", "MediaPlayPause", "MediaFastForward", "MediaStop",
|
||||||
"`", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "-_", "=+", "Backspace", "Insert", "Home", "Page Up", "NumLock", "Num /", "Num *", "Num -",
|
"G1", "`", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "-_", "=+", "Backspace", "Insert", "Home", "Page Up", "NumLock", "Num /", "Num *", "Num -",
|
||||||
"Tab", "Q", "W", "E", "R", "T", "Y", "U", "I", "O", "P", "[", "]", "\\", "Del", "End", "Page Down", "Num 7", "Num 8", "Num 9", "Num +",
|
"G2", "Tab", "Q", "W", "E", "R", "T", "Y", "U", "I", "O", "P", "[", "]", "\\", "Del", "End", "Page Down", "Num 7", "Num 8", "Num 9", "Num +",
|
||||||
"CapsLock", "A", "S", "D", "F", "G", "H", "J", "K", "L", ";", "'", "ISO_/", "Enter", "Num 4", "Num 5", "Num 6",
|
"G3", "CapsLock", "A", "S", "D", "F", "G", "H", "J", "K", "L", ";", "'", "ISO_#", "Enter", "Num 4", "Num 5", "Num 6",
|
||||||
"Left Shift", "ISO_Y", "Z", "X", "C", "V", "B", "N", "M", ",", ".", "/", "Right Shift", "Up Arrow", "Num 1", "Num 2", "Num 3", "Num Enter",
|
"G4", "Left Shift", "ISO_<", "Z", "X", "C", "V", "B", "N", "M", ",", ".", "/", "Right Shift", "Up Arrow", "Num 1", "Num 2", "Num 3", "Num Enter",
|
||||||
"Left Ctrl", "Left Win", "Left Alt", "Space", "Right Alt", "Fn", "Menu", "Right Ctrl", "Left Arrow", "Down Arrow", "Right Arrow", "Num 0", "Num .",
|
"G5", "Left Ctrl", "Left Win", "Left Alt", "Space", "Right Alt", "Right Win", "Menu", "Right Ctrl", "Left Arrow", "Down Arrow", "Right Arrow", "Num 0", "Num .",
|
||||||
"G1", "G2", "G3", "G4", "G5", "G logo", "Brightness", "Previous", "Play", "Next", "Mute"
|
|
||||||
];
|
];
|
||||||
|
|
||||||
const vKeymap = [
|
const vLeds = [
|
||||||
|
213, 156,
|
||||||
0x29, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48,
|
41, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 168, 158, 160, 159,
|
||||||
0x35, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x2D, 0x2E, 0x2A, 0x49, 0x4A, 0x4B, 0x53, 0x54, 0x55, 0x56,
|
183, 53, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 45, 46, 42, 73, 74, 75, 83, 84, 85, 86,
|
||||||
0x2B, 0x14, 0x1A, 0x08, 0x15, 0x17, 0x1C, 0x18, 0x0C, 0x12, 0x13, 0x2F, 0x30, 0x31, 0x4C, 0x4D, 0x4E, 0x5F, 0x60, 0x61, 0x57,
|
184, 43, 20, 26, 8, 21, 23, 28, 24, 12, 18, 19, 47, 48, 49, 76, 77, 78, 95, 96, 97, 87,
|
||||||
0x39, 0x04, 0x16, 0x07, 0x09, 0x0A, 0x0B, 0x0D, 0x0E, 0x0F, 0x33, 0x34, 0x32, 0x28, 0x5C, 0x5D, 0x5E,
|
185, 57, 4, 22, 7, 9, 10, 11, 13, 14, 15, 51, 52, 50, 40, 92, 93, 94,
|
||||||
0x6C, 0x64, 0x1D, 0x1B, 0x06, 0x19, 0x05, 0x11, 0x10, 0x36, 0x37, 0x38, 0x70, 0x52, 0x59, 0x5A, 0x5B, 0x58,
|
186, 225, 100, 29, 27, 6, 25, 5, 17, 16, 54, 55, 56, 229, 82, 89, 90, 91, 88,
|
||||||
0x6B, 0x6E, 0x6D, 0x2C, 0x71, 0x72, 0x65, 0x6F, 0x50, 0x51, 0x4F, 0x62, 0x63,
|
187, 224, 227, 226, 44, 230, 231, 101, 228, 80, 81, 79, 98, 99,
|
||||||
0xB7, 0xB8, 0xB9, 0xBA, 0xBB, 0xD5, 0x9C, 0xA1, 0x9E, 0xA0, 0x9F
|
|
||||||
|
|
||||||
];
|
];
|
||||||
|
|
||||||
const vLedPositions = [
|
const vLedPositions = [
|
||||||
|
[0, 0], [10, 0],
|
||||||
[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1], [11, 1], [12, 1], [13, 1], [15, 1], [16, 1], [17, 1],
|
[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [7, 1], [8, 1], [9, 1], [10, 1], [11, 1], [12, 1], [13, 1], [14, 1], [15, 1], [16, 1], [17, 1], [18, 1], [19, 1], [20, 1], [21, 1],
|
||||||
[1, 2], [2, 2], [3, 2], [4, 2], [5, 2], [6, 2], [7, 2], [8, 2], [9, 2], [10, 2], [11, 2], [12, 2], [13, 2], [14, 2], [15, 2], [16, 2], [17, 2], [18, 2], [19, 2], [20, 2], [21, 2],
|
[0, 2], [1, 2], [2, 2], [3, 2], [4, 2], [5, 2], [6, 2], [7, 2], [8, 2], [9, 2], [10, 2], [11, 2], [12, 2], [13, 2], [14, 2], [15, 2], [16, 2], [17, 2], [18, 2], [19, 2], [20, 2], [21, 2],
|
||||||
[1, 3], [2, 3], [3, 3], [4, 3], [5, 3], [6, 3], [7, 3], [8, 3], [9, 3], [10, 3], [11, 3], [12, 3], [13, 3], [14, 3], [15, 3], [16, 3], [17, 3], [18, 3], [19, 3], [20, 3], [21, 3],
|
[0, 3], [1, 3], [2, 3], [3, 3], [4, 3], [5, 3], [6, 3], [7, 3], [8, 3], [9, 3], [10, 3], [11, 3], [12, 3], [13, 3], [14, 3], [15, 3], [16, 3], [17, 3], [18, 3], [19, 3], [20, 3], [21, 3],
|
||||||
[1, 4], [2, 4], [3, 4], [4, 4], [5, 4], [6, 4], [7, 4], [8, 4], [9, 4], [10, 4], [11, 4], [12, 4], [13, 4], [14, 4], [18, 4], [19, 4], [20, 4],
|
[0, 4], [1, 4], [2, 4], [3, 4], [4, 4], [5, 4], [6, 4], [7, 4], [8, 4], [9, 4], [10, 4], [11, 4], [12, 4], [13, 4], [14, 4], [18, 4], [19, 4], [20, 4],
|
||||||
[1, 5], [2, 5], [2, 5], [3, 5], [4, 5], [5, 5], [6, 5], [7, 5], [8, 5], [9, 5], [10, 5], [11, 5], [14, 5], [16, 5], [18, 5], [19, 5], [20, 5], [21, 5],
|
[0, 5], [1, 5], [2, 5], [3, 5], [4, 5], [5, 5], [6, 5], [7, 5], [8, 5], [9, 5], [10, 5], [11, 5], [12, 5], [14, 5], [16, 5], [18, 5], [19, 5], [20, 5], [21, 5],
|
||||||
[1, 6], [2, 6], [3, 6], [7, 6], [11, 6], [12, 6], [13, 6], [14, 6], [15, 6], [16, 6], [17, 6], [18, 6], [19, 6],
|
[0, 6], [1, 6], [2, 6], [3, 6], [7, 6], [11, 6], [12, 6], [13, 6], [14, 6], [15, 6], [16, 6], [17, 6], [18, 6], [20, 6],
|
||||||
[0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 0], [7, 0], [18, 1], [19, 1], [20, 1], [21, 1]
|
|
||||||
|
|
||||||
];
|
];
|
||||||
|
|
||||||
const vGkeyPositions = [
|
|
||||||
[0, 2], [0, 3], [0, 4], [0, 5], [0, 6]
|
|
||||||
];
|
|
||||||
const vLogoPositions = [
|
|
||||||
[0, 0]
|
|
||||||
];
|
|
||||||
export function LedNames(){
|
export function LedNames(){
|
||||||
return vLedNames;
|
return vLedNames;
|
||||||
}
|
}
|
||||||
@ -69,98 +57,91 @@ export function LedPositions() {
|
|||||||
return vLedPositions;
|
return vLedPositions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export function Initialize(){
|
export function Initialize(){
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function Render(){
|
||||||
function Apply() {
|
sendColors();
|
||||||
const packet = [];
|
apply();
|
||||||
|
//applyExtra();
|
||||||
packet[0] = 0x11;
|
|
||||||
packet[1] = 0xFF;
|
|
||||||
packet[2] = 0x0C;
|
|
||||||
packet[3] = 0x5E;
|
|
||||||
|
|
||||||
device.set_endpoint(1, 0x0602, 0xff43); // System IF
|
|
||||||
device.write(packet, 20);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function SendGkeys(shutdown = false) {
|
export function Shutdown(SystemSuspending) {
|
||||||
const packet = [];
|
const color = SystemSuspending ? "#000000" : shutdownColor;
|
||||||
packet[0] = 0x12;
|
sendColors(color);
|
||||||
packet[1] = 0xFF;
|
apply();
|
||||||
packet[2] = 0x10;
|
applyExtra();
|
||||||
packet[3] = 0x1F;
|
}
|
||||||
packet[4] = 0x00;
|
|
||||||
packet[5] = 4;
|
|
||||||
packet[6] = 0x00;
|
|
||||||
packet[7] = 6; // led count
|
|
||||||
|
|
||||||
for(let iIdx = 0; iIdx < vGkeyPositions.length; iIdx++){
|
function sendColors(overrideColor) {
|
||||||
const iLedIdx = (iIdx * 4) + 8;
|
|
||||||
const iKeyPosX = vGkeyPositions[iIdx][0];
|
|
||||||
const iKeyPosY = vGkeyPositions[iIdx][1];
|
|
||||||
var color;
|
|
||||||
|
|
||||||
if(shutdown){
|
let packet = [];
|
||||||
color = hexToRgb(shutdownColor);
|
const RGBData = [];
|
||||||
|
const RGBDataExtra = [];
|
||||||
|
|
||||||
|
for (let idx = 0; idx < vLeds.length; idx++) {
|
||||||
|
const iPxX = vLedPositions[idx][0];
|
||||||
|
const iPxY = vLedPositions[idx][1];
|
||||||
|
let color;
|
||||||
|
|
||||||
|
if(overrideColor){
|
||||||
|
color = hexToRgb(overrideColor);
|
||||||
}else if (LightingMode === "Forced") {
|
}else if (LightingMode === "Forced") {
|
||||||
color = hexToRgb(forcedColor);
|
color = hexToRgb(forcedColor);
|
||||||
}else{
|
}else{
|
||||||
color = device.color(iKeyPosX, iKeyPosY);
|
color = device.color(iPxX, iPxY);
|
||||||
}
|
}
|
||||||
|
|
||||||
packet[iLedIdx] = iIdx;
|
if ([ 213, 156, 183, 184, 185, 186, 187, 161, 158, 160, 159 ].includes(vLeds[idx])) {
|
||||||
packet[iLedIdx+1] = color[0];
|
RGBDataExtra.push(vLeds[idx]);
|
||||||
packet[iLedIdx+2] = color[1];
|
RGBDataExtra.push(color[0]);
|
||||||
packet[iLedIdx+3] = color[2];
|
RGBDataExtra.push(color[1]);
|
||||||
|
RGBDataExtra.push(color[2]);
|
||||||
|
} else {
|
||||||
|
RGBData[(idx*4)] = vLeds[idx];
|
||||||
|
RGBData[(idx*4)+1] = color[0];
|
||||||
|
RGBData[(idx*4)+2] = color[1];
|
||||||
|
RGBData[(idx*4)+3] = color[2];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Send normal keys
|
||||||
|
while(RGBData.length > 0) {
|
||||||
|
const ledsToSend = Math.min(14, RGBData.length/4);
|
||||||
|
|
||||||
|
packet = [0x12, 0xFF, 0x0C, 0x3E, 0x00, 0x01, 0x00, ledsToSend].concat(RGBData.splice(0, ledsToSend*4));
|
||||||
|
|
||||||
device.set_endpoint(1, 0x0604, 0xff43); // Lighting IF
|
device.set_endpoint(1, 0x0604, 0xff43); // Lighting IF
|
||||||
device.write(packet, 64);
|
device.write(packet, 64);
|
||||||
device.pause(1);
|
device.pause(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
function SendLogoZones(shutdown = false){
|
// Send extra keys
|
||||||
const packet = [];
|
while(RGBDataExtra.length > 0) {
|
||||||
packet[0] = 0x11;
|
const ledsToSend = Math.min(4, RGBDataExtra.length/4);
|
||||||
packet[1] = 0xFF;
|
|
||||||
packet[2] = 0x10;
|
|
||||||
packet[3] = 0x3d;
|
|
||||||
packet[4] = 0x00;
|
|
||||||
packet[5] = 0x10;
|
|
||||||
packet[6] = 0x00;
|
|
||||||
packet[7] = 0x02;
|
|
||||||
|
|
||||||
for(let iIdx = 0; iIdx < vLogoPositions.length; iIdx++){
|
packet = [0x11, 0xFF, 0x10, 0x1F].concat(RGBDataExtra.splice(0, ledsToSend*4));
|
||||||
const iLedIdx = (iIdx * 4) + 8;
|
|
||||||
const iKeyPosX = vLogoPositions[iIdx][0];
|
|
||||||
const iKeyPosY = vLogoPositions[iIdx][1];
|
|
||||||
var color;
|
|
||||||
|
|
||||||
if(shutdown){
|
|
||||||
color = hexToRgb(shutdownColor);
|
|
||||||
}else if (LightingMode === "Forced") {
|
|
||||||
color = hexToRgb(forcedColor);
|
|
||||||
}else{
|
|
||||||
color = device.color(iKeyPosX, iKeyPosY);
|
|
||||||
}
|
|
||||||
|
|
||||||
packet[iLedIdx] = iIdx+1;
|
|
||||||
packet[iLedIdx+1] = color[0];
|
|
||||||
packet[iLedIdx+2] = color[1];
|
|
||||||
packet[iLedIdx+3] = color[2];
|
|
||||||
}
|
|
||||||
|
|
||||||
//device.set_endpoint(1, 0x0604, 0xff43); // Lighting IF
|
|
||||||
device.set_endpoint(1, 0x0602, 0xff43); // System IF
|
device.set_endpoint(1, 0x0602, 0xff43); // System IF
|
||||||
|
|
||||||
device.write(packet, 20);
|
device.write(packet, 20);
|
||||||
device.pause(1);
|
device.pause(1);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function apply() {
|
||||||
|
const packet = [0x11, 0xFF, 0x0C, 0x5E];
|
||||||
|
|
||||||
|
device.set_endpoint(1, 0x0602, 0xff43); // System IF
|
||||||
|
device.write(packet, 20);
|
||||||
|
}
|
||||||
|
|
||||||
|
function applyExtra() {
|
||||||
|
const packet = [0x11, 0xFF, 0x10, 0x7E];
|
||||||
|
|
||||||
|
device.set_endpoint(1, 0x0602, 0xff43); // System IF
|
||||||
|
device.write(packet, 4);
|
||||||
|
}
|
||||||
|
|
||||||
function hexToRgb(hex) {
|
function hexToRgb(hex) {
|
||||||
const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
|
const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
|
||||||
@ -172,111 +153,6 @@ function hexToRgb(hex) {
|
|||||||
return colors;
|
return colors;
|
||||||
}
|
}
|
||||||
|
|
||||||
function SendZonePacket(startIdx, count, zone, shutdown = false) {
|
|
||||||
const packet = [];
|
|
||||||
packet[0] = 0x12;
|
|
||||||
packet[1] = 0xFF;
|
|
||||||
packet[2] = 0x0C;
|
|
||||||
packet[3] = 0x3D;
|
|
||||||
packet[4] = 0x00;
|
|
||||||
packet[5] = zone;
|
|
||||||
packet[6] = 0x00;
|
|
||||||
packet[7] = count; // led count
|
|
||||||
|
|
||||||
for(let iIdx = 0; iIdx < count; iIdx++){
|
|
||||||
const iLedIdx = (iIdx * 4) + 8;
|
|
||||||
const iKeyIdx = startIdx + iIdx;
|
|
||||||
const iKeyPosX = vLedPositions[iKeyIdx][0];
|
|
||||||
const iKeyPosY = vLedPositions[iKeyIdx][1];
|
|
||||||
var color;
|
|
||||||
|
|
||||||
if(shutdown){
|
|
||||||
color = hexToRgb(shutdownColor);
|
|
||||||
}else if (LightingMode === "Forced") {
|
|
||||||
color = hexToRgb(forcedColor);
|
|
||||||
}else{
|
|
||||||
color = device.color(iKeyPosY, iKeyPosX);
|
|
||||||
}
|
|
||||||
|
|
||||||
packet[iLedIdx] = vKeymap[iKeyIdx];
|
|
||||||
packet[iLedIdx+1] = color[0];
|
|
||||||
packet[iLedIdx+2] = color[1];
|
|
||||||
packet[iLedIdx+3] = color[2];
|
|
||||||
}
|
|
||||||
|
|
||||||
device.set_endpoint(1, 0x0604, 0xff43); // Lighting IF
|
|
||||||
device.write(packet, 64);
|
|
||||||
device.pause(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
function SendPacket(startIdx, count, shutdown = false) {
|
|
||||||
const packet = [];
|
|
||||||
packet[0] = 0x12;
|
|
||||||
packet[1] = 0xFF;
|
|
||||||
packet[2] = 0x0C;
|
|
||||||
packet[3] = 0x3D;
|
|
||||||
packet[4] = 0x00;
|
|
||||||
packet[5] = 0x01; // zone?
|
|
||||||
packet[6] = 0x00;
|
|
||||||
packet[7] = count; // led count
|
|
||||||
|
|
||||||
for(let iIdx = 0; iIdx < count; iIdx++){
|
|
||||||
const iLedIdx = (iIdx * 4) + 8;
|
|
||||||
const iKeyIdx = startIdx + iIdx;
|
|
||||||
const iKeyPosX = vLedPositions[iKeyIdx][0];
|
|
||||||
const iKeyPosY = vLedPositions[iKeyIdx][1];
|
|
||||||
var color;
|
|
||||||
|
|
||||||
if(shutdown){
|
|
||||||
color = hexToRgb(shutdownColor);
|
|
||||||
}else if (LightingMode === "Forced") {
|
|
||||||
color = hexToRgb(forcedColor);
|
|
||||||
}else{
|
|
||||||
color = device.color(iKeyPosX, iKeyPosY);
|
|
||||||
}
|
|
||||||
|
|
||||||
packet[iLedIdx] = vKeymap[iKeyIdx];
|
|
||||||
packet[iLedIdx+1] = color[0];
|
|
||||||
packet[iLedIdx+2] = color[1];
|
|
||||||
packet[iLedIdx+3] = color[2];
|
|
||||||
}
|
|
||||||
|
|
||||||
device.set_endpoint(1, 0x0604, 0xff43); // Lighting IF
|
|
||||||
device.write(packet, 64);
|
|
||||||
device.pause(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
export function Render() {
|
|
||||||
SendPacket(0, 14);
|
|
||||||
SendPacket(14, 14);
|
|
||||||
SendPacket(28, 14);
|
|
||||||
SendPacket(42, 14);
|
|
||||||
SendPacket(56, 14);
|
|
||||||
SendPacket(70, 14);
|
|
||||||
SendPacket(84, 14);
|
|
||||||
SendPacket(98, 9);
|
|
||||||
SendGkeys();
|
|
||||||
SendLogoZones();
|
|
||||||
Apply();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
export function Shutdown() {
|
|
||||||
SendPacket(0, 14, true);
|
|
||||||
SendPacket(14, 14, true);
|
|
||||||
SendPacket(28, 14, true);
|
|
||||||
SendPacket(42, 14, true);
|
|
||||||
SendPacket(56, 14, true);
|
|
||||||
SendPacket(70, 14, true);
|
|
||||||
SendPacket(84, 14, true);
|
|
||||||
SendPacket(98, 9, true);
|
|
||||||
SendGkeys(true);
|
|
||||||
SendLogoZones(true);
|
|
||||||
Apply();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
export function Validate(endpoint) {
|
export function Validate(endpoint) {
|
||||||
return (endpoint.interface === 1 && endpoint.usage === 0x0602) ||
|
return (endpoint.interface === 1 && endpoint.usage === 0x0602) ||
|
||||||
(endpoint.interface === 1 && endpoint.usage === 0x0604);
|
(endpoint.interface === 1 && endpoint.usage === 0x0604);
|
||||||
|
Loading…
Reference in New Issue
Block a user