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