41 lines
1.6 KiB
TypeScript
41 lines
1.6 KiB
TypeScript
/**
|
||
* Firmware version gates for UI features.
|
||
*
|
||
* Versions are compared using `parseFirmwareVersion` (e.g. 2007 → 2.0.0.7).
|
||
* Adjust thresholds here instead of hardcoding in page components.
|
||
*/
|
||
export const FIRMWARE_FEATURE_MIN_VERSION = {
|
||
/** Boot sound: indices 7–10 (-35…-50 dB); legacy firmware caps at index 6. */
|
||
bootSoundExtendedSteps: 26,
|
||
/** Subwoofer LPF/HPF full-range toggles on the Effects page. */
|
||
subwooferFullRange: 2001,
|
||
/** Hearing compensation section on the Effects page. */
|
||
hearingCompensation: 2007,
|
||
/** PEQ preset rename (peqRename) and reorder (peqSoft) in manage dialog. */
|
||
peqPresetRenameAndSort: 2008,
|
||
/** Audio 页面耳机最大音量和耳机启动音量设置。 */
|
||
hpVolumeSettings: 2011,
|
||
} as const;
|
||
|
||
export type FirmwareFeatureKey = keyof typeof FIRMWARE_FEATURE_MIN_VERSION;
|
||
|
||
export function isFirmwareFeatureAvailable(
|
||
feature: FirmwareFeatureKey,
|
||
firmwareVersion: number,
|
||
): boolean {
|
||
return firmwareVersion >= FIRMWARE_FEATURE_MIN_VERSION[feature];
|
||
}
|
||
|
||
/** Max `bootSound` select index (0–6 legacy, 0–10 when extended steps are supported). */
|
||
export function getBootSoundMaxIndex(firmwareVersion: number): number {
|
||
return isFirmwareFeatureAvailable("bootSoundExtendedSteps", firmwareVersion) ? 10 : 6;
|
||
}
|
||
|
||
export function supportsPeqPresetRenameAndSort(firmwareVersion: number): boolean {
|
||
return isFirmwareFeatureAvailable("peqPresetRenameAndSort", firmwareVersion);
|
||
}
|
||
|
||
export function supportsHpVolumeSettings(firmwareVersion: number): boolean {
|
||
return isFirmwareFeatureAvailable("hpVolumeSettings", firmwareVersion);
|
||
}
|