hid/main.go

50 lines
832 B
Go
Raw Normal View History

2017-10-26 14:51:49 -06:00
package main
import (
2017-10-26 17:50:36 -06:00
"encoding/binary"
2017-10-26 14:51:49 -06:00
"fmt"
"os"
)
2017-10-26 17:05:49 -06:00
const (
LCTRL byte = 1 << iota
LSHIFT
LALT
LSUPER
RCTRL
RSHIFT
RALT
RSUPER
)
func main() {
2017-10-26 14:51:49 -06:00
var (
2017-10-27 14:14:03 -06:00
test [8]byte = [...]byte{0x00, 0x00, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09}
unpress [8]byte = [...]byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
write []byte
2017-10-26 14:51:49 -06:00
)
2017-10-26 17:05:49 -06:00
fmt.Printf("%08b\n%08b\n%08b\n%08b\n%08b\n%08b\n%08b\n%08b\n\n", LCTRL,
LSHIFT,
LALT,
LSUPER,
RCTRL,
RSHIFT,
RALT,
RSUPER)
fmt.Println()
2017-10-26 18:08:14 -06:00
fmt.Printf("%08b\n", test[0])
//test[0] |= LCTRL
fmt.Printf("%08b\n", test[0])
2017-10-26 17:51:30 -06:00
file, err := os.OpenFile("/dev/hidg0", os.O_WRONLY, os.ModePerm)
2017-10-27 14:14:03 -06:00
2017-10-26 17:50:36 -06:00
fmt.Println(err)
2017-10-27 14:20:45 -06:00
for i := 1; i <= 1000; i++ {
2017-10-27 14:14:03 -06:00
write = append(write, test[:]...)
write = append(write, unpress[:]...)
}
binary.Write(file, binary.BigEndian, write)
2017-10-26 17:24:18 -06:00
file.Close()
2017-10-27 14:14:03 -06:00
2017-10-26 14:51:49 -06:00
}