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 <stdint.h>
#include <stdio.h>
@ -6,10 +5,6 @@
#include <time.h>
#include <unistd.h>
#include <linux/fb.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
#include "shorthand.h"
#include "ppu.c"
#include "uxn-fast.c"

View File

@ -1,19 +1,25 @@
#include <fcntl.h>
#include <string.h>
#include <termios.h>
#include <linux/fb.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
#include "ppu.h"
/*
Copyright (c) 2021 Devine Lu Linvega
Copyright (c) 2021 Andrew Alderwick
Copyright (c) 2021 Bad Diode
Copyright (c) 2021 Devine Lu Linvega
Copyright (c) 2021 Andrew Alderwick
Copyright (c) 2021 Bad Diode
Permission to use, copy, modify, and distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
Permission to use, copy, modify, and distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE.
*/
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE.
*/
static size_t screen_width = 0;
static size_t screen_height = 0;
@ -111,6 +117,22 @@ ppu_init(void) {
pixels_fg = malloc(screen_width * screen_height);
pixels_bg = malloc(screen_width * 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.
palette[0] = 0x444444;