Login
[x]
Log in using an account from:
Fedora Account System
Red Hat Associate
Red Hat Customer
Or login using a Red Hat Bugzilla account
Forgot Password
Login:
Hide Forgot
Create an Account
Red Hat Bugzilla – Attachment 576746 Details for
Bug 811548
Playstation Move controller needs similar treatment as Sixaxis
[?]
New
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
|
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh83 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
This site requires JavaScript to be enabled to function correctly, please enable it.
[patch]
Patch implementing PSMove pairing
psmove-pairing.patch (text/plain), 9.12 KB, created by
Thomas Sailer
on 2012-04-11 11:49:09 UTC
(
hide
)
Description:
Patch implementing PSMove pairing
Filename:
MIME Type:
Creator:
Thomas Sailer
Created:
2012-04-11 11:49:09 UTC
Size:
9.12 KB
patch
obsolete
>--- bluez-4.96/plugins/cable.c.psmove 2012-04-11 12:21:42.511648004 +0200 >+++ bluez-4.96/plugins/cable.c 2012-04-11 13:26:27.959332348 +0200 >@@ -3,6 +3,7 @@ > * BlueZ - Bluetooth protocol stack for Linux > * > * Copyright (C) 2009 Bastien Nocera <hadess@hadess.net> >+ * Copyright (C) 2012 Thomas Sailer <t.sailer@alumni.ethz.ch> > * > * > * This program is free software; you can redistribute it and/or modify >@@ -45,8 +46,13 @@ > > /* Vendor and product ID for the Sixaxis PS3 controller */ > #define VENDOR 0x054c >-#define PRODUCT 0x0268 >+#define SIXAXIS_PRODUCT 0x0268 > #define SIXAXIS_PNP_RECORD "3601920900000A000100000900013503191124090004350D35061901000900113503190011090006350909656E09006A0901000900093508350619112409010009000D350F350D350619010009001335031900110901002513576972656C65737320436F6E74726F6C6C65720901012513576972656C65737320436F6E74726F6C6C6572090102251B536F6E7920436F6D707574657220456E7465727461696E6D656E740902000901000902010901000902020800090203082109020428010902052801090206359A35980822259405010904A101A102850175089501150026FF00810375019513150025013500450105091901291381027501950D0600FF8103150026FF0005010901A10075089504350046FF0009300931093209358102C0050175089527090181027508953009019102750895300901B102C0A1028502750895300901B102C0A10285EE750895300901B102C0A10285EF750895300901B102C0C0090207350835060904090901000902082800090209280109020A280109020B09010009020C093E8009020D280009020E2800" >+ >+/* Vendor and product ID for the PSMove PS3 controller */ >+#define PSMOVE_PRODUCT 0x03d5 >+#define PSMOVE_PNP_RECORD "3601AC0900000A000100020900013503191124090004350D35061901000900113503190011090006350909656E09006A0901000900093508350619112409010009000D350F350D3506190100090013350319001109010025114D6F74696F6E20436F6E74726F6C6C657209010125114D6F74696F6E20436F6E74726F6C6C6572090102251B536F6E7920436F6D707574657220456E7465727461696E6D656E74090200090100090201090111090202080809020308000902042800090205280109020635B835B6082225B205010905A101850105091901291815002501350045017501951881020600FF092475089503810205010930093109320935150026FF00950481020600FF09209526810285020921953091028506092795089102850309239508B102851009229530B10285E009259530B102851109269530B102C00602FF0920A10109218504150026FF007508950FB102092285059516B102C00603FF0920A101092185A0150026FF0075089522B102092285A19516B102C0090207350835060904090901000902082800090209280109020A280109020B09010009020C091F4009020D280009020E2800" >+ > #define HID_UUID "00001124-0000-1000-8000-00805f9b34fb" > > static struct btd_device *create_cable_association(DBusConnection *conn, >@@ -92,7 +98,7 @@ > return device; > } > >-static char *get_bdaddr(libusb_device_handle *devh, int itfnum) >+static char *get_sixaxis_bdaddr(libusb_device_handle *devh, int itfnum) > { > unsigned char msg[17]; > char *address; >@@ -112,12 +118,12 @@ > address = g_strdup_printf("%02X:%02X:%02X:%02X:%02X:%02X", > msg[4], msg[5], msg[6], msg[7], msg[8], msg[9]); > >- DBG("Device Bluetooth address: %s\n", address); >+ DBG("Device Bluetooth address: %s", address); > > return address; > } > >-static gboolean set_master_bdaddr(libusb_device_handle *devh, int itfnum, char *host) >+static gboolean set_sixaxis_master_bdaddr(libusb_device_handle *devh, int itfnum, char *host) > { > unsigned char msg[8]; > int mac[6]; >@@ -150,20 +156,102 @@ > > return TRUE; > } >+ >+static void get_psmove_bdaddr(libusb_device_handle *devh, int itfnum, char **devaddr, char **masteraddr) >+{ >+ unsigned char msg[16]; >+ int res; >+ >+ if (devaddr) >+ *devaddr = NULL; >+ if (masteraddr) >+ *masteraddr = NULL; >+ >+ res = libusb_control_transfer(devh, >+ LIBUSB_ENDPOINT_IN | LIBUSB_REQUEST_TYPE_CLASS | LIBUSB_RECIPIENT_INTERFACE, >+ 0x01, 0x0304, itfnum, >+ (void*) msg, sizeof(msg), >+ 5000); >+ >+ if (res < 0) { >+ DBG("Getting the device Bluetooth address failed"); >+ return; >+ } >+ >+ if (devaddr) >+ *devaddr = g_strdup_printf("%02X:%02X:%02X:%02X:%02X:%02X", >+ msg[6], msg[5], msg[4], msg[3], msg[2], msg[1]); >+ >+ if (masteraddr) >+ *masteraddr = g_strdup_printf("%02X:%02X:%02X:%02X:%02X:%02X", >+ msg[15], msg[14], msg[13], msg[12], msg[11], msg[10]); >+ >+ if (devaddr && masteraddr) >+ DBG("Device Bluetooth address: %s, Master address: %s", *devaddr, *masteraddr); >+ else if (devaddr) >+ DBG("Device Bluetooth address: %s", *devaddr); >+ else if (masteraddr) >+ DBG("Device Master address: %s", *masteraddr); >+} >+ >+static gboolean set_psmove_master_bdaddr(libusb_device_handle *devh, int itfnum, char *host) >+{ >+ unsigned char msg[11]; >+ 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] = 0x05; >+ msg[1] = mac[0]; >+ msg[2] = mac[1]; >+ msg[3] = mac[2]; >+ msg[4] = mac[3]; >+ msg[5] = mac[4]; >+ msg[6] = mac[5]; >+ msg[7] = 0x10; >+ msg[8] = 0x01; >+ msg[9] = 0x02; >+ msg[10] = 0x12; >+ >+ res = libusb_control_transfer(devh, >+ LIBUSB_ENDPOINT_OUT | LIBUSB_REQUEST_TYPE_CLASS | LIBUSB_RECIPIENT_INTERFACE, >+ 0x09, 0x0305, itfnum, >+ (void*) msg, sizeof(msg), >+ 5000); >+ >+ if (res < 0) { >+ DBG("Setting the master Bluetooth address failed"); >+ return FALSE; >+ } >+ >+ return TRUE; >+} >+ >+typedef enum { >+ devtype_sixaxis, >+ devtype_psmove >+} devtype_t; >+ > static void handle_usb_device(struct btd_adapter *adapter, > libusb_device *dev, > struct libusb_config_descriptor *cfg, > int itfnum, >- const struct libusb_interface_descriptor *alt) >+ const struct libusb_interface_descriptor *alt, >+ devtype_t devtype) > { > DBusConnection *conn; > libusb_device_handle *devh; > char *device_bdaddr; >+ char *master_bdaddr; > char adapter_bdaddr[18]; > struct btd_device *device; > bdaddr_t dst; > >- device_bdaddr = NULL; >+ device_bdaddr = master_bdaddr = NULL; > conn = dbus_bus_get(DBUS_BUS_SYSTEM, NULL); > if (conn == NULL) { > DBG("Failed to get on the bus"); >@@ -181,31 +269,67 @@ > goto bail; > } > >- device_bdaddr = get_bdaddr(devh, itfnum); >+ switch (devtype) { >+ case devtype_sixaxis: >+ device_bdaddr = get_sixaxis_bdaddr(devh, itfnum); >+ break; >+ >+ case devtype_psmove: >+ get_psmove_bdaddr(devh, itfnum, &device_bdaddr, &master_bdaddr); >+ break; >+ } >+ > if (device_bdaddr == NULL) { > DBG("Failed to get the Bluetooth address from the device"); > goto bail; > } > >- device = create_cable_association(conn, >- adapter, >- "PLAYSTATION(R)3 Controller", >- device_bdaddr, >- VENDOR, PRODUCT, SIXAXIS_PNP_RECORD); >+ switch (devtype) { >+ case devtype_sixaxis: >+ device = create_cable_association(conn, >+ adapter, >+ "PLAYSTATION(R)3 Controller", >+ device_bdaddr, >+ VENDOR, SIXAXIS_PRODUCT, SIXAXIS_PNP_RECORD); >+ break; >+ >+ case devtype_psmove: >+ device = create_cable_association(conn, >+ adapter, >+ "Sony Computer Entertainment Motion Controller", >+ device_bdaddr, >+ VENDOR, PSMOVE_PRODUCT, PSMOVE_PNP_RECORD); >+ break; >+ } > btd_device_add_uuid(device, HID_UUID); > > adapter_get_address(adapter, &dst); > ba2str(&dst, adapter_bdaddr); > DBG("Adapter bdaddr %s", adapter_bdaddr); > >- if (set_master_bdaddr(devh, itfnum, adapter_bdaddr) == FALSE) { >- DBG("Failed to set the master Bluetooth address"); >- goto bail; >+ if (g_strcmp0(master_bdaddr, adapter_bdaddr) == 0) { >+ DBG("Bluetooth Adapter Address already set, skipping"); >+ } else { >+ gboolean ok = FALSE; >+ switch (devtype) { >+ case devtype_sixaxis: >+ ok = set_sixaxis_master_bdaddr(devh, itfnum, adapter_bdaddr); >+ break; >+ >+ case devtype_psmove: >+ ok = set_psmove_master_bdaddr(devh, itfnum, adapter_bdaddr); >+ break; >+ } >+ if (ok == FALSE) { >+ DBG("Failed to set the master Bluetooth address"); >+ goto bail; >+ } > } > > bail: > dbus_connection_unref(conn); > g_free(device_bdaddr); >+ g_free(master_bdaddr); > libusb_release_interface(devh, itfnum); > /* We ignore errors from the reattach, as there's nothing we > * can do about it */ >@@ -223,15 +347,26 @@ > ssize_t num_devices; > struct libusb_device_descriptor desc; > guint8 j; >- >- if (g_strcmp0(udev_device_get_property_value(udevice, "ID_SERIAL"), >- "Sony_PLAYSTATION_R_3_Controller") != 0) >+ devtype_t devtype; >+ const char *devname; >+ const char *idserial; >+ >+ idserial = udev_device_get_property_value(udevice, "ID_SERIAL"); >+ if (g_strcmp0(idserial, "Sony_PLAYSTATION_R_3_Controller") == 0) { >+ devtype = devtype_sixaxis; >+ devname = "Sixaxis"; >+ } else if (g_strcmp0(idserial, "Sony_Computer_Entertainment_Motion_Controller") == 0) { >+ devtype = devtype_psmove; >+ devname = "PSMove"; >+ } else { > return; >+ } >+ > /* Don't look at events with an associated driver */ > if (udev_device_get_property_value(udevice, "ID_USB_DRIVER") != NULL) > return; > >- DBG("Found Sixaxis device"); >+ DBG("Found %s device", devname); > > /* Look for the default adapter */ > adapter = manager_get_default_adapter(); >@@ -264,7 +399,7 @@ > > libusb_free_device_list(list, TRUE); > if (usbdev == NULL) { >- DBG("Found a Sixaxis, but couldn't find it via libusb"); >+ DBG("Found a %s, but couldn't find it via libusb", devname); > goto out; > } > >@@ -292,7 +427,7 @@ > > alt = itf->altsetting[l]; > if (alt.bInterfaceClass == 3) { >- handle_usb_device(adapter, usbdev, config, l, &alt); >+ handle_usb_device(adapter, usbdev, config, l, &alt, devtype); > } > } > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 811548
: 576746