attempt to support VT switches on OpenBSD
This commit is contained in:
parent
cc09e26976
commit
b4462cb033
3 changed files with 37 additions and 5 deletions
|
@ -21,11 +21,17 @@
|
|||
#define K_ENABLE K_XLATE
|
||||
#define K_DISABLE K_RAW
|
||||
#define FRSIG SIGIO
|
||||
#elif defined(__NetBSD__) || defined(__OpenBSD__)
|
||||
#elif defined(__NetBSD__)
|
||||
#include <dev/wscons/wsdisplay_usl_io.h>
|
||||
#define K_ENABLE K_XLATE
|
||||
#define K_DISABLE K_RAW
|
||||
#define FRSIG 0 // unimplemented
|
||||
#elif defined(__OpenBSD__)
|
||||
#include <dev/wscons/wsconsio.h>
|
||||
#include <dev/wscons/wsdisplay_usl_io.h>
|
||||
#define K_ENABLE K_XLATE
|
||||
#define K_DISABLE K_RAW
|
||||
#define FRSIG SIGIO
|
||||
#else
|
||||
#error Unsupported platform
|
||||
#endif
|
||||
|
@ -161,10 +167,16 @@ static int get_tty_path(int tty, char path[static TTYPATHLEN]) {
|
|||
|
||||
int terminal_open(int vt) {
|
||||
char path[TTYPATHLEN];
|
||||
log_debugf("terminal_open vt %d", vt);
|
||||
#ifdef __OpenBSD__
|
||||
if (vt > 0)
|
||||
vt--;
|
||||
#endif
|
||||
if (get_tty_path(vt, path) == -1) {
|
||||
log_errorf("Could not generate tty path: %s", strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
log_debugf("terminal_open path %s", path);
|
||||
int fd = open(path, O_RDWR | O_NOCTTY);
|
||||
if (fd == -1) {
|
||||
log_errorf("Could not open target tty: %s", strerror(errno));
|
||||
|
@ -174,7 +186,7 @@ int terminal_open(int vt) {
|
|||
}
|
||||
|
||||
int terminal_current_vt(int fd) {
|
||||
#if defined(__linux__) || defined(__NetBSD__)
|
||||
#if defined(__linux__) || defined(__NetBSD__) || defined(__OpenBSD__)
|
||||
struct vt_stat st;
|
||||
int res = ioctl(fd, VT_GETSTATE, &st);
|
||||
close(fd);
|
||||
|
@ -183,7 +195,7 @@ int terminal_current_vt(int fd) {
|
|||
return -1;
|
||||
}
|
||||
return st.v_active;
|
||||
#elif defined(__FreeBSD__) || defined(__OpenBSD__)
|
||||
#elif defined(__FreeBSD__)
|
||||
int vt;
|
||||
int res = ioctl(fd, VT_GETACTIVE, &vt);
|
||||
close(fd);
|
||||
|
@ -252,11 +264,20 @@ int terminal_ack_acquire(int fd) {
|
|||
|
||||
int terminal_set_keyboard(int fd, bool enable) {
|
||||
log_debugf("Setting KD keyboard state to %d", enable);
|
||||
#ifndef __OpenBSD1__
|
||||
if (ioctl(fd, KDSKBMODE, enable ? K_ENABLE : K_DISABLE) == -1) {
|
||||
log_errorf("Could not set KD keyboard mode to %s: %s",
|
||||
enable ? "enabled" : "disabled", strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
#else
|
||||
int mode = enable ? WSKBD_RAW : WSKBD_TRANSLATED;
|
||||
if (ioctl(fd, WSKBDIO_SETMODE, &mode) == -1) {
|
||||
log_errorf("Could not set keyboard mode to %s: %s",
|
||||
enable ? "translated" : "raw", strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
#if defined(__FreeBSD__)
|
||||
struct termios tios;
|
||||
if (tcgetattr(fd, &tios) == -1) {
|
||||
|
@ -279,10 +300,19 @@ int terminal_set_keyboard(int fd, bool enable) {
|
|||
|
||||
int terminal_set_graphics(int fd, bool enable) {
|
||||
log_debugf("Setting KD graphics state to %d", enable);
|
||||
#ifndef __OpenBSD1__
|
||||
if (ioctl(fd, KDSETMODE, enable ? KD_GRAPHICS : KD_TEXT) == -1) {
|
||||
log_errorf("Could not set KD graphics mode to %s: %s", enable ? "graphics" : "text",
|
||||
strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
#else
|
||||
int mode = enable ? WSDISPLAYIO_MODE_MAPPED : WSDISPLAYIO_MODE_EMUL;
|
||||
if (ioctl(fd, WSDISPLAYIO_SMODE, &mode) == -1) {
|
||||
log_errorf("Could not set graphics mode to %s: %s",
|
||||
enable ? "mapped" : "emul", strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue