/* try to init eeze */
if (!eeze_init()) goto eeze_err;
+ _ecore_drm_inputs_init();
+
ECORE_DRM_EVENT_ACTIVATE = ecore_event_type_new();
ECORE_DRM_EVENT_OUTPUT = ecore_event_type_new();
ECORE_DRM_EVENT_SEAT_ADD = ecore_event_type_new();
/* shutdown eina */
eina_shutdown();
+ _ecore_drm_inputs_shutdown();
+
/* return init count */
return _ecore_drm_init_count;
}
#include "ecore_drm_private.h"
EAPI int ECORE_DRM_EVENT_SEAT_ADD = -1;
+static Eina_Hash *_fd_hash = NULL;
/* local functions */
static int
_cb_open_restricted(const char *path, int flags, void *data)
{
Ecore_Drm_Input *input;
- Ecore_Drm_Seat *seat;
- Ecore_Drm_Evdev *edev;
- Eina_List *l, *ll;
int fd = -1;
if (!(input = data)) return -1;
/* try to open the device */
fd = _ecore_drm_launcher_device_open_no_pending(path, flags);
if (fd < 0) ERR("Could not open device");
-
- EINA_LIST_FOREACH(input->dev->seats, l, seat)
- {
- EINA_LIST_FOREACH(seat->devices, ll, edev)
- {
- if (strstr(path, edev->path))
- {
- edev->fd = fd;
- return fd;
- }
- }
- }
+ if (_fd_hash)
+ eina_hash_add(_fd_hash, path, (void *)(intptr_t)fd);
return fd;
}
if (edev->fd == fd)
{
_ecore_drm_launcher_device_close(edev->path, fd);
+
+ /* re-initialize fd after closing */
+ edev->fd = -1;
return;
}
}
return;
}
+ edev->fd = (int)(intptr_t)eina_hash_find(_fd_hash, edev->path);
+
/* append this device to the seat */
seat->devices = eina_list_append(seat->devices, edev);
/* remove this evdev from the seat's list of devices */
edev->seat->devices = eina_list_remove(edev->seat->devices, edev);
+ if (_fd_hash)
+ eina_hash_del_by_key(_fd_hash, edev->path);
+
/* tell launcher to release device */
- _ecore_drm_launcher_device_close(edev->path, edev->fd);
+ if (edev->fd >= 0)
+ _ecore_drm_launcher_device_close(edev->path, edev->fd);
/* destroy this evdev */
_ecore_drm_evdev_device_destroy(edev);
EINA_SAFETY_ON_NULL_RETURN_VAL(seat, NULL);
return seat->devices;
}
+
+void
+_ecore_drm_inputs_init(void)
+{
+ _fd_hash = eina_hash_string_superfast_new(NULL);
+}
+
+void
+_ecore_drm_inputs_shutdown(void)
+{
+ eina_hash_free(_fd_hash);
+ _fd_hash = NULL;
+}