8000 fix(usb_config): check if usb_config is defined in kvm_config.json by ym · Pull Request #220 · jetkvm/kvm · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fix(usb_config): check if usb_config is defined in kvm_config.json #220

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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: "",
Expand Down Expand Up @@ -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
}

Expand Down
4 changes: 2 additions & 2 deletions jsonrpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
0