mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2025-11-02 09:01:38 -05:00
Implement device type discovery using ioctl calls
This commit implements device type discovery by calling two ioctls (DRM_IOCTL_VERSION and EVIOCGVERSION) on the device. These iocts are specific to drm and input devices respectively, therefore we can determine the device type based on which one returns an error.
This commit is contained in:
parent
bbeed1bd31
commit
7a5d3c4d3b
2 changed files with 15 additions and 29 deletions
|
|
@ -3,6 +3,7 @@
|
|||
#define __BSD_VISIBLE 1
|
||||
#define INPUT_MAJOR 0
|
||||
#endif
|
||||
#include <dev/evdev/input.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
|
|
@ -159,14 +160,15 @@ static void communicate(int sock) {
|
|||
ret = errno;
|
||||
}
|
||||
#else
|
||||
if (strncmp(msg.path, "/dev/drm/", 9) &&
|
||||
strncmp(msg.path, "/dev/input/event", 16)) {
|
||||
|
||||
int ev;
|
||||
struct drm_version dv = {0};
|
||||
if (ioctl(fd, EVIOCGVERSION, &ev) == -1 &&
|
||||
ioctl(fd, DRM_IOCTL_VERSION, &dv) == -1) {
|
||||
ret = ENOTSUP;
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (strncmp(msg.path, "/dev/drm/", 9) == 0 && drmSetMaster(fd)) {
|
||||
if (dv.version_major != 0 && drmSetMaster(fd)) {
|
||||
ret = errno;
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue