mirror of https://github.com/OrbTools/OrbMap
Work on windows
parent
2b9f96966f
commit
efdd225b03
@ -0,0 +1,16 @@
|
||||
package common
|
||||
|
||||
var KEYCODE_WINDOWS_FROM_HID = [256]byte{
|
||||
255, 255, 255, 255, 30, 48, 46, 32, 18, 33, 34, 35, 23, 36, 37, 38, 50, 49, 24, 25, 16, 19, 31, 20,
|
||||
22, 47, 17, 45, 21, 44, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 255, 1, 14, 15, 255, 12, 13, 26, 27, 43, 255,
|
||||
39, 40, 41, 51, 52, 53, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 87, 88, 183, 70, 69, 210, 199,
|
||||
201, 211, 207, 209, 205, 203, 208, 200, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
|
||||
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
|
||||
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
|
||||
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
|
||||
255, 255, 255, 255, 255, 255, 255, 28, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
|
||||
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
|
||||
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
|
||||
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 29, 42, 56,
|
||||
219, 157, 54, 184, 220, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
|
||||
255, 255, 255, 255, 255, 255, 255, 255, 255, 255}
|
@ -1,13 +1,67 @@
|
||||
package orbweaver
|
||||
|
||||
import (
|
||||
"encoding/hex"
|
||||
"math/big"
|
||||
|
||||
"github.com/google/gousb"
|
||||
"github.com/minizbot2012/orbmap/devices/common"
|
||||
"github.com/minizbot2012/orbmap/interface/keyevents"
|
||||
)
|
||||
|
||||
const (
|
||||
vendor = gousb.ID(0x1532)
|
||||
prod = gousb.ID(0x0207)
|
||||
)
|
||||
|
||||
//OrbLoop Main loop for this device
|
||||
func OrbLoop(km *KeyMaps, KeyBus chan *keyevents.KeyEvent) {
|
||||
// TODO: NEED HELP!!
|
||||
for i := 0; i < 26; i++ {
|
||||
ecm[uint16(eventcodes[i])] = i
|
||||
}
|
||||
ctx := gousb.NewContext()
|
||||
dev, err := ctx.OpenDeviceWithVIDPID(vendor, prod)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
defer dev.Close()
|
||||
conf, err := dev.Config(1)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
intf, err := conf.Interface(0, 0)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
defer intf.Close()
|
||||
in, err := intf.InEndpoint(1)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
data := make([]byte, in.Desc.MaxPacketSize)
|
||||
rs, _ := in.NewStream(in.Desc.MaxPacketSize, 3)
|
||||
var bits big.Int
|
||||
for {
|
||||
_, err := rs.Read(data)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
for i := 2; i < in.Desc.MaxPacketSize; i++ {
|
||||
if common.KEYCODE_WINDOWS_FROM_HID[data[i]] == 255 {
|
||||
data[i] = 0
|
||||
} else {
|
||||
data[i] = common.KEYCODE_WINDOWS_FROM_HID[data[i]]
|
||||
}
|
||||
if data[i] != 0 && bits.Bit(ecm[uint16(data[i])]) == 0 {
|
||||
KeyEv := &keyevents.KeyEvent{
|
||||
Code: uint16(data[i]),
|
||||
Type: 1,
|
||||
}
|
||||
bits.SetBit()
|
||||
KeyEv.Code = km.Maps[km.Currentmap].Keymap[ecm[KeyEv.Code]]
|
||||
} else if
|
||||
}
|
||||
//Not quite sure how to handle this data quite yet
|
||||
println(hex.EncodeToString(data))
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue