linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH BlueZ v1 1/2] autopair: Move handling of wii controllers
@ 2025-01-07 15:42 Luiz Augusto von Dentz
  2025-01-07 15:42 ` [PATCH BlueZ v1 2/2] build: Remove wiimote plugin Luiz Augusto von Dentz
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Luiz Augusto von Dentz @ 2025-01-07 15:42 UTC (permalink / raw)
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

This moves the pairing handling of wii controllers to autopair plugin.

Link: https://github.com/bluez/bluez/issues/911#issuecomment-2571606630
---
 plugins/autopair.c | 80 ++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 80 insertions(+)

diff --git a/plugins/autopair.c b/plugins/autopair.c
index 0b09e893f817..2274b5e2f897 100644
--- a/plugins/autopair.c
+++ b/plugins/autopair.c
@@ -30,6 +30,80 @@
 #include "src/storage.h"
 #include "src/shared/util.h"
 
+/*
+ * Nintendo Wii Remote devices require the bdaddr of the host as pin input for
+ * authentication. This plugin registers a pin-callback and forces this pin
+ * to be used for authentication.
+ *
+ * There are two ways to place the wiimote into discoverable mode.
+ *  - Pressing the red-sync button on the back of the wiimote. This module
+ *    supports pairing via this method. Auto-reconnect should be possible after
+ *    the device was paired once.
+ *  - Pressing the 1+2 buttons on the front of the wiimote. This module does
+ *    not support this method since this method never enables auto-reconnect.
+ *    Hence, pairing is not needed. Use it without pairing if you want.
+ * After connecting the wiimote you should immediately connect to the input
+ * service of the wiimote. If you don't, the wiimote will close the connection.
+ * The wiimote waits about 5 seconds until it turns off again.
+ * Auto-reconnect is only enabled when pairing with the wiimote via the red
+ * sync-button and then connecting to the input service. If you do not connect
+ * to the input service, then auto-reconnect is not enabled.
+ * If enabled, the wiimote connects to the host automatically when any button
+ * is pressed.
+ */
+
+static uint16_t wii_ids[][2] = {
+	{ 0x057e, 0x0306 },		/* 1st gen */
+	{ 0x054c, 0x0306 },		/* LEGO wiimote */
+	{ 0x057e, 0x0330 },		/* 2nd gen */
+};
+
+static const char *wii_names[] = {
+	"Nintendo RVL-CNT-01",		/* 1st gen */
+	"Nintendo RVL-CNT-01-TR",	/* 2nd gen */
+	"Nintendo RVL-CNT-01-UC",	/* Wii U Pro Controller */
+	"Nintendo RVL-WBC-01",		/* Balance Board */
+};
+
+static ssize_t wii_pincb(struct btd_adapter *adapter, struct btd_device *device,
+						char *pinbuf, bool *display,
+						unsigned int attempt)
+{
+	uint16_t vendor, product;
+	char addr[18], name[25];
+	unsigned int i;
+
+	/* Only try the pin code once per device. If it's not correct then it's
+	 * an unknown device.
+	 */
+	if (attempt > 1)
+		return 0;
+
+	ba2str(device_get_address(device), addr);
+
+	vendor = btd_device_get_vendor(device);
+	product = btd_device_get_product(device);
+
+	device_get_name(device, name, sizeof(name));
+
+	for (i = 0; i < G_N_ELEMENTS(wii_ids); ++i) {
+		if (vendor == wii_ids[i][0] && product == wii_ids[i][1])
+			goto found;
+	}
+
+	for (i = 0; i < G_N_ELEMENTS(wii_names); ++i) {
+		if (g_str_equal(name, wii_names[i]))
+			goto found;
+	}
+
+	return 0;
+
+found:
+	DBG("Forcing fixed pin on detected wiimote %s", addr);
+	memcpy(pinbuf, btd_adapter_get_address(adapter), 6);
+	return 6;
+}
+
 /*
  * Plugin to handle automatic pairing of devices with reduced user
  * interaction, including implementing the recommendation of the HID spec
@@ -51,6 +125,12 @@ static ssize_t autopair_pincb(struct btd_adapter *adapter,
 	char name[25];
 	uint32_t class;
 	uint32_t val;
+	ssize_t ret;
+
+	/* Try with the wii_pincb first */
+	ret = wii_pincb(adapter, device, pinbuf, display, attempt);
+	if (ret > 0)
+		return ret;
 
 	ba2str(device_get_address(device), addr);
 
-- 
2.47.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH BlueZ v1 2/2] build: Remove wiimote plugin
  2025-01-07 15:42 [PATCH BlueZ v1 1/2] autopair: Move handling of wii controllers Luiz Augusto von Dentz
@ 2025-01-07 15:42 ` Luiz Augusto von Dentz
  2025-01-07 17:08 ` [BlueZ,v1,1/2] autopair: Move handling of wii controllers bluez.test.bot
  2025-01-08 19:30 ` [PATCH BlueZ v1 1/2] " patchwork-bot+bluetooth
  2 siblings, 0 replies; 4+ messages in thread
