fix: 完善前端 USB OTG 动态配置功能的选项

This commit is contained in:
mofeng
2026-01-27 22:16:45 +08:00
parent 9d5451f588
commit 46c2edeb96
5 changed files with 13 additions and 3 deletions

View File

@@ -166,6 +166,8 @@ impl Default for OtgDescriptorConfig {
pub enum OtgHidProfile { pub enum OtgHidProfile {
/// Full HID device set (keyboard + relative mouse + absolute mouse + consumer control) /// Full HID device set (keyboard + relative mouse + absolute mouse + consumer control)
Full, Full,
/// Full HID device set without MSD
FullNoMsd,
/// Legacy profile: only keyboard /// Legacy profile: only keyboard
LegacyKeyboard, LegacyKeyboard,
/// Legacy profile: only relative mouse /// Legacy profile: only relative mouse
@@ -234,6 +236,7 @@ impl OtgHidProfile {
pub fn resolve_functions(&self, custom: &OtgHidFunctions) -> OtgHidFunctions { pub fn resolve_functions(&self, custom: &OtgHidFunctions) -> OtgHidFunctions {
match self { match self {
Self::Full => OtgHidFunctions::full(), Self::Full => OtgHidFunctions::full(),
Self::FullNoMsd => OtgHidFunctions::full(),
Self::LegacyKeyboard => OtgHidFunctions::legacy_keyboard(), Self::LegacyKeyboard => OtgHidFunctions::legacy_keyboard(),
Self::LegacyMouseRelative => OtgHidFunctions::legacy_mouse_relative(), Self::LegacyMouseRelative => OtgHidFunctions::legacy_mouse_relative(),
Self::Custom => custom.clone(), Self::Custom => custom.clone(),

View File

@@ -584,7 +584,8 @@ export default {
otgHidProfile: 'OTG HID Profile', otgHidProfile: 'OTG HID Profile',
otgHidProfileDesc: 'Select which HID functions are exposed to the host', otgHidProfileDesc: 'Select which HID functions are exposed to the host',
profile: 'Profile', profile: 'Profile',
otgProfileFull: 'Full (keyboard + relative mouse + absolute mouse + consumer)', otgProfileFull: 'Full (keyboard + relative mouse + absolute mouse + consumer + MSD)',
otgProfileFullNoMsd: 'Full (keyboard + relative mouse + absolute mouse + consumer, no MSD)',
otgProfileLegacyKeyboard: 'Legacy: keyboard only', otgProfileLegacyKeyboard: 'Legacy: keyboard only',
otgProfileLegacyMouseRelative: 'Legacy: relative mouse only', otgProfileLegacyMouseRelative: 'Legacy: relative mouse only',
otgProfileCustom: 'Custom', otgProfileCustom: 'Custom',

View File

@@ -584,7 +584,8 @@ export default {
otgHidProfile: 'OTG HID 组合', otgHidProfile: 'OTG HID 组合',
otgHidProfileDesc: '选择对目标主机暴露的 HID 功能', otgHidProfileDesc: '选择对目标主机暴露的 HID 功能',
profile: '组合', profile: '组合',
otgProfileFull: '完整(键盘 + 相对鼠标 + 绝对鼠标 + 多媒体)', otgProfileFull: '完整(键盘 + 相对鼠标 + 绝对鼠标 + 多媒体 + 虚拟媒体',
otgProfileFullNoMsd: '完整(键盘 + 相对鼠标 + 绝对鼠标 + 多媒体,不含虚拟媒体)',
otgProfileLegacyKeyboard: '兼容:仅键盘', otgProfileLegacyKeyboard: '兼容:仅键盘',
otgProfileLegacyMouseRelative: '兼容:仅相对鼠标', otgProfileLegacyMouseRelative: '兼容:仅相对鼠标',
otgProfileCustom: '自定义', otgProfileCustom: '自定义',
@@ -596,7 +597,7 @@ export default {
otgFunctionMouseAbsoluteDesc: '绝对定位(类似触控)', otgFunctionMouseAbsoluteDesc: '绝对定位(类似触控)',
otgFunctionConsumer: '多媒体控制', otgFunctionConsumer: '多媒体控制',
otgFunctionConsumerDesc: '音量/播放/暂停等按键', otgFunctionConsumerDesc: '音量/播放/暂停等按键',
otgFunctionMsd: 'U盘MSD', otgFunctionMsd: '虚拟媒体MSD',
otgFunctionMsdDesc: '向目标主机暴露 USB 存储', otgFunctionMsdDesc: '向目标主机暴露 USB 存储',
otgProfileWarning: '修改 HID 功能将导致 USB 设备重新连接', otgProfileWarning: '修改 HID 功能将导致 USB 设备重新连接',
otgFunctionMinWarning: '请至少启用一个 HID 功能后再保存', otgFunctionMinWarning: '请至少启用一个 HID 功能后再保存',

View File

@@ -58,6 +58,8 @@ export interface OtgDescriptorConfig {
export enum OtgHidProfile { export enum OtgHidProfile {
/** Full HID device set (keyboard + relative mouse + absolute mouse + consumer control) */ /** Full HID device set (keyboard + relative mouse + absolute mouse + consumer control) */
Full = "full", Full = "full",
/** Full HID device set without MSD */
FullNoMsd = "full_no_msd",
/** Legacy profile: only keyboard */ /** Legacy profile: only keyboard */
LegacyKeyboard = "legacy_keyboard", LegacyKeyboard = "legacy_keyboard",
/** Legacy profile: only relative mouse */ /** Legacy profile: only relative mouse */

View File

@@ -548,6 +548,8 @@ async function saveConfig() {
if (config.value.hid_backend === 'otg') { if (config.value.hid_backend === 'otg') {
if (config.value.hid_otg_profile === 'full') { if (config.value.hid_otg_profile === 'full') {
desiredMsdEnabled = true desiredMsdEnabled = true
} else if (config.value.hid_otg_profile === 'full_no_msd') {
desiredMsdEnabled = false
} else if ( } else if (
config.value.hid_otg_profile === 'legacy_keyboard' config.value.hid_otg_profile === 'legacy_keyboard'
|| config.value.hid_otg_profile === 'legacy_mouse_relative' || config.value.hid_otg_profile === 'legacy_mouse_relative'
@@ -1477,6 +1479,7 @@ onMounted(async () => {
<Label for="otg-profile">{{ t('settings.profile') }}</Label> <Label for="otg-profile">{{ t('settings.profile') }}</Label>
<select id="otg-profile" v-model="config.hid_otg_profile" class="w-full h-9 px-3 rounded-md border border-input bg-background text-sm"> <select id="otg-profile" v-model="config.hid_otg_profile" class="w-full h-9 px-3 rounded-md border border-input bg-background text-sm">
<option value="full">{{ t('settings.otgProfileFull') }}</option> <option value="full">{{ t('settings.otgProfileFull') }}</option>
<option value="full_no_msd">{{ t('settings.otgProfileFullNoMsd') }}</option>
<option value="legacy_keyboard">{{ t('settings.otgProfileLegacyKeyboard') }}</option> <option value="legacy_keyboard">{{ t('settings.otgProfileLegacyKeyboard') }}</option>
<option value="legacy_mouse_relative">{{ t('settings.otgProfileLegacyMouseRelative') }}</option> <option value="legacy_mouse_relative">{{ t('settings.otgProfileLegacyMouseRelative') }}</option>
<option value="custom">{{ t('settings.otgProfileCustom') }}</option> <option value="custom">{{ t('settings.otgProfileCustom') }}</option>