From e60fa7740cd7d245d1b22a25fea9df0768d32668 Mon Sep 17 00:00:00 2001 From: Benji Dial Date: Sun, 19 May 2024 04:34:40 -0400 Subject: mouse support (working in qemu, semi-working in virtualbox) --- libraries/daguerre/source/daguerre.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'libraries/daguerre/source') diff --git a/libraries/daguerre/source/daguerre.cpp b/libraries/daguerre/source/daguerre.cpp index fb3ddc7..7c13a88 100644 --- a/libraries/daguerre/source/daguerre.cpp +++ b/libraries/daguerre/source/daguerre.cpp @@ -8,15 +8,22 @@ namespace daguerre { return image(ptr, width, height, pitch, false); } + //TODO: make this more robust unsigned read_text_int(std::FILE *input) { unsigned n = 0; char ch; - while (true) { + std::fread(&ch, 1, 1, input); + if (ch == '#') { + do + std::fread(&ch, 1, 1, input); + while (ch != '\n'); std::fread(&ch, 1, 1, input); - if (ch < '0' || ch > '9') - return n; - n = n * 10 + ch - '0'; } + do { + n = n * 10 + ch - '0'; + std::fread(&ch, 1, 1, input); + } while (ch >= '0' && ch <= '9'); + return n; } bool try_load_ppm(std::FILE *input, image &into) { -- cgit v1.2.3