2022-11-21 21:43:22 -07:00
|
|
|
package main
|
|
|
|
|
|
|
|
import "os"
|
2022-11-24 20:16:22 -07:00
|
|
|
import "fmt"
|
2022-11-21 21:43:22 -07:00
|
|
|
import "image"
|
|
|
|
import _ "image/png"
|
|
|
|
import "git.tebibyte.media/sashakoshka/stone"
|
|
|
|
import _ "git.tebibyte.media/sashakoshka/stone/backends/x"
|
|
|
|
|
|
|
|
var application = &stone.Application { }
|
|
|
|
|
|
|
|
func main () {
|
|
|
|
application.SetTitle("press any key")
|
|
|
|
application.SetSize(8, 1)
|
|
|
|
|
|
|
|
iconFile16, err := os.Open("assets/scaffold16.png")
|
|
|
|
if err != nil { panic(err) }
|
|
|
|
icon16, _, err := image.Decode(iconFile16)
|
|
|
|
if err != nil { panic(err) }
|
|
|
|
iconFile16.Close()
|
|
|
|
iconFile32, err := os.Open("assets/scaffold32.png")
|
|
|
|
if err != nil { panic(err) }
|
|
|
|
icon32, _, err := image.Decode(iconFile32)
|
|
|
|
if err != nil { panic(err) }
|
|
|
|
iconFile16.Close()
|
|
|
|
|
|
|
|
application.SetIcon([]image.Image { icon16, icon32 })
|
|
|
|
|
|
|
|
application.OnPress(onPress)
|
|
|
|
application.OnRelease(onRelease)
|
|
|
|
|
|
|
|
err = application.Run()
|
|
|
|
if err != nil { panic(err) }
|
|
|
|
}
|
|
|
|
|
2022-11-21 22:21:35 -07:00
|
|
|
func onPress (button stone.Button, modifiers stone.Modifiers) {
|
2022-11-24 20:16:22 -07:00
|
|
|
fmt.Printf (
|
|
|
|
"=>>\t0x%X\tsh: %t\tctrl: %t\talt: %t\tm: %t\ts: %t \th: %t\tnumpad: %t\n",
|
|
|
|
button,
|
|
|
|
modifiers.Shift,
|
|
|
|
modifiers.Control,
|
|
|
|
modifiers.Alt,
|
|
|
|
modifiers.Meta,
|
|
|
|
modifiers.Super,
|
|
|
|
modifiers.Hyper,
|
|
|
|
modifiers.NumberPad)
|
2022-11-21 21:43:22 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
func onRelease (button stone.Button) {
|
2022-11-24 20:16:22 -07:00
|
|
|
fmt.Printf("<--\t0x%X\n", button)
|
2022-11-21 21:43:22 -07:00
|
|
|
}
|