Date: Fri, 23 Apr 2021 16:14:14 GMT From: Jan Beich <jbeich@FreeBSD.org> To: ports-committers@FreeBSD.org, dev-commits-ports-all@FreeBSD.org, dev-commits-ports-branches@FreeBSD.org, dev-commits-ports-main@FreeBSD.org Subject: git: cdf1aef1ccda - main - www/firefox: update gamepad patch Message-ID: <202104231614.13NGEEoJ016101@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch main has been updated by jbeich: URL: https://cgit.FreeBSD.org/ports/commit/?id=cdf1aef1ccda3584edab59654b173e55500eae6c commit cdf1aef1ccda3584edab59654b173e55500eae6c Author: Jan Beich <jbeich@FreeBSD.org> AuthorDate: 2021-04-23 06:54:32 +0000 Commit: Jan Beich <jbeich@FreeBSD.org> CommitDate: 2021-04-23 16:13:15 +0000 www/firefox: update gamepad patch --- www/firefox/Makefile | 1 + www/firefox/files/patch-bug1680982 | 59 +++++++++++++++++++++++++------------- 2 files changed, 40 insertions(+), 20 deletions(-) diff --git a/www/firefox/Makefile b/www/firefox/Makefile index 0214820bf4a0..30556e7188b7 100644 --- a/www/firefox/Makefile +++ b/www/firefox/Makefile @@ -2,6 +2,7 @@ PORTNAME= firefox DISTVERSION= 88.0 +PORTREVISION= 1 PORTEPOCH= 2 CATEGORIES= www MASTER_SITES= MOZILLA/${PORTNAME}/releases/${DISTVERSION}/source \ diff --git a/www/firefox/files/patch-bug1680982 b/www/firefox/files/patch-bug1680982 index 17604ac3b6a2..c9fc2344bb44 100644 --- a/www/firefox/files/patch-bug1680982 +++ b/www/firefox/files/patch-bug1680982 @@ -1,28 +1,28 @@ -commit d947b92c7503 +commit 3204512f58a1 Author: Greg V <greg@unrelenting.technology> Date: Sun Dec 6 22:07:00 2020 +0000 - Bug 1680982 - Use evdev for gamepads on Linux/FreeBSD + Bug 1680982 - Use evdev instead of the Linux legacy joystick API for gamepads - Switch from the legacy Linux joystick API to the generic evdev API. + Using evdev is a prerequisite for adding rumble (haptic feedback) and LED support. - 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 + - we support even strange devices that combine both styles in one device + - the Linux gamepad module is enabled on FreeBSD and DragonFly, because + these kernels provide evdev, and libudev-devd provides enough of libudev (evdev headers are provided by the devel/evdev-proto package) Differential Revision: https://phabricator.services.mozilla.com/D98868 --- - dom/gamepad/linux/LinuxGamepad.cpp | 243 +++++++++++++++++++++++++++++++------ + dom/gamepad/linux/LinuxGamepad.cpp | 262 ++++++++++++++++++++++++++++++++----- dom/gamepad/moz.build | 2 +- - 2 files changed, 210 insertions(+), 35 deletions(-) + 2 files changed, 229 insertions(+), 35 deletions(-) diff --git dom/gamepad/linux/LinuxGamepad.cpp dom/gamepad/linux/LinuxGamepad.cpp -index 512ac765020d..0e51183c2a2d 100644 +index deee47b9d267..31f0aad7ae4a 100644 --- dom/gamepad/linux/LinuxGamepad.cpp +++ dom/gamepad/linux/LinuxGamepad.cpp @@ -5,15 +5,16 @@ @@ -109,13 +109,15 @@ index 512ac765020d..0e51183c2a2d 100644 static gboolean OnGamepadData(GIOChannel* source, GIOCondition condition, gpointer data); -@@ -114,8 +129,12 @@ void LinuxGamepadService::AddDevice(struct udev_device* dev) { +@@ -114,8 +129,14 @@ void LinuxGamepadService::AddDevice(struct udev_device* dev) { g_io_channel_set_encoding(channel, nullptr, nullptr); g_io_channel_set_buffered(channel, FALSE); int fd = g_io_channel_unix_get_fd(channel); + -+ struct input_id id = {0}; -+ ioctl(fd, EVIOCGID, &id); ++ struct input_id id {}; ++ if (ioctl(fd, EVIOCGID, &id) == -1) { ++ return; ++ } + char name[128]; - if (ioctl(fd, JSIOCGNAME(sizeof(name)), &name) == -1) { @@ -123,7 +125,7 @@ index 512ac765020d..0e51183c2a2d 100644 strcpy(name, "unknown"); } const char* vendor_id = -@@ -131,20 +150,69 @@ void LinuxGamepadService::AddDevice(struct udev_device* dev) { +@@ -131,20 +152,86 @@ void LinuxGamepadService::AddDevice(struct udev_device* dev) { model_id = mUdev.udev_device_get_sysattr_value(parent, "id/product"); } } @@ -148,8 +150,11 @@ index 512ac765020d..0e51183c2a2d 100644 + unsigned long abs_bits[NLONGS(ABS_CNT)] = {0}; + ioctl(fd, EVIOCGBIT(EV_KEY, sizeof(key_bits)), key_bits); + ioctl(fd, EVIOCGBIT(EV_ABS, sizeof(abs_bits)), abs_bits); ++ ++ /* Here, we try to support even strange cases where proper semantic ++ * BTN_GAMEPAD button are combined with arbitrary extra buttons. */ + for (uint16_t i = BTN_JOYSTICK; i < KEY_MAX; i++) { -+ /* Skip proper gamepad events, they are handled directly */ ++ /* Do not map semantic buttons, they are handled directly */ + if (i == BTN_GAMEPAD) { + i = BTN_THUMBR + 1; + continue; @@ -167,6 +172,13 @@ index 512ac765020d..0e51183c2a2d 100644 + gamepad->key_map[i] = numButtons++; + } + } ++ for (uint16_t i = BTN_GAMEPAD; i <= BTN_THUMBR; i++) { ++ /* But if any semantic event exists, count them all */ ++ if (TestBit(key_bits, i)) { ++ numButtons += BUTTON_INDEX_COUNT; ++ break; ++ } ++ } + for (uint16_t i = 0; i < ABS_MAX; ++i) { + if (TestBit(abs_bits, i)) { + gamepad->abs_info.emplace(i, input_absinfo{}); @@ -181,6 +193,13 @@ index 512ac765020d..0e51183c2a2d 100644 + } + } + ++ if (numAxes == 0) { ++ NS_WARNING("Gamepad with zero axes detected?"); ++ } ++ if (numButtons == 0) { ++ NS_WARNING("Gamepad with zero buttons detected?"); ++ } ++ + bool defaultRemapper = false; + RefPtr<GamepadRemapper> remapper = + GetGamepadRemapper(id.vendor, id.product, defaultRemapper); @@ -200,7 +219,7 @@ index 512ac765020d..0e51183c2a2d 100644 // TODO: Bug 1523355, implement gamepad lighindicator and touch for Linux. gamepad->source_id = -@@ -257,7 +325,7 @@ bool LinuxGamepadService::is_gamepad(struct udev_device* dev) { +@@ -257,7 +344,7 @@ bool LinuxGamepadService::is_gamepad(struct udev_device* dev) { if (!devpath) { return false; } @@ -209,16 +228,16 @@ index 512ac765020d..0e51183c2a2d 100644 return false; } -@@ -292,7 +360,7 @@ gboolean LinuxGamepadService::OnGamepadData(GIOChannel* source, +@@ -292,7 +379,7 @@ gboolean LinuxGamepadService::OnGamepadData(GIOChannel* source, if (condition & G_IO_ERR || condition & G_IO_HUP) return FALSE; while (true) { - struct js_event event; -+ struct input_event event = {0}; ++ struct input_event event {}; gsize count; GError* err = nullptr; if (g_io_channel_read_chars(source, (gchar*)&event, sizeof(event), &count, -@@ -301,18 +369,125 @@ gboolean LinuxGamepadService::OnGamepadData(GIOChannel* source, +@@ -301,18 +388,125 @@ gboolean LinuxGamepadService::OnGamepadData(GIOChannel* source, break; } @@ -355,7 +374,7 @@ index 512ac765020d..0e51183c2a2d 100644 } } diff --git dom/gamepad/moz.build dom/gamepad/moz.build -index 5f55d5a95e96..b5d10e9d095a 100644 +index 5f55d5a95e96..544b7f927736 100644 --- dom/gamepad/moz.build +++ dom/gamepad/moz.build @@ -59,7 +59,7 @@ elif CONFIG["MOZ_WIDGET_TOOLKIT"] == "windows": @@ -363,7 +382,7 @@ index 5f55d5a95e96..b5d10e9d095a 100644 elif CONFIG["MOZ_WIDGET_TOOLKIT"] == "android": UNIFIED_SOURCES += ["android/AndroidGamepad.cpp"] -elif CONFIG["OS_ARCH"] == "Linux": -+elif CONFIG["OS_ARCH"] == "Linux" or CONFIG["OS_ARCH"] == "FreeBSD": ++elif CONFIG["OS_ARCH"] in ("Linux", "FreeBSD", "DragonFly"): UNIFIED_SOURCES += ["linux/LinuxGamepad.cpp"] else: UNIFIED_SOURCES += ["fallback/FallbackGamepad.cpp"]
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202104231614.13NGEEoJ016101>