From dcf8296202f5f1231b0be794f6efa96547fd69c7 Mon Sep 17 00:00:00 2001 From: WhySoBad <49595640+WhySoBad@users.noreply.github.com> Date: Thu, 25 Mar 2021 07:52:50 +0100 Subject: [PATCH 1/5] added index.d.ts --- index.d.ts | 403 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 403 insertions(+) create mode 100644 index.d.ts diff --git a/index.d.ts b/index.d.ts new file mode 100644 index 0000000..1776bbf --- /dev/null +++ b/index.d.ts @@ -0,0 +1,403 @@ +export enum CorsairDeviceType { + CDT_Unknown = 0, + CDT_Mouse = 1, + CDT_Keyboard = 2, + CDT_Headset = 3, + CDT_MouseMat = 4, + CDT_HeadsetStand = 5, + CDT_CommanderPro = 6, + CDT_LightingNodePro = 7, + CDT_MemoryModule = 8, + CDT_Cooler = 9, + CDT_Motherboard = 10, + CDT_GraphicsCard = 11 +} + +export enum CorsairPhysicalLayout { + CDT_Unknown = 0, + CDT_Mouse = 1, + CDT_Keyboard = 2, + CDT_Headset = 3, + CDT_MouseMat = 4, + CDT_HeadsetStand = 5, + CDT_CommanderPro = 6, + CDT_LightingNodePro = 7, + CDT_MemoryModule = 8, + CDT_Cooler = 9, + CDT_Motherboard = 10, + CDT_GraphicsCard = 11 +} + +export enum CorsairLogicalLayout { + CLL_Invalid = 0, + CLL_US_Int = 1, + CLL_NA = 2, + CLL_EU = 3, + CLL_UK = 4, + CLL_BE = 5, + CLL_BR = 6, + CLL_CH = 7, + CLL_CN = 8, + CLL_DE = 9, + CLL_ES = 10, + CLL_FR = 11, + CLL_IT = 12, + CLL_ND = 13, + CLL_RU = 14, + CLL_JP = 15, + CLL_KR = 16, + CLL_TW = 17, + CLL_MEX = 18 +} + +export type CorsairLogicalLayoutString = [ + 'CLL_Invalid', + 'CLL_US_Int', + 'CLL_NA', + 'CLL_EU', + 'CLL_UK', + 'CLL_BE', + 'CLL_BR', + 'CLL_CH', + 'CLL_CN', + 'CLL_DE', + 'CLL_ES', + 'CLL_FR', + 'CLL_IT', + 'CLL_ND', + 'CLL_RU', + 'CLL_JP', + 'CLL_KR', + 'CLL_TW', + 'CLL_MEX' +] + +export enum CorsairDeviceCaps { + CDC_None = 0x0000, + CDC_Lighting = 0x0001, + CDC_PropertyLookup = 0x0002 +} + +export enum CorsairAccessMode { + CAM_ExclusiveLightingControl = 0 +} + +export enum CorsairError { + CE_Success = 0, + CE_ServerNotFound = 1, + CE_NoControl = 2, + CE_ProtocolHandshakeMissing = 3, + CE_IncompatibleProtocol = 4, + CE_InvalidArguments = 5 +} + +export type CorsairErrorString = [ + 'CE_Success', + 'CE_ServerNotFound', + 'CE_NoControl', + 'CE_ProtocolHandshakeMissing', + 'CE_IncompatibleProtocol', + 'CE_InvalidArguments' +] + +export enum CorsairChannelDeviceType { + CCDT_Invalid = 0, + CCDT_HD_Fan = 1, + CCDT_SP_Fan = 2, + CCDT_LL_Fan = 3, + CCDT_ML_Fan = 4, + CCDT_Strip = 5, + CCDT_DAP = 6, + CCDT_Pump = 7, + CCDT_QL_Fan = 8, + CCDT_WaterBlock = 9, + CCDT_SPPRO_Fan = 10 +} + +export enum CorsairDevicePropertyType { + CDPT_Boolean = 0x1000, + CDPT_Int32 = 0x2000 +} + +export enum CorsairDevicePropertyId { + CDPI_Headset_MicEnabled = 0x1000, + CDPI_Headset_SurroundSoundEnabled = 0x1001, + CDPI_Headset_SidetoneEnabled = 0x1002, + CDPI_Headset_EqualizerPreset = 0x2000 +} + +export interface CorsairProtocolHandshake { + sdkVersion: string + serverVersion: string + sdkProtocolVersion: number + serverProtocolVersion: number + breakingChanges: boolean +} + +export interface CorsairDevice { + type: number + model: string + physicalLayout: number + logicalLayout: number + capsMask: number + ledsCount: number + channels: { + channelsCount: number + } +} + +export interface CorsairLedColor { + ledId: number + r: number + g: number + b: number +} + +export interface CorsairLed { + ledId: number + top: number + left: number + height: number + width: number +} + +/** + * Function to get the last occured error + * + * @returns number + */ + +export function CorsairGetLastError(): number + +/** + * Function to get the amount of conntected + * + * devices + * + * @returns number + */ + +export function CorsairGetDeviceCount(): number + +/** + * Function to check file and protocol version of CUE + * + * @returns CorsairProtocolHandshake + */ + +export function CorsairPerformProtocolHandshake(): CorsairProtocolHandshake + +/** + * Function to get the device information by + * + * the device index + * + * @param device zero based device index + * + * @returns CorsairDevice | undefined + */ + +export function CorsairGetDeviceInfo(device: number): CorsairDevice | undefined + +/** + * Function to get the current color for CorsairLedColor's in an array. + * + * The function replaces the r,g,b values in the array with + * + * the current values + * + * @param colors array with CorsairLedColor + * + * @returns boolean + */ + +export function CorsairGetLedsColors(colors: Array): boolean + +/** + * Function to set the current color for CorsairLedColor's in an array + * + * @param colors array with CorsairLedColor + * + * @returns boolean + */ + +export function CorsairSetLedsColors(colors: Array): boolean + +/** + * Function to get the current color for CorsairLedColor's in an array + * + * for a specific device. The function replaces the r,g,b values + * + * in the array with the current values + * + * @param deviceIndex zero based device index + * + * @param colors array with CorsairLedColor + * + * @returns boolean + */ + +export function CorsairGetLedsColorsByDeviceIndex( + deviceIndex: number, + colors: Array +): boolean + +/** + * Function to set the current color for CorsairLedColor's in an array for a + * + * specific device. + * + * @param deviceIndex zero based device index + * + * @param colors array with CorsairLedColor + * + * @returns boolean + */ + +export function CorsairSetLedsColorsBufferByDeviceIndex( + deviceIndex: number, + colors: Array +): boolean + +/** + * Function to write the previously filled buffer + * + * to the device LEDs + * + * @returns boolean + */ + +export function CorsairSetLedsColorsFlushBuffer(): boolean + +/** + * Function to write the previously filled buffer + * + * asynchronously to the devices LED + * + * @param callback callback function + * + * @returns boolean + */ + +export function CorsairSetLedsColorsFlushBufferAsync( + callback: Function +): boolean + +/** + * Function to set the current color for all CorsairLedColor's in an array + * + * asynchronously + * + * @param colors array with CorsairLedColor + * + * @param callback callback function + * + * @returns boolean + */ + +export function CorsairSetLedsColorsAsync( + colors: Array, + callback: Function +): boolean + +/** + * Function to get an array with CorsairLed containing + * + * the position and ledId of the LED + * + * @returns Array + */ + +export function CorsairGetLedPositions(): Array + +/** + * Function to get an array with CorsairLed containing + * + * the position and ledId of the led for a specific + * + * device + * + * @param deviceIndex zero based device index + */ + +export function CorsairGetLedPositionsByDeviceIndex( + deviceIndex: number +): Array + +/** + * Function to get the ledId for a + * + * @param key key character + * + * @returns number + */ + +export function CorsairGetLedIdForKeyName(key: string): number + +/** + * Function to request explusive control + * + * @returns void + */ + +export function CorsairRequestControl(): void + +/** + * Function to release exclusive requested control + * + * @returns void + */ + +export function CorsairReleaseControl(): void + +/** + * Function to set the priority for the layer. The priority + * + * has to be between 0 and 127 + * + * @param priority number + * + * @returns boolean + */ + +export function CorsairSetLayerPriority(priority: number): boolean + +/** + * Function to get the property for a device + * + * @param deviceIndex zero based device index + * + * @param propertyId number + * + * @returns boolean + */ + +export function CorsairGetDeviceProperty( + deviceIndex: number, + propertyId: number +): void + +/** + * Function to subscribe to events. The callback param gets + * + * called when an event occured + * + * @param callback callback function + * + * @returns boolean + */ + +export function CorsairSubscribeForEvents( + callback: (event: { + id: 'macrokeydown' | 'macrokeyup' | 'deviceconnect' | 'devicedisconnect' + deviceId: string + }) => void +): boolean + +/** + * Function to unsubscribe to events + * + * @returns boolean + */ + +export function CorsairUnsubscribeFromEvents(): boolean From 357a1ed40e3d0026894c0369e161796815dcb989 Mon Sep 17 00:00:00 2001 From: Corsin Date: Sat, 24 Apr 2021 09:55:52 +0200 Subject: [PATCH 2/5] changes applied --- index.d.ts | 30 ++++++++++++++------ package-lock.json | 70 +++++++++++++++++++++++++++-------------------- package.json | 2 +- 3 files changed, 63 insertions(+), 39 deletions(-) diff --git a/index.d.ts b/index.d.ts index 1776bbf..590c935 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1,3 +1,5 @@ +import { LogicalLayout } from '../../src/types' + export enum CorsairDeviceType { CDT_Unknown = 0, CDT_Mouse = 1, @@ -134,15 +136,23 @@ export interface CorsairProtocolHandshake { breakingChanges: boolean } -export interface CorsairDevice { +export interface CorsairDeviceInfo { type: number model: string - physicalLayout: number - logicalLayout: number + physicalLayout: CorsairPhysicalLayout + logicalLayout: CorsairLogicalLayout capsMask: number ledsCount: number channels: { channelsCount: number + channels?: Array<{ + totalLedsCount: number + devicesCount: number + devices: Array<{ + type: CorsairDeviceType + deviceLedCount: number + }> + }> } } @@ -197,7 +207,9 @@ export function CorsairPerformProtocolHandshake(): CorsairProtocolHandshake * @returns CorsairDevice | undefined */ -export function CorsairGetDeviceInfo(device: number): CorsairDevice | undefined +export function CorsairGetDeviceInfo( + device: number +): CorsairDeviceInfo | undefined /** * Function to get the current color for CorsairLedColor's in an array. @@ -337,18 +349,18 @@ export function CorsairGetLedIdForKeyName(key: string): number /** * Function to request explusive control * - * @returns void + * @returns boolean */ -export function CorsairRequestControl(): void +export function CorsairRequestControl(): boolean /** * Function to release exclusive requested control * - * @returns void + * @returns boolean */ -export function CorsairReleaseControl(): void +export function CorsairReleaseControl(): boolean /** * Function to set the priority for the layer. The priority @@ -395,7 +407,7 @@ export function CorsairSubscribeForEvents( ): boolean /** - * Function to unsubscribe to events + * Function to unsubscribe from events * * @returns boolean */ diff --git a/package-lock.json b/package-lock.json index cb57877..1de60f4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -72,15 +72,15 @@ "dev": true }, "aws4": { - "version": "1.10.1", - "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.10.1.tgz", - "integrity": "sha512-zg7Hz2k5lI8kb7U32998pRRFin7zJlkfezGJjUc2heaD4Pw2wObakCDVzkKztTm/Ln7eiVvYsjqak0Ed4LkMDA==", + "version": "1.11.0", + "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.11.0.tgz", + "integrity": "sha512-xh1Rl34h6Fi1DC2WWKfxUTVqRsNnr6LsKz2+hfwDxQJWmrx8+c7ylaqBMcHfl1U1r2dsifOvKX3LQuLNZ+XSvA==", "dev": true }, "balanced-match": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", - "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", "dev": true }, "base64-js": { @@ -228,9 +228,9 @@ } }, "env-paths": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/env-paths/-/env-paths-2.2.0.tgz", - "integrity": "sha512-6u0VYSCo/OW6IoD5WCLLy9JUGARbamfSavcNXry/eu8aHVFei6CD3Sw+VGX5alea1i9pgPHW0mbu6Xj0uBh7gA==", + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/env-paths/-/env-paths-2.2.1.tgz", + "integrity": "sha512-+h1lkLKhZMTYjog1VEpJNG7NZJWcuc2DDk/qsqSTRRCOXiLjeQ1d1/udrUGhqMxUgAlwKNZ0cf2uqan5GLuS2A==", "dev": true }, "execspawn": { @@ -344,9 +344,9 @@ } }, "graceful-fs": { - "version": "4.2.4", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.4.tgz", - "integrity": "sha512-WjKPNJF79dtJAVniUlGGWHYGz2jWxT6VhN/4m1NdkbZ2nOsEF+cI1Edgql5zCRhs/VsQYRvrXctxktVXZUkixw==", + "version": "4.2.6", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.6.tgz", + "integrity": "sha512-nTnJ528pbqxYanhpDYsi4Rd8MAeaBA67+RZ10CM1m3bTAVFEDcd5AuA4a6W5YkGZ1iNXHzZz8T6TBKLeBuNriQ==", "dev": true }, "har-schema": { @@ -473,19 +473,28 @@ "verror": "1.10.0" } }, + "lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "dev": true, + "requires": { + "yallist": "^4.0.0" + } + }, "mime-db": { - "version": "1.44.0", - "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.44.0.tgz", - "integrity": "sha512-/NOTfLrsPBVeH7YtFPgsVWveuL+4SjjYxaQ1xtM1KMFj7HdxlBlxeyNLzhyJVx7r4rZGJAZ/6lkKCitSc/Nmpg==", + "version": "1.47.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.47.0.tgz", + "integrity": "sha512-QBmA/G2y+IfeS4oktet3qRZ+P5kPhCKRXxXnQEudYqUaEioAU1/Lq2us3D/t1Jfo4hE9REQPrbB7K5sOczJVIw==", "dev": true }, "mime-types": { - "version": "2.1.27", - "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.27.tgz", - "integrity": "sha512-JIhqnCasI9yD+SsmkquHBxTSEuZdQX5BuQnS2Vc7puQQQ+8yiP5AY5uWhpdv4YL4VM5c6iliiYWPgJ/nJQLp7w==", + "version": "2.1.30", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.30.tgz", + "integrity": "sha512-crmjA4bLtR8m9qLpHvgxSChT+XoSlZi8J4n/aIdn3z92e/U47Z0V/yl+Wh9W046GgFVAmoNR/fmdbZYcSSIUeg==", "dev": true, "requires": { - "mime-db": "1.44.0" + "mime-db": "1.47.0" } }, "minimatch": { @@ -779,10 +788,13 @@ "dev": true }, "semver": { - "version": "7.3.2", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.2.tgz", - "integrity": "sha512-OrOb32TeeambH6UrhtShmF7CRDqhL6/5XpPNp2DuRH6+9QLw/orhp72j87v8Qa1ScDkvrrBNpZcDejAirJmfXQ==", - "dev": true + "version": "7.3.5", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.5.tgz", + "integrity": "sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ==", + "dev": true, + "requires": { + "lru-cache": "^6.0.0" + } }, "set-blocking": { "version": "2.0.0", @@ -843,9 +855,9 @@ } }, "tar": { - "version": "6.0.5", - "resolved": "https://registry.npmjs.org/tar/-/tar-6.0.5.tgz", - "integrity": "sha512-0b4HOimQHj9nXNEAA7zWwMM91Zhhba3pspja6sQbgTpynOJf+bkjBnfybNYzbpLbnwXnbyB4LOREvlyXLkCHSg==", + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/tar/-/tar-6.1.0.tgz", + "integrity": "sha512-DUCttfhsnLCjwoDoFcI+B2iJgYa93vBnDUATYEeRx6sntCTdN01VnqsIuTlALXla/LWooNg0yEGeB+Y8WdFxGA==", "dev": true, "requires": { "chownr": "^2.0.0", @@ -928,9 +940,9 @@ "dev": true }, "uri-js": { - "version": "4.4.0", - "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.0.tgz", - "integrity": "sha512-B0yRTzYdUCCn9n+F4+Gh4yIDtMQcaJsmYBDsTSG8g/OejKBodLQ2IHfN3bM7jUsRXndopT7OIXWdYqc1fjmV6g==", + "version": "4.4.1", + "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", + "integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==", "dev": true, "requires": { "punycode": "^2.1.0" diff --git a/package.json b/package.json index 845a4dc..c0da048 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,7 @@ "node-gyp-build": "4.2.3" }, "devDependencies": { - "node-gyp": "7.1.1", + "node-gyp": "^7.1.1", "prebuildify": "4.1.0" } } From f6d77ebf2b6faa99af181bccd2c9240ea0e07a9e Mon Sep 17 00:00:00 2001 From: WhySoBad <49595640+WhySoBad@users.noreply.github.com> Date: Sat, 24 Apr 2021 15:59:08 +0200 Subject: [PATCH 3/5] Update package.json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c0da048..845a4dc 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,7 @@ "node-gyp-build": "4.2.3" }, "devDependencies": { - "node-gyp": "^7.1.1", + "node-gyp": "7.1.1", "prebuildify": "4.1.0" } } From 4f284f5f995c62377851888542296b740f0dfe29 Mon Sep 17 00:00:00 2001 From: WhySoBad <49595640+WhySoBad@users.noreply.github.com> Date: Sat, 24 Apr 2021 16:06:00 +0200 Subject: [PATCH 4/5] Update package-lock.json --- package-lock.json | 70 ++++++++++++++++++++--------------------------- 1 file changed, 29 insertions(+), 41 deletions(-) diff --git a/package-lock.json b/package-lock.json index 1de60f4..cb57877 100644 --- a/package-lock.json +++ b/package-lock.json @@ -72,15 +72,15 @@ "dev": true }, "aws4": { - "version": "1.11.0", - "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.11.0.tgz", - "integrity": "sha512-xh1Rl34h6Fi1DC2WWKfxUTVqRsNnr6LsKz2+hfwDxQJWmrx8+c7ylaqBMcHfl1U1r2dsifOvKX3LQuLNZ+XSvA==", + "version": "1.10.1", + "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.10.1.tgz", + "integrity": "sha512-zg7Hz2k5lI8kb7U32998pRRFin7zJlkfezGJjUc2heaD4Pw2wObakCDVzkKztTm/Ln7eiVvYsjqak0Ed4LkMDA==", "dev": true }, "balanced-match": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", - "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", + "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", "dev": true }, "base64-js": { @@ -228,9 +228,9 @@ } }, "env-paths": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/env-paths/-/env-paths-2.2.1.tgz", - "integrity": "sha512-+h1lkLKhZMTYjog1VEpJNG7NZJWcuc2DDk/qsqSTRRCOXiLjeQ1d1/udrUGhqMxUgAlwKNZ0cf2uqan5GLuS2A==", + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/env-paths/-/env-paths-2.2.0.tgz", + "integrity": "sha512-6u0VYSCo/OW6IoD5WCLLy9JUGARbamfSavcNXry/eu8aHVFei6CD3Sw+VGX5alea1i9pgPHW0mbu6Xj0uBh7gA==", "dev": true }, "execspawn": { @@ -344,9 +344,9 @@ } }, "graceful-fs": { - "version": "4.2.6", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.6.tgz", - "integrity": "sha512-nTnJ528pbqxYanhpDYsi4Rd8MAeaBA67+RZ10CM1m3bTAVFEDcd5AuA4a6W5YkGZ1iNXHzZz8T6TBKLeBuNriQ==", + "version": "4.2.4", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.4.tgz", + "integrity": "sha512-WjKPNJF79dtJAVniUlGGWHYGz2jWxT6VhN/4m1NdkbZ2nOsEF+cI1Edgql5zCRhs/VsQYRvrXctxktVXZUkixw==", "dev": true }, "har-schema": { @@ -473,28 +473,19 @@ "verror": "1.10.0" } }, - "lru-cache": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", - "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", - "dev": true, - "requires": { - "yallist": "^4.0.0" - } - }, "mime-db": { - "version": "1.47.0", - "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.47.0.tgz", - "integrity": "sha512-QBmA/G2y+IfeS4oktet3qRZ+P5kPhCKRXxXnQEudYqUaEioAU1/Lq2us3D/t1Jfo4hE9REQPrbB7K5sOczJVIw==", + "version": "1.44.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.44.0.tgz", + "integrity": "sha512-/NOTfLrsPBVeH7YtFPgsVWveuL+4SjjYxaQ1xtM1KMFj7HdxlBlxeyNLzhyJVx7r4rZGJAZ/6lkKCitSc/Nmpg==", "dev": true }, "mime-types": { - "version": "2.1.30", - "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.30.tgz", - "integrity": "sha512-crmjA4bLtR8m9qLpHvgxSChT+XoSlZi8J4n/aIdn3z92e/U47Z0V/yl+Wh9W046GgFVAmoNR/fmdbZYcSSIUeg==", + "version": "2.1.27", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.27.tgz", + "integrity": "sha512-JIhqnCasI9yD+SsmkquHBxTSEuZdQX5BuQnS2Vc7puQQQ+8yiP5AY5uWhpdv4YL4VM5c6iliiYWPgJ/nJQLp7w==", "dev": true, "requires": { - "mime-db": "1.47.0" + "mime-db": "1.44.0" } }, "minimatch": { @@ -788,13 +779,10 @@ "dev": true }, "semver": { - "version": "7.3.5", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.5.tgz", - "integrity": "sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ==", - "dev": true, - "requires": { - "lru-cache": "^6.0.0" - } + "version": "7.3.2", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.2.tgz", + "integrity": "sha512-OrOb32TeeambH6UrhtShmF7CRDqhL6/5XpPNp2DuRH6+9QLw/orhp72j87v8Qa1ScDkvrrBNpZcDejAirJmfXQ==", + "dev": true }, "set-blocking": { "version": "2.0.0", @@ -855,9 +843,9 @@ } }, "tar": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/tar/-/tar-6.1.0.tgz", - "integrity": "sha512-DUCttfhsnLCjwoDoFcI+B2iJgYa93vBnDUATYEeRx6sntCTdN01VnqsIuTlALXla/LWooNg0yEGeB+Y8WdFxGA==", + "version": "6.0.5", + "resolved": "https://registry.npmjs.org/tar/-/tar-6.0.5.tgz", + "integrity": "sha512-0b4HOimQHj9nXNEAA7zWwMM91Zhhba3pspja6sQbgTpynOJf+bkjBnfybNYzbpLbnwXnbyB4LOREvlyXLkCHSg==", "dev": true, "requires": { "chownr": "^2.0.0", @@ -940,9 +928,9 @@ "dev": true }, "uri-js": { - "version": "4.4.1", - "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", - "integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==", + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.0.tgz", + "integrity": "sha512-B0yRTzYdUCCn9n+F4+Gh4yIDtMQcaJsmYBDsTSG8g/OejKBodLQ2IHfN3bM7jUsRXndopT7OIXWdYqc1fjmV6g==", "dev": true, "requires": { "punycode": "^2.1.0" From d065ca1fbea5a07f07508049e5c216c427418e77 Mon Sep 17 00:00:00 2001 From: Corsin Date: Sat, 24 Apr 2021 16:18:25 +0200 Subject: [PATCH 5/5] finished CorsairDeviceInfo --- index.d.ts | 156 +++++++++++++++++++++++++++-------------------------- 1 file changed, 80 insertions(+), 76 deletions(-) diff --git a/index.d.ts b/index.d.ts index 590c935..6489e34 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1,5 +1,3 @@ -import { LogicalLayout } from '../../src/types' - export enum CorsairDeviceType { CDT_Unknown = 0, CDT_Mouse = 1, @@ -12,7 +10,7 @@ export enum CorsairDeviceType { CDT_MemoryModule = 8, CDT_Cooler = 9, CDT_Motherboard = 10, - CDT_GraphicsCard = 11 + CDT_GraphicsCard = 11, } export enum CorsairPhysicalLayout { @@ -27,7 +25,7 @@ export enum CorsairPhysicalLayout { CDT_MemoryModule = 8, CDT_Cooler = 9, CDT_Motherboard = 10, - CDT_GraphicsCard = 11 + CDT_GraphicsCard = 11, } export enum CorsairLogicalLayout { @@ -49,7 +47,7 @@ export enum CorsairLogicalLayout { CLL_JP = 15, CLL_KR = 16, CLL_TW = 17, - CLL_MEX = 18 + CLL_MEX = 18, } export type CorsairLogicalLayoutString = [ @@ -71,17 +69,17 @@ export type CorsairLogicalLayoutString = [ 'CLL_JP', 'CLL_KR', 'CLL_TW', - 'CLL_MEX' -] + 'CLL_MEX', +]; export enum CorsairDeviceCaps { CDC_None = 0x0000, CDC_Lighting = 0x0001, - CDC_PropertyLookup = 0x0002 + CDC_PropertyLookup = 0x0002, } export enum CorsairAccessMode { - CAM_ExclusiveLightingControl = 0 + CAM_ExclusiveLightingControl = 0, } export enum CorsairError { @@ -90,7 +88,7 @@ export enum CorsairError { CE_NoControl = 2, CE_ProtocolHandshakeMissing = 3, CE_IncompatibleProtocol = 4, - CE_InvalidArguments = 5 + CE_InvalidArguments = 5, } export type CorsairErrorString = [ @@ -99,8 +97,8 @@ export type CorsairErrorString = [ 'CE_NoControl', 'CE_ProtocolHandshakeMissing', 'CE_IncompatibleProtocol', - 'CE_InvalidArguments' -] + 'CE_InvalidArguments', +]; export enum CorsairChannelDeviceType { CCDT_Invalid = 0, @@ -113,62 +111,68 @@ export enum CorsairChannelDeviceType { CCDT_Pump = 7, CCDT_QL_Fan = 8, CCDT_WaterBlock = 9, - CCDT_SPPRO_Fan = 10 + CCDT_SPPRO_Fan = 10, } export enum CorsairDevicePropertyType { CDPT_Boolean = 0x1000, - CDPT_Int32 = 0x2000 + CDPT_Int32 = 0x2000, } export enum CorsairDevicePropertyId { CDPI_Headset_MicEnabled = 0x1000, CDPI_Headset_SurroundSoundEnabled = 0x1001, CDPI_Headset_SidetoneEnabled = 0x1002, - CDPI_Headset_EqualizerPreset = 0x2000 + CDPI_Headset_EqualizerPreset = 0x2000, } export interface CorsairProtocolHandshake { - sdkVersion: string - serverVersion: string - sdkProtocolVersion: number - serverProtocolVersion: number - breakingChanges: boolean + sdkVersion: string; + serverVersion: string; + sdkProtocolVersion: number; + serverProtocolVersion: number; + breakingChanges: boolean; +} + +export interface CorsairChannelDeviceInfo { + type: CorsairChannelDeviceType; + deviceLedCount: number; +} + +export interface CorsairChannelInfo { + totalLedsCount: number; + devicesCount: number; + devices: Array; +} + +export interface CorsairChannelsInfo { + channelsCount: number; + channels?: Array; } export interface CorsairDeviceInfo { - type: number - model: string - physicalLayout: CorsairPhysicalLayout - logicalLayout: CorsairLogicalLayout - capsMask: number - ledsCount: number - channels: { - channelsCount: number - channels?: Array<{ - totalLedsCount: number - devicesCount: number - devices: Array<{ - type: CorsairDeviceType - deviceLedCount: number - }> - }> - } + type: number; + model: string; + physicalLayout: CorsairPhysicalLayout; + logicalLayout: CorsairLogicalLayout; + capsMask: number; + ledsCount: number; + channels: CorsairChannelsInfo; } export interface CorsairLedColor { - ledId: number - r: number - g: number - b: number + ledId: number; + r: number; + g: number; + b: number; } export interface CorsairLed { - ledId: number - top: number - left: number - height: number - width: number + ledId: number; + top: number; + left: number; + height: number; + width: number; } /** @@ -177,7 +181,7 @@ export interface CorsairLed { * @returns number */ -export function CorsairGetLastError(): number +export function CorsairGetLastError(): number; /** * Function to get the amount of conntected @@ -187,7 +191,7 @@ export function CorsairGetLastError(): number * @returns number */ -export function CorsairGetDeviceCount(): number +export function CorsairGetDeviceCount(): number; /** * Function to check file and protocol version of CUE @@ -195,7 +199,7 @@ export function CorsairGetDeviceCount(): number * @returns CorsairProtocolHandshake */ -export function CorsairPerformProtocolHandshake(): CorsairProtocolHandshake +export function CorsairPerformProtocolHandshake(): CorsairProtocolHandshake; /** * Function to get the device information by @@ -208,8 +212,8 @@ export function CorsairPerformProtocolHandshake(): CorsairProtocolHandshake */ export function CorsairGetDeviceInfo( - device: number -): CorsairDeviceInfo | undefined + device: number, +): CorsairDeviceInfo | undefined; /** * Function to get the current color for CorsairLedColor's in an array. @@ -223,7 +227,7 @@ export function CorsairGetDeviceInfo( * @returns boolean */ -export function CorsairGetLedsColors(colors: Array): boolean +export function CorsairGetLedsColors(colors: Array): boolean; /** * Function to set the current color for CorsairLedColor's in an array @@ -233,7 +237,7 @@ export function CorsairGetLedsColors(colors: Array): boolean * @returns boolean */ -export function CorsairSetLedsColors(colors: Array): boolean +export function CorsairSetLedsColors(colors: Array): boolean; /** * Function to get the current color for CorsairLedColor's in an array @@ -251,8 +255,8 @@ export function CorsairSetLedsColors(colors: Array): boolean export function CorsairGetLedsColorsByDeviceIndex( deviceIndex: number, - colors: Array -): boolean + colors: Array, +): boolean; /** * Function to set the current color for CorsairLedColor's in an array for a @@ -268,8 +272,8 @@ export function CorsairGetLedsColorsByDeviceIndex( export function CorsairSetLedsColorsBufferByDeviceIndex( deviceIndex: number, - colors: Array -): boolean + colors: Array, +): boolean; /** * Function to write the previously filled buffer @@ -279,7 +283,7 @@ export function CorsairSetLedsColorsBufferByDeviceIndex( * @returns boolean */ -export function CorsairSetLedsColorsFlushBuffer(): boolean +export function CorsairSetLedsColorsFlushBuffer(): boolean; /** * Function to write the previously filled buffer @@ -292,8 +296,8 @@ export function CorsairSetLedsColorsFlushBuffer(): boolean */ export function CorsairSetLedsColorsFlushBufferAsync( - callback: Function -): boolean + callback: Function, +): boolean; /** * Function to set the current color for all CorsairLedColor's in an array @@ -309,8 +313,8 @@ export function CorsairSetLedsColorsFlushBufferAsync( export function CorsairSetLedsColorsAsync( colors: Array, - callback: Function -): boolean + callback: Function, +): boolean; /** * Function to get an array with CorsairLed containing @@ -320,7 +324,7 @@ export function CorsairSetLedsColorsAsync( * @returns Array */ -export function CorsairGetLedPositions(): Array +export function CorsairGetLedPositions(): Array; /** * Function to get an array with CorsairLed containing @@ -333,8 +337,8 @@ export function CorsairGetLedPositions(): Array */ export function CorsairGetLedPositionsByDeviceIndex( - deviceIndex: number -): Array + deviceIndex: number, +): Array; /** * Function to get the ledId for a @@ -344,7 +348,7 @@ export function CorsairGetLedPositionsByDeviceIndex( * @returns number */ -export function CorsairGetLedIdForKeyName(key: string): number +export function CorsairGetLedIdForKeyName(key: string): number; /** * Function to request explusive control @@ -352,7 +356,7 @@ export function CorsairGetLedIdForKeyName(key: string): number * @returns boolean */ -export function CorsairRequestControl(): boolean +export function CorsairRequestControl(): boolean; /** * Function to release exclusive requested control @@ -360,7 +364,7 @@ export function CorsairRequestControl(): boolean * @returns boolean */ -export function CorsairReleaseControl(): boolean +export function CorsairReleaseControl(): boolean; /** * Function to set the priority for the layer. The priority @@ -372,7 +376,7 @@ export function CorsairReleaseControl(): boolean * @returns boolean */ -export function CorsairSetLayerPriority(priority: number): boolean +export function CorsairSetLayerPriority(priority: number): boolean; /** * Function to get the property for a device @@ -386,8 +390,8 @@ export function CorsairSetLayerPriority(priority: number): boolean export function CorsairGetDeviceProperty( deviceIndex: number, - propertyId: number -): void + propertyId: number, +): void; /** * Function to subscribe to events. The callback param gets @@ -401,10 +405,10 @@ export function CorsairGetDeviceProperty( export function CorsairSubscribeForEvents( callback: (event: { - id: 'macrokeydown' | 'macrokeyup' | 'deviceconnect' | 'devicedisconnect' - deviceId: string - }) => void -): boolean + id: 'macrokeydown' | 'macrokeyup' | 'deviceconnect' | 'devicedisconnect'; + deviceId: string; + }) => void, +): boolean; /** * Function to unsubscribe from events @@ -412,4 +416,4 @@ export function CorsairSubscribeForEvents( * @returns boolean */ -export function CorsairUnsubscribeFromEvents(): boolean +export function CorsairUnsubscribeFromEvents(): boolean;