MCPcopy Create free account
hub / github.com/drosoCode/atvremote / SendKey

Method SendKey

pkg/v1/command/command.go:82–105  ·  view source on GitHub ↗

emulate a key press on the android tv device

(keycode common.RemoteKeyCode)

Source from the content-addressed store, hash-verified

80
81// emulate a key press on the android tv device
82func (c *Command) SendKey(keycode common.RemoteKeyCode) error {
83 err := c.sendConfiguration()
84 if err != nil {
85 return err
86 }
87
88 code := byte(keycode)
89 press := []byte{1, 2, 0, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, code}
90 _, err = c.Connection.Write(press)
91 if err != nil {
92 return err
93 }
94
95 // wait 100ms between press and released
96 time.Sleep(100 * time.Millisecond)
97
98 release := []byte{1, 2, 0, 16, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, code}
99 _, err = c.Connection.Write(release)
100 if err != nil {
101 return err
102 }
103
104 return nil
105}
106
107// converts a string to a byte array
108func text2byte(text string) []byte {

Callers

nothing calls this directly

Calls 1

sendConfigurationMethod · 0.95

Tested by

no test coverage detected