gonetz / GLideN64

A new generation, open-source graphics plugin for N64 emulators.
Other
754 stars 174 forks source link

Hotkeys don't work on Linux #2805

Open scurest opened 6 months ago

scurest commented 6 months ago

OS: Arch Linux Frontend: RMG

Hotkeys don't work on my Linux laptop. Nothing happens when I press one.

I did a little investigation into why. The relevant file is src/osal/osal_keys_linux.c in the osal module.

There are two problems:

  1. osal can't find my keyboard. How this works is it looks for files of the form /dev/input/by-id/*kbd*.

    /dev/input/by-id is typically populated by USB devices. I'm using a laptop, not a USB keyboard, so my keyboard isn't listed there.

    Workaround: Plug in a USB keyboard. Alternatively, you can use the environment variable GLIDEN64_KEYBOARD to directly set the path to the device you want to use (eg. /dev/input/event3 for me).

  2. osal cannot open the device file after it finds it. fopen fails with a permission error.

    I believe this is a security hardening measure against keyloggers. I think programs are generally expected to get keypresses from X/Wayland instead of directly reading device files. See this forum thread.

    Workaround: I was able to fix this by adding myself to the input group (usermod -aG input scurest) and rebooting. See this. (Sudo will also likely work.)

Not sure how feasible these are to fix, especially (2), but hopefully this can at least be useful to someone else who has the same problem.

Rosalie241 commented 5 months ago

ideally I'd make a mupen64plus API which allows plugins to receive the state of the keyboard from the front-end, sadly though this was the best I could do at the time due to not coming up with a good API design, maybe this'll change in the future though!

I'm glad you were able to find the workarounds though