Skip to content

Commit

Permalink
chardev_term: Set termios config manually
Browse files Browse the repository at this point in the history
- Set VMIN to 1, this feature is unwanted here and breaks input on systems which set it to >1
- Set VTIME to 0 for lowest latency
- Set iflag, oflag, lflag manually to prevent breakage from previous program termios config
- Keep cflag, since it controls baud rate of the host terminal and such
- Fixes terminal input on Haiku
  • Loading branch information
LekKit committed Jul 28, 2024
1 parent 37cccaf commit 155a03e
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/devices/chardev_term.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
#include <termios.h>
#include <unistd.h>
#include <fcntl.h>

#ifndef O_CLOEXEC
#define O_CLOEXEC 0
#endif
Expand All @@ -47,10 +48,15 @@ static void term_rawmode()
{
tcgetattr(STDIN_FILENO, &orig_term_opts);
call_at_deinit(term_origmode);
struct termios term_opts = orig_term_opts;
term_opts.c_lflag &= ~(ECHO | ICANON | ISIG | IEXTEN);
term_opts.c_iflag &= ~(IXON | ICRNL);
tcsetattr(STDIN_FILENO, TCSAFLUSH, &term_opts);

struct termios term_opts = {
.c_iflag = ICRNL,
.c_oflag = OPOST | ONLCR,
.c_cflag = orig_term_opts.c_cflag,
.c_lflag = 0,
.c_cc[VMIN] = 1,
};
tcsetattr(STDIN_FILENO, TCSANOW, &term_opts);
}

#elif defined(_WIN32) && !defined(UNDER_CE)
Expand Down

0 comments on commit 155a03e

Please sign in to comment.