Fix input
This commit is contained in:
@@ -170,17 +170,14 @@ func (p *WiFiSetupPage) HandleEvent(event *sdl.Event) error {
|
||||
|
||||
case *sdl.TextInputEvent:
|
||||
if p.isEnteringPassword {
|
||||
text := e.GetText()
|
||||
|
||||
// Append text exactly as SDL delivers it
|
||||
p.passwordInput += text
|
||||
|
||||
// Log every character
|
||||
for _, r := range text {
|
||||
logger.Info("WiFi Password character entered: %c", r)
|
||||
// If we get a TextInputEvent, the system supports high-level input.
|
||||
// Mark it supported so we don't double-type from KeyboardEvents.
|
||||
if !p.textInputSupported {
|
||||
p.textInputSupported = true
|
||||
} else {
|
||||
p.passwordInput += e.GetText()
|
||||
p.updatePasswordTexture()
|
||||
}
|
||||
|
||||
p.updatePasswordTexture()
|
||||
}
|
||||
|
||||
case *sdl.KeyboardEvent:
|
||||
@@ -189,7 +186,8 @@ func (p *WiFiSetupPage) HandleEvent(event *sdl.Event) error {
|
||||
}
|
||||
|
||||
if p.isEnteringPassword {
|
||||
p.handlePasswordInput(e.Keysym.Sym)
|
||||
// Pass the Modifiers (Shift/Caps) to the handler
|
||||
p.handlePasswordInput(e.Keysym.Sym, e.Keysym.Mod)
|
||||
} else {
|
||||
p.handleNetworkSelection(e.Keysym.Sym)
|
||||
}
|
||||
@@ -199,7 +197,9 @@ func (p *WiFiSetupPage) HandleEvent(event *sdl.Event) error {
|
||||
}
|
||||
|
||||
// handlePasswordInput manages keyboard events during password entry.
|
||||
func (p *WiFiSetupPage) handlePasswordInput(sym sdl.Keycode) {
|
||||
// Update the signature to include mod
|
||||
// handlePasswordInput manages keyboard events during password entry.
|
||||
func (p *WiFiSetupPage) handlePasswordInput(sym sdl.Keycode, mod uint16) {
|
||||
switch sym {
|
||||
|
||||
case sdl.K_RETURN:
|
||||
@@ -228,11 +228,21 @@ func (p *WiFiSetupPage) handlePasswordInput(sym sdl.Keycode) {
|
||||
|
||||
case sdl.K_ESCAPE:
|
||||
logger.Info("WiFi Password entry cancelled")
|
||||
|
||||
p.isEnteringPassword = false
|
||||
p.pendingSSID = ""
|
||||
p.connectionError = ""
|
||||
p.exitPasswordMode()
|
||||
|
||||
default:
|
||||
// FALLBACK: If the kiosk environment doesn't fire TextInputEvents,
|
||||
// manually convert keycodes to characters.
|
||||
if !p.textInputSupported {
|
||||
if ch := keycodeToChar(sym, mod); ch != 0 {
|
||||
p.passwordInput += string(ch)
|
||||
logger.Info("Manual character fallback: %c", ch)
|
||||
p.updatePasswordTexture()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user