Disable tty echo

This commit is contained in:
Bad Diode 2022-03-04 19:01:53 +01:00
parent 6b29a0cb08
commit a46fb7bd7e
2 changed files with 67 additions and 50 deletions

View File

@ -1,4 +1,3 @@
#include <fcntl.h>
#include <stdbool.h> #include <stdbool.h>
#include <stdint.h> #include <stdint.h>
#include <stdio.h> #include <stdio.h>
@ -6,10 +5,6 @@
#include <time.h> #include <time.h>
#include <unistd.h> #include <unistd.h>
#include <linux/fb.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
#include "shorthand.h" #include "shorthand.h"
#include "ppu.c" #include "ppu.c"
#include "uxn-fast.c" #include "uxn-fast.c"

View File

@ -1,4 +1,10 @@
#include <fcntl.h>
#include <string.h> #include <string.h>
#include <termios.h>
#include <linux/fb.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
#include "ppu.h" #include "ppu.h"
@ -111,6 +117,22 @@ ppu_init(void) {
pixels_fg = malloc(screen_width * screen_height); pixels_fg = malloc(screen_width * screen_height);
pixels_bg = malloc(screen_width * screen_height); pixels_bg = malloc(screen_width * screen_height);
dirty_lines = malloc(screen_height); dirty_lines = malloc(screen_height);
if (pixels_fg == NULL || pixels_bg == NULL || dirty_lines == NULL) {
fprintf(stderr, "error: couldn't allocate memory for the ppu\n");
exit(EXIT_FAILURE);
}
// Disable echo.
struct termios t;
if (tcgetattr(STDIN_FILENO, &t)) {
fprintf(stderr, "error: couldn't disable terminal echo\n");
exit(EXIT_FAILURE);
}
t.c_lflag &= ~((tcflag_t) ECHO);
if (tcsetattr(STDIN_FILENO, TCSANOW, &t)) {
fprintf(stderr, "error: couldn't disable terminal echo\n");
exit(EXIT_FAILURE);
}
// Initialize default palette. // Initialize default palette.
palette[0] = 0x444444; palette[0] = 0x444444;