static inline void remote_name_information(int dev, bdaddr_t *sba, void *ptr) { evt_remote_name_req_complete *evt = ptr; bdaddr_t dba; bacpy(&dba, &evt->bdaddr); if (!evt->status) { char name[249]; memset(name, 0, sizeof(name)); memcpy(name, evt->name, 248); write_device_name(sba, &dba, name); hcid_dbus_remote_name(sba, &dba, name); } else hcid_dbus_remote_name_failed(sba, &dba, evt->status); }
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; }