mirror of
https://github.com/OrbTools/OrbMap
synced 2024-11-15 18:13:58 +00:00
*TEST REL* MAY BREAK WINDOWS
This commit is contained in:
parent
b415dd14fa
commit
293eb5981b
@ -5,28 +5,26 @@ package orbweaver
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/binary"
|
||||
"os"
|
||||
|
||||
morb "github.com/OrbTools/OrbCommon/devices/orbweaver"
|
||||
"github.com/OrbTools/OrbMap/interface/keyevents"
|
||||
evdev "github.com/gvalkov/golang-evdev"
|
||||
)
|
||||
|
||||
//OrbLoop Main loop for this device
|
||||
func OrbLoop(km *morb.KeyMaps, KeyBus chan keyevents.KeyEvent) {
|
||||
func OrbLoop(km *morb.KeyMaps, KeyBus chan *evdev.InputEvent) {
|
||||
eventcodes = morb.BINDING[:]
|
||||
for i := 0; i < len(eventcodes); i++ {
|
||||
ecm[uint16(eventcodes[i])] = i
|
||||
}
|
||||
println("UnixLoop starting")
|
||||
f, err := os.Open("/dev/input/by-id/usb-Razer_Razer_Orbweaver_Chroma-event-kbd")
|
||||
f, err := evdev.Open("/dev/input/by-id/usb-Razer_Razer_Orbweaver_Chroma-event-kbd")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
defer f.Close()
|
||||
f.Grab()
|
||||
b := make([]byte, 24)
|
||||
for {
|
||||
f.Read(b)
|
||||
KeyEv := keyevents.KeyEvent{}
|
||||
KeyEv, _ := f.ReadOne()
|
||||
binary.Read(bytes.NewReader(b[16:]), binary.LittleEndian, &KeyEv)
|
||||
KeyEv.Code = km.Maps[km.Currentmap].Keymap[ecm[KeyEv.Code]]
|
||||
if KeyEv.Code != 0 && KeyEv.Type != 4 {
|
||||
|
@ -9,8 +9,8 @@ import (
|
||||
|
||||
morb "github.com/OrbTools/OrbCommon/devices/orbweaver"
|
||||
"github.com/OrbTools/OrbCommon/hid"
|
||||
"github.com/OrbTools/OrbMap/interface/keyevents"
|
||||
"github.com/google/gousb"
|
||||
evdev "github.com/gvalkov/golang-evdev"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -101,7 +101,7 @@ func (s *swapInt) Differ(s2 *swapInt) []byte {
|
||||
}
|
||||
|
||||
//OrbLoop Main loop for this device
|
||||
func OrbLoop(km *morb.KeyMaps, KeyBus chan keyevents.KeyEvent) {
|
||||
func OrbLoop(km *morb.KeyMaps, KeyBus chan *evdev.InputEvent) {
|
||||
eventcodes = morb.BINDING[:]
|
||||
for i := 0; i < len(eventcodes); i++ {
|
||||
ecm[uint16(eventcodes[i])] = i
|
||||
@ -163,7 +163,7 @@ func OrbLoop(km *morb.KeyMaps, KeyBus chan keyevents.KeyEvent) {
|
||||
}
|
||||
for _, pre := range swaper.S1.Differ(swaper.S2) {
|
||||
if pre != 0 {
|
||||
KeyEv := keyevents.KeyEvent{}
|
||||
KeyEv := &evdev.InputEvent{}
|
||||
KeyEv.Code = uint16(pre)
|
||||
KeyEv.Type = 1
|
||||
KeyBus <- KeyEv
|
||||
@ -171,7 +171,7 @@ func OrbLoop(km *morb.KeyMaps, KeyBus chan keyevents.KeyEvent) {
|
||||
}
|
||||
for _, rel := range swaper.S2.Differ(swaper.S1) {
|
||||
if rel != 0 {
|
||||
KeyEv := keyevents.KeyEvent{}
|
||||
KeyEv := &evdev.InputEvent{}
|
||||
KeyEv.Code = uint16(rel)
|
||||
KeyEv.Type = 2
|
||||
KeyBus <- KeyEv
|
||||
|
@ -3,14 +3,14 @@
|
||||
package emu
|
||||
|
||||
import (
|
||||
"github.com/OrbTools/OrbMap/interface/keyevents"
|
||||
"github.com/bendahl/uinput"
|
||||
evdev "github.com/gvalkov/golang-evdev"
|
||||
)
|
||||
|
||||
var vkm uinput.Keyboard = nil
|
||||
|
||||
//ProcKey keyboard emulator loop
|
||||
func ProcKey(kb chan keyevents.KeyEvent) {
|
||||
func ProcKey(kb chan *evdev.InputEvent) {
|
||||
println("Emu Unix Starting")
|
||||
var err error
|
||||
vkm, err = uinput.CreateKeyboard("/dev/uinput", []byte("Orbmap"))
|
||||
@ -20,7 +20,7 @@ func ProcKey(kb chan keyevents.KeyEvent) {
|
||||
defer vkm.Close()
|
||||
for {
|
||||
KeyEv := <-kb
|
||||
if KeyEv.Type == 1 {
|
||||
if KeyEv.Code == 1 {
|
||||
if KeyEv.Value == 1 {
|
||||
vkm.KeyDown(int(KeyEv.Code))
|
||||
} else if KeyEv.Value == 2 {
|
||||
|
@ -5,7 +5,7 @@ package emu
|
||||
import (
|
||||
"unsafe"
|
||||
|
||||
"github.com/OrbTools/OrbMap/interface/keyevents"
|
||||
evdev "github.com/gvalkov/golang-evdev"
|
||||
"github.com/lxn/win"
|
||||
)
|
||||
|
||||
@ -39,7 +39,7 @@ func upKey(key uint16) {
|
||||
}
|
||||
|
||||
//ProcKey Windows support is so weird
|
||||
func ProcKey(kb chan keyevents.KeyEvent) {
|
||||
func ProcKey(kb chan *evdev.InputEvent) {
|
||||
println("Emu Windows Starting")
|
||||
for {
|
||||
KeyEv := <-kb
|
||||
|
3
go.mod
3
go.mod
@ -6,6 +6,7 @@ require (
|
||||
github.com/OrbTools/OrbCommon v0.0.0-20210302052644-6a27f15862ae
|
||||
github.com/bendahl/uinput v1.4.1
|
||||
github.com/google/gousb v1.1.1
|
||||
github.com/gvalkov/golang-evdev v0.0.0-20191114124502-287e62b94bcb // indirect
|
||||
github.com/lxn/win v0.0.0-20210218163916-a377121e959e
|
||||
golang.org/x/sys v0.0.0-20210423185535-09eb48e85fd7 // indirect
|
||||
golang.org/x/sys v0.0.0-20210426230700-d19ff857e887 // indirect
|
||||
)
|
||||
|
6
go.sum
6
go.sum
@ -4,8 +4,10 @@ github.com/bendahl/uinput v1.4.1 h1:ecxSLcVxWk0EFyZBtmCTnOKjK/HCNdsUcWXRTkNt06k=
|
||||
github.com/bendahl/uinput v1.4.1/go.mod h1:Np7w3DINc9wB83p12fTAM3DPPhFnAKP0WTXRqCQJ6Z8=
|
||||
github.com/google/gousb v1.1.1 h1:2sjwXlc0PIBgDnXtNxUrHcD/RRFOmAtRq4QgnFBE6xc=
|
||||
github.com/google/gousb v1.1.1/go.mod h1:b3uU8itc6dHElt063KJobuVtcKHWEfFOysOqBNzHhLY=
|
||||
github.com/gvalkov/golang-evdev v0.0.0-20191114124502-287e62b94bcb h1:WHSAxLz3P5t4DKukfJ5wu7+aMyVkuTNSbCiAjVS92sM=
|
||||
github.com/gvalkov/golang-evdev v0.0.0-20191114124502-287e62b94bcb/go.mod h1:SAzVFKCRezozJTGavF3GX8MBUruETCqzivVLYiywouA=
|
||||
github.com/lxn/win v0.0.0-20210218163916-a377121e959e h1:H+t6A/QJMbhCSEH5rAuRxh+CtW96g0Or0Fxa9IKr4uc=
|
||||
github.com/lxn/win v0.0.0-20210218163916-a377121e959e/go.mod h1:KxxjdtRkfNoYDCUP5ryK7XJJNTnpC8atvtmTheChOtk=
|
||||
golang.org/x/sys v0.0.0-20201018230417-eeed37f84f13/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210423185535-09eb48e85fd7 h1:iGu644GcxtEcrInvDsQRCwJjtCIOlT2V7IRt6ah2Whw=
|
||||
golang.org/x/sys v0.0.0-20210423185535-09eb48e85fd7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210426230700-d19ff857e887 h1:dXfMednGJh/SUUFjTLsWJz3P+TQt9qnR11GgeI3vWKs=
|
||||
golang.org/x/sys v0.0.0-20210426230700-d19ff857e887/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
|
@ -1,8 +0,0 @@
|
||||
package keyevents
|
||||
|
||||
//KeyEvent represents a keyevent
|
||||
type KeyEvent struct {
|
||||
Type uint16
|
||||
Code uint16
|
||||
Value int32
|
||||
}
|
4
main.go
4
main.go
@ -6,13 +6,13 @@ import (
|
||||
|
||||
"github.com/OrbTools/OrbMap/devices/orbweaver"
|
||||
"github.com/OrbTools/OrbMap/emu"
|
||||
"github.com/OrbTools/OrbMap/interface/keyevents"
|
||||
evdev "github.com/gvalkov/golang-evdev"
|
||||
)
|
||||
|
||||
func main() {
|
||||
orbs := flag.String("orbweaver", "", "Comma seperated string of orbs for the orbweaver")
|
||||
flag.Parse()
|
||||
KeyBus := make(chan keyevents.KeyEvent, 128)
|
||||
KeyBus := make(chan *evdev.InputEvent, 128)
|
||||
Maps := orbweaver.ProcOrbFiles(*orbs)
|
||||
go orbweaver.OrbLoop(Maps, KeyBus)
|
||||
emu.ProcKey(KeyBus)
|
||||
|
Loading…
Reference in New Issue
Block a user