mirror of
https://github.com/moonlight-stream/moonlight-embedded.git
synced 2025-07-01 23:35:47 +00:00
Also grab mouse input devices (fixes #756)
This commit is contained in:
parent
eb94742266
commit
243ef8ae0b
@ -56,6 +56,7 @@ struct input_abs_parms {
|
|||||||
struct input_device {
|
struct input_device {
|
||||||
struct libevdev *dev;
|
struct libevdev *dev;
|
||||||
bool is_keyboard;
|
bool is_keyboard;
|
||||||
|
bool is_mouse;
|
||||||
struct mapping* map;
|
struct mapping* map;
|
||||||
int key_map[KEY_MAX];
|
int key_map[KEY_MAX];
|
||||||
int abs_map[ABS_MAX];
|
int abs_map[ABS_MAX];
|
||||||
@ -529,6 +530,7 @@ void evdev_create(const char* device, struct mapping* mappings, bool verbose) {
|
|||||||
memset(&devices[dev].key_map, -2, sizeof(devices[dev].key_map));
|
memset(&devices[dev].key_map, -2, sizeof(devices[dev].key_map));
|
||||||
memset(&devices[dev].abs_map, -2, sizeof(devices[dev].abs_map));
|
memset(&devices[dev].abs_map, -2, sizeof(devices[dev].abs_map));
|
||||||
devices[dev].is_keyboard = is_keyboard;
|
devices[dev].is_keyboard = is_keyboard;
|
||||||
|
devices[dev].is_mouse = is_mouse;
|
||||||
|
|
||||||
int nbuttons = 0;
|
int nbuttons = 0;
|
||||||
for (int i = BTN_JOYSTICK; i < KEY_MAX; ++i) {
|
for (int i = BTN_JOYSTICK; i < KEY_MAX; ++i) {
|
||||||
@ -563,7 +565,7 @@ void evdev_create(const char* device, struct mapping* mappings, bool verbose) {
|
|||||||
fprintf(stderr, "Mapping for %s (%s) on %s is incorrect\n", name, str_guid, device);
|
fprintf(stderr, "Mapping for %s (%s) on %s is incorrect\n", name, str_guid, device);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (grabbingDevices && is_keyboard) {
|
if (grabbingDevices && (is_keyboard || is_mouse)) {
|
||||||
if (ioctl(fd, EVIOCGRAB, 1) < 0) {
|
if (ioctl(fd, EVIOCGRAB, 1) < 0) {
|
||||||
fprintf(stderr, "EVIOCGRAB failed with error %d\n", errno);
|
fprintf(stderr, "EVIOCGRAB failed with error %d\n", errno);
|
||||||
}
|
}
|
||||||
@ -690,7 +692,7 @@ void evdev_start() {
|
|||||||
// we're ready to take input events. Ctrl+C works up until
|
// we're ready to take input events. Ctrl+C works up until
|
||||||
// this point.
|
// this point.
|
||||||
for (int i = 0; i < numDevices; i++) {
|
for (int i = 0; i < numDevices; i++) {
|
||||||
if (devices[i].is_keyboard && ioctl(devices[i].fd, EVIOCGRAB, 1) < 0) {
|
if ((devices[i].is_keyboard || devices[i].is_mouse) && ioctl(devices[i].fd, EVIOCGRAB, 1) < 0) {
|
||||||
fprintf(stderr, "EVIOCGRAB failed with error %d\n", errno);
|
fprintf(stderr, "EVIOCGRAB failed with error %d\n", errno);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user