Open Bug 1680982 Opened 2 years ago Updated 7 months ago

Use evdev for gamepads on Linux/FreeBSD

Categories

(Core :: DOM: Device Interfaces, enhancement)

Desktop
FreeBSD
enhancement

Tracking

()

Tracking Status
firefox85 --- affected

People

(Reporter: unrelentingtech, Unassigned)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

Currently, Firefox uses Linux's legacy joystick API (https://www.kernel.org/doc/html/latest/input/joydev/joystick-api.html) which

  • is limited to 2 axes
  • does not support analog triggers
  • does not have well-defined driver-agnostic meaningful mappings
  • does not support rumble, LED, etc.
  • is not implemented on FreeBSD :)
  • discouraged by Linux kernel docs: "Newer clients are encouraged to switch to the generic event (evdev) interface"

I just wrote a patch that switches this to evdev.
It should resolve bug 1643358, maybe bug 1650152, bug 1523355, and is a prerequisite for rumble/LED/etc. support (I see in bug 680289 someone tried to use evdev only for these extras, keeping legacy joystick for the core input, which is… uh, very silly.)

Switch from the legacy Linux joystick API to the generic evdev API.

  • BTN_GAMEPAD semantic buttons are interpreted directly,
    since all kernel drivers are supposed to use them correctly:
    https://www.kernel.org/doc/html/latest/input/gamepad.html
  • BTN_JOYSTICK legacy style numbered buttons use the model specific remappers
  • using evdev is a prerequisite for adding rumble (haptic feedback) and other extras
  • the Linux gamepad module is enabled on FreeBSD, because
    FreeBSD provides evdev, and libudev-devd provides enough of libudev
    (evdev headers are provided by the devel/evdev-proto package)
Blocks: 1643835
See Also: → 1643358, 1523355

Comment on attachment 9191539 [details]
Bug 1680982 - Use evdev instead of the Linux legacy joystick API for gamepads

Clang in C++ mode seems to trip on -Wmissing-braces (via -Wall) despite https://github.com/llvm/llvm-project/commit/fa52e00c85ce

$ c++ --version
FreeBSD clang version 11.0.1 (git@github.com:llvm/llvm-project.git llvmorg-11.0.1-0-g43ff75f2c3fe)
Target: x86_64-unknown-freebsd13.0
Thread model: posix
InstalledDir: /usr/bin

$ echo "ac_add_options --enable-warnings-as-errors" >>.mozconfig
$ ./mach build
[...]
In file included from Unified_cpp_dom_gamepad0.cpp:137:
dom/gamepad/linux/LinuxGamepad.cpp:363:33: error: suggest braces around initialization of subobject [-Werror,-Wmissing-braces]
    struct input_event event = {0};
                                ^
                                {}
1 error generated.
$ clang a.c -Wall
$ clang -xc++ a.c -Wall
a.c:13:31: warning: suggest braces around initialization of subobject [-Wmissing-braces]
  struct input_event event = {0};
                              ^
                              {}
1 warning generated.

$ cat a.c
struct input_event {
  struct {
    long tv_sec;
    long tv_usec;
  } time;
  unsigned short type;
  unsigned short code;
  int value;
};

int main()
{
  struct input_event event = {0};
  (void)event;
  return 0;
}
Attachment #9191539 - Attachment description: Bug 1680982 - Use evdev for gamepads on Linux/FreeBSD → Bug 1680982 - Use evdev instead of the Linux legacy joystick API for gamepads

The bug has a release status flag that shows some version of Firefox is affected, thus it will be considered confirmed.

Status: UNCONFIRMED → NEW
Ever confirmed: true
You need to log in before you can comment on or make changes to this bug.