Skip to content

Commit

Permalink
Add device.GetKeyboardCount() (#43)
Browse files Browse the repository at this point in the history
  • Loading branch information
sago35 authored Jul 18, 2024
1 parent f81c852 commit 1f08528
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 4 additions & 0 deletions keyboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,10 @@ func (d *Device) Init() error {
return nil
}

func (d *Device) GetKeyboardCount() int {
return len(d.kb)
}

func (d *Device) GetMaxKeyCount() int {
cnt := 0
for _, k := range d.kb {
Expand Down
6 changes: 3 additions & 3 deletions via.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,8 @@ func rxHandler2(b []byte) bool {
for i := 0; i < int(sz/2); i++ {
//fmt.Printf(" %02X %02X\n", b[4+i+1], b[4+i+0])
tmp := i + int(offset)/2
layer := tmp / (cnt * len(device.kb))
tmp = tmp % (cnt * len(device.kb))
layer := tmp / (cnt * device.GetKeyboardCount())
tmp = tmp % (cnt * device.GetKeyboardCount())
kbd := tmp / cnt
idx := tmp % cnt
//layer := 0
Expand Down Expand Up @@ -265,7 +265,7 @@ func rxHandler2(b []byte) bool {

func Save() error {
layers := 6
keyboards := len(device.kb)
keyboards := device.GetKeyboardCount()

cnt := device.GetMaxKeyCount()
wbuf := make([]byte, 4+layers*keyboards*cnt*2+len(device.Macros))
Expand Down

0 comments on commit 1f08528

Please sign in to comment.