예제 #1
0
static void *iohidmanager_hid_init(void)
{
   iohidmanager_hid_t *hid_apple = (iohidmanager_hid_t*)
      calloc(1, sizeof(*hid_apple));

   if (!hid_apple)
      goto error;
   hid_apple->slots = pad_connection_init(MAX_USERS);

   if (!hid_apple->slots)
      goto error;
   if (iohidmanager_hid_manager_init(hid_apple) == -1)
      goto error;
   if (iohidmanager_hid_manager_set_device_matching(hid_apple) == -1)
      goto error;

   return hid_apple;

error:
   if (hid_apple->slots)
      free(hid_apple->slots);
   hid_apple->slots = NULL;
   if (hid_apple)
      free(hid_apple);
   return NULL;
}
예제 #2
0
static hid_driver_t *init_hid_driver(void)
{
   joypad_connection_t *connections = NULL;
   unsigned connections_size        = MAX_USERS - (WIIU_WIIMOTE_CHANNELS+1);

   hid_data                         = (wiiu_hid_t *)wiiu_hid.init();
   connections                      = pad_connection_init(connections_size);

   if (!hid_data || !connections)
      goto error;

   hid_data->connections = connections;
   hid_data->connections_size = connections_size;
   return &wiiu_hid;

error:
   if (connections)
      free(connections);
   if (hid_data)
   {
      wiiu_hid.free(hid_data);
      hid_data = NULL;
   }
   return NULL;
}
예제 #3
0
static bool apple_joypad_init(void)
{
   slots = (joypad_connection_t*)pad_connection_init(MAX_PLAYERS);
    
   if (!slots)
      return false;
   return true;
}
예제 #4
0
static bool apple_joypad_init(void)
{
   if (!apple_hid_init())
       return false;
    
   slots = (joypad_connection_t*)pad_connection_init(MAX_USERS);

   return true;
}
예제 #5
0
static void *wiiusb_hid_init(void)
{
   unsigned i;
   u8 count;
   int ret;
   usb_device_entry *dev_entries;
   wiiusb_hid_t *hid = (wiiusb_hid_t*)calloc(1, sizeof(*hid));

   (void)ret;

   if (!hid)
      goto error;

   hid->slots = pad_connection_init(MAX_USERS);

   if (!hid->slots)
      goto error;

   dev_entries = (usb_device_entry *)calloc(MAX_USERS, sizeof(*dev_entries));

   if (!dev_entries)
      goto error;

   USB_Initialize();

   if (USB_GetDeviceList(dev_entries, MAX_USERS, USB_CLASS_HID, &count) < 0)
   {
      free(dev_entries);
      goto error;
   }

   for (i = 0; i < count; i++)
   {
      if (dev_entries[i].vid > 0 && dev_entries[i].pid > 0)
         add_adapter(hid, &dev_entries[i]);
   }

   free(dev_entries);

   USB_DeviceChangeNotifyAsync(USB_CLASS_HID, wiiusb_hid_changenotify_cb, (void *)hid);

   return hid;

error:
   wiiusb_hid_free(hid);
   return NULL;
}
예제 #6
0
static bool init_pad_list(hid_driver_instance_t *instance, unsigned slots)
{
   if(!instance || slots > MAX_USERS)
      return false;

   if(instance->pad_list)
      return true;

   RARCH_LOG("[hid]: initializing pad list...\n");
   instance->pad_list = pad_connection_init(slots);
   if(!instance->pad_list)
      return false;

   instance->max_slot = slots;

   return true;
}
예제 #7
0
static bool wiiu_joypad_init(void* data)
{
   set_connection_listener(&wiiu_pad_connection_listener);
   hid_instance.pad_list = pad_connection_init(MAX_USERS);
   hid_instance.max_slot = MAX_USERS;

   wpad_driver.init(data);
   kpad_driver.init(data);
#ifdef WIIU_HID
   hidpad_driver.init(data);
#endif

   ready = true;
   (void)data;

   return true;
}
예제 #8
0
static void *btstack_hid_init(void)
{
   btstack_hid_t *hid = (btstack_hid_t*)calloc(1, sizeof(btstack_hid_t));

   if (!hid)
      goto error;

   hid->slots = pad_connection_init(MAX_USERS);

   if (!hid->slots)
      goto error;

   btstack_set_poweron(false);
   btpad_set_inquiry_state(false);

   return hid;

error:
   btstack_hid_free(hid);
   return NULL;
}
예제 #9
0
static void *wiiusb_hid_init(void)
{
   joypad_connection_t *connections = NULL;
   wiiusb_hid_t                *hid = (wiiusb_hid_t*)calloc(1, sizeof(*hid));

   if (!hid)
      goto error;

   connections = pad_connection_init(MAX_USERS);

   if (!connections)
      goto error;

   /* Initialize HID values */
   hid->connections      = connections;
   hid->adapters_head    = NULL;
   hid->removal_cb       = FALSE;
   hid->manual_removal   = FALSE;
   hid->poll_thread_quit = FALSE;
   /* we set it initially to TRUE so we force
    * to add the already connected pads */
   hid->device_detected  = TRUE;

   hid->poll_thread      = sthread_create(wiiusb_hid_poll_thread, hid);

   if (!hid->poll_thread)
   {
      RARCH_ERR("Error initializing poll thread.\n");
      goto error;
   }

   USB_DeviceChangeNotifyAsync(USB_CLASS_HID, wiiusb_hid_change_cb, (void *)hid);

   return hid;

error:
   wiiusb_hid_free(hid);
   return NULL;
}
예제 #10
0
static void *libusb_hid_init(void)
{
   unsigned i, count;
   int ret;
   struct libusb_device **devices;
   libusb_hid_t *hid = (libusb_hid_t*)calloc(1, sizeof(*hid));

   if (!hid)
      goto error;

   ret = libusb_init(&hid->ctx);

   if (ret < 0)
      goto error;

   if (!libusb_has_capability(LIBUSB_CAP_HAS_HOTPLUG))
      goto error;

   hid->slots = pad_connection_init(MAX_USERS);

   if (!hid->slots)
      goto error;

   count = libusb_get_device_list(hid->ctx, &devices);

   for (i = 0; i < count; i++)
   {
      struct libusb_device_descriptor desc;
      libusb_get_device_descriptor(devices[i], &desc);

      if (desc.idVendor > 0 && desc.idProduct > 0)
         add_adapter(hid, devices[i]);
   }

   if (count > 0)
      libusb_free_device_list(devices, 1);

   ret = libusb_hotplug_register_callback(
         hid->ctx,
         (libusb_hotplug_event)(LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED |
         LIBUSB_HOTPLUG_EVENT_DEVICE_LEFT),
         (libusb_hotplug_flag)LIBUSB_HOTPLUG_ENUMERATE,
         LIBUSB_HOTPLUG_MATCH_ANY,
         LIBUSB_HOTPLUG_MATCH_ANY,
         LIBUSB_HOTPLUG_MATCH_ANY,
         libusb_hid_hotplug_callback,
         hid,
         &hid->hp);

   if (ret != LIBUSB_SUCCESS)
   {
      RARCH_ERR("Error creating a hotplug callback.\n");
      goto error;
   }

   hid->poll_thread = sthread_create(poll_thread, hid);

   if (!hid->poll_thread)
   {
      RARCH_ERR("Error creating polling thread");
      goto error;
   }

   return hid;

error:
   if (hid)
      libusb_hid_free(hid);
   return NULL;
}