mirror of https://github.com/jetkvm/kvm.git
Compare commits
1 Commits
efdd72ce87
...
b9988220bf
| Author | SHA1 | Date |
|---|---|---|
|
|
b9988220bf |
36
jsonrpc.go
36
jsonrpc.go
|
|
@ -1111,38 +1111,28 @@ func rpcKeyboardReportMulti(ctx context.Context, macro []map[string]any) (usbgad
|
|||
}
|
||||
|
||||
var modifier byte
|
||||
switch m := step["modifier"].(type) {
|
||||
case uint8:
|
||||
modifier = m
|
||||
case int:
|
||||
modifier = byte(m)
|
||||
case float64:
|
||||
if m, ok := step["modifier"].(float64); ok {
|
||||
modifier = byte(int(m))
|
||||
default:
|
||||
return last, fmt.Errorf("invalid modifier type: %T", m)
|
||||
} else if mi, ok := step["modifier"].(int); ok {
|
||||
modifier = byte(mi)
|
||||
} else if mb, ok := step["modifier"].(uint8); ok {
|
||||
modifier = mb
|
||||
}
|
||||
|
||||
var keys []byte
|
||||
switch k := step["keys"].(type) {
|
||||
case []byte:
|
||||
keys = k
|
||||
case []any:
|
||||
arr := k
|
||||
if arr, ok := step["keys"].([]any); ok {
|
||||
keys = make([]byte, 0, len(arr))
|
||||
for _, v := range arr {
|
||||
switch f := v.(type) {
|
||||
case uint8:
|
||||
keys = append(keys, f)
|
||||
case int:
|
||||
keys = append(keys, byte(f))
|
||||
case float64:
|
||||
if f, ok := v.(float64); ok {
|
||||
keys = append(keys, byte(int(f)))
|
||||
default:
|
||||
return last, fmt.Errorf("invalid key type: %T", f)
|
||||
} else if i, ok := v.(int); ok {
|
||||
keys = append(keys, byte(i))
|
||||
} else if b, ok := v.(uint8); ok {
|
||||
keys = append(keys, b)
|
||||
}
|
||||
}
|
||||
default:
|
||||
return last, fmt.Errorf("invalid keys type: %T", k)
|
||||
} else if bs, ok := step["keys"].([]byte); ok {
|
||||
keys = bs
|
||||
}
|
||||
|
||||
// Use context-aware sleep that can be cancelled
|
||||
|
|
|
|||
Loading…
Reference in New Issue