diff options
author | Florian Didron <0x6664@hey.com> | 2020-10-08 13:06:34 +0900 |
---|---|---|
committer | Florian Didron <0x6664@hey.com> | 2020-10-08 13:06:34 +0900 |
commit | 7cb7c820cc36e9577e2a5a2ca6d475ac2f43d7d0 (patch) | |
tree | 51b6b564c1860b68371e2674f1a4a32be1995b66 | |
parent | eff8eea082b5668ecb63269b91e235152da2673f (diff) |
feat: support new vids/pids
-rw-r--r-- | wally/usb.go | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/wally/usb.go b/wally/usb.go index 307179c..79bcb99 100644 --- a/wally/usb.go +++ b/wally/usb.go @@ -38,6 +38,20 @@ const ( eraseFlash = 2 ) +var vendorIds = []int{0xfeed, 0x3297} // legacy - zsa's vendor id +var ergodoxIds = []int{0x1307, 0x4974, 0x4975, 0x4976} // legacy - standard - shine - glow +var planckIds = []int{0x6060, 0xc6ce, 0xc6cf} // legacy - standard - glow +var moonlanderIds = []int{0x1969} // mk1 + +func contains(s []int, e int) bool { + for _, a := range s { + if a == e { + return true + } + } + return false +} + func ProbeDevices(s *State) []Device { devices := []Device{} ctx := gousb.NewContext() @@ -45,16 +59,16 @@ func ProbeDevices(s *State) []Device { s.Log("info", "Probing compatible usb devices") _, err := ctx.OpenDevices(func(desc *gousb.DeviceDesc) bool { - if desc.Vendor == gousb.ID(vendorID1) || desc.Vendor == gousb.ID(vendorID2) { - if desc.Product == gousb.ID(planckID) { + if contains(vendorIds, int(desc.Vendor)) { + if contains(planckIds, int(desc.Product)) { devices = append(devices, Device{Model: 0, Bus: desc.Bus, Port: desc.Port}) } - if desc.Product == gousb.ID(ergodoxID) { + if contains(ergodoxIds, int(desc.Product)) { devices = append(devices, Device{Model: 1, Bus: desc.Bus, Port: desc.Port}) } - if desc.Product == gousb.ID(moonlanderID) { + if contains(moonlanderIds, int(desc.Product)) { devices = append(devices, Device{Model: 2, Bus: desc.Bus, Port: desc.Port}) } } |