Raspberry Pi 上没有 X11 的 SDL2 应用程序中的键盘和鼠标

Keyboard and mouse in SDL2 app without X11 on Raspberry Pi

我正在处理 SDL2 应用程序。现在我尝试在 Raspberry PI(零 W)上 运行 安装 Raspbian Stretch Lite,不安装 X11。

我按照 here 所述从源构建并安装了 SDL2。

使用了这些配置标志:

./configure \
--disable-pulseaudio \
--disable-esd \
--disable-video-mir \
--disable-video-wayland \
--disable-video-x11 \
--host=arm-raspberry-linux-gnueabihf \

现在我可以编译 运行 我的应用程序了。它以全屏模式正确显示主屏幕。

但它无法接收到任何预期的键盘或鼠标事件。

我假设我在 SDL2 构建配置中遗漏了一些东西。 如何在应用中启用鼠标和键盘?

默认情况下通常禁止普通用户直接读取 /dev/input/* 文件,这是当 运行 在原始 Linux 帧缓冲区控制台上时 SDL 所做的。

来自the SDL docs (README-raspberrypi.md)

================================================================================
 No input
================================================================================

Make sure you belong to the "input" group.

    sudo usermod -aG input `whoami`

或者运行你的程序作为 root。

按照@genpfault 的指示添加一个组并安装 libudev-dev 然后重建 SDL 解决了问题。