Skip to content

fix: replace keyboard lib with imgui in tiny video game example#5

Open
hugooole wants to merge 1 commit into
spiriMirror:mainfrom
hugooole:fix/tiny-video-game-keyboard-root
Open

fix: replace keyboard lib with imgui in tiny video game example#5
hugooole wants to merge 1 commit into
spiriMirror:mainfrom
hugooole:fix/tiny-video-game-keyboard-root

Conversation

@hugooole
Copy link
Copy Markdown

@hugooole hugooole commented Apr 30, 2026

Summary

  • Remove keyboard library dependency from example 4 (tiny video game)
  • Replace with polyscope's bundled imgui (ImGuiKey_* constants + IsKeyDown())
  • No root/sudo required — imgui reads input within the polyscope render loop

Root cause: The keyboard library on Linux reads /dev/input devices directly, which requires root privileges. This caused an ImportError: You must be root to use this library on linux. at startup.

Test plan

  • Run examples/4_tiny_video_game/main.py as a normal (non-root) user and verify it starts without error
  • Verify W/A/S/D/E/Q keys move the character as expected inside the polyscope window

The `keyboard` library requires root on Linux to read /dev/input devices.
Replace it with polyscope's bundled imgui (ImGuiKey_* + IsKeyDown) which
works without elevated privileges inside the polyscope render loop.
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request replaces the keyboard library with imgui for handling key presses in the tiny_video_game example. It introduces a _KEY_MAP to translate string keys to imgui key constants and updates the IO.is_key_down method accordingly. I have no feedback to provide.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant