linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Antonio Ospite <ospite@studenti.unina.it>
To: linux-bluetooth@vger.kernel.org
Cc: Antonio Ospite <ospite@studenti.unina.it>,
	Bastien Nocera <hadess@hadess.net>,
	linux-input@vger.kernel.org, Jim Paris <jim@jtan.com>,
	Ranulf Doswell <ralf@ranulf.net>,
	"Pascal A . Brisset" <pascal44973@pabr.org>,
	Marcin Tolysz <tolysz@gmail.com>,
	Christian Birchinger <joker@netswarm.net>,
	Filipe Lopes <falktx@gmail.com>, Alan Ott <alan@signal11.us>,
	Mikko Virkkila <virkkila@kapsi.fi>
Subject: [PATCH v2 1/3] Remove input/sixpair.c
Date: Fri, 25 Feb 2011 11:04:50 +0100	[thread overview]
Message-ID: <1298628292-8842-2-git-send-email-ospite@studenti.unina.it> (raw)
In-Reply-To: <1298628292-8842-1-git-send-email-ospite@studenti.unina.it>

This is the old way to associate to a Sixaxis controller and it is not
even compiled in, so we can safely get rid of it.

Signed-off-by: Antonio Ospite <ospite@studenti.unina.it>
---
 input/sixpair.c |  299 -------------------------------------------------------
 1 files changed, 0 insertions(+), 299 deletions(-)
 delete mode 100644 input/sixpair.c

diff --git a/input/sixpair.c b/input/sixpair.c
deleted file mode 100644
index 5c58b9b..0000000
--- a/input/sixpair.c
+++ /dev/null
@@ -1,299 +0,0 @@
-/* To compile
- * gcc -g -Wall -I../src -I../lib/ -I../include -DSTORAGEDIR=\"/var/lib/bluetooth\" -o sixpair sixpair.c ../src/storage.c ../common/libhelper.a -I../common `pkg-config --libs --cflags glib-2.0 libusb-1.0` -lbluetooth
- */
-
-#include <unistd.h>
-#include <stdio.h>
-#include <inttypes.h>
-
-#include <sdp.h>
-#include <bluetooth/bluetooth.h>
-#include <bluetooth/sdp_lib.h>
-#include <glib.h>
-#include <libusb.h>
-
-#include "storage.h"
-
-/* Vendor and product ID for the Sixaxis PS3 controller */
-#define VENDOR 0x054c
-#define PRODUCT 0x0268
-
-#define PS3_PNP_RECORD "3601920900000A000100000900013503191124090004350D35061901000900113503190011090006350909656E09006A0901000900093508350619112409010009000D350F350D350619010009001335031900110901002513576972656C65737320436F6E74726F6C6C65720901012513576972656C65737320436F6E74726F6C6C6572090102251B536F6E7920436F6D707574657220456E7465727461696E6D656E740902000901000902010901000902020800090203082109020428010902052801090206359A35980822259405010904A101A102850175089501150026FF00810375019513150025013500450105091901291381027501950D0600FF8103150026FF0005010901A10075089504350046FF0009300931093209358102C0050175089527090181027508953009019102750895300901B102C0A1028502750895300901B102C0A10285EE750895300901B102C0A10285EF750895300901B102C0C0090207350835060904090901000902082800090209280109020A280109020B090
 10009020C093E8009020D280009020E2800"
