mirror of https://github.com/OrbTools/OrbMap
Major refactor and code rebuild
Main new feature is the idea of "Backends" This allows customization beyond what is already available Devices can now be defined in a json file as part of OrbCommonmain
parent
838a8806ad
commit
9c905fab16
@ -0,0 +1,42 @@
|
||||
package keypad
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/OrbTools/OrbCommon/devices"
|
||||
"github.com/OrbTools/OrbMap/registry"
|
||||
)
|
||||
|
||||
type Keypad struct {
|
||||
eventcodes []byte
|
||||
ecm map[uint16]int
|
||||
keymaps *devices.KeyMaps
|
||||
definition *devices.DeviceDef
|
||||
}
|
||||
|
||||
//ProbcOrbFiles processes orbs
|
||||
func (p *Keypad) ProcOrbs(dev *devices.DeviceDef, orbs []string) {
|
||||
p.definition = dev
|
||||
p.keymaps = &devices.KeyMaps{Currentmap: 0}
|
||||
if len(orbs) > 0 {
|
||||
for _, orb := range orbs {
|
||||
abs, _ := filepath.Abs(orb)
|
||||
fmt.Println("Loading Orb " + abs)
|
||||
KMap := devices.LoadKeymap(abs, dev)
|
||||
p.keymaps.Maps = append(p.keymaps.Maps, KMap)
|
||||
}
|
||||
p.keymaps.MCount = len(orbs)
|
||||
} else {
|
||||
panic("No orbs")
|
||||
}
|
||||
p.ecm = make(map[uint16]int)
|
||||
p.eventcodes = p.definition.Binding
|
||||
for i := 0; i < len(p.eventcodes); i++ {
|
||||
p.ecm[uint16(p.eventcodes[i])] = i
|
||||
}
|
||||
}
|
||||
|
||||
func init() {
|
||||
registry.Systems["keypad"] = registry.Device(&Keypad{})
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
_ "github.com/OrbTools/OrbMap/devices/orbweaver"
|
||||
_ "github.com/OrbTools/OrbMap/backend/keypad"
|
||||
)
|
@ -1,43 +0,0 @@
|
||||
package orbweaver
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"path/filepath"
|
||||
|
||||
morb "github.com/OrbTools/OrbCommon/devices/orbweaver"
|
||||
"github.com/OrbTools/OrbMap/registry"
|
||||
)
|
||||
|
||||
type Orbweaver struct {
|
||||
eventcodes []byte
|
||||
ecm map[uint16]int
|
||||
keymaps *morb.KeyMaps
|
||||
}
|
||||
|
||||
//ProbcOrbFiles processes orbs
|
||||
func (p *Orbweaver) ProcOrbs(orbs []string) {
|
||||
p.keymaps = &morb.KeyMaps{Currentmap: 0}
|
||||
if len(orbs) > 0 {
|
||||
for idx, orb := range orbs {
|
||||
abs, err := filepath.Abs(orb)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
fmt.Println("Loading Orb " + abs)
|
||||
KMap := morb.LoadKM(abs)
|
||||
p.keymaps.Maps[idx] = KMap
|
||||
}
|
||||
p.keymaps.MCount = len(orbs)
|
||||
} else {
|
||||
panic("No orbs")
|
||||
}
|
||||
p.ecm = make(map[uint16]int)
|
||||
p.eventcodes = morb.BINDING[:]
|
||||
for i := 0; i < len(p.eventcodes); i++ {
|
||||
p.ecm[uint16(p.eventcodes[i])] = i
|
||||
}
|
||||
}
|
||||
|
||||
func init() {
|
||||
registry.Systems["orbweaver"] = registry.Device(&Orbweaver{})
|
||||
}
|
Loading…
Reference in New Issue