Potentially fixed text input on kiosk machine
This commit is contained in:
@@ -130,22 +130,12 @@ func (p *WiFiSetupPage) startScan() {
|
||||
|
||||
func (p *WiFiSetupPage) HandleEvent(event *sdl.Event) error {
|
||||
switch e := (*event).(type) {
|
||||
|
||||
case *sdl.TextInputEvent:
|
||||
// SDL fires TextInputEvent for every printable character typed.
|
||||
// This is the correct SDL2 way — no manual keycode mapping needed.
|
||||
if p.isEnteringPassword {
|
||||
p.textInputSupported = true
|
||||
p.passwordInput += e.GetText()
|
||||
p.rebuildPasswordTexture()
|
||||
}
|
||||
|
||||
case *sdl.KeyboardEvent:
|
||||
if e.Type != sdl.KEYDOWN {
|
||||
return nil
|
||||
}
|
||||
if p.isEnteringPassword {
|
||||
p.handlePasswordKey(e.Keysym.Sym)
|
||||
p.handlePasswordKey(e.Keysym.Sym, e.Keysym.Mod)
|
||||
} else {
|
||||
p.handleNavKey(e.Keysym.Sym)
|
||||
}
|
||||
@@ -153,23 +143,26 @@ func (p *WiFiSetupPage) HandleEvent(event *sdl.Event) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *WiFiSetupPage) handlePasswordKey(sym sdl.Keycode) {
|
||||
func (p *WiFiSetupPage) handlePasswordKey(sym sdl.Keycode, mod uint16) {
|
||||
switch sym {
|
||||
case sdl.K_RETURN:
|
||||
p.submitPassword()
|
||||
|
||||
case sdl.K_BACKSPACE:
|
||||
if len(p.passwordInput) > 0 {
|
||||
runes := []rune(p.passwordInput)
|
||||
p.passwordInput = string(runes[:len(runes)-1])
|
||||
p.rebuildPasswordTexture()
|
||||
}
|
||||
|
||||
case sdl.K_ESCAPE:
|
||||
logger.Info("wifi: password entry cancelled")
|
||||
p.exitPasswordMode()
|
||||
p.connectError = ""
|
||||
p.selectedNet = nil
|
||||
default:
|
||||
if ch := keycodeToChar(sym, mod); ch != 0 {
|
||||
p.passwordInput += string(ch)
|
||||
p.rebuildPasswordTexture()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user