From: Luiz Augusto von Dentz @ 2025-01-07 15:42 UTC (permalink / raw)
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

---
 Makefile.plugins  |   3 --
 plugins/wiimote.c | 130 ----------------------------------------------
 2 files changed, 133 deletions(-)
 delete mode 100644 plugins/wiimote.c

diff --git a/Makefile.plugins b/Makefile.plugins
index 9da29a3ce43a..7644041b3b6d 100644
--- a/Makefile.plugins
+++ b/Makefile.plugins
@@ -2,9 +2,6 @@
 builtin_modules += hostname
 builtin_sources += plugins/hostname.c
 
-builtin_modules += wiimote
-builtin_sources += plugins/wiimote.c
-
 builtin_modules += autopair
 builtin_sources += plugins/autopair.c
 
diff --git a/plugins/wiimote.c b/plugins/wiimote.c
deleted file mode 100644
index 9c4e0a58b0c8..000000000000
--- a/plugins/wiimote.c
+++ /dev/null
@@ -1,130 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-or-later
-/*
- *
- *  BlueZ - Bluetooth protocol stack for Linux
- *
- *  Copyright (C) 2011-2012 David Herrmann <dh.herrmann@googlemail.com>
- *
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <stdbool.h>
-
-#include <glib.h>
-
-#include "bluetooth/bluetooth.h"
-#include "bluetooth/sdp.h"
-
-#include "src/plugin.h"
-#include "src/adapter.h"
-#include "src/device.h"
-#include "src/log.h"
-#include "src/storage.h"
-
-/*
- * Nintendo Wii Remote devices require the bdaddr of the host as pin input for
- * authentication. This plugin registers a pin-callback and forces this pin
- * to be used for authentication.
- *
- * There are two ways to place the wiimote into discoverable mode.
- *  - Pressing the red-sync button on the back of the wiimote. This module
- *    supports pairing via this method. Auto-reconnect should be possible after
- *    the device was paired once.
- *  - Pressing the 1+2 buttons on the front of the wiimote. This module does
- *    not support this method since this method never enables auto-reconnect.
- *    Hence, pairing is not needed. Use it without pairing if you want.
- * After connecting the wiimote you should immediately connect to the input
- * service of the wiimote. If you don't, the wiimote will close the connection.
- * The wiimote waits about 5 seconds until it turns off again.
- * Auto-reconnect is only enabled when pairing with the wiimote via the red
- * sync-button and then connecting to the input service. If you do not connect
- * to the input service, then auto-reconnect is not enabled.
- * If enabled, the wiimote connects to the host automatically when any button
- * is pressed.
- */
-
-static uint16_t wii_ids[][2] = {
-	{ 0x057e, 0x0306 },		/* 1st gen */
-	{ 0x054c, 0x0306 },		/* LEGO wiimote */
-	{ 0x057e, 0x0330 },		/* 2nd gen */
-};
-
-static const char *wii_names[] = {
-	"Nintendo RVL-CNT-01",		/* 1st gen */
-	"Nintendo RVL-CNT-01-TR",	/* 2nd gen */
-	"Nintendo RVL-CNT-01-UC",	/* Wii U Pro Controller */
-	"Nintendo RVL-WBC-01",		/* Balance Board */
-};
-
-static ssize_t wii_pincb(struct btd_adapter *adapter, struct btd_device *device,
-						char *pinbuf, bool *display,
-						unsigned int attempt)
-{
-	uint16_t vendor, product;
-	char addr[18], name[25];
-	unsigned int i;
-
-	/* Only try the pin code once per device. If it's not correct then it's
-	 * an unknown device. */
-	if (attempt > 1)
-		return 0;
-
-	ba2str(device_get_address(device), addr);
-
-	vendor = btd_device_get_vendor(device);
-	product = btd_device_get_product(device);
-
-	device_get_name(device, name, sizeof(name));
-
-	for (i = 0; i < G_N_ELEMENTS(wii_ids); ++i) {
-		if (vendor == wii_ids[i][0] && product == wii_ids[i][1])
-			goto found;
-	}
-
-	for (i = 0; i < G_N_ELEMENTS(wii_names); ++i) {
-		if (g_str_equal(name, wii_names[i]))
-			goto found;
-	}
-
-	return 0;
-
-found:
-	DBG("Forcing fixed pin on detected wiimote %s", addr);
-	memcpy(pinbuf, btd_adapter_get_address(adapter), 6);
-	return 6;
-}
-
-static int wii_probe(struct btd_adapter *adapter)
-{
-	btd_adapter_register_pin_cb(adapter, wii_pincb);
-
-	return 0;
-}
-
-static void wii_remove(struct btd_adapter *adapter)
-{
-	btd_adapter_unregister_pin_cb(adapter, wii_pincb);
-}
-
-static struct btd_adapter_driver wii_driver = {
-	.name	= "wiimote",
-	.probe	= wii_probe,
-	.remove	= wii_remove,
-};
-
-static int wii_init(void)
-{
-	return btd_register_adapter_driver(&wii_driver);
-}
-
-static void wii_exit(void)
-{
-	btd_unregister_adapter_driver(&wii_driver);
-}
-
-BLUETOOTH_PLUGIN_DEFINE(wiimote, VERSION,
-		BLUETOOTH_PLUGIN_PRIORITY_LOW, wii_init, wii_exit)
-- 
2.47.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* RE: [BlueZ,v1,1/2] autopair: Move handling of wii controllers
  2025-01-07 15:42 [PATCH BlueZ v1 1/2] autopair: Move handling of wii controllers Luiz Augusto von Dentz
  2025-01-07 15:42 ` [PATCH BlueZ v1 2/2] build: Remove wiimote plugin Luiz Augusto von Dentz
@ 2025-01-07 17:08 ` bluez.test.bot
  2025-01-08 19:30 ` [PATCH BlueZ v1 1/2] " patchwork-bot+bluetooth
  2 siblings, 0 replies; 4+ messages in thread
From: bluez.test.bot @ 2025-01-07 17:08 UTC (permalink / raw)
  To: linux-bluetooth, luiz.dentz

[-- Attachment #1: Type: text/plain, Size: 1260 bytes --]

This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list.
This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=923027

---Test result---

Test Summary:
CheckPatch                    PENDING   0.27 seconds
GitLint                       PENDING   0.26 seconds
BuildEll                      PASS      20.54 seconds
BluezMake                     PASS      1567.06 seconds
MakeCheck                     PASS      13.16 seconds
MakeDistcheck                 PASS      159.22 seconds
CheckValgrind                 PASS      217.42 seconds
CheckSmatch                   PASS      273.27 seconds
bluezmakeextell               PASS      98.73 seconds
IncrementalBuild              PENDING   0.36 seconds
ScanBuild                     PASS      844.21 seconds

Details
##############################
Test: CheckPatch - PENDING
Desc: Run checkpatch.pl script
Output:

##############################
Test: GitLint - PENDING
Desc: Run gitlint
Output:

##############################
Test: IncrementalBuild - PENDING
Desc: Incremental build with the patches in the series
Output:



---
Regards,
Linux Bluetooth


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH BlueZ v1 1/2] autopair: Move handling of wii controllers
  2025-01-07 15:42 [PATCH BlueZ v1 1/2] autopair: Move handling of wii controllers Luiz Augusto von Dentz
  2025-01-07 15:42 ` [PATCH BlueZ v1 2/2] build: Remove wiimote plugin Luiz Augusto von Dentz
  2025-01-07 17:08 ` [BlueZ,v1,1/2] autopair: Move handling of wii controllers bluez.test.bot
@ 2025-01-08 19:30 ` patchwork-bot+bluetooth
  2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+bluetooth @ 2025-01-08 19:30 UTC (permalink / raw)
  To: Luiz Augusto von Dentz; +Cc: linux-bluetooth

Hello:

This series was applied to bluetooth/bluez.git (master)
by Luiz Augusto von Dentz <luiz.von.dentz@intel.com>:

On Tue,  7 Jan 2025 10:42:07 -0500 you wrote:
> From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
> 
> This moves the pairing handling of wii controllers to autopair plugin.
> 
> Link: https://github.com/bluez/bluez/issues/911#issuecomment-2571606630
> ---
>  plugins/autopair.c | 80 ++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 80 insertions(+)

Here is the summary with links:
  - [BlueZ,v1,1/2] autopair: Move handling of wii controllers
    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=c281bc460884
  - [BlueZ,v1,2/2] build: Remove wiimote plugin
    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=7679c96954ec

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-01-08 19:30 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-07 15:42 [PATCH BlueZ v1 1/2] autopair: Move handling of wii controllers Luiz Augusto von Dentz
2025-01-07 15:42 ` [PATCH BlueZ v1 2/2] build: Remove wiimote plugin Luiz Augusto von Dentz
2025-01-07 17:08 ` [BlueZ,v1,1/2] autopair: Move handling of wii controllers bluez.test.bot
2025-01-08 19:30 ` [PATCH BlueZ v1 1/2] " patchwork-bot+bluetooth

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).