Skip to content

examples/client: fix SDLvncviewer numpad keys#716

Open
marcofortina wants to merge 1 commit into
LibVNC:masterfrom
marcofortina:fix/sdlvncviewer-numpad-keys
Open

examples/client: fix SDLvncviewer numpad keys#716
marcofortina wants to merge 1 commit into
LibVNC:masterfrom
marcofortina:fix/sdlvncviewer-numpad-keys

Conversation

@marcofortina
Copy link
Copy Markdown
Contributor

@marcofortina marcofortina commented May 16, 2026

Summary

Fix SDLvncviewer keypad handling so keypad digits are not sent twice with NumLock enabled, and keypad keys can be translated to navigation keysyms when NumLock is disabled.

Issue #315 reports two Windows/MinGW/SDL2 problems:

  • with NumLock ON, keypad digits can be sent twice because SDL_KEYDOWN sends an XK_KP_* keysym and SDL_TEXTINPUT then sends the printable character;
  • with NumLock OFF, keypad keys should behave as keypad navigation keys instead of printable digits.

Changes

  • Track NumLock state inside SDLvncviewer, initialized from SDL_GetModState().
  • Update the tracked state when SDL reports SDLK_NUMLOCKCLEAR.
  • Map keypad digits to navigation keypad keysyms when tracked NumLock is off.
  • Suppress the matching one-character SDL_TEXTINPUT event after keypad keydown, avoiding duplicate keypad text.
  • Avoid sending key events for unmapped SDL keysyms.

Validation

Local Linux/no-SDL regression build:

cmake -S . -B build-315-patch \
  -DWITH_EXAMPLES=OFF \
  -DWITH_TESTS=ON \
  -DWITH_OPENSSL=OFF \
  -DWITH_GNUTLS=OFF \
  -DWITH_GCRYPT=OFF \
  -DWITH_SDL=OFF \
  -DWITH_GTK=OFF \
  -DWITH_QT=OFF \
  -DWITH_FFMPEG=OFF \
  -DWITH_XCB=OFF \
  -DWITH_LIBSSHTUNNEL=OFF \
  -DWITH_SYSTEMD=OFF \
  -DCMAKE_BUILD_TYPE=Debug
cmake --build build-315-patch --parallel 1
ctest --test-dir build-315-patch --output-on-failure

Result:

100% tests passed, 0 tests failed out of 5

Windows/MSYS2 UCRT64/SDL2 smoke

Validated with:

  • examples/server/vncev.exe
  • examples/client/SDLvncviewer.exe localhost
  • Windows On-Screen Keyboard numeric keypad

Result:

  • NumLock ON: keypad digits generated only keypad keysyms, with no duplicate ASCII text events.
  • NumLock OFF: keypad keys generated keypad navigation keysyms instead of numeric ASCII text.

Notes

Closes #315.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Numpad keys are not working properly in SDLvncviewer 0.9.12 built with MinGW

2 participants