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"`
|
DisplayMaxBrightness int `json:"display_max_brightness"`
|
||||||
DisplayDimAfterSec int `json:"display_dim_after_sec"`
|
DisplayDimAfterSec int `json:"display_dim_after_sec"`
|
||||||
DisplayOffAfterSec int `json:"display_off_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"
|
const configPath = "/userdata/kvm_config.json"
|
||||||
|
@ -50,7 +50,7 @@ var defaultConfig = &Config{
|
||||||
DisplayMaxBrightness: 64,
|
DisplayMaxBrightness: 64,
|
||||||
DisplayDimAfterSec: 120, // 2 minutes
|
DisplayDimAfterSec: 120, // 2 minutes
|
||||||
DisplayOffAfterSec: 1800, // 30 minutes
|
DisplayOffAfterSec: 1800, // 30 minutes
|
||||||
UsbConfig: UsbConfig{
|
UsbConfig: &UsbConfig{
|
||||||
VendorId: "0x1d6b", //The Linux Foundation
|
VendorId: "0x1d6b", //The Linux Foundation
|
||||||
ProductId: "0x0104", //Multifunction Composite Gadget
|
ProductId: "0x0104", //Multifunction Composite Gadget
|
||||||
SerialNumber: "",
|
SerialNumber: "",
|
||||||
|
@ -90,6 +90,11 @@ func LoadConfig() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// merge the user config with the default config
|
||||||
|
if loadedConfig.UsbConfig == nil {
|
||||||
|
loadedConfig.UsbConfig = defaultConfig.UsbConfig
|
||||||
|
}
|
||||||
|
|
||||||
config = &loadedConfig
|
config = &loadedConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -540,12 +540,12 @@ func rpcSetUsbEmulationState(enabled bool) error {
|
||||||
|
|
||||||
func rpcGetUsbConfig() (UsbConfig, error) {
|
func rpcGetUsbConfig() (UsbConfig, error) {
|
||||||
LoadConfig()
|
LoadConfig()
|
||||||
return config.UsbConfig, nil
|
return *config.UsbConfig, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func rpcSetUsbConfig(usbConfig UsbConfig) error {
|
func rpcSetUsbConfig(usbConfig UsbConfig) error {
|
||||||
LoadConfig()
|
LoadConfig()
|
||||||
config.UsbConfig = usbConfig
|
config.UsbConfig = &usbConfig
|
||||||
|
|
||||||
err := UpdateGadgetConfig()
|
err := UpdateGadgetConfig()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in New Issue