2017-10-26 13:51:49 -07:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2017-10-26 16:50:36 -07:00
|
|
|
"encoding/binary"
|
2017-10-26 13:51:49 -07:00
|
|
|
"fmt"
|
|
|
|
"os"
|
|
|
|
)
|
|
|
|
|
2017-10-26 16:05:49 -07:00
|
|
|
const (
|
|
|
|
LCTRL byte = 1 << iota
|
|
|
|
LSHIFT
|
|
|
|
LALT
|
|
|
|
LSUPER
|
|
|
|
RCTRL
|
|
|
|
RSHIFT
|
|
|
|
RALT
|
|
|
|
RSUPER
|
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
2017-10-26 13:51:49 -07:00
|
|
|
var (
|
2017-10-26 17:29:37 -07:00
|
|
|
test [9]byte = [...]byte{0x00, 0x00, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x00}
|
2017-10-26 13:51:49 -07:00
|
|
|
)
|
2017-10-26 16:05:49 -07: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 17:08:14 -07:00
|
|
|
fmt.Printf("%08b\n", test[0])
|
|
|
|
//test[0] |= LCTRL
|
|
|
|
fmt.Printf("%08b\n", test[0])
|
2017-10-26 16:51:30 -07:00
|
|
|
file, err := os.OpenFile("/dev/hidg0", os.O_WRONLY, os.ModePerm)
|
|
|
|
file2, err2 := os.OpenFile("test", os.O_WRONLY|os.O_CREATE, os.ModePerm)
|
2017-10-26 16:50:36 -07:00
|
|
|
fmt.Println(err)
|
|
|
|
fmt.Println(err2)
|
2017-10-26 16:57:51 -07:00
|
|
|
binary.Write(file, binary.BigEndian, test[:])
|
|
|
|
binary.Write(file2, binary.BigEndian, test[:])
|
2017-10-26 16:24:18 -07:00
|
|
|
file.Close()
|
2017-10-26 16:50:36 -07:00
|
|
|
file2.Close()
|
2017-10-26 13:51:49 -07:00
|
|
|
}
|