Compare commits

..

1 Commits

Author SHA1 Message Date
Aveline b9988220bf
Merge f58e5476bf into c8dd84c6b7 2025-09-09 22:13:25 +00:00
1 changed files with 13 additions and 23 deletions

View File

@ -1111,38 +1111,28 @@ func rpcKeyboardReportMulti(ctx context.Context, macro []map[string]any) (usbgad
} }
var modifier byte var modifier byte
switch m := step["modifier"].(type) { if m, ok := step["modifier"].(float64); ok {
case uint8:
modifier = m
case int:
modifier = byte(m)
case float64:
modifier = byte(int(m)) modifier = byte(int(m))
default: } else if mi, ok := step["modifier"].(int); ok {
return last, fmt.Errorf("invalid modifier type: %T", m) modifier = byte(mi)
} else if mb, ok := step["modifier"].(uint8); ok {
modifier = mb
} }
var keys []byte var keys []byte
switch k := step["keys"].(type) { if arr, ok := step["keys"].([]any); ok {
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 {
switch f := v.(type) { if f, ok := v.(float64); ok {
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)))
default: } else if i, ok := v.(int); ok {
return last, fmt.Errorf("invalid key type: %T", f) keys = append(keys, byte(i))
} else if b, ok := v.(uint8); ok {
keys = append(keys, b)
} }
} }
default: } else if bs, ok := step["keys"].([]byte); ok {
return last, fmt.Errorf("invalid keys type: %T", k) keys = bs
} }
// Use context-aware sleep that can be cancelled // Use context-aware sleep that can be cancelled