mirror of https://github.com/jetkvm/kvm.git
fix(usb_config): check if usb_config is defined in kvm_config.json
This commit is contained in:
parent
7e6a24800e
commit
a60d373849
|
@ -37,7 +37,7 @@ type Config struct {
|
|||
DisplayMaxBrightness int `json:"display_max_brightness"`
|
||||
DisplayDimAfterSec int `json:"display_dim_after_sec"`
|
||||
DisplayOffAfterSec int `json:"display_off_after_sec"`
|
||||
UsbConfig UsbConfig `json:"usb_config"`
|
||||
UsbConfig *UsbConfig `json:"usb_config"`
|
||||
}
|
||||
|
||||
const configPath = "/userdata/kvm_config.json"
|
||||
|
@ -50,7 +50,7 @@ var defaultConfig = &Config{
|
|||
DisplayMaxBrightness: 64,
|
||||
DisplayDimAfterSec: 120, // 2 minutes
|
||||
DisplayOffAfterSec: 1800, // 30 minutes
|
||||
UsbConfig: UsbConfig{
|
||||
UsbConfig: &UsbConfig{
|
||||
VendorId: "0x1d6b", //The Linux Foundation
|
||||
ProductId: "0x0104", //Multifunction Composite Gadget
|
||||
SerialNumber: "",
|
||||
|
@ -90,6 +90,11 @@ func LoadConfig() {
|
|||
return
|
||||
}
|
||||
|
||||
// merge the user config with the default config
|
||||
if loadedConfig.UsbConfig == nil {
|
||||
loadedConfig.UsbConfig = defaultConfig.UsbConfig
|
||||
}
|
||||
|
||||
config = &loadedConfig
|
||||
}
|
||||
|
||||
|
|
|
@ -540,12 +540,12 @@ func rpcSetUsbEmulationState(enabled bool) error {
|
|||
|
||||
func rpcGetUsbConfig() (UsbConfig, error) {
|
||||
LoadConfig()
|
||||
return config.UsbConfig, nil
|
||||
return *config.UsbConfig, nil
|
||||
}
|
||||
|
||||
func rpcSetUsbConfig(usbConfig UsbConfig) error {
|
||||
LoadConfig()
|
||||
config.UsbConfig = usbConfig
|
||||
config.UsbConfig = &usbConfig
|
||||
|
||||
err := UpdateGadgetConfig()
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in New Issue