Print pressed buttons
This commit is contained in:
parent
3bc64c2438
commit
c9cf7b73b4
2
go.mod
2
go.mod
@ -6,5 +6,7 @@ require github.com/clktmr/n64 v0.1.2
|
||||
|
||||
require (
|
||||
github.com/embeddedgo/display v1.1.0 // indirect
|
||||
github.com/sigurn/crc8 v0.0.0-20220107193325-2243fe600f9f // indirect
|
||||
golang.org/x/exp v0.0.0-20250620022241-b7579e27df2b // indirect
|
||||
golang.org/x/text v0.14.0 // indirect
|
||||
)
|
||||
|
||||
12
main.go
12
main.go
@ -5,6 +5,7 @@ import (
|
||||
"image"
|
||||
"image/color"
|
||||
|
||||
"github.com/clktmr/n64/drivers/controller"
|
||||
"github.com/clktmr/n64/drivers/display"
|
||||
"github.com/clktmr/n64/drivers/draw"
|
||||
"github.com/clktmr/n64/fonts/gomono12"
|
||||
@ -22,8 +23,18 @@ func main() {
|
||||
// Allocate framebuffer
|
||||
display := display.NewDisplay(image.Pt(320, 240), video.BPP16)
|
||||
|
||||
controllers := make(chan [4]controller.Controller)
|
||||
go func() {
|
||||
var states [4]controller.Controller
|
||||
for {
|
||||
controller.Poll(&states)
|
||||
controllers <- states
|
||||
}
|
||||
}()
|
||||
|
||||
for {
|
||||
fb := display.Swap() // Blocks until next VBlank
|
||||
input := <-controllers
|
||||
|
||||
textarea := fb.Bounds().Inset(15)
|
||||
pt := textarea.Min.Add(image.Pt(0, int(face.Ascent)))
|
||||
@ -31,6 +42,7 @@ func main() {
|
||||
draw.Src.Draw(fb, fb.Bounds(), background, fb.Bounds().Min)
|
||||
|
||||
text := fmt.Appendln(nil, "N⁶⁴ - Get N or Get Out ♫")
|
||||
text = fmt.Appendln(text, input[0].Down())
|
||||
pt = draw.DrawText(fb, textarea, face, pt, image.Black, nil, text)
|
||||
|
||||
draw.Flush() // Blocks until everything is drawn
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user