2020-10-12 19:29:30 +02:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2021-03-06 20:23:17 +01:00
|
|
|
"fyne.io/fyne/v2"
|
|
|
|
"fyne.io/fyne/v2/widget"
|
2020-10-12 19:29:30 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
type panelJoystick struct {
|
|
|
|
w fyne.Widget
|
|
|
|
labelJoy1 *widget.Label
|
|
|
|
labelJoy2 *widget.Label
|
|
|
|
}
|
|
|
|
|
|
|
|
const textJoystickNotAvailable = "unplugged"
|
|
|
|
|
|
|
|
func newPanelJoystick() *panelJoystick {
|
|
|
|
var pj panelJoystick
|
|
|
|
|
|
|
|
pj.labelJoy1 = widget.NewLabel("")
|
|
|
|
pj.labelJoy2 = widget.NewLabel("")
|
2021-03-06 20:23:17 +01:00
|
|
|
pj.w = widget.NewCard(
|
2020-10-12 19:29:30 +02:00
|
|
|
"Joysticks",
|
2021-03-06 20:23:17 +01:00
|
|
|
"",
|
2020-10-12 19:29:30 +02:00
|
|
|
widget.NewForm(
|
|
|
|
widget.NewFormItem("Joystick 1", pj.labelJoy1),
|
|
|
|
widget.NewFormItem("Joystick 2", pj.labelJoy2),
|
|
|
|
),
|
|
|
|
)
|
|
|
|
|
|
|
|
return &pj
|
|
|
|
}
|
|
|
|
|
|
|
|
func (pj *panelJoystick) updateJoy1(info *joystickInfo) {
|
|
|
|
newName := textJoystickNotAvailable
|
|
|
|
if info != nil {
|
|
|
|
newName = info.name
|
|
|
|
}
|
|
|
|
if newName != pj.labelJoy1.Text {
|
|
|
|
pj.labelJoy1.SetText(newName)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (pj *panelJoystick) updateJoy2(info *joystickInfo) {
|
|
|
|
newName := textJoystickNotAvailable
|
|
|
|
if info != nil {
|
|
|
|
newName = info.name
|
|
|
|
}
|
|
|
|
if newName != pj.labelJoy2.Text {
|
|
|
|
pj.labelJoy2.SetText(newName)
|
|
|
|
}
|
|
|
|
}
|