ALL: Compartimentalize

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

@ -6,14 +6,14 @@ import (
"strings"
"github.com/Minizbot2012/minxdr"
"github.com/OrbTools/OrbCommon/devices"
"github.com/OrbTools/OrbCommon/devices/structs"
)
func main() {
files, _ := os.ReadDir("devices/json/")
for _, file := range files {
data, _ := os.ReadFile("devices/json/" + file.Name())
DevDef := &devices.DeviceDef{}
DevDef := &structs.DeviceDef{}
json.Unmarshal(data, DevDef)
xdo, _ := os.Create("devices/xdr/" + strings.Split(file.Name(), ".")[0] + ".bin")
minxdr.Marshal(xdo, DevDef)

@ -4,6 +4,7 @@ import (
"bytes"
"embed"
"github.com/Minizbot2012/minxdr"
_ "github.com/OrbTools/OrbCommon/devices/structs"
"io"
"io/fs"
"strings"
@ -14,42 +15,6 @@ var DeviceTypes map[string]*DeviceDef
//go:embed xdr/*
var df embed.FS
//KeyMap singular keymap
type KeyMap struct {
Device string
Keymap []uint16
Color []byte
}
//KeyMaps a set of keymaps
type KeyMaps struct {
Maps []*KeyMap
Currentmap int
MCount int
}
type DeviceDef struct {
Backend string
IsColor bool
MaxMappings int
NumKeys int
NumColor int
Binding []byte
Device struct {
SystemFile string
VendorID int
ProdID int
}
GuiPages []struct {
Name string
Type string
Keys []struct {
KeyID int
KeyName string
}
}
}
func init() {
DeviceTypes = make(map[string]*DeviceDef)
files, _ := fs.ReadDir(df, "xdr")

@ -0,0 +1,37 @@
package structs
//KeyMap singular keymap
type KeyMap struct {
Device string
Keymap []uint16
Color []byte
}
//KeyMaps a set of keymaps
type KeyMaps struct {
Maps []*KeyMap
Currentmap int
MCount int
}
type DeviceDef struct {
Backend string
IsColor bool
MaxMappings int
NumKeys int
NumColor int
Binding []byte
Device struct {
SystemFile string
VendorID int
ProdID int
}
GuiPages []struct {
Name string
Type string
Keys []struct {
KeyID int
KeyName string
}
}
}

Binary file not shown.

Binary file not shown.

@ -2,7 +2,7 @@ package main
import (
"github.com/Minizbot2012/minxdr"
"github.com/OrbTools/OrbCommon/hid"
"github.com/OrbTools/OrbCommon/hid/structs"
"io"
"io/fs"
"os"
@ -17,22 +17,22 @@ func main() {
byts, _ := io.ReadAll(fil)
fil.Close()
matches := rege.FindAllSubmatch(byts, -1)
KeyMaps := hid.KeyMaps{
Usb: make(map[uint16]hid.Key),
Evdev: make(map[uint16]hid.Key),
Xkb: make(map[uint16]hid.Key),
Win: make(map[uint16]hid.Key),
Mac: make(map[uint16]hid.Key),
Code: make(map[string]hid.Key),
KeyMaps := structs.KeyMaps{
Usb: make(map[uint16]structs.Key),
Evdev: make(map[uint16]structs.Key),
Xkb: make(map[uint16]structs.Key),
Win: make(map[uint16]structs.Key),
Mac: make(map[uint16]structs.Key),
Code: make(map[string]structs.Key),
}
Arr := make([]hid.Key, 0)
Arr := make([]structs.Key, 0)
for _, bar := range matches {
U, _ := strconv.ParseUint(string(bar[1]), 16, 16)
E, _ := strconv.ParseUint(string(bar[2]), 16, 16)
X, _ := strconv.ParseUint(string(bar[3]), 16, 16)
W, _ := strconv.ParseUint(string(bar[4]), 16, 16)
M, _ := strconv.ParseUint(string(bar[5]), 16, 16)
Keys := hid.Key{
Keys := structs.Key{
Usb: uint16(U),
Evdev: uint16(E),
Xkb: uint16(X),

@ -4,27 +4,9 @@ import (
"bytes"
_ "embed"
"github.com/Minizbot2012/minxdr"
structs "github.com/OrbTools/OrbCommon/hid/structs"
)
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
}
//go:embed generated.bin
var file []byte
@ -32,24 +14,24 @@ func init() {
minxdr.Unmarshal(bytes.NewReader(file), &Mappings)
}
var Mappings KeyMaps = KeyMaps{}
var Mappings KeyMaps = structs.KeyMaps{}
func GetMappingFromHID(uv uint16) Key {
func GetMappingFromHID(uv uint16) structs.Key {
return Mappings.Usb[uv]
}
func GetMappingFromWindows(uv uint16) Key {
func GetMappingFromWindows(uv uint16) structs.Key {
return Mappings.Win[uv]
}
func GetMappingFromLinux(uv uint16) Key {
func GetMappingFromLinux(uv uint16) structs.Key {
return Mappings.Evdev[uv]
}
func GetMappingFromName(name string) Key {
func GetMappingFromName(name string) structs.Key {
return Mappings.Code[name]
}
func GetMappingFromX(code uint16) Key {
func GetMappingFromX(code uint16) structs.Key {
return Mappings.Xkb[code]
}

@ -0,0 +1,20 @@
package structs
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
}
Loading…
Cancel
Save