File tree Expand file tree Collapse file tree 2 files changed +9
-4
lines changed Expand file tree Collapse file tree 2 files changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -37,7 +37,7 @@ type Config struct {
37
37
DisplayMaxBrightness int `json:"display_max_brightness"`
38
38
DisplayDimAfterSec int `json:"display_dim_after_sec"`
39
39
DisplayOffAfterSec int `json:"display_off_after_sec"`
40
- UsbConfig UsbConfig `json:"usb_config"`
40
+ UsbConfig * UsbConfig `json:"usb_config"`
41
41
}
42
42
43
43
const configPath = "/userdata/kvm_config.json"
@@ -50,7 +50,7 @@ var defaultConfig = &Config{
50
50
DisplayMaxBrightness : 64 ,
51
51
DisplayDimAfterSec : 120 , // 2 minutes
52
52
DisplayOffAfterSec : 1800 , // 30 minutes
53
- UsbConfig : UsbConfig {
53
+ UsbConfig : & UsbConfig {
54
54
VendorId : "0x1d6b" , //The Linux Foundation
55
55
ProductId : "0x0104" , //Multifunction Composite Gadget
56
56
SerialNumber : "" ,
@@ -90,6 +90,11 @@ func LoadConfig() {
90
90
return
91
91
}
92
92
93
+ // merge the user config with the default config
94
+ if loadedConfig .UsbConfig == nil {
95
+ loadedConfig .UsbConfig = defaultConfig .UsbConfig
96
+ }
97
+
93
98
config = & loadedConfig
94
99
}
95
100
Original file line number Diff line number Diff line change @@ -540,12 +540,12 @@ func rpcSetUsbEmulationState(enabled bool) error {
540
540
541
541
func rpcGetUsbConfig () (UsbConfig , error ) {
542
542
LoadConfig ()
543
- return config .UsbConfig , nil
543
+ return * config .UsbConfig , nil
544
544
}
545
545
546
546
func rpcSetUsbConfig (usbConfig UsbConfig ) error {
547
547
LoadConfig ()
548
- config .UsbConfig = usbConfig
548
+ config .UsbConfig = & usbConfig
549
549
550
550
err := UpdateGadgetConfig ()
551
551
if err != nil {
You can’t perform that action at this time.
0 commit comments