Skip to content

Commit

Permalink
Add vial support to wiokey
Browse files Browse the repository at this point in the history
  • Loading branch information
sago35 committed Sep 14, 2023
1 parent 040c02c commit 733f425
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 3 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ gen-def:
go run ./cmd/gen-def/main.go ./targets/macropad-rp2040/vial.json
go run ./cmd/gen-def/main.go ./targets/sgkb/left/vial.json
go run ./cmd/gen-def/main.go ./targets/sgkb/left-0.3.0/vial.json
go run ./cmd/gen-def/main.go ./targets/wiokey/vial.json
go run ./cmd/gen-def/main.go ./targets/sgkey/vial.json
go run ./cmd/gen-def/main.go ./targets/xiao-kb01/vial.json
go run ./cmd/gen-def/main.go ./tutorial/gpio-vial/vial.json
Expand Down
9 changes: 9 additions & 0 deletions targets/wiokey/def.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package main

import keyboard "github.com/sago35/tinygo-keyboard"

func loadKeyboardDef() {
keyboard.KeyboardDef = []byte{
0x5D, 0x00, 0x00, 0x80, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x3D, 0x82, 0x80, 0x19, 0x1B, 0x9A, 0xE8, 0xB8, 0xA7, 0x6E, 0x26, 0x77, 0x5D, 0x26, 0xFB, 0x93, 0xC2, 0xE2, 0xE7, 0x46, 0x70, 0xEA, 0x4B, 0x5E, 0x65, 0x13, 0x28, 0x62, 0x26, 0x17, 0xF0, 0x0C, 0xF2, 0x89, 0xC9, 0x3F, 0x3A, 0x65, 0x6E, 0x43, 0xF3, 0x24, 0x90, 0x75, 0x37, 0x15, 0xBE, 0x2C, 0x65, 0x65, 0xB5, 0x6D, 0xF8, 0x0B, 0xCF, 0x9C, 0xF9, 0xD2, 0xD3, 0x50, 0x37, 0x31, 0x88, 0xBB, 0x60, 0x41, 0x20, 0x4C, 0xAE, 0x48, 0x21, 0xB2, 0x69, 0xA2, 0x3E, 0x54, 0x5F, 0x2D, 0xC9, 0x73, 0x3A, 0xD9, 0xC5, 0xE8, 0xDE, 0x7C, 0xC7, 0x85, 0xA3, 0x92, 0x79, 0xD0, 0x6D, 0x1C, 0x65, 0x7D, 0x46, 0xD7, 0xE1, 0xEC, 0xA8, 0xC5, 0x30, 0xC4, 0xF1, 0xA6, 0xD4, 0xBD, 0x10, 0x08, 0x1E, 0xC7, 0x32, 0x1C, 0x57, 0xD2, 0x30, 0xCE, 0xC9, 0xB1, 0xCD, 0x05, 0xF2, 0xE3, 0xE9, 0x36, 0xE1, 0x0B, 0x3F, 0x04, 0x94, 0xB9, 0x07, 0xDA, 0xF2, 0xE9, 0xDD, 0x9F, 0x78, 0x0F, 0x41, 0xFC, 0x12, 0x20, 0xDB, 0x1B, 0x4C, 0x29, 0x46, 0x4A, 0xDF, 0xE6, 0xA3, 0x6C, 0x90, 0x70, 0x23, 0xA3, 0xD3, 0x68, 0x5D, 0xB2, 0x77, 0xC3, 0x2E, 0xDF, 0x29, 0xFD, 0x03, 0x73, 0x0A, 0x7E, 0xBB, 0x43, 0xB4, 0x97, 0x3D, 0x00, 0x28, 0xC5, 0x76, 0xAC, 0x73, 0xAD, 0x43, 0xBF, 0xFD, 0x32, 0x6D, 0x20,
}
}
12 changes: 9 additions & 3 deletions targets/wiokey/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"log"
"machine"
"machine/usb"

keyboard "github.com/sago35/tinygo-keyboard"
"github.com/sago35/tinygo-keyboard/keycodes/jp"
Expand All @@ -18,6 +19,8 @@ func main() {
}

func run() error {
usb.Product = "wiokey-0.1.0"

d := keyboard.New()

colPins := []machine.Pin{
Expand Down Expand Up @@ -65,17 +68,20 @@ func run() error {
jp.KeyB,
jp.KeyC,
jp.KeyMediaVolumeInc,
jp.KeyMediaPrevTrack,
jp.KeyMediaNextTrack,
jp.KeyLeft,
jp.KeyRight,
jp.KeyMediaVolumeDec,
jp.KeyMediaPlayPause,
jp.KeyEnter,
},
})

gk.SetCallback(func(layer, index int, state keyboard.State) {
fmt.Printf("gk: %d %d %d\n", layer, index, state)
})

// for Vial
loadKeyboardDef()

d.Debug = true
return d.Loop(context.Background())
}
13 changes: 13 additions & 0 deletions targets/wiokey/vial.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"name": "tinygo-wiokey",
"vendorId": "0x2886",
"productId": "0x802D",
"matrix": {"rows": 2, "cols": 8},
"layouts": {
"keymap": [
["1,2","1,1","1,0", {"x":1.25},"1,3", {"x":1.75},"0,0","0,1"],
[{"x":3.25},"1,4","1,7","1,5", {"x":0.75},"0,2","0,3"],
[{"x":4.25},"1,6", {"x":1.75},"0,4","0,5"]
]
}
}

0 comments on commit 733f425

Please sign in to comment.