src/joystick/hidapi/SDL_hidapijoystick.c
changeset 12181 70224e91e883
parent 12168 a5459597367f
child 12185 b6aa21d1a522
equal deleted inserted replaced
12180:a3c2b6e89522 12181:70224e91e883
   276     if (SDL_HIDAPI_discovery.m_pUdev) {
   276     if (SDL_HIDAPI_discovery.m_pUdev) {
   277         SDL_HIDAPI_discovery.m_pUdevMonitor = udev_monitor_new_from_netlink(SDL_HIDAPI_discovery.m_pUdev, "udev");
   277         SDL_HIDAPI_discovery.m_pUdevMonitor = udev_monitor_new_from_netlink(SDL_HIDAPI_discovery.m_pUdev, "udev");
   278         if (SDL_HIDAPI_discovery.m_pUdevMonitor) {
   278         if (SDL_HIDAPI_discovery.m_pUdevMonitor) {
   279             udev_monitor_enable_receiving(SDL_HIDAPI_discovery.m_pUdevMonitor);
   279             udev_monitor_enable_receiving(SDL_HIDAPI_discovery.m_pUdevMonitor);
   280             SDL_HIDAPI_discovery.m_nUdevFd = udev_monitor_get_fd(SDL_HIDAPI_discovery.m_pUdevMonitor);
   280             SDL_HIDAPI_discovery.m_nUdevFd = udev_monitor_get_fd(SDL_HIDAPI_discovery.m_pUdevMonitor);
   281             SDL_HIDAPI_discovery.m_bCanGetNotifications = true;
   281             SDL_HIDAPI_discovery.m_bCanGetNotifications = SDL_TRUE;
   282         }
   282         }
   283     }
   283     }
   284 
   284 
   285 #endif /* SDL_USE_LIBUDEV */
   285 #endif /* SDL_USE_LIBUDEV */
   286 }
   286 }
   327          * do a new discovery on any kind or number of notifications.
   327          * do a new discovery on any kind or number of notifications.
   328          * This could be made more restrictive if necessary.
   328          * This could be made more restrictive if necessary.
   329          */
   329          */
   330         for (;;) {
   330         for (;;) {
   331             struct pollfd PollUdev;
   331             struct pollfd PollUdev;
       
   332             struct udev_device *pUdevDevice;
   332 
   333 
   333             PollUdev.fd = SDL_HIDAPI_discovery.m_nUdevFd;
   334             PollUdev.fd = SDL_HIDAPI_discovery.m_nUdevFd;
   334             PollUdev.events = POLLIN;
   335             PollUdev.events = POLLIN;
   335             if (poll(&PollUdev, 1, 0) != 1) {
   336             if (poll(&PollUdev, 1, 0) != 1) {
   336                 break;
   337                 break;
   337             }
   338             }
   338 
   339 
   339             SDL_HIDAPI_discovery.m_bHaveDevicesChanged = true;
   340             SDL_HIDAPI_discovery.m_bHaveDevicesChanged = SDL_TRUE;
   340 
   341 
   341             struct udev_device *pUdevDevice = udev_monitor_receive_device(SDL_HIDAPI_discovery.m_pUdevMonitor);
   342             pUdevDevice = udev_monitor_receive_device(SDL_HIDAPI_discovery.m_pUdevMonitor);
   342             if (pUdevDevice) {
   343             if (pUdevDevice) {
   343                 udev_device_unref(pUdevDevice);
   344                 udev_device_unref(pUdevDevice);
   344             }
   345             }
   345         }
   346         }
   346     }
   347     }