-
-gboolean option_get_master = TRUE;
-char *option_master= NULL;
-gboolean option_store_info = TRUE;
-const char *option_device = NULL;
-gboolean option_quiet = FALSE;
-
-const GOptionEntry options[] = {
-	{ "get-master", '\0', 0, G_OPTION_ARG_NONE, &option_get_master, "Get currently set master address", NULL },
-	{ "set-master", '\0', 0, G_OPTION_ARG_STRING, &option_master, "Set master address (\"auto\" for automatic)", NULL },
-	{ "store-info", '\0', 0, G_OPTION_ARG_NONE, &option_store_info, "Store the HID info into the input database", NULL },
-	{ "device", '\0', 0, G_OPTION_ARG_STRING, &option_device, "Only handle one device (default, all supported", NULL },
-	{ "quiet", 'q', 0, G_OPTION_ARG_NONE, &option_quiet, "Quieten the output", NULL },
-	{ NULL }
-};
-
-static gboolean
-show_master (libusb_device_handle *devh, int itfnum)
-{
-	unsigned char msg[8];
-	int res;
-
-	res = libusb_control_transfer (devh,
-				       LIBUSB_ENDPOINT_IN | LIBUSB_REQUEST_TYPE_CLASS | LIBUSB_RECIPIENT_INTERFACE,
-				       0x01, 0x03f5, itfnum,
-				       (void*) msg, sizeof(msg),
-				       5000);
-
-	if (res < 0) {
-		g_warning ("Getting the master Bluetooth address failed");
-		return FALSE;
-	}
-	g_print ("Current Bluetooth master: %02X:%02X:%02X:%02X:%02X:%02X\n",
-		 msg[2], msg[3], msg[4], msg[5], msg[6], msg[7]);
-
-	return TRUE;
-}
-
-static char *
-get_bdaddr (libusb_device_handle *devh, int itfnum)
-{
-	unsigned char msg[17];
-	char *address;
-	int res;
-
-	res = libusb_control_transfer (devh,
-				       LIBUSB_ENDPOINT_IN | LIBUSB_REQUEST_TYPE_CLASS | LIBUSB_RECIPIENT_INTERFACE,
-				       0x01, 0x03f2, itfnum,
-				       (void*) msg, sizeof(msg),
-				       5000);
-
-	if (res < 0) {
-		g_warning ("Getting the device Bluetooth address failed");
-		return NULL;
-	}
-
-	address = g_strdup_printf ("%02X:%02X:%02X:%02X:%02X:%02X",
-				   msg[4], msg[5], msg[6], msg[7], msg[8], msg[9]);
-
-	if (option_quiet == FALSE) {
-		g_print ("Device Bluetooth address: %s\n", address);
-	}
-
-	return address;
-}
-
-static gboolean
-set_master_bdaddr (libusb_device_handle *devh, int itfnum, char *host)
-{
-	unsigned char msg[8];
-	int mac[6];
-	int res;
-
-	if (sscanf(host, "%X:%X:%X:%X:%X:%X",
-		   &mac[0],&mac[1],&mac[2],&mac[3],&mac[4],&mac[5]) != 6) {
-		return FALSE;
-	}
-
-	msg[0] = 0x01;
-	msg[1] = 0x00;
-	msg[2] = mac[0];
-	msg[3] = mac[1];
-	msg[4] = mac[2];
-	msg[5] = mac[3];
-	msg[6] = mac[4];
-	msg[7] = mac[5];
-
-	res = libusb_control_transfer (devh,
-				       LIBUSB_ENDPOINT_OUT | LIBUSB_REQUEST_TYPE_CLASS | LIBUSB_RECIPIENT_INTERFACE,
-				       0x09, 0x03f5, itfnum,
-				       (void*) msg, sizeof(msg),
-				       5000);
-
-	if (res < 0) {
-		g_warning ("Setting the master Bluetooth address failed");
-		return FALSE;
-	}
-
-	return TRUE;
-}
-
-static char *
-get_host_bdaddr (void)
-{
-	FILE *f;
-	int mac[6];
-
-	//FIXME use dbus to get the default adapter
-
-	f = popen("hcitool dev", "r");
-
-	if (f == NULL) {
-		//FIXME
-		return NULL;
-	}
-	if (fscanf(f, "%*s\n%*s %X:%X:%X:%X:%X:%X",
-		   &mac[0],&mac[1],&mac[2],&mac[3],&mac[4],&mac[5]) != 6) {
-		//FIXME
-		return NULL;
-	}
-
-	return g_strdup_printf ("%02X:%02X:%02X:%02X:%02X:%02X", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
-}
-
-static int
-handle_device (libusb_device *dev, struct libusb_config_descriptor *cfg, int itfnum, const struct libusb_interface_descriptor *alt)
-{
-	libusb_device_handle *devh;
-	int res, retval;
-
-	retval = -1;
-
-	if (libusb_open (dev, &devh) < 0) {
-		g_warning ("Can't open device");
-		goto bail;
-	}
-	libusb_detach_kernel_driver (devh, itfnum);
-
-	res = libusb_claim_interface (devh, itfnum);
-	if (res < 0) {
-		g_warning ("Can't claim interface %d", itfnum);
-		goto bail;
-	}
-
-	if (option_get_master != FALSE) {
-		if (show_master (devh, itfnum) == FALSE)
-			goto bail;
-		retval = 0;
-	}
-
-	if (option_master != NULL) {
-		if (strcmp (option_master, "auto") == 0) {
-			g_free (option_master);
-			option_master = get_host_bdaddr ();
-			if (option_master == NULL) {
-				g_warning ("Can't get bdaddr from default device");
-				retval = -1;
-				goto bail;
-			}
-		}
-	} else {
-		option_master = get_host_bdaddr ();
-		if (option_master == NULL) {
-			g_warning ("Can't get bdaddr from default device");
-			retval = -1;
-			goto bail;
-		}
-	}
-
-	if (option_store_info != FALSE) {
-		sdp_record_t *rec;
-		char *device;
-		bdaddr_t dst, src;
-
-		device = get_bdaddr (devh, itfnum);
-		if (device == NULL) {
-			retval = -1;
-			goto bail;
-		}
-
-		rec = record_from_string (PS3_PNP_RECORD);
-		store_record(option_master, device, rec);
-		write_trust(option_master, device, "[all]", TRUE);
-		store_device_id(option_master, device, 0xffff, 0x054c, 0x0268, 0);
-		str2ba(option_master, &src);
-		str2ba(device, &dst);
-		write_device_profiles(&src, &dst, "");
-		write_device_name(&src, &dst, "PLAYSTATION(R)3 Controller");
-		sdp_record_free(rec);
-
-		if (set_master_bdaddr (devh, itfnum, option_master) == FALSE) {
-			retval = -1;
-			goto bail;
-		}
-	}
-
-bail:
-	libusb_release_interface (devh, itfnum);
-	res = libusb_attach_kernel_driver(devh, itfnum);
-	if (res < 0) {
-		//FIXME sometimes the kernel tells us ENOENT, but succeeds anyway...
-		g_warning ("Reattaching the driver failed: %d", res);
-	}
-	if (devh != NULL)
-		libusb_close (devh);
-
-	return retval;
-}
-
-int main (int argc, char **argv)
-{
-	GOptionContext *context;
-	GError *error = NULL;
-	libusb_device **list;
-	ssize_t num_devices, i;
-
-	context = g_option_context_new ("- Manage Sixaxis PS3 controllers");
-	g_option_context_add_main_entries (context, options, NULL);
-	if (g_option_context_parse (context, &argc, &argv, &error) == FALSE) {
-		g_warning ("Couldn't parse command-line options: %s", error->message);
-		return 1;
-	}
-
-	/* Check that the passed bdaddr is correct */
-	if (option_master != NULL && strcmp (option_master, "auto") != 0) {
-		//FIXME check bdaddr
-	}
-
-	libusb_init (NULL);
-
-	/* Find device(s) */
-	num_devices = libusb_get_device_list (NULL, &list);
-	if (num_devices < 0) {
-		g_warning ("libusb_get_device_list failed");
-		return 1;
-	}
-
-	for (i = 0; i < num_devices; i++) {
-		struct libusb_config_descriptor *cfg;
-		libusb_device *dev = list[i];
-		struct libusb_device_descriptor desc;
-		guint8 j;
-
-		if (libusb_get_device_descriptor (dev, &desc) < 0) {
-			g_warning ("libusb_get_device_descriptor failed");
-			continue;
-		}
-
-		/* Here we check for the supported devices */
-		if (desc.idVendor != VENDOR || desc.idProduct != PRODUCT)
-			continue;
-
-		/* Look for the interface number that interests us */
-		for (j = 0; j < desc.bNumConfigurations; j++) {
-			struct libusb_config_descriptor *config;
-			guint8 k;
-
-			libusb_get_config_descriptor (dev, j, &config);
-
-			for (k = 0; k < config->bNumInterfaces; k++) {
-				const struct libusb_interface *itf = &config->interface[k];
-				int l;
-
-				for (l = 0; l < itf->num_altsetting ; l++) {
-					struct libusb_interface_descriptor alt;
-
-					alt = itf->altsetting[l];
-					if (alt.bInterfaceClass == 3) {
-						handle_device (dev, cfg, l, &alt);
-					}
-				}
-			}
-		}
-	}
-
-	return 0;
-}
-
-- 
1.7.4.1


  reply	other threads:[~2011-02-25 10:08 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-25 10:04 [PATCH v2 0/3] Another try for the Sixaxis plugin Antonio Ospite
2011-02-25 10:04 ` Antonio Ospite [this message]
2011-02-25 10:04 ` [PATCH v2 2/3] Re-add manager_get_default_adapter() Antonio Ospite
2011-02-25 10:04 ` [PATCH v2 3/3] Add sixaxis plugin: USB pairing and LEDs settings Antonio Ospite
     [not found]   ` <1298628292-8842-4-git-send-email-ospite-aNJ+ML1ZbiP93QAQaVx+gl6hYfS7NtTn@public.gmane.org>
2011-05-06  1:14     ` Bastien Nocera
     [not found]       ` <1304644488.16101.28.camel-7u+x0O+HiKDXoxyGr5pmpw@public.gmane.org>
2011-05-06  8:45         ` Antonio Ospite
2011-05-06 23:14         ` Antonio Ospite
     [not found]           ` <20110507011412.ba0ad1e9.ospite-aNJ+ML1ZbiP93QAQaVx+gl6hYfS7NtTn@public.gmane.org>
2011-05-07 16:57             ` Bastien Nocera
2011-06-03 11:59               ` Antonio Ospite
     [not found]                 ` <20110603135904.096660bc.ospite-aNJ+ML1ZbiP93QAQaVx+gl6hYfS7NtTn@public.gmane.org>
2011-06-03 15:25                   ` Bastien Nocera
2011-06-03 15:56                     ` simon
2011-06-08  9:20                       ` Antonio Ospite
     [not found] ` <1298628292-8842-1-git-send-email-ospite-aNJ+ML1ZbiP93QAQaVx+gl6hYfS7NtTn@public.gmane.org>
2011-02-25 12:34   ` [PATCH v2 0/3] Another try for the Sixaxis plugin Bastien Nocera
2011-03-24 17:32     ` Antonio Ospite
2011-03-25 15:31       ` Jim Paris
2011-03-25 16:27         ` Antonio Ospite
2011-02-25 14:11 ` pascal44973
2011-02-25 15:49 ` Simon Kenyon
     [not found]   ` <4D67CF87.50600-YTvESifDTt4@public.gmane.org>
2011-02-25 16:02     ` Bastien Nocera
2011-04-30 11:31 ` Joakim Plate

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1298628292-8842-2-git-send-email-ospite@studenti.unina.it \
    --to=ospite@studenti.unina.it \
    --cc=alan@signal11.us \
    --cc=falktx@gmail.com \
    --cc=hadess@hadess.net \
    --cc=jim@jtan.com \
    --cc=joker@netswarm.net \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=linux-input@vger.kernel.org \
    --cc=pascal44973@pabr.org \
    --cc=ralf@ranulf.net \
    --cc=tolysz@gmail.com \
    --cc=virkkila@kapsi.fi \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).