generator: hid use builtin structures

main
Minizbot2012 3 years ago
parent f8ef4546d9
commit ba70f397f5
No known key found for this signature in database
GPG Key ID: 977C8ADE12361917

@ -35,7 +35,7 @@ func LoadKeymap(file io.ReadCloser, dev *DeviceDef) *KeyMap {
return mapped return mapped
} }
//SavePKMKeymap saves an orb after edit //SaveKeymap Saves Orbmap KM structure
func SaveKeymap(file io.WriteCloser, mapped interface{}) { func SaveKeymap(file io.WriteCloser, mapped interface{}) {
binary.Write(file, binary.LittleEndian, mapped) binary.Write(file, binary.LittleEndian, mapped)
file.Close() file.Close()

Binary file not shown.

@ -2,34 +2,15 @@ package main
import ( import (
"encoding/json" "encoding/json"
"github.com/OrbTools/OrbCommon/hid"
xdr "github.com/davecgh/go-xdr/xdr2"
"io" "io"
"io/fs" "io/fs"
"os" "os"
"regexp" "regexp"
"strconv" "strconv"
xdr "github.com/davecgh/go-xdr/xdr2"
) )
type KeyMaps struct {
Usb map[uint16]Key
Evdev map[uint16]Key
Xkb map[uint16]Key
Win map[uint16]Key
Mac map[uint16]Key
Code map[string]Key
Arr []Key
}
type Key struct {
Usb uint16
Evdev uint16
Xkb uint16
Win uint16
Mac uint16
Code string
}
func main() { func main() {
rege, _ := regexp.Compile("DOM_CODE\\(0x07([0-9a-f]*), 0x([0-9a-f]*), 0x([0-9a-f]*), 0x([0-9a-f]*), 0x([0-9a-f]*), \"?[A-Za-z0-9]*\"?, ([A-Za-z_0-9]*)") rege, _ := regexp.Compile("DOM_CODE\\(0x07([0-9a-f]*), 0x([0-9a-f]*), 0x([0-9a-f]*), 0x([0-9a-f]*), 0x([0-9a-f]*), \"?[A-Za-z0-9]*\"?, ([A-Za-z_0-9]*)")
//DOM_CODE(USB, evdev, XKB, Win, Mac, _, Code) //DOM_CODE(USB, evdev, XKB, Win, Mac, _, Code)
@ -37,22 +18,22 @@ func main() {
byts, _ := io.ReadAll(fil) byts, _ := io.ReadAll(fil)
fil.Close() fil.Close()
matches := rege.FindAllSubmatch(byts, -1) matches := rege.FindAllSubmatch(byts, -1)
KeyMaps := KeyMaps{ KeyMaps := hid.KeyMaps{
Usb: make(map[uint16]Key), Usb: make(map[uint16]hid.Key),
Evdev: make(map[uint16]Key), Evdev: make(map[uint16]hid.Key),
Xkb: make(map[uint16]Key), Xkb: make(map[uint16]hid.Key),
Win: make(map[uint16]Key), Win: make(map[uint16]hid.Key),
Mac: make(map[uint16]Key), Mac: make(map[uint16]hid.Key),
Code: make(map[string]Key), Code: make(map[string]hid.Key),
} }
Arr := make([]Key, 0) Arr := make([]hid.Key, 0)
for _, bar := range matches { for _, bar := range matches {
U, _ := strconv.ParseUint(string(bar[1]), 16, 16) U, _ := strconv.ParseUint(string(bar[1]), 16, 16)
E, _ := strconv.ParseUint(string(bar[2]), 16, 16) E, _ := strconv.ParseUint(string(bar[2]), 16, 16)
X, _ := strconv.ParseUint(string(bar[3]), 16, 16) X, _ := strconv.ParseUint(string(bar[3]), 16, 16)
W, _ := strconv.ParseUint(string(bar[4]), 16, 16) W, _ := strconv.ParseUint(string(bar[4]), 16, 16)
M, _ := strconv.ParseUint(string(bar[5]), 16, 16) M, _ := strconv.ParseUint(string(bar[5]), 16, 16)
Keys := Key{ Keys := hid.Key{
Usb: uint16(U), Usb: uint16(U),
Evdev: uint16(E), Evdev: uint16(E),
Xkb: uint16(X), Xkb: uint16(X),

Loading…
Cancel
Save