diff options
author | June McEnroe <june@causal.agency> | 2018-05-13 00:41:58 -0400 |
---|---|---|
committer | June McEnroe <june@causal.agency> | 2018-05-13 00:42:28 -0400 |
commit | 869f6622bbb883257a0eb96742752b9969cfb0be (patch) | |
tree | 7d2b2ff7b0c4dd5395bfc23585d27fe9052802a9 /bin/gfx/fb.c | |
parent | Tabify shell scripts (diff) | |
download | src-869f6622bbb883257a0eb96742752b9969cfb0be.tar.gz src-869f6622bbb883257a0eb96742752b9969cfb0be.zip |
Tabify bin
Diffstat (limited to 'bin/gfx/fb.c')
-rw-r--r-- | bin/gfx/fb.c | 76 |
1 files changed, 38 insertions, 38 deletions
diff --git a/bin/gfx/fb.c b/bin/gfx/fb.c index 651ed80c..e1ef5e82 100644 --- a/bin/gfx/fb.c +++ b/bin/gfx/fb.c @@ -32,56 +32,56 @@ static struct termios saveTerm; static void restoreTerm(void) { - tcsetattr(STDERR_FILENO, TCSADRAIN, &saveTerm); + tcsetattr(STDERR_FILENO, TCSADRAIN, &saveTerm); } int main(int argc, char *argv[]) { - int error; + int error; - error = init(argc, argv); - if (error) return error; + error = init(argc, argv); + if (error) return error; - const char *path = getenv("FRAMEBUFFER"); - if (!path) path = "/dev/fb0"; + const char *path = getenv("FRAMEBUFFER"); + if (!path) path = "/dev/fb0"; - int fb = open(path, O_RDWR); - if (fb < 0) err(EX_OSFILE, "%s", path); + int fb = open(path, O_RDWR); + if (fb < 0) err(EX_OSFILE, "%s", path); - struct fb_var_screeninfo info; - error = ioctl(fb, FBIOGET_VSCREENINFO, &info); - if (error) err(EX_IOERR, "%s", path); + struct fb_var_screeninfo info; + error = ioctl(fb, FBIOGET_VSCREENINFO, &info); + if (error) err(EX_IOERR, "%s", path); - size_t size = 4 * info.xres * info.yres; - uint32_t *buf = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, fb, 0); - if (buf == MAP_FAILED) err(EX_IOERR, "%s", path); + size_t size = 4 * info.xres * info.yres; + uint32_t *buf = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, fb, 0); + if (buf == MAP_FAILED) err(EX_IOERR, "%s", path); - error = tcgetattr(STDERR_FILENO, &saveTerm); - if (error) err(EX_IOERR, "tcgetattr"); - atexit(restoreTerm); + error = tcgetattr(STDERR_FILENO, &saveTerm); + if (error) err(EX_IOERR, "tcgetattr"); + atexit(restoreTerm); - struct termios term = saveTerm; - term.c_lflag &= ~(ICANON | ECHO); - error = tcsetattr(STDERR_FILENO, TCSADRAIN, &term); - if (error) err(EX_IOERR, "tcsetattr"); + struct termios term = saveTerm; + term.c_lflag &= ~(ICANON | ECHO); + error = tcsetattr(STDERR_FILENO, TCSADRAIN, &term); + if (error) err(EX_IOERR, "tcsetattr"); - uint32_t saveBg = buf[0]; + uint32_t saveBg = buf[0]; - uint32_t back[info.xres * info.yres]; - for (;;) { - draw(back, info.xres, info.yres); - memcpy(buf, back, size); + uint32_t back[info.xres * info.yres]; + for (;;) { + draw(back, info.xres, info.yres); + memcpy(buf, back, size); - char in; - ssize_t len = read(STDERR_FILENO, &in, 1); - if (len < 0) err(EX_IOERR, "read"); - if (!len) return EX_DATAERR; + char in; + ssize_t len = read(STDERR_FILENO, &in, 1); + if (len < 0) err(EX_IOERR, "read"); + if (!len) return EX_DATAERR; - if (!input(in)) { - for (uint32_t i = 0; i < info.xres * info.yres; ++i) { - buf[i] = saveBg; - } - fprintf(stderr, "%s\n", status()); - return EX_OK; - } - } + if (!input(in)) { + for (uint32_t i = 0; i < info.xres * info.yres; ++i) { + buf[i] = saveBg; + } + fprintf(stderr, "%s\n", status()); + return EX_OK; + } + } } |