--- bluez-utils-3.19/hidd/main.c.orig 2007-05-09 08:40:42.000000000 +0200 +++ bluez-utils-3.19/hidd/main.c 2007-10-15 02:29:40.000000000 +0200 @@ -87,15 +87,15 @@ if (bind(sk, (struct sockaddr *) &addr, sizeof(addr)) < 0) { close(sk); return -1; } memset(&opts, 0, sizeof(opts)); - opts.imtu = HIDP_DEFAULT_MTU; + opts.imtu = 64; opts.omtu = HIDP_DEFAULT_MTU; opts.flush_to = 0xffff; setsockopt(sk, SOL_L2CAP, L2CAP_OPTIONS, &opts, sizeof(opts)); memset(&addr, 0, sizeof(addr)); addr.l2_family = AF_BLUETOOTH; @@ -128,15 +128,15 @@ close(sk); return -1; } setsockopt(sk, SOL_L2CAP, L2CAP_LM, &lm, sizeof(lm)); memset(&opts, 0, sizeof(opts)); - opts.imtu = HIDP_DEFAULT_MTU; + opts.imtu = 64; opts.omtu = HIDP_DEFAULT_MTU; opts.flush_to = 0xffff; setsockopt(sk, SOL_L2CAP, L2CAP_OPTIONS, &opts, sizeof(opts)); if (listen(sk, backlog) < 0) { close(sk); @@ -240,14 +240,25 @@ { const unsigned char buf[] = { 0x53 /*HIDP_TRANS_SET_REPORT | HIDP_DATA_RTYPE_FEATURE*/, 0xf4, 0x42, 0x03, 0x00, 0x00 }; int err; err = write(csk, buf, sizeof(buf)); + + /* Wait for ack from device to ensure compliance with HIDP 7.9.1 + * (only one outstanding request on the control channel). */ + struct pollfd p = { .fd=csk, .events=POLLIN, .revents=0 }; + struct timespec t = { .tv_sec=1, .tv_nsec=0 }; + unsigned char result; + if ( ppoll(&p, 1, &t, NULL) != 1 || + ! (p.revents & POLLIN) || + read(csk, &result, 1) != 1 || + result != 0 ) + syslog(LOG_WARNING, "Failed to enable sixaxis"); } static int create_device(int ctl, int csk, int isk, uint8_t subclass, int nosdp, int nocheck, int bootonly, int encrypt, int timeout) { struct hidp_connadd_req req; struct sockaddr_l2 addr; socklen_t addrlen;