File: command.go

package info (click to toggle)
bettercap 2.33.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 8,668 kB
  • sloc: sh: 154; makefile: 76; python: 52; ansic: 9
file content (39 lines) | stat: -rw-r--r-- 606 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package hid

import (
	"time"
)

type Frame struct {
	Data  []byte
	Delay time.Duration
}

func NewFrame(buf []byte, delay int) Frame {
	return Frame{
		Data:  buf,
		Delay: time.Millisecond * time.Duration(delay),
	}
}

type Command struct {
	Mode   byte
	HID    byte
	Sleep  int
	Frames []Frame
}

func (cmd *Command) AddFrame(buf []byte, delay int) {
	if cmd.Frames == nil {
		cmd.Frames = make([]Frame, 0)
	}
	cmd.Frames = append(cmd.Frames, NewFrame(buf, delay))
}

func (cmd Command) IsHID() bool {
	return cmd.HID != 0 || cmd.Mode != 0
}

func (cmd Command) IsSleep() bool {
	return cmd.Sleep > 0
}