-
Notifications
You must be signed in to change notification settings - Fork 0
/
remote.go
54 lines (41 loc) · 1.01 KB
/
remote.go
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package piplayer
import (
"fmt"
"log"
"github.com/17xande/keylogger"
)
type remote struct {
Name string
Vendor uint16
Product uint16
}
var directions = []string{"UP", "DOWN", "HOLD"}
func remoteRead(p *Player, cie chan keylogger.InputEvent) {
var ie keylogger.InputEvent
if p.api.debug {
log.Println("starting remote read for this device")
}
send := p.ConnViewer.getChanSend()
for {
ie = <-cie
// ignore events that are not EV_KEY events that are KEY_DOWN presses
if ie.Type != keylogger.EventTypes["EV_KEY"] || directions[ie.Value] != "DOWN" {
continue
}
key := ie.KeyString()
fmt.Println(ie.Code, ie.Value, ie.Type)
if p.api.debug {
log.Println("Key:", key, directions[ie.Value])
log.Println("Sending keypress to page and nothing else.")
}
msg := wsMessage{
Component: "remote",
Arguments: map[string]string{"keyString": key},
Event: "keyDown",
}
send <- msg
log.Println("Message sent")
}
}
// func (p *Player) handleRemote(e keylogger.InputEvent) {
// }