mirror of
https://github.com/luckfox-eng29/kvm.git
synced 2026-01-18 03:28:19 +01:00
feat(usb): dynamic usb devices config
This commit is contained in:
18
config.go
18
config.go
@@ -20,6 +20,13 @@ type UsbConfig struct {
|
||||
Product string `json:"product"`
|
||||
}
|
||||
|
||||
type UsbDevicesConfig struct {
|
||||
AbsoluteMouse bool `json:"absolute_mouse"`
|
||||
RelativeMouse bool `json:"relative_mouse"`
|
||||
Keyboard bool `json:"keyboard"`
|
||||
MassStorage bool `json:"mass_storage"`
|
||||
}
|
||||
|
||||
type Config struct {
|
||||
CloudURL string `json:"cloud_url"`
|
||||
CloudAppURL string `json:"cloud_app_url"`
|
||||
@@ -38,6 +45,7 @@ type Config struct {
|
||||
DisplayDimAfterSec int `json:"display_dim_after_sec"`
|
||||
DisplayOffAfterSec int `json:"display_off_after_sec"`
|
||||
UsbConfig *UsbConfig `json:"usb_config"`
|
||||
UsbDevices *UsbDevicesConfig `json:"usb_devices"`
|
||||
}
|
||||
|
||||
const configPath = "/userdata/kvm_config.json"
|
||||
@@ -57,6 +65,12 @@ var defaultConfig = &Config{
|
||||
Manufacturer: "JetKVM",
|
||||
Product: "USB Emulation Device",
|
||||
},
|
||||
UsbDevices: &UsbDevicesConfig{
|
||||
AbsoluteMouse: true,
|
||||
RelativeMouse: true,
|
||||
Keyboard: true,
|
||||
MassStorage: true,
|
||||
},
|
||||
}
|
||||
|
||||
var (
|
||||
@@ -95,6 +109,10 @@ func LoadConfig() {
|
||||
loadedConfig.UsbConfig = defaultConfig.UsbConfig
|
||||
}
|
||||
|
||||
if loadedConfig.UsbDevices == nil {
|
||||
loadedConfig.UsbDevices = defaultConfig.UsbDevices
|
||||
}
|
||||
|
||||
config = &loadedConfig
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user