moonlight-stream / moonlight-embedded

Gamestream client for embedded systems
https://github.com/moonlight-stream/moonlight-embedded/wiki
GNU General Public License v3.0
1.5k stars 325 forks source link

Only grab input devices if they are keyboards #737

Closed hhromic closed 5 years ago

hhromic commented 5 years ago

Description

The current evdev input implementation attempts to grab (EVIOCGRAB) every device it finds. This is required for the CTRL+C combo to not interrupt Moonlight when streaming. However, other devices that are not keyboards, i.e. gamepads, do not require this grabbing, and doing so prevent other external applications from using them concurrently. This situation can happen for example when monitoring the gamepad for activity with the purpose of turning it off as done in WIP work in RetroPie for DS3 controllers.

This PR makes the grabbing code to be more specific and only grab keyboard-type devices in evdev_create(). Furthermore, the is_keyboard boolean is promoted to the input_device struct so it can be used in evdev_start() as well. These are the only two places where EVIOCGRAB is issued.

Tested using a real keyobard, a DS3 controller and a simple button input device on a Raspberry Pi 3 B+.

Purpose

Prevent Moonlight from grabbing input devices that are not keyboards, allowing them to be used by other external applications concurrently.