terminal: Set K_RAW and term raw mode on FreeBSD
Taken from X11, weston and consolekit2 ports for FreeBSD. Setting just K_CODE as done before makes input seemingly have no ill effects, but it is still buffered and possibly send to the terminal after application exit if stdin is never drained. Setting raw mode appears to be needed to solve that issue. A K_OFF-like VT keyboard setting like Linux has would seem more appropriate, but that is not currently available to us on FreeBSD.
This commit is contained in:
parent
4ae4793b25
commit
8e0b58f90d
1 changed files with 18 additions and 1 deletions
|
@ -17,9 +17,10 @@
|
||||||
#elif defined(__FreeBSD__)
|
#elif defined(__FreeBSD__)
|
||||||
#include <sys/consio.h>
|
#include <sys/consio.h>
|
||||||
#include <sys/kbio.h>
|
#include <sys/kbio.h>
|
||||||
|
#include <termios.h>
|
||||||
#define TTYF "/dev/ttyv%d"
|
#define TTYF "/dev/ttyv%d"
|
||||||
#define K_ENABLE K_XLATE
|
#define K_ENABLE K_XLATE
|
||||||
#define K_DISABLE K_CODE
|
#define K_DISABLE K_RAW
|
||||||
#define FRSIG SIGIO
|
#define FRSIG SIGIO
|
||||||
#else
|
#else
|
||||||
#error Unsupported platform
|
#error Unsupported platform
|
||||||
|
@ -111,6 +112,22 @@ int terminal_set_keyboard(int fd, bool enable) {
|
||||||
log_errorf("could not set KD keyboard mode: %s", strerror(errno));
|
log_errorf("could not set KD keyboard mode: %s", strerror(errno));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
#if defined(__FreeBSD__)
|
||||||
|
struct termios tios;
|
||||||
|
if (tcgetattr(fd, &tios) == -1) {
|
||||||
|
log_errorf("could not set get terminal mode: %s", strerror(errno));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (enable) {
|
||||||
|
cfmakesane(&tios);
|
||||||
|
} else {
|
||||||
|
cfmakeraw(&tios);
|
||||||
|
}
|
||||||
|
if (tcsetattr(fd, TCSAFLUSH, &tios) == -1) {
|
||||||
|
log_errorf("could not set terminal mode: %s", strerror(errno));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue