* [Bluez-devel] HID initiated connections and input service @ 2007-06-15 16:44 Bastien Nocera 2007-06-16 7:05 ` Marcel Holtmann 2007-06-16 7:25 ` Marcel Holtmann 0 siblings, 2 replies; 17+ messages in thread From: Bastien Nocera @ 2007-06-15 16:44 UTC (permalink / raw) To: BlueZ Hackers Heya, (As promised to Claudio) 2(3) HID devices I own have the same problem with BlueZ when using the input service. Both use HID initiated connections, rather than the Host initiated connection use case you would see when addind a Bluetooth mouse to a laptop for example. * First device: Logitech MX5000 mouse/keyboard combo When not switched into HCI mode, the device works as a normal USB HID. On boot, hid2hci is run, and the 2 devices (mouse and keyboard) try to connect to bluetooth dongle (ex-USB wireless dongle). There's no bluetooth-applet, or other services, and the requests are dropped to the floor, and I end up with a Bluetooth HCI device, and no keyboard or mouse (unplug/replug "fixes" the problem though). Could we integrate hid2hci into the input service, so that it would only be started when a session is available? I'm not sure how to handle the pairing without a keyboard or mouse though... * Second device: Sixaxis PS3 Bluetooth joypad Again, 2 connections modes. Firstly, there's no pairing, the joypad knows about the computer when one runs sixpair when the pad is connected via USB, as per: http://www.pabr.org/sixlinux/sixlinux.en.html (Marcel talked about integrating this with udev, which should be pretty straight forward) Once disconnected from USB, and turned on, the device will try to connect to the computer. bluetooth-applet will request auth, and ask us whether we want to allow the connection. But as the device was never discovered/setup using CreateDevice, the get_store_device_info in input/server.c will fail. You can't use CreateDevice with the device, as it's either connecting to our computer, or off, and connection requests will fail. Any idea on how to handle those type of devices using the Input Service and giving good user experience? Cheers -- Bastien Nocera <hadess@hadess.net> ------------------------------------------------------------------------- This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ _______________________________________________ Bluez-devel mailing list Bluez-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/bluez-devel ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [Bluez-devel] HID initiated connections and input service 2007-06-15 16:44 [Bluez-devel] HID initiated connections and input service Bastien Nocera @ 2007-06-16 7:05 ` Marcel Holtmann 2007-06-16 16:35 ` Bastien Nocera 2007-06-16 7:25 ` Marcel Holtmann 1 sibling, 1 reply; 17+ messages in thread From: Marcel Holtmann @ 2007-06-16 7:05 UTC (permalink / raw) To: BlueZ development Hi Bastien, > 2(3) HID devices I own have the same problem with BlueZ when using the > input service. Both use HID initiated connections, rather than the Host > initiated connection use case you would see when addind a Bluetooth > mouse to a laptop for example. > > * First device: Logitech MX5000 mouse/keyboard combo > > When not switched into HCI mode, the device works as a normal USB HID. > On boot, hid2hci is run, and the 2 devices (mouse and keyboard) try to > connect to bluetooth dongle (ex-USB wireless dongle). > There's no bluetooth-applet, or other services, and the requests are > dropped to the floor, and I end up with a Bluetooth HCI device, and no > keyboard or mouse (unplug/replug "fixes" the problem though). you can do a adapter.SetTrusted(address) call once and no authorization agent is called. > Could we integrate hid2hci into the input service, so that it would only > be started when a session is available? I'm not sure how to handle the > pairing without a keyboard or mouse though... I wanna integrate hid2hci somehow, but currently I don't know how. > * Second device: Sixaxis PS3 Bluetooth joypad > > Again, 2 connections modes. Firstly, there's no pairing, the joypad > knows about the computer when one runs sixpair when the pad is connected > via USB, as per: > http://www.pabr.org/sixlinux/sixlinux.en.html > (Marcel talked about integrating this with udev, which should be pretty > straight forward) > > Once disconnected from USB, and turned on, the device will try to > connect to the computer. bluetooth-applet will request auth, and ask us > whether we want to allow the connection. But as the device was never > discovered/setup using CreateDevice, the get_store_device_info in > input/server.c will fail. > > You can't use CreateDevice with the device, as it's either connecting to > our computer, or off, and connection requests will fail. The sixpair.c tool needs to do some nasty tricks. It hast to get its own Bluetooth address from the controller and then get its HID report descriptor over USB. Then store them in /var/lib/bluetooth and also set itself to trusted. We might wanna integrate that into the input service, but to be honest I currently don't know how. It also might make more sense to let a HAL addon handle this kind of authentication instead of at udev level. Regards Marcel ------------------------------------------------------------------------- This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ _______________________________________________ Bluez-devel mailing list Bluez-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/bluez-devel ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [Bluez-devel] HID initiated connections and input service 2007-06-16 7:05 ` Marcel Holtmann @ 2007-06-16 16:35 ` Bastien Nocera 2007-06-16 19:35 ` Marcel Holtmann 0 siblings, 1 reply; 17+ messages in thread From: Bastien Nocera @ 2007-06-16 16:35 UTC (permalink / raw) To: BlueZ development Hey Marcel, On Sat, 2007-06-16 at 09:05 +0200, Marcel Holtmann wrote: <snip> > > * Second device: Sixaxis PS3 Bluetooth joypad > > > > Again, 2 connections modes. Firstly, there's no pairing, the joypad > > knows about the computer when one runs sixpair when the pad is connected > > via USB, as per: > > http://www.pabr.org/sixlinux/sixlinux.en.html > > (Marcel talked about integrating this with udev, which should be pretty > > straight forward) > > > > Once disconnected from USB, and turned on, the device will try to > > connect to the computer. bluetooth-applet will request auth, and ask us > > whether we want to allow the connection. But as the device was never > > discovered/setup using CreateDevice, the get_store_device_info in > > input/server.c will fail. > > > > You can't use CreateDevice with the device, as it's either connecting to > > our computer, or off, and connection requests will fail. > > The sixpair.c tool needs to do some nasty tricks. It hast to get its own > Bluetooth address from the controller and then get its HID report > descriptor over USB. Then store them in /var/lib/bluetooth and also set > itself to trusted. > > We might wanna integrate that into the input service, but to be honest I > currently don't know how. It also might make more sense to let a HAL > addon handle this kind of authentication instead of at udev level. What we could do is: 1) have a HAL addon that will set the device's bdaddr in a property of the device when plugged into USB 2) have bluetooth-applet (or any other front-end) ask the user whether to set the device as trusted when it's plugged in (can be switched off with a config item) 3) Add a method to the input service (AddUSBDevice(string address, string usbdev) that will get the USB HID report descriptor, and set the device as trusted along with the rest of the info I could work on that (it should be pretty straight-forward), except I don't have any code to get the bdaddr from the device and I don't know how to get the HID report descriptor from the device either. If you have some code that does that, feel free to pass it on, I can do the integration. Cheers -- Bastien Nocera <hadess@hadess.net> ------------------------------------------------------------------------- This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ _______________________________________________ Bluez-devel mailing list Bluez-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/bluez-devel ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [Bluez-devel] HID initiated connections and input service 2007-06-16 16:35 ` Bastien Nocera @ 2007-06-16 19:35 ` Marcel Holtmann 2007-06-17 20:25 ` Bastien Nocera 0 siblings, 1 reply; 17+ messages in thread From: Marcel Holtmann @ 2007-06-16 19:35 UTC (permalink / raw) To: BlueZ development Hi Bastien, > > > * Second device: Sixaxis PS3 Bluetooth joypad > > > > > > Again, 2 connections modes. Firstly, there's no pairing, the joypad > > > knows about the computer when one runs sixpair when the pad is connected > > > via USB, as per: > > > http://www.pabr.org/sixlinux/sixlinux.en.html > > > (Marcel talked about integrating this with udev, which should be pretty > > > straight forward) > > > > > > Once disconnected from USB, and turned on, the device will try to > > > connect to the computer. bluetooth-applet will request auth, and ask us > > > whether we want to allow the connection. But as the device was never > > > discovered/setup using CreateDevice, the get_store_device_info in > > > input/server.c will fail. > > > > > > You can't use CreateDevice with the device, as it's either connecting to > > > our computer, or off, and connection requests will fail. > > > > The sixpair.c tool needs to do some nasty tricks. It hast to get its own > > Bluetooth address from the controller and then get its HID report > > descriptor over USB. Then store them in /var/lib/bluetooth and also set > > itself to trusted. > > > > We might wanna integrate that into the input service, but to be honest I > > currently don't know how. It also might make more sense to let a HAL > > addon handle this kind of authentication instead of at udev level. > > What we could do is: > 1) have a HAL addon that will set the device's bdaddr in a property of > the device when plugged into USB I think a HAL addon that export the BD_ADDR of the controller as a property is a good idea. We might also wanna add the current configured host controller for that device and add a method to change that address. > 2) have bluetooth-applet (or any other front-end) ask the user whether > to set the device as trusted when it's plugged in (can be switched off > with a config item) Personally I think this should happen without any user-interaction once you plugin the controller. However haven't thought about it that much. > 3) Add a method to the input service (AddUSBDevice(string address, > string usbdev) that will get the USB HID report descriptor, and set the > device as trusted along with the rest of the info No. I don't wanna have hardware specific methods in that API. > I could work on that (it should be pretty straight-forward), except I > don't have any code to get the bdaddr from the device and I don't know > how to get the HID report descriptor from the device either. If you have > some code that does that, feel free to pass it on, I can do the > integration. Check http://www.holtmann.org/papers/bluetooth/csw2007_slides.pdf and you will see the report ids that will give you that information. I do have code for that, but can't find it right now. Maybe it is on one of my machines that I switched off. Regards Marcel ------------------------------------------------------------------------- This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ _______________________________________________ Bluez-devel mailing list Bluez-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/bluez-devel ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [Bluez-devel] HID initiated connections and input service 2007-06-16 19:35 ` Marcel Holtmann @ 2007-06-17 20:25 ` Bastien Nocera 2007-06-18 13:06 ` Bastien Nocera 0 siblings, 1 reply; 17+ messages in thread From: Bastien Nocera @ 2007-06-17 20:25 UTC (permalink / raw) To: BlueZ development [-- Attachment #1: Type: text/plain, Size: 2830 bytes --] Hey Marcel, On Sat, 2007-06-16 at 21:35 +0200, Marcel Holtmann wrote: <snip> > > What we could do is: > > 1) have a HAL addon that will set the device's bdaddr in a property of > > the device when plugged into USB > > I think a HAL addon that export the BD_ADDR of the controller as a > property is a good idea. We might also wanna add the current configured > host controller for that device and add a method to change that address. That would be pretty straight forward, although probably unnecessary in this particular case. > > 2) have bluetooth-applet (or any other front-end) ask the user whether > > to set the device as trusted when it's plugged in (can be switched off > > with a config item) > > Personally I think this should happen without any user-interaction once > you plugin the controller. However haven't thought about it that much. How do we need to behave when there's more than one bluetooth adapter in the machine? > > 3) Add a method to the input service (AddUSBDevice(string address, > > string usbdev) that will get the USB HID report descriptor, and set the > > device as trusted along with the rest of the info > > No. I don't wanna have hardware specific methods in that API. Well, it would do the work of adding the usb device to the database as trusted, and copying the HID report descriptor data over. > > I could work on that (it should be pretty straight-forward), except I > > don't have any code to get the bdaddr from the device and I don't know > > how to get the HID report descriptor from the device either. If you have > > some code that does that, feel free to pass it on, I can do the > > integration. > > Check http://www.holtmann.org/papers/bluetooth/csw2007_slides.pdf and > you will see the report ids that will give you that information. I do > have code for that, but can't find it right now. Maybe it is on one of > my machines that I switched off. Got it (after much brain damage), thanks. I've cooked up the attached program. The goal is: - Run program from udev when device is plugged in - Program gets host bdaddr, device bdaddr and hid report descriptor - Sets the host bdaddr on the device - Stores the HID report descriptor in the input storage So, the process would be all automated, and hopefully integrated in bluez-utils. It could easily be extended to other device types (such as the proxy dongles) given a method of getting the device's bluetooth address(es). An example program attached, that I'd like to integrate into bluez-utils. Not really tested, as my system decided to not give me the HID desc report anymore... Marcel, could you check the USB HID desc report <-> hidp_connadd_req code? The compile line is at the top of the file, you need to run the compilation from within bluez-utils/input/ Cheers -- Bastien Nocera <hadess@hadess.net> [-- Attachment #2: sixpair2.c --] [-- Type: text/x-csrc, Size: 8764 bytes --] /* To compile * gcc -g -Wall -DSTORAGEDIR=\"/var/lib/bluetooth\" -o sixpair2 sixpair2.c storage.c ../common/libhelper.a -I../common `pkg-config --libs --cflags glib-2.0 libusb` -lbluetooth */ #include <unistd.h> #include <stdio.h> #include <inttypes.h> #include <bluetooth/bluetooth.h> #include <bluetooth/hidp.h> #include <glib.h> #include <usb.h> #include "storage.h" /* Vendor and product ID for the Sixaxis PS3 controller */ #define VENDOR 0x054c #define PRODUCT 0x0268 #define USB_DIR_IN 0x80 #define USB_DIR_OUT 0 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 (usb_dev_handle *devh, int itfnum) { unsigned char msg[8]; int res; res = usb_control_msg (devh, USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_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 (usb_dev_handle *devh, int itfnum) { unsigned char msg[17]; char *address; int res; res = usb_control_msg (devh, USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE, 0x01, 0x03f2, itfnum, (void*) msg, sizeof(msg), 5000); if (res < 0) { //FIXME 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 (usb_dev_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 = usb_control_msg (devh, USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_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 ("%x:%x:%x:%x:%x:%x", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]); } static int get_record_info (struct usb_interface_descriptor *alt, unsigned int *_len, unsigned int *_country, uint16_t *_version) { unsigned char *buf; unsigned int size, len, country; uint16_t version; int l; len = 0; country = 0; version = 0; if (!alt->extralen) return 0; size = alt->extralen; buf = alt->extra; while (size >= 2 * sizeof(u_int8_t)) { if (buf[0] < 2 || buf[1] != USB_DT_HID) continue; country = buf[4]; // FIXME is this correct? version = (buf[2] << 8) + buf[3]; for (l = 0; l < buf[5]; l++) { /* we are just interested in report descriptors*/ if (buf[6+3*l] != USB_DT_REPORT) continue; len = buf[7+3*l] | (buf[8+3*l] << 8); } size -= buf[0]; buf += buf[0]; } if (len == 0) return -1; *_len = len; *_country = country; *_version = version; return 0; } static void fill_req_from_usb (struct usb_device *dev, struct hidp_connadd_req *req, unsigned char *data, unsigned int len, unsigned int country, uint16_t version) { req->vendor = dev->descriptor.idVendor; req->product = dev->descriptor.idProduct; req->version = version; /* req->subclass already set */ req->country = country; /* Default value */ req->parser = 0x0100; /* FIXME */ req->flags = 0; req->rd_size = len; req->rd_data = data; } static void store_info (const char *host, const char *device, struct hidp_connadd_req *req) { bdaddr_t dest, src; if (str2ba (host, &src) < 0) { //FIXME return; } if (str2ba (device, &dest) < 0) { //FIXME return; } store_device_info (&src, &dest, req); } static int handle_device (struct usb_device *dev, struct usb_config_descriptor *cfg, int itfnum, struct usb_interface_descriptor *alt) { usb_dev_handle *devh; int res, retval; retval = -1; devh = usb_open (dev); if (devh == NULL) { g_warning ("Can't open device"); goto bail; } usb_detach_kernel_driver_np (devh, itfnum); res = usb_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) { unsigned char data[8192]; struct hidp_connadd_req req; unsigned int len, country; uint16_t version; char *device; device = get_bdaddr (devh, itfnum); if (device == NULL) { retval = -1; goto bail; } if (get_record_info (alt, &len, &country, &version) < 0) { g_warning ("Can't get record info"); retval = -1; goto bail; } if (usb_control_msg(devh, USB_ENDPOINT_IN | USB_TYPE_STANDARD | USB_RECIP_INTERFACE, USB_REQ_GET_DESCRIPTOR, (USB_DT_REPORT << 8), itfnum, (void *)data, len, 5000) > 0) { g_warning ("Can't get report descriptor"); retval = -1; goto bail; } req.subclass = alt->bInterfaceSubClass; fill_req_from_usb (dev, &req, data, len, country, version); store_info (option_master, device, &req); if (set_master_bdaddr (devh, itfnum, option_master) == FALSE) { retval = -1; goto bail; } } bail: if (devh != NULL) usb_close (devh); return retval; } int main (int argc, char **argv) { GOptionContext *context; GError *error = NULL; struct usb_bus *busses, *bus; 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 } /* Find device(s) */ usb_init (); if (usb_find_busses () < 0) { g_warning ("usb_find_busses failed"); return 1; } if (usb_find_devices () < 0) { g_warning ("usb_find_devices failed"); return 1; } busses = usb_get_busses(); if (busses == NULL) { g_warning ("usb_get_busses failed"); return 1; } for (bus = busses; bus; bus = bus->next) { struct usb_device *dev; for (dev = bus->devices; dev; dev = dev->next) { struct usb_config_descriptor *cfg; /* Here we check for the supported devices */ if (dev->descriptor.idVendor != VENDOR || dev->descriptor.idProduct != PRODUCT) continue; /* Look for the interface number that interests us */ for (cfg = dev->config; cfg < dev->config + dev->descriptor.bNumConfigurations; ++cfg) { int itfnum; for (itfnum = 0; itfnum < cfg->bNumInterfaces; ++itfnum) { struct usb_interface *itf = &cfg->interface[itfnum]; struct usb_interface_descriptor *alt; for (alt = itf->altsetting; alt < itf->altsetting + itf->num_altsetting; ++alt) { if (alt->bInterfaceClass == 3) { handle_device (dev, cfg, itfnum, alt); } } } } } } return 0; } [-- Attachment #3: Type: text/plain, Size: 286 bytes --] ------------------------------------------------------------------------- This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ [-- Attachment #4: Type: text/plain, Size: 164 bytes --] _______________________________________________ Bluez-devel mailing list Bluez-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/bluez-devel ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [Bluez-devel] HID initiated connections and input service 2007-06-17 20:25 ` Bastien Nocera @ 2007-06-18 13:06 ` Bastien Nocera 2007-06-18 14:00 ` Pascal 0 siblings, 1 reply; 17+ messages in thread From: Bastien Nocera @ 2007-06-18 13:06 UTC (permalink / raw) To: BlueZ development [-- Attachment #1: Type: text/plain, Size: 794 bytes --] On Sun, 2007-06-17 at 21:25 +0100, Bastien Nocera wrote: <snip> > An example program attached, that I'd like to integrate into > bluez-utils. Not really tested, as my system decided to not give me the > HID desc report anymore... An updated program attached. I got the test of getting the report descriptor the wrong way around. So it does put data in my /var/lib/bluetooth/*/input now. But I get those errors in my /var/log/messages now: Jun 18 13:56:40 cookie kernel: hidp_input_report: Unknown key (scancode 0x84) pressed. Jun 18 13:56:40 cookie kernel: hidp_input_report: Unknown key (scancode 0x82) pressed. Jun 18 13:56:40 cookie kernel: hidp_input_report: Unknown key (scancode 0x82) released. Any ideas? Did I stuff incorrect data in rd_data? -- Bastien Nocera <hadess@hadess.net> [-- Attachment #2: sixpair2.c --] [-- Type: text/x-csrc, Size: 8896 bytes --] /* To compile * gcc -g -Wall -DSTORAGEDIR=\"/var/lib/bluetooth\" -o sixpair2 sixpair2.c storage.c ../common/libhelper.a -I../common `pkg-config --libs --cflags glib-2.0 libusb` -lbluetooth */ #include <unistd.h> #include <stdio.h> #include <inttypes.h> #include <bluetooth/bluetooth.h> #include <bluetooth/hidp.h> #include <glib.h> #include <usb.h> #include "storage.h" /* Vendor and product ID for the Sixaxis PS3 controller */ #define VENDOR 0x054c #define PRODUCT 0x0268 #define USB_DIR_IN 0x80 #define USB_DIR_OUT 0 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 (usb_dev_handle *devh, int itfnum) { unsigned char msg[8]; int res; res = usb_control_msg (devh, USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_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 (usb_dev_handle *devh, int itfnum) { unsigned char msg[17]; char *address; int res; res = usb_control_msg (devh, USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_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 (usb_dev_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 = usb_control_msg (devh, USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_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 ("%x:%x:%x:%x:%x:%x", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]); } static int get_record_info (struct usb_interface_descriptor *alt, unsigned int *_len, unsigned int *_country, uint16_t *_version) { unsigned char *buf; unsigned int size, len, country; uint16_t version; int l; len = 0; country = 0; version = 0; if (!alt->extralen) return 0; size = alt->extralen; buf = alt->extra; while (size >= 2 * sizeof(u_int8_t)) { if (buf[0] < 2 || buf[1] != USB_DT_HID) continue; country = buf[4]; // FIXME is this correct? version = (buf[2] << 8) + buf[3]; for (l = 0; l < buf[5]; l++) { /* we are just interested in report descriptors*/ if (buf[6+3*l] != USB_DT_REPORT) continue; len = buf[7+3*l] | (buf[8+3*l] << 8); } size -= buf[0]; buf += buf[0]; } if (len == 0) return -1; *_len = len; *_country = country; *_version = version; return 0; } static void fill_req_from_usb (struct usb_device *dev, struct hidp_connadd_req *req, unsigned char *data, unsigned int len, unsigned int country, uint16_t version) { req->vendor = dev->descriptor.idVendor; req->product = dev->descriptor.idProduct; req->version = version; /* req->subclass already set */ req->country = country; /* Default value */ req->parser = 0x0100; /* FIXME what are we expecting here? */ req->flags = 0; req->rd_size = len; req->rd_data = data; } static void store_info (const char *host, const char *device, struct hidp_connadd_req *req) { bdaddr_t dest, src; if (str2ba (host, &src) < 0) { //FIXME return; } if (str2ba (device, &dest) < 0) { //FIXME return; } store_device_info (&src, &dest, req); } static int handle_device (struct usb_device *dev, struct usb_config_descriptor *cfg, int itfnum, struct usb_interface_descriptor *alt) { usb_dev_handle *devh; int res, retval; retval = -1; devh = usb_open (dev); if (devh == NULL) { g_warning ("Can't open device"); goto bail; } usb_detach_kernel_driver_np (devh, itfnum); res = usb_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) { unsigned char data[8192]; struct hidp_connadd_req req; unsigned int len, country; int n; uint16_t version; char *device; device = get_bdaddr (devh, itfnum); if (device == NULL) { retval = -1; goto bail; } if (get_record_info (alt, &len, &country, &version) < 0) { g_warning ("Can't get record info"); retval = -1; goto bail; } if ((n = usb_control_msg(devh, USB_ENDPOINT_IN | USB_TYPE_STANDARD | USB_RECIP_INTERFACE, USB_REQ_GET_DESCRIPTOR, (USB_DT_REPORT << 8), itfnum, (void *)data, len, 5000)) < 0) { g_warning ("Can't get report descriptor (length: %d, interface: %d)", len, itfnum); retval = -1; goto bail; } req.subclass = alt->bInterfaceSubClass; fill_req_from_usb (dev, &req, data, n, country, version); store_info (option_master, device, &req); if (set_master_bdaddr (devh, itfnum, option_master) == FALSE) { retval = -1; goto bail; } } bail: if (devh != NULL) usb_close (devh); return retval; } int main (int argc, char **argv) { GOptionContext *context; GError *error = NULL; struct usb_bus *busses, *bus; 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 } /* Find device(s) */ usb_init (); if (usb_find_busses () < 0) { g_warning ("usb_find_busses failed"); return 1; } if (usb_find_devices () < 0) { g_warning ("usb_find_devices failed"); return 1; } busses = usb_get_busses(); if (busses == NULL) { g_warning ("usb_get_busses failed"); return 1; } for (bus = busses; bus; bus = bus->next) { struct usb_device *dev; for (dev = bus->devices; dev; dev = dev->next) { struct usb_config_descriptor *cfg; /* Here we check for the supported devices */ if (dev->descriptor.idVendor != VENDOR || dev->descriptor.idProduct != PRODUCT) continue; /* Look for the interface number that interests us */ for (cfg = dev->config; cfg < dev->config + dev->descriptor.bNumConfigurations; ++cfg) { int itfnum; for (itfnum = 0; itfnum < cfg->bNumInterfaces; ++itfnum) { struct usb_interface *itf = &cfg->interface[itfnum]; struct usb_interface_descriptor *alt; for (alt = itf->altsetting; alt < itf->altsetting + itf->num_altsetting; ++alt) { if (alt->bInterfaceClass == 3) { handle_device (dev, cfg, itfnum, alt); } } } } } } return 0; } [-- Attachment #3: Type: text/plain, Size: 286 bytes --] ------------------------------------------------------------------------- This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ [-- Attachment #4: Type: text/plain, Size: 164 bytes --] _______________________________________________ Bluez-devel mailing list Bluez-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/bluez-devel ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [Bluez-devel] HID initiated connections and input service 2007-06-18 13:06 ` Bastien Nocera @ 2007-06-18 14:00 ` Pascal 2007-06-18 14:36 ` Bastien Nocera 0 siblings, 1 reply; 17+ messages in thread From: Pascal @ 2007-06-18 14:00 UTC (permalink / raw) To: bluez-devel Bastien Nocera wrote: > Jun 18 13:56:40 cookie kernel: hidp_input_report: Unknown key (scancode 0x84) pressed. > Jun 18 13:56:40 cookie kernel: hidp_input_report: Unknown key (scancode 0x82) pressed. > Jun 18 13:56:40 cookie kernel: hidp_input_report: Unknown key (scancode 0x82) released. This typically occurs when the kernel thinks the device is reporting in "boot protocol" mode, for example when net/bluetooth/hidp/core.c:hidp_add_connection() fails to parse the report descriptor and consequently initializes session->input instead of session->hid. Another possible cause is that your kernel does not have HIDP support at all (2.6.20 or earlier). Pascal ------------------------------------------------------------------------- This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ _______________________________________________ Bluez-devel mailing list Bluez-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/bluez-devel ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [Bluez-devel] HID initiated connections and input service 2007-06-18 14:00 ` Pascal @ 2007-06-18 14:36 ` Bastien Nocera 2007-06-18 16:00 ` Bastien Nocera 0 siblings, 1 reply; 17+ messages in thread From: Bastien Nocera @ 2007-06-18 14:36 UTC (permalink / raw) To: BlueZ development On Mon, 2007-06-18 at 16:00 +0200, Pascal wrote: > Bastien Nocera wrote: > > Jun 18 13:56:40 cookie kernel: hidp_input_report: Unknown key (scancode 0x84) pressed. > > Jun 18 13:56:40 cookie kernel: hidp_input_report: Unknown key (scancode 0x82) pressed. > > Jun 18 13:56:40 cookie kernel: hidp_input_report: Unknown key (scancode 0x82) released. > > This typically occurs when the kernel thinks the device > is reporting in "boot protocol" mode, for example when > net/bluetooth/hidp/core.c:hidp_add_connection() fails to > parse the report descriptor and consequently initializes > session->input instead of session->hid. > > Another possible cause is that your kernel does not have > HIDP support at all (2.6.20 or earlier). Absolutely ancient FC6 kernel (2.6.19-1.2895.fc6 because of the crappy driver, for my crappy wireless card). Will test on my rawhide laptop. Thanks for the pointer! -- Bastien Nocera <hadess@hadess.net> ------------------------------------------------------------------------- This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ _______________________________________________ Bluez-devel mailing list Bluez-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/bluez-devel ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [Bluez-devel] HID initiated connections and input service 2007-06-18 14:36 ` Bastien Nocera @ 2007-06-18 16:00 ` Bastien Nocera 2007-06-18 17:30 ` Pascal 0 siblings, 1 reply; 17+ messages in thread From: Bastien Nocera @ 2007-06-18 16:00 UTC (permalink / raw) To: BlueZ development On Mon, 2007-06-18 at 15:36 +0100, Bastien Nocera wrote: > On Mon, 2007-06-18 at 16:00 +0200, Pascal wrote: > > Bastien Nocera wrote: > > > Jun 18 13:56:40 cookie kernel: hidp_input_report: Unknown key (scancode 0x84) pressed. > > > Jun 18 13:56:40 cookie kernel: hidp_input_report: Unknown key (scancode 0x82) pressed. > > > Jun 18 13:56:40 cookie kernel: hidp_input_report: Unknown key (scancode 0x82) released. > > > > This typically occurs when the kernel thinks the device > > is reporting in "boot protocol" mode, for example when > > net/bluetooth/hidp/core.c:hidp_add_connection() fails to > > parse the report descriptor and consequently initializes > > session->input instead of session->hid. > > > > Another possible cause is that your kernel does not have > > HIDP support at all (2.6.20 or earlier). > > Absolutely ancient FC6 kernel (2.6.19-1.2895.fc6 because of the crappy > driver, for my crappy wireless card). > > Will test on my rawhide laptop. Thanks for the pointer! On the laptop, after getting the authorisation dialogue, I get this message from the input service: Jun 18 16:27:12 snoogens input[4052]: New input device 00:19:C1:7D:2E:FA () But no device is actually created. The class show up in the bluez files as 0x000508, which seems to be correct for a gamepad. The kernel has HIDP support built in to a module, and seems to be getting automatically loaded. Could it be that I'm not setting the device flags to HIDP_BOOT_PROTOCOL_MODE? (Incidentally, is there any way to check whether a device is in this mode, or in full HID mode?) Any idea on how to debug this? -- Bastien Nocera <hadess@hadess.net> ------------------------------------------------------------------------- This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ _______________________________________________ Bluez-devel mailing list Bluez-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/bluez-devel ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [Bluez-devel] HID initiated connections and input service 2007-06-18 16:00 ` Bastien Nocera @ 2007-06-18 17:30 ` Pascal 2007-06-18 19:23 ` Bastien Nocera 0 siblings, 1 reply; 17+ messages in thread From: Pascal @ 2007-06-18 17:30 UTC (permalink / raw) To: bluez-devel Bastien Nocera wrote: > Jun 18 16:27:12 snoogens input[4052]: New input device 00:19:C1:7D:2E:FA () > > But no device is actually created. Do you mean nothing shows up in /dev/input/ ? Maybe you need to "modprobe joydev" or "modprobe evdev" manually. > Could it be that I'm not setting the device flags to > HIDP_BOOT_PROTOCOL_MODE? (Incidentally, is there any way to check > whether a device is in this mode, or in full HID mode?) You want it to be in "report protocol" mode, not "boot protocol". The PS3 controller only supports "report protocol" anyway. "hcidump -V -x" will show whether hidp.ko is trying to send a "HIDP: Set protocol" command. Pascal ------------------------------------------------------------------------- This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ _______________________________________________ Bluez-devel mailing list Bluez-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/bluez-devel ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [Bluez-devel] HID initiated connections and input service 2007-06-18 17:30 ` Pascal @ 2007-06-18 19:23 ` Bastien Nocera 2007-06-18 20:16 ` Pascal 0 siblings, 1 reply; 17+ messages in thread From: Bastien Nocera @ 2007-06-18 19:23 UTC (permalink / raw) To: BlueZ development On Mon, 2007-06-18 at 19:30 +0200, Pascal wrote: > Bastien Nocera wrote: > > Jun 18 16:27:12 snoogens input[4052]: New input device 00:19:C1:7D:2E:FA () > > > > But no device is actually created. > > Do you mean nothing shows up in /dev/input/ ? > Maybe you need to "modprobe joydev" or "modprobe evdev" manually. evdev is builtin, joydev is loaded (and is getting loaded). > > Could it be that I'm not setting the device flags to > > HIDP_BOOT_PROTOCOL_MODE? (Incidentally, is there any way to check > > whether a device is in this mode, or in full HID mode?) > > You want it to be in "report protocol" mode, not "boot protocol". > The PS3 controller only supports "report protocol" anyway. > "hcidump -V -x" will show whether hidp.ko is trying to send a > "HIDP: Set protocol" command. It's trying to "HIDP: Set report: Feature report" and gets disconnected afterwards. -- Bastien Nocera <hadess@hadess.net> ------------------------------------------------------------------------- This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ _______________________________________________ Bluez-devel mailing list Bluez-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/bluez-devel ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [Bluez-devel] HID initiated connections and input service 2007-06-18 19:23 ` Bastien Nocera @ 2007-06-18 20:16 ` Pascal 2007-06-18 22:40 ` Bastien Nocera 0 siblings, 1 reply; 17+ messages in thread From: Pascal @ 2007-06-18 20:16 UTC (permalink / raw) To: bluez-devel Bastien Nocera wrote: > It's trying to "HIDP: Set report: Feature report" and gets disconnected > afterwards. OK, this comes from bluez-utils/input/server.c, right before ioctl(HIDPCONNADD). You could strace the bluetoothd-service-input process to check whether this ioctl returns an error code. If that doesn't help, you will have to add printk()s in linux/net/bluetooth/hidp/core.c:hidp_add_connection() to understand what is happening. Pascal ------------------------------------------------------------------------- This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ _______________________________________________ Bluez-devel mailing list Bluez-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/bluez-devel ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [Bluez-devel] HID initiated connections and input service 2007-06-18 20:16 ` Pascal @ 2007-06-18 22:40 ` Bastien Nocera 0 siblings, 0 replies; 17+ messages in thread From: Bastien Nocera @ 2007-06-18 22:40 UTC (permalink / raw) To: BlueZ development On Mon, 2007-06-18 at 22:16 +0200, Pascal wrote: > Bastien Nocera wrote: > > > It's trying to "HIDP: Set report: Feature report" and gets disconnected > > afterwards. > > OK, this comes from bluez-utils/input/server.c, right > before ioctl(HIDPCONNADD). > > You could strace the bluetoothd-service-input process > to check whether this ioctl returns an error code. I'm getting an EINVAL. Which probably means that my version of sixpair pushes garbage in the input store. If anyone fancies checking the stupid things I'm doing in there... -- Bastien Nocera <hadess@hadess.net> ------------------------------------------------------------------------- This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ _______________________________________________ Bluez-devel mailing list Bluez-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/bluez-devel ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [Bluez-devel] HID initiated connections and input service 2007-06-15 16:44 [Bluez-devel] HID initiated connections and input service Bastien Nocera 2007-06-16 7:05 ` Marcel Holtmann @ 2007-06-16 7:25 ` Marcel Holtmann 2007-06-16 16:44 ` Bastien Nocera 1 sibling, 1 reply; 17+ messages in thread From: Marcel Holtmann @ 2007-06-16 7:25 UTC (permalink / raw) To: BlueZ development Hi Bastien, > 2(3) HID devices I own have the same problem with BlueZ when using the > input service. Both use HID initiated connections, rather than the > Host > initiated connection use case you would see when addind a Bluetooth > mouse to a laptop for example. > > * First device: Logitech MX5000 mouse/keyboard combo > > When not switched into HCI mode, the device works as a normal USB HID. > On boot, hid2hci is run, and the 2 devices (mouse and keyboard) try to > connect to bluetooth dongle (ex-USB wireless dongle). > There's no bluetooth-applet, or other services, and the requests are > dropped to the floor, and I end up with a Bluetooth HCI device, and no > keyboard or mouse (unplug/replug "fixes" the problem though). > > Could we integrate hid2hci into the input service, so that it would only > be started when a session is available? I'm not sure how to handle the > pairing without a keyboard or mouse though... after catching up with the IRC, I realized another problem with this HID proxy dongles. We can fix that for the original firmwares from CSR that are used by Apple, but for the Logitech's (they are slightly modified) I am not sure. So when you switch a HID proxy dongle from HID mode into HCI, you have to read its information about stored devices and their link keys. These information have then to be put into /var/lib/bluetooth. This leaves out the HID report descriptor that we also need. So that needs to be gotten while it is still in USB mode. Getting the HID report descriptor over USB makes always the assumption that it is exactly the same as on Bluetooth. This should be checked. We can't use 2 L2CAP connections and SDP at the same time, because some devices are limited of the maximum L2CAP connection. If the HID report descriptors are different then this is all becomes a little bit more trickier. In general it is possible since you first have to disconnect the interrupt channel of HID and then do SDP and re-connect it. If I remember the specification correctly, this should work. Regards Marcel ------------------------------------------------------------------------- This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ _______________________________________________ Bluez-devel mailing list Bluez-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/bluez-devel ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [Bluez-devel] HID initiated connections and input service 2007-06-16 7:25 ` Marcel Holtmann @ 2007-06-16 16:44 ` Bastien Nocera 2007-06-16 19:24 ` Marcel Holtmann 0 siblings, 1 reply; 17+ messages in thread From: Bastien Nocera @ 2007-06-16 16:44 UTC (permalink / raw) To: BlueZ development Hey Marcel, On Sat, 2007-06-16 at 09:25 +0200, Marcel Holtmann wrote: > Hi Bastien, > > > 2(3) HID devices I own have the same problem with BlueZ when using the > > input service. Both use HID initiated connections, rather than the > > Host > > initiated connection use case you would see when addind a Bluetooth > > mouse to a laptop for example. > > > > * First device: Logitech MX5000 mouse/keyboard combo > > > > When not switched into HCI mode, the device works as a normal USB HID. > > On boot, hid2hci is run, and the 2 devices (mouse and keyboard) try to > > connect to bluetooth dongle (ex-USB wireless dongle). > > There's no bluetooth-applet, or other services, and the requests are > > dropped to the floor, and I end up with a Bluetooth HCI device, and no > > keyboard or mouse (unplug/replug "fixes" the problem though). > > > > Could we integrate hid2hci into the input service, so that it would only > > be started when a session is available? I'm not sure how to handle the > > pairing without a keyboard or mouse though... > > after catching up with the IRC, I realized another problem with this HID > proxy dongles. We can fix that for the original firmwares from CSR that > are used by Apple, but for the Logitech's (they are slightly modified) I > am not sure. > > So when you switch a HID proxy dongle from HID mode into HCI, you have > to read its information about stored devices and their link keys. These > information have then to be put into /var/lib/bluetooth. This leaves out > the HID report descriptor that we also need. So that needs to be gotten > while it is still in USB mode. So it would be: 1) Get info from dongle about its own bdaddr, and the bdaddr of the attached devices (do you have code to do that for Logitech devices?) 2) Add attached devices' bdaddr as trusted for the device, and get the HID report descriptor, save it 3) switch the dongle to HCI mode Would that work? We could even do this in a HAL addon, or udev callback so that we're sure that newly plugged dongles are handled automatically. > Getting the HID report descriptor over USB makes always the assumption > that it is exactly the same as on Bluetooth. This should be checked. How can I verify that? Cheers -- Bastien Nocera <hadess@hadess.net> ------------------------------------------------------------------------- This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ _______________________________________________ Bluez-devel mailing list Bluez-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/bluez-devel ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [Bluez-devel] HID initiated connections and input service 2007-06-16 16:44 ` Bastien Nocera @ 2007-06-16 19:24 ` Marcel Holtmann 2007-06-18 16:08 ` Bastien Nocera 0 siblings, 1 reply; 17+ messages in thread From: Marcel Holtmann @ 2007-06-16 19:24 UTC (permalink / raw) To: BlueZ development Hi Bastien, > > > 2(3) HID devices I own have the same problem with BlueZ when using the > > > input service. Both use HID initiated connections, rather than the > > > Host > > > initiated connection use case you would see when addind a Bluetooth > > > mouse to a laptop for example. > > > > > > * First device: Logitech MX5000 mouse/keyboard combo > > > > > > When not switched into HCI mode, the device works as a normal USB HID. > > > On boot, hid2hci is run, and the 2 devices (mouse and keyboard) try to > > > connect to bluetooth dongle (ex-USB wireless dongle). > > > There's no bluetooth-applet, or other services, and the requests are > > > dropped to the floor, and I end up with a Bluetooth HCI device, and no > > > keyboard or mouse (unplug/replug "fixes" the problem though). > > > > > > Could we integrate hid2hci into the input service, so that it would only > > > be started when a session is available? I'm not sure how to handle the > > > pairing without a keyboard or mouse though... > > > > after catching up with the IRC, I realized another problem with this HID > > proxy dongles. We can fix that for the original firmwares from CSR that > > are used by Apple, but for the Logitech's (they are slightly modified) I > > am not sure. > > > > So when you switch a HID proxy dongle from HID mode into HCI, you have > > to read its information about stored devices and their link keys. These > > information have then to be put into /var/lib/bluetooth. This leaves out > > the HID report descriptor that we also need. So that needs to be gotten > > while it is still in USB mode. > > So it would be: > 1) Get info from dongle about its own bdaddr, and the bdaddr of the > attached devices (do you have code to do that for Logitech devices?) > 2) Add attached devices' bdaddr as trusted for the device, and get the > HID report descriptor, save it > 3) switch the dongle to HCI mode > > Would that work? We could even do this in a HAL addon, or udev callback > so that we're sure that newly plugged dongles are handled automatically. something like that and I have no idea how to do that for Logitech devices. I have strange code for pure CSR dongles, but it is so ugly that I am not going to share it. It is mostly CSR vendor stuff. > > Getting the HID report descriptor over USB makes always the assumption > > that it is exactly the same as on Bluetooth. This should be checked. > > How can I verify that? I don't have code for that. Need to write a tool that does this. Regards Marcel ------------------------------------------------------------------------- This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ _______________________________________________ Bluez-devel mailing list Bluez-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/bluez-devel ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [Bluez-devel] HID initiated connections and input service 2007-06-16 19:24 ` Marcel Holtmann @ 2007-06-18 16:08 ` Bastien Nocera 0 siblings, 0 replies; 17+ messages in thread From: Bastien Nocera @ 2007-06-18 16:08 UTC (permalink / raw) To: BlueZ development On Sat, 2007-06-16 at 21:24 +0200, Marcel Holtmann wrote: <snip> > something like that and I have no idea how to do that for Logitech > devices. I have strange code for pure CSR dongles, but it is so ugly > that I am not going to share it. It is mostly CSR vendor stuff. Shame. Is there any reason to run hid2hci by default then? As in, shouldn't be opt-in, rather than opt-out? > > > Getting the HID report descriptor over USB makes always the assumption > > > that it is exactly the same as on Bluetooth. This should be checked. > > > > How can I verify that? > > I don't have code for that. Need to write a tool that does this. My version of sixpair gets the report descriptor over usb, and stuff it in a hci_connadd_req, but the point is moot for HCI proxy dongles, and I don't know how to get the Bluetooth one for the sixaxis. -- Bastien Nocera <hadess@hadess.net> ------------------------------------------------------------------------- This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ _______________________________________________ Bluez-devel mailing list Bluez-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/bluez-devel ^ permalink raw reply [flat|nested] 17+ messages in thread
end of thread, other threads:[~2007-06-18 22:40 UTC | newest] Thread overview: 17+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2007-06-15 16:44 [Bluez-devel] HID initiated connections and input service Bastien Nocera 2007-06-16 7:05 ` Marcel Holtmann 2007-06-16 16:35 ` Bastien Nocera 2007-06-16 19:35 ` Marcel Holtmann 2007-06-17 20:25 ` Bastien Nocera 2007-06-18 13:06 ` Bastien Nocera 2007-06-18 14:00 ` Pascal 2007-06-18 14:36 ` Bastien Nocera 2007-06-18 16:00 ` Bastien Nocera 2007-06-18 17:30 ` Pascal 2007-06-18 19:23 ` Bastien Nocera 2007-06-18 20:16 ` Pascal 2007-06-18 22:40 ` Bastien Nocera 2007-06-16 7:25 ` Marcel Holtmann 2007-06-16 16:44 ` Bastien Nocera 2007-06-16 19:24 ` Marcel Holtmann 2007-06-18 16:08 ` Bastien Nocera
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox