From 733f425dbec7ff0f8a69ff3b0bb8ca514f9fa19a Mon Sep 17 00:00:00 2001 From: sago35 Date: Thu, 14 Sep 2023 21:38:56 +0900 Subject: [PATCH] Add vial support to wiokey --- Makefile | 1 + targets/wiokey/def.go | 9 +++++++++ targets/wiokey/main.go | 12 +++++++++--- targets/wiokey/vial.json | 13 +++++++++++++ 4 files changed, 32 insertions(+), 3 deletions(-) create mode 100644 targets/wiokey/def.go create mode 100644 targets/wiokey/vial.json diff --git a/Makefile b/Makefile index be672e2..485b9f1 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/targets/wiokey/def.go b/targets/wiokey/def.go new file mode 100644 index 0000000..07fb29d --- /dev/null +++ b/targets/wiokey/def.go @@ -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, + } +} diff --git a/targets/wiokey/main.go b/targets/wiokey/main.go index f2a8bcf..af4f25c 100644 --- a/targets/wiokey/main.go +++ b/targets/wiokey/main.go @@ -5,6 +5,7 @@ import ( "fmt" "log" "machine" + "machine/usb" keyboard "github.com/sago35/tinygo-keyboard" "github.com/sago35/tinygo-keyboard/keycodes/jp" @@ -18,6 +19,8 @@ func main() { } func run() error { + usb.Product = "wiokey-0.1.0" + d := keyboard.New() colPins := []machine.Pin{ @@ -65,10 +68,10 @@ func run() error { jp.KeyB, jp.KeyC, jp.KeyMediaVolumeInc, - jp.KeyMediaPrevTrack, - jp.KeyMediaNextTrack, + jp.KeyLeft, + jp.KeyRight, jp.KeyMediaVolumeDec, - jp.KeyMediaPlayPause, + jp.KeyEnter, }, }) @@ -76,6 +79,9 @@ func run() error { fmt.Printf("gk: %d %d %d\n", layer, index, state) }) + // for Vial + loadKeyboardDef() + d.Debug = true return d.Loop(context.Background()) } diff --git a/targets/wiokey/vial.json b/targets/wiokey/vial.json new file mode 100644 index 0000000..c985a09 --- /dev/null +++ b/targets/wiokey/vial.json @@ -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"] + ] + } +}