Add input state queries

This commit is contained in:
Sasha Koshka 2022-11-02 15:14:59 -04:00
parent ce6a108d27
commit 32e30440f7
2 changed files with 40 additions and 6 deletions

View File

@ -36,16 +36,20 @@ func (application *Application) Run (callback func (application *Application)) {
color.RGBA { R: 0xFF, G: 0xFF, B: 0xFF, A: 0xFF },
}
// TODO: instead, return the error
var err error
application.backend, err = instantiateBackend(application)
if err != nil { panic(err.Error()) }
application.backend.Run(callback)
}
func (application *Application) Await (timeout time.Duration) (keepRunning bool) {
keepRunning = application.Await(timeout)
keepRunning = application.backend.Await(timeout)
return
}
func (application *Application) Poll () (keepRunning bool) {
keepRunning = application.Poll()
keepRunning = application.backend.Poll()
return
}
@ -59,10 +63,10 @@ func (application *Application) Config () (config *Config) {
return
}
// func (application *Application) Resized () (resized bool) {
// resized = application.boundsDirty
// return
// }
func (application *Application) Resized () (resized bool) {
resized = application.backend.Resized()
return
}
// // updateWindowSize updates the window size according to the buffer size.

View File

@ -83,6 +83,36 @@ func (backend *Backend) SetTitle (title string) {
}
}
func (backend *Backend) JustPressed (button stone.Button) (pressed bool) {
pressed = backend.window.JustPressed(pixelgl.Button(button))
return
}
func (backend *Backend) JustReleased (button stone.Button) (released bool) {
released = backend.window.JustReleased(pixelgl.Button(button))
return
}
func (backend *Backend) Pressed (button stone.Button) (pressed bool) {
pressed = backend.window.Pressed(pixelgl.Button(button))
return
}
func (backend *Backend) Repeated (button stone.Button) (repeated bool) {
repeated = backend.window.Repeated(pixelgl.Button(button))
return
}
func (backend *Backend) Typed () (text string) {
text = backend.window.Typed()
return
}
func (backend *Backend) Resized () (resized bool) {
resized = backend.boundsDirty
return
}
func (backend *Backend) draw () {
didDrawing := false