Skip to content

Commit

Permalink
Add ./targets/gobadge/
Browse files Browse the repository at this point in the history
  • Loading branch information
sago35 committed Oct 10, 2023
1 parent d7a744a commit d435f1e
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ smoketest: FORCE
go build .
mkdir -p out
tinygo build -o ./out/fric10key.uf2 --target xiao-rp2040 --size short ./targets/fric10key/
tinygo build -o ./out/gobadge.uf2 --target gobadge --size short ./targets/gobadge/
tinygo build -o ./out/gopher-badge.uf2 --target gopher-badge --size short ./targets/gopher-badge/
tinygo build -o ./out/macropad-rp2040.uf2 --target macropad-rp2040 --size short ./targets/macropad-rp2040/
tinygo build -o ./out/sgkb-left.uf2 --target xiao-rp2040 --size short ./targets/sgkb/left/
Expand All @@ -21,6 +22,7 @@ gen-def-with-find:
gen-def:
go run ./cmd/gen-def/main.go ./targets/fric10key/vial.json
go run ./cmd/gen-def/main.go ./targets/gopher-badge/vial.json
go run ./cmd/gen-def/main.go ./targets/gobadge/vial.json
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
Expand Down
9 changes: 9 additions & 0 deletions targets/gobadge/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, 0xF9, 0x60, 0x39, 0xF4, 0x55, 0x01, 0x47, 0x4C, 0x56, 0xC8, 0x64, 0x74, 0x65, 0x1D, 0x60, 0xF8, 0xD1, 0xD5, 0x32, 0x8A, 0xAB, 0x67, 0xE2, 0x11, 0xAC, 0xA9, 0x29, 0xEA, 0xB7, 0xFC, 0x27, 0x75, 0xDC, 0x87, 0xCF, 0xE4, 0x64, 0x3F, 0xE5, 0xBD, 0x64, 0xAB, 0x96, 0xEB, 0x3C, 0x97, 0xED, 0xFB, 0xC0, 0x56, 0xCD, 0x4F, 0xA3, 0x69, 0xB4, 0x8E, 0x8F, 0xF5, 0xB9, 0x67, 0xB0, 0xA0, 0xBA, 0x67, 0x9F, 0xFD, 0xA8, 0xEC, 0xF2, 0x1D, 0x73, 0x9F, 0x68, 0x5D, 0x63, 0x8E, 0xBF, 0x82, 0xE3, 0xE3, 0x77, 0xBF, 0x4F, 0x26, 0xC1, 0xFE, 0xC3, 0x4F, 0xFD, 0xE9, 0x85, 0x26, 0xD4, 0x20, 0x9E, 0xED, 0x80, 0x5F, 0x9B, 0x71, 0xCE, 0xA1, 0xF5, 0x7D, 0x7B, 0x69, 0x5B, 0x35, 0x32, 0xE9, 0x64, 0x1F, 0x62, 0x43, 0x22, 0x44, 0xEB, 0x16, 0xAC, 0x7D, 0xA1, 0xD9, 0x61, 0x5A, 0xA6, 0xAC, 0xF5, 0x21, 0xF1, 0x4C, 0xEA, 0xFA, 0x29, 0x5C, 0x1F, 0xA7, 0x9D, 0x02, 0x73, 0xDC, 0x9F, 0xAD, 0x1E, 0xFD, 0x9B, 0x1B, 0xF3, 0xD8, 0xBE, 0x17, 0xB4, 0x79, 0xE2, 0xEF, 0xDB, 0x7D, 0xBE, 0xFF, 0xF8, 0x9D, 0xA8, 0x40,
}
}
52 changes: 52 additions & 0 deletions targets/gobadge/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package main

import (
"context"
_ "embed"
"log"
"machine/usb"

keyboard "github.com/sago35/tinygo-keyboard"
"github.com/sago35/tinygo-keyboard/keycodes/jp"
"tinygo.org/x/drivers/shifter"
)

func main() {
usb.Product = "gobadge-0.1.0"

err := run()
if err != nil {
log.Fatal(err)
}
}

type RCS struct {
row, col int
state keyboard.State
}

func run() error {
d := keyboard.New()

buttons := shifter.NewButtons()
buttons.Configure()

d.AddShifterKeyboard(buttons, [][]keyboard.Keycode{
{
jp.KeyT, // Left
jp.KeyI, // Up
jp.KeyN, // Down
jp.KeyY, // Right
jp.KeyG, // Select
jp.KeyO, // Start
jp.KeyA, // A
jp.KeyB, // B
},
})

// for Vial
loadKeyboardDef()

d.Debug = true
return d.Loop(context.Background())
}
14 changes: 14 additions & 0 deletions targets/gobadge/vial.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "tinygo-gobadge",
"vendorId": "0x239A",
"productId": "0x8033",
"matrix": {"rows": 1, "cols": 8},
"layouts": {
"keymap": [
[{"x":1}, "0,4", {"x":3}, "0,5"],
[{"y":0.5,"x":1}, "0,1", {"x":4}, "0,7"],
["0,0", {"x":1}, "0,3", {"x":2}, "0,6"],
[{"x":1}, "0,2"]
]
}
}

0 comments on commit d435f1e

Please sign in to comment.