diff --git a/src/headphone_list.ts b/src/headphone_list.ts index 1cd0f39..0fd69af 100644 --- a/src/headphone_list.ts +++ b/src/headphone_list.ts @@ -1,57 +1,207 @@ -import KnownHeadphone from './models/known_headphone'; +import KnownHeadphone, { KnownHeadphoneFactory } from './models/known_headphone'; const list: KnownHeadphone[] = [ - new KnownHeadphone('Arctis Pro Wireless', KnownHeadphone.ArctisPro_Wireless_ProductID, [0x40, 0xaa], 0, 0, 0, 0), - new KnownHeadphone( - 'Arctis Nova Pro Wireless', - KnownHeadphone.Arctis_Nova_Pro_Wireless_ProductID, - [0x06, 0xb0], - 0, - 0, - 4, - 6, - 15 - ), + KnownHeadphoneFactory({ + name: 'Arctis Pro Wireless', + productId: KnownHeadphone.ArctisPro_Wireless_ProductID, + writeBytes: [0x40, 0xaa], + usagePage: 0, + usage: 0, + interfaceNum: 0, + batteryPercentIdx: 0 + }), + KnownHeadphoneFactory({ + name: 'Arctis Nova Pro Wireless', + productId: KnownHeadphone.Arctis_Nova_Pro_Wireless_ProductID, + writeBytes: [0x06, 0xb0], + usagePage: 0, + usage: 0, + interfaceNum: 4, + batteryPercentIdx: 6, + chargingStatusIdx: 15 + }), - new KnownHeadphone('Arctis 7 2017', KnownHeadphone.Arctis7_2017_ProductID, [0x06, 0x18], 0, 0, 0x05, 2), - new KnownHeadphone('Arctis 7 2019', KnownHeadphone.Arctis7_2019_ProductID, [0x06, 0x18], 0, 0, 0x05, 2), - new KnownHeadphone('Arctis Pro 2019', KnownHeadphone.ArctisPro_2019_ProductID, [0x06, 0x18], 0, 0, 0x05, 2), - new KnownHeadphone('Arctis Pro GameDac', KnownHeadphone.ArctisPro_GameDac_ProductID, [0x06, 0x18], 0, 0, 0x05, 2), + KnownHeadphoneFactory({ + name: 'Arctis 7 2017', + productId: KnownHeadphone.Arctis7_2017_ProductID, + writeBytes: [0x06, 0x18], + usagePage: 0, + usage: 0, + interfaceNum: 0x05, + batteryPercentIdx: 2 + }), + KnownHeadphoneFactory({ + name: 'Arctis 7 2019', + productId: KnownHeadphone.Arctis7_2019_ProductID, + writeBytes: [0x06, 0x18], + usagePage: 0, + usage: 0, + interfaceNum: 0x05, + batteryPercentIdx: 2 + }), + KnownHeadphoneFactory({ + name: 'Arctis Pro 2019', + productId: KnownHeadphone.ArctisPro_2019_ProductID, + writeBytes: [0x06, 0x18], + usagePage: 0, + usage: 0, + interfaceNum: 0x05, + batteryPercentIdx: 2 + }), + KnownHeadphoneFactory({ + name: 'Arctis Pro GameDac', + productId: KnownHeadphone.ArctisPro_GameDac_ProductID, + writeBytes: [0x06, 0x18], + usagePage: 0, + usage: 0, + interfaceNum: 0x05, + batteryPercentIdx: 2 + }), - new KnownHeadphone('Arctis 9', KnownHeadphone.Arctis9_ProductID, [0x0, 0x20], 0, 0, 0, 3, 4), + KnownHeadphoneFactory({ + name: 'Arctis 9', + productId: KnownHeadphone.Arctis9_ProductID, + writeBytes: [0x0, 0x20], + usagePage: 0, + usage: 0, + interfaceNum: 0, + batteryPercentIdx: 3, + chargingStatusIdx: 4 + }), - new KnownHeadphone('Arctis 1 Wireless', KnownHeadphone.Arctis1W_ProductID, [0x06, 0x12], 0xff43, 0x202, 0x03, 3, 4), - new KnownHeadphone('Arctis 1 Xbox', KnownHeadphone.Arctis1X_ProductID, [0x06, 0x12], 0xff43, 0x202, 0x03, 3, 4), - new KnownHeadphone('Arctis 7X', KnownHeadphone.Arctis7X_ProductID, [0x06, 0x12], 0xff43, 0x202, 0x03, 3, 4, 5), - new KnownHeadphone('Arctis 7P', KnownHeadphone.Arctis7P_ProductID, [0x06, 0x12], 0xff43, 0x0202, 3, 3, 4), + KnownHeadphoneFactory({ + name: 'Arctis 1 Wireless', + productId: KnownHeadphone.Arctis1W_ProductID, + writeBytes: [0x06, 0x12], + usagePage: 0xff43, + usage: 0x202, + interfaceNum: 0x03, + batteryPercentIdx: 3, + chargingStatusIdx: 4 + }), + KnownHeadphoneFactory({ + name: 'Arctis 1 Xbox', + productId: KnownHeadphone.Arctis1X_ProductID, + writeBytes: [0x06, 0x12], + usagePage: 0xff43, + usage: 0x202, + interfaceNum: 0x03, + batteryPercentIdx: 3, + chargingStatusIdx: 4 + }), + KnownHeadphoneFactory({ + name: 'Arctis 7X', + productId: KnownHeadphone.Arctis7X_ProductID, + writeBytes: [0x06, 0x12], + usagePage: 0xff43, + usage: 0x202, + interfaceNum: 0x03, + batteryPercentIdx: 3, + chargingStatusIdx: 4, + micStatusIdx: 5 + }), + KnownHeadphoneFactory({ + name: 'Arctis 7P', + productId: KnownHeadphone.Arctis7P_ProductID, + writeBytes: [0x06, 0x12], + usagePage: 0xff43, + usage: 0x202, + interfaceNum: 0x03, + batteryPercentIdx: 3, + chargingStatusIdx: 4 + }), - new KnownHeadphone('Arctis 7 Plus', KnownHeadphone.Arctis7_Plus_ProductID, [0x00, 0xb0], 0xffc0, 0x1, 3, 2, 3), - new KnownHeadphone('Arctis 7P Plus', KnownHeadphone.Arctis7P_Plus_ProductID, [0x00, 0xb0], 0xffc0, 0x1, 3, 2, 3), - new KnownHeadphone('Arctis 7X Plus', KnownHeadphone.Arctis7X_Plus_ProductID, [0x00, 0xb0], 0xffc0, 0x1, 3, 2, 3), - new KnownHeadphone( - 'Arctis 7 Destiny Plus', - KnownHeadphone.Arctis7_Plus_Destiny_ProductID, - [0x00, 0xb0], - 0xffc0, - 0x1, - 2, - 3 - ), + KnownHeadphoneFactory({ + name: 'Arctis 7 Plus', + productId: KnownHeadphone.Arctis7_Plus_ProductID, + writeBytes: [0x00, 0xb0], + usagePage: 0xffc0, + usage: 0x1, + interfaceNum: 3, + batteryPercentIdx: 2, + chargingStatusIdx: 3 + }), + KnownHeadphoneFactory({ + name: 'Arctis 7P Plus', + productId: KnownHeadphone.Arctis7P_Plus_ProductID, + writeBytes: [0x00, 0xb0], + usagePage: 0xffc0, + usage: 0x1, + interfaceNum: 3, + batteryPercentIdx: 2, + chargingStatusIdx: 3 + }), + KnownHeadphoneFactory({ + name: 'Arctis 7X Plus', + productId: KnownHeadphone.Arctis7X_Plus_ProductID, + writeBytes: [0x00, 0xb0], + usagePage: 0xffc0, + usage: 0x1, + interfaceNum: 3, + batteryPercentIdx: 2, + chargingStatusIdx: 3 + }), + KnownHeadphoneFactory({ + name: 'Arctis 7 Destiny Plus', + productId: KnownHeadphone.Arctis7_Plus_Destiny_ProductID, + writeBytes: [0x00, 0xb0], + usagePage: 0xffc0, + usage: 0x1, + interfaceNum: 3, + batteryPercentIdx: 2, + chargingStatusIdx: 3 + }), - new KnownHeadphone('Arctis Nova 7', KnownHeadphone.ArctisNova7_ProductID, [0x00, 0xb0], 0xffc0, 0x1, 3, 2, 3), - new KnownHeadphone('Arctis Nova 7X', KnownHeadphone.ArctisNova7X_ProductID, [0x00, 0xb0], 0xffc0, 0x1, 3, 2, 3), - new KnownHeadphone('Arctis Nova 7P', KnownHeadphone.ArctisNova7P_ProductID, [0x00, 0xb0], 0xffc0, 0x1, 3, 2, 3), - new KnownHeadphone('Arctis Nova 7X V2', KnownHeadphone.ArctisNova7X_V2_ProductID, [0x00, 0xb0], 0xffc0, 0x1, 3, 2, 3), - new KnownHeadphone( - 'Arctis Nova 7 Diablo IV', - KnownHeadphone.ArctisNova7_Diablo_IV_ProductID, - [0x00, 0xb0], - 0xffc0, - 0x1, - 3, - 2, - 3 - ) + KnownHeadphoneFactory({ + name: 'Arctis Nova 7', + productId: KnownHeadphone.ArctisNova7_ProductID, + writeBytes: [0x00, 0xb0], + usagePage: 0xffc0, + usage: 0x1, + interfaceNum: 3, + batteryPercentIdx: 2, + chargingStatusIdx: 3 + }), + KnownHeadphoneFactory({ + name: 'Arctis Nova 7X', + productId: KnownHeadphone.ArctisNova7X_ProductID, + writeBytes: [0x00, 0xb0], + usagePage: 0xffc0, + usage: 0x1, + interfaceNum: 3, + batteryPercentIdx: 2, + chargingStatusIdx: 3 + }), + KnownHeadphoneFactory({ + name: 'Arctis Nova 7P', + productId: KnownHeadphone.ArctisNova7P_ProductID, + writeBytes: [0x00, 0xb0], + usagePage: 0xffc0, + usage: 0x1, + interfaceNum: 3, + batteryPercentIdx: 2, + chargingStatusIdx: 3 + }), + KnownHeadphoneFactory({ + name: 'Arctis Nova 7X V2', + productId: KnownHeadphone.ArctisNova7X_V2_ProductID, + writeBytes: [0x00, 0xb0], + usagePage: 0xffc0, + usage: 0x1, + interfaceNum: 3, + batteryPercentIdx: 2, + chargingStatusIdx: 3 + }), + KnownHeadphoneFactory({ + name: 'Arctis Nova 7 Diablo IV', + productId: KnownHeadphone.ArctisNova7_Diablo_IV_ProductID, + writeBytes: [0x00, 0xb0], + usagePage: 0xffc0, + usage: 0x1, + interfaceNum: 3, + batteryPercentIdx: 2, + chargingStatusIdx: 3 + }) ]; export default list; diff --git a/src/models/known_headphone.ts b/src/models/known_headphone.ts index 7a3e2b1..c4b8383 100644 --- a/src/models/known_headphone.ts +++ b/src/models/known_headphone.ts @@ -1,3 +1,38 @@ +interface KnownHeadphoneProps { + name: string; + productId: number; + writeBytes: number[]; + usagePage: number; + usage: number; + interfaceNum: number; + batteryPercentIdx: number; + chargingStatusIdx?: number; + micStatusIdx?: number; +} + +export const KnownHeadphoneFactory = ({ + name, + productId, + writeBytes, + usagePage, + usage, + interfaceNum, + batteryPercentIdx, + chargingStatusIdx, + micStatusIdx +}: KnownHeadphoneProps): KnownHeadphone => + new KnownHeadphone( + name, + productId, + writeBytes, + usagePage, + usage, + interfaceNum, + batteryPercentIdx, + chargingStatusIdx, + micStatusIdx + ); + export default class KnownHeadphone { static ArctisVendorID = 4152;