wscons: Move to its own device type
This reduces ifdefs and avoids overloading evdev as something it is not.
This commit is contained in:
parent
684dd61945
commit
0462e9331d
7 changed files with 51 additions and 27 deletions
|
@ -9,11 +9,6 @@
|
||||||
#include <sys/sysmacros.h>
|
#include <sys/sysmacros.h>
|
||||||
#elif defined(__FreeBSD__)
|
#elif defined(__FreeBSD__)
|
||||||
#include <dev/evdev/input.h>
|
#include <dev/evdev/input.h>
|
||||||
#elif defined(__NetBSD__)
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#else
|
|
||||||
#error Unsupported platform
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "evdev.h"
|
#include "evdev.h"
|
||||||
|
@ -30,28 +25,15 @@ int path_is_evdev(const char *path) {
|
||||||
int evdev_revoke(int fd) {
|
int evdev_revoke(int fd) {
|
||||||
return ioctl(fd, EVIOCREVOKE, NULL);
|
return ioctl(fd, EVIOCREVOKE, NULL);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(__linux__)
|
|
||||||
int dev_is_evdev(dev_t device) {
|
|
||||||
return major(device) == INPUT_MAJOR;
|
|
||||||
}
|
|
||||||
#elif defined(__NetBSD__)
|
#elif defined(__NetBSD__)
|
||||||
int dev_is_evdev(dev_t device) {
|
|
||||||
return major(device) == getdevmajor("wskbd", S_IFCHR) ||
|
|
||||||
major(device) == getdevmajor("wsmouse", S_IFCHR) ||
|
|
||||||
major(device) == getdevmajor("wsmux", S_IFCHR);
|
|
||||||
}
|
|
||||||
int path_is_evdev(const char *path) {
|
int path_is_evdev(const char *path) {
|
||||||
const char *wskbd = "/dev/wskbd";
|
(void)path;
|
||||||
const char *wsmouse = "/dev/wsmouse";
|
return 0;
|
||||||
const char *wsmux = "/dev/wsmux";
|
|
||||||
return strncmp(path, wskbd, STRLEN(wskbd)) == 0 ||
|
|
||||||
strncmp(path, wsmouse, STRLEN(wsmouse)) == 0 ||
|
|
||||||
strncmp(path, wsmux, STRLEN(wsmouse)) == 0;
|
|
||||||
}
|
}
|
||||||
int evdev_revoke(int fd) {
|
int evdev_revoke(int fd) {
|
||||||
(void)fd;
|
(void)fd;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
#error Unsupported platform
|
||||||
#endif
|
#endif
|
||||||
|
|
27
common/wscons.c
Normal file
27
common/wscons.c
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#if defined(__NetBSD__)
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "wscons.h"
|
||||||
|
|
||||||
|
#define STRLEN(s) ((sizeof(s) / sizeof(s[0])) - 1)
|
||||||
|
|
||||||
|
#if defined(__NetBSD__)
|
||||||
|
int path_is_wscons(const char *path) {
|
||||||
|
const char *wskbd = "/dev/wskbd";
|
||||||
|
const char *wsmouse = "/dev/wsmouse";
|
||||||
|
const char *wsmux = "/dev/wsmux";
|
||||||
|
return strncmp(path, wskbd, STRLEN(wskbd)) == 0 ||
|
||||||
|
strncmp(path, wsmouse, STRLEN(wsmouse)) == 0 ||
|
||||||
|
strncmp(path, wsmux, STRLEN(wsmouse)) == 0;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
int path_is_wscons(const char *path) {
|
||||||
|
(void)path;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
|
@ -4,9 +4,4 @@
|
||||||
int evdev_revoke(int fd);
|
int evdev_revoke(int fd);
|
||||||
int path_is_evdev(const char *path);
|
int path_is_evdev(const char *path);
|
||||||
|
|
||||||
#if defined(__linux__) || defined(__NetBSD__)
|
|
||||||
#include <sys/types.h>
|
|
||||||
int dev_is_evdev(dev_t device);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -13,6 +13,7 @@ enum seat_device_type {
|
||||||
SEAT_DEVICE_TYPE_NORMAL,
|
SEAT_DEVICE_TYPE_NORMAL,
|
||||||
SEAT_DEVICE_TYPE_EVDEV,
|
SEAT_DEVICE_TYPE_EVDEV,
|
||||||
SEAT_DEVICE_TYPE_DRM,
|
SEAT_DEVICE_TYPE_DRM,
|
||||||
|
SEAT_DEVICE_TYPE_WSCONS,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct seat_device {
|
struct seat_device {
|
||||||
|
|
6
include/wscons.h
Normal file
6
include/wscons.h
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
#ifndef _SEATD_WSCONS_H
|
||||||
|
#define _SEATD_WSCONS_H
|
||||||
|
|
||||||
|
int path_is_wscons(const char *path);
|
||||||
|
|
||||||
|
#endif
|
|
@ -114,6 +114,7 @@ server_files = [
|
||||||
'common/connection.c',
|
'common/connection.c',
|
||||||
'common/evdev.c',
|
'common/evdev.c',
|
||||||
'common/drm.c',
|
'common/drm.c',
|
||||||
|
'common/wscons.c',
|
||||||
'seatd/poller.c',
|
'seatd/poller.c',
|
||||||
'seatd/seat.c',
|
'seatd/seat.c',
|
||||||
'seatd/client.c',
|
'seatd/client.c',
|
||||||
|
|
12
seatd/seat.c
12
seatd/seat.c
|
@ -17,6 +17,7 @@
|
||||||
#include "protocol.h"
|
#include "protocol.h"
|
||||||
#include "seat.h"
|
#include "seat.h"
|
||||||
#include "terminal.h"
|
#include "terminal.h"
|
||||||
|
#include "wscons.h"
|
||||||
|
|
||||||
static int seat_close_client(struct client *client);
|
static int seat_close_client(struct client *client);
|
||||||
static int vt_close(int vt);
|
static int vt_close(int vt);
|
||||||
|
@ -235,6 +236,8 @@ struct seat_device *seat_open_device(struct client *client, const char *path) {
|
||||||
type = SEAT_DEVICE_TYPE_EVDEV;
|
type = SEAT_DEVICE_TYPE_EVDEV;
|
||||||
} else if (path_is_drm(sanitized_path)) {
|
} else if (path_is_drm(sanitized_path)) {
|
||||||
type = SEAT_DEVICE_TYPE_DRM;
|
type = SEAT_DEVICE_TYPE_DRM;
|
||||||
|
} else if (path_is_wscons(sanitized_path)) {
|
||||||
|
type = SEAT_DEVICE_TYPE_WSCONS;
|
||||||
} else {
|
} else {
|
||||||
log_errorf("%s is not a supported device type ", sanitized_path);
|
log_errorf("%s is not a supported device type ", sanitized_path);
|
||||||
errno = ENOENT;
|
errno = ENOENT;
|
||||||
|
@ -281,6 +284,9 @@ struct seat_device *seat_open_device(struct client *client, const char *path) {
|
||||||
case SEAT_DEVICE_TYPE_EVDEV:
|
case SEAT_DEVICE_TYPE_EVDEV:
|
||||||
// Nothing to do here
|
// Nothing to do here
|
||||||
break;
|
break;
|
||||||
|
case SEAT_DEVICE_TYPE_WSCONS:
|
||||||
|
// Nothing to do here
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
log_error("Invalid seat device type");
|
log_error("Invalid seat device type");
|
||||||
abort();
|
abort();
|
||||||
|
@ -333,6 +339,9 @@ static int seat_deactivate_device(struct seat_device *seat_device) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case SEAT_DEVICE_TYPE_WSCONS:
|
||||||
|
// Nothing to do here
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
log_error("Invalid seat device type");
|
log_error("Invalid seat device type");
|
||||||
abort();
|
abort();
|
||||||
|
@ -382,6 +391,9 @@ static int seat_activate_device(struct client *client, struct seat_device *seat_
|
||||||
case SEAT_DEVICE_TYPE_EVDEV:
|
case SEAT_DEVICE_TYPE_EVDEV:
|
||||||
errno = EINVAL;
|
errno = EINVAL;
|
||||||
return -1;
|
return -1;
|
||||||
|
case SEAT_DEVICE_TYPE_WSCONS:
|
||||||
|
// Nothing to do here
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
log_error("Invalid seat device type");
|
log_error("Invalid seat device type");
|
||||||
abort();
|
abort();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue