Skip to content

Commit

Permalink
Use KnownHeadphoneFactory
Browse files Browse the repository at this point in the history
  • Loading branch information
richrace committed Jul 28, 2024
1 parent 4d40391 commit ac9cfe0
Show file tree
Hide file tree
Showing 2 changed files with 232 additions and 47 deletions.
244 changes: 197 additions & 47 deletions src/headphone_list.ts
Original file line number Diff line number Diff line change
@@ -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;
35 changes: 35 additions & 0 deletions src/models/known_headphone.ts
Original file line number Diff line number Diff line change
@@ -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;

Expand Down

0 comments on commit ac9cfe0

Please sign in to comment.