mirror of
git://projects.qi-hardware.com/antorcha.git
synced 2024-11-01 05:43:09 +02:00
tools/: exit from sample mode by pressing Q or by closing the window
This commit is contained in:
parent
4eb1065dd7
commit
87050bc12a
@ -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);
|
||||
}
|
||||
|
24
tools/plot.c
24
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;
|
||||
}
|
||||
|
||||
|
||||
|
@ -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 */
|
||||
|
Loading…
Reference in New Issue
Block a user