flutter-pi icon indicating copy to clipboard operation
flutter-pi copied to clipboard

Handling of input devices which identify as both mouse and keyboard

Open laynor opened this issue 3 years ago • 1 comments

Some input devices may identify as both mouse and keyboard. In this case, flutter-pi handles only mouse input, and the keyboard is non-functional.

In our case, the input device is a virtual device created with evdev (which identifies only as a keyboard on my development machine, but for reasons I haven't investigated well, identifies as both pointer and keyboard on the PI).

I worked around the issue checking for keyboard first in user_input.c::on_device_added, but I think in the general case all events should be handled. While modifying the code from

    // Our workaround for the virtual keyboard, check for keyboard first
    if (libinput_device_has_capability(device, LIBINPUT_DEVICE_CAP_KEYBOARD)) {  
       ...
    }else  if (libinput_device_has_capability(device, LIBINPUT_DEVICE_CAP_POINTER)) {
        ...
    } else if (libinput_device_has_capability(device, LIBINPUT_DEVICE_CAP_TOUCH)) {

to

if (libinput_device_has_capability(device, LIBINPUT_DEVICE_CAP_KEYBOARD)) {
   ...
}
if (libinput_device_has_capability(device, LIBINPUT_DEVICE_CAP_POINTER)) {
    ...
}
if (libinput_device_has_capability(device, LIBINPUT_DEVICE_CAP_TOUCH)) {
may be enough, I'm not familiar enough with the code at hand to propose a PR for this

laynor avatar Jul 04 '22 09:07 laynor

Yeah I think just removing the else is fine, though handling a device that is both a pointer and a touch device requires some modifications to flutter device id calculations, so I'd keep the else if there. I don't know how to handle tablets correctly anyway.

ardera avatar Jul 04 '22 17:07 ardera