diff --git a/tools/antorcha.c b/tools/antorcha.c index 5cb969c..408dbe6 100644 --- a/tools/antorcha.c +++ b/tools/antorcha.c @@ -315,9 +315,11 @@ static void samples(struct atrf_dsc *dsc) y |= *s++ << 8; if (debug) fprintf(stderr, "\t%d %d\n", x, y); - plot(x, y); + if (!plot(x, y)) + goto quit; } } +quit: buf[0] = 0; packet(dsc, SAMPLE, 0, 0, buf, PAYLOAD); } diff --git a/tools/plot.c b/tools/plot.c index 6e61390..42a0dee 100644 --- a/tools/plot.c +++ b/tools/plot.c @@ -16,6 +16,8 @@ #include "SDL.h" #include "SDL_gfxPrimitives.h" +#include "plot.h" + #define XRES 1024 #define YRES 1024 @@ -44,8 +46,10 @@ static SDL_Rect front_rect = { }; -void plot(int x, int y) +int plot(int x, int y) { + SDL_Event event; + if (!first) { SDL_BlitSurface(back, &back_rect, surf, &front_rect); SDL_LockSurface(surf); @@ -71,6 +75,24 @@ void plot(int x, int y) first = 0; last_x = x; last_y = y; + + while (SDL_PollEvent(&event)) + switch (event.type) { + case SDL_KEYDOWN: + switch (event.key.keysym.sym) { + case SDLK_q: + return 0; + default: + break; + } + break; + case SDL_QUIT: + return 0; + default: + break; + } + + return 1; } diff --git a/tools/plot.h b/tools/plot.h index b2aea85..fb6a621 100644 --- a/tools/plot.h +++ b/tools/plot.h @@ -14,7 +14,7 @@ #ifndef PLOT_H #define PLOT_H -void plot(int x, int y); +int plot(int x, int y); void plot_init(void); #endif /* !PLOT_H */