From 2d957c6efa1a96ed5cdbbc3a4a49d50282f166a9 Mon Sep 17 00:00:00 2001 From: Grazvydas Ignotas Date: Fri, 23 Mar 2012 00:31:11 +0200 Subject: [PATCH] op_test_inputs: adjust validation code, relax nub range --- op_test_inputs.c | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/op_test_inputs.c b/op_test_inputs.c index 130dadf..8a1e471 100644 --- a/op_test_inputs.c +++ b/op_test_inputs.c @@ -40,6 +40,13 @@ #define array_size(x) (sizeof(x) / sizeof(x[0])) +/* this sucks, but EvilDragon wants it */ +#ifdef VALIDATION +#define NUB_RANGE_REQ (256-8*3) +#else +#define NUB_RANGE_REQ 256 +#endif + typedef struct { int x, y; int code; @@ -215,14 +222,14 @@ static void redraw_nubs(unsigned short *fb, int x1, int y1, int x2, int y2) text_out16(fb + 200, 32*2 + x1/8, 32*2 + y1/8, 0x001f, "@"); text_out16(fb + 450, 32*2 + x2/8, 32*2 + y2/8, 0x001f, "@"); - if (x1 == -256) nub_range_hit |= 0x01; - if (x1 == 256) nub_range_hit |= 0x02; - if (y1 == -256) nub_range_hit |= 0x04; - if (y1 == 256) nub_range_hit |= 0x08; - if (x2 == -256) nub_range_hit |= 0x10; - if (x2 == 256) nub_range_hit |= 0x20; - if (y2 == -256) nub_range_hit |= 0x40; - if (y2 == 256) nub_range_hit |= 0x80; + if (x1 <= -NUB_RANGE_REQ) nub_range_hit |= 0x01; + if (x1 >= NUB_RANGE_REQ) nub_range_hit |= 0x02; + if (y1 <= -NUB_RANGE_REQ) nub_range_hit |= 0x04; + if (y1 >= NUB_RANGE_REQ) nub_range_hit |= 0x08; + if (x2 <= -NUB_RANGE_REQ) nub_range_hit |= 0x10; + if (x2 >= NUB_RANGE_REQ) nub_range_hit |= 0x20; + if (y2 <= -NUB_RANGE_REQ) nub_range_hit |= 0x40; + if (y2 >= NUB_RANGE_REQ) nub_range_hit |= 0x80; snprintf(buff, sizeof(buff), "%3i", x1/8); text_out16_small(fb, 235, 130, (nub_range_hit & 0x03) == 0x03 ? 0xce6f : 0x7bef, buff); @@ -411,6 +418,7 @@ int main(int argc, char *argv[]) int nubx[2] = {0,0}, nuby[2] = {0,0}; int pressed_l = 0, pressed_r = 0; struct tsdev *ts = NULL; + int retval = 0; fbdev = open("/dev/fb0", O_RDWR); if (fbdev == -1) @@ -516,7 +524,7 @@ int main(int argc, char *argv[]) fd_set fdset; #ifdef VALIDATION - if (early_leave_attempt) { + if (early_leave_attempt > 1) { char buff[128]; snprintf(buff, sizeof(buff), "not everything tested (%s%s%s%s), L+R to override", nub_range_hit == 0xff ? "" : "nubs", all_btns_tested ? "" : " buttons", @@ -524,7 +532,7 @@ int main(int argc, char *argv[]) memset(screen, 0, 800*12*2); if (nub_range_hit == 0xff && all_btns_tested && lid_tested && ts_tested) text_out16_small(screen, 220, 3, 0x07c0, - "press menu/pandora to shutdown, L+Start to exit"); + "press menu/pandora to exit"); else text_out16_small(screen, 4, 3, 0xf800, buff); } @@ -589,22 +597,14 @@ int main(int argc, char *argv[]) if (ev[i].code == KEY_RIGHTCTRL) pressed_r = !!ev[i].value; #ifdef VALIDATION - if (ev[i].code == KEY_LEFTALT && !!ev[i].value && pressed_l) { - // L+Start, legacy code + if (ev[i].code == KEY_MENU && !!ev[i].value) { if (nub_range_hit == 0xff && all_btns_tested && lid_tested && ts_tested) goto end; - if (pressed_l && pressed_r) - goto end; - early_leave_attempt = 1; - } - if (ev[i].code == KEY_MENU && !!ev[i].value) { - if ((nub_range_hit == 0xff && all_btns_tested && lid_tested && ts_tested) || - (pressed_l && pressed_r)) { - sync(); - //system("poweroff -f"); + if (pressed_l && pressed_r) { + retval = 1; goto end; } - early_leave_attempt = 1; + early_leave_attempt++; } #endif if (ev[i].code == KEY_LEFT) @@ -651,6 +651,6 @@ end: close(ifd[i]); munmap(screen, 800*480*2); close(fbdev); - return 0; + return retval; } -- 2.39.5