From: Grazvydas Ignotas Date: Sun, 16 Jan 2011 22:28:52 +0000 (+0200) Subject: all-key test X-Git-Tag: sz_beta3~19^2~2 X-Git-Url: http://git.openpandora.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6b5300f9292ee9c9d6cc772baee56458c7315ce2;p=pandora-misc.git all-key test --- diff --git a/op_test_inputs.c b/op_test_inputs.c index 6db1b07..ec5fd8b 100644 --- a/op_test_inputs.c +++ b/op_test_inputs.c @@ -119,8 +119,9 @@ static key_item key_items[] = #define KI_COUNT (sizeof(key_items) / sizeof(key_items[0])) -static int ts_old_x = 0, ts_old_y = 0; -static int lid_closed = 0; +static int nub_range_hit, all_btns_tested, lid_tested, ts_tested; +static int ts_old_x, ts_old_y; +static int lid_closed; static void draw_ts_cross(unsigned short *fb, unsigned short col, int x, int y) { @@ -133,7 +134,10 @@ static void draw_ts_cross(unsigned short *fb, unsigned short col, int x, int y) if (x >= 0 && x < 800) for (y1 = y - 5, i = 0; i < 11; i++, y1++) if (y1 >= 0 && y1 < 480) fb[y1 * 800 + x] = col; - + + if (x != ts_old_x && y != ts_old_y) + ts_tested = 1; + ts_old_x = x; ts_old_y = y; } @@ -194,39 +198,41 @@ static void text_out16_small(unsigned short *fb, int x, int y, unsigned short co static void redraw_nubs(unsigned short *fb, int x1, int y1, int x2, int y2) { - static int range_hit; char buff[32]; - int y; + int fill = 0, y; fb += 90*800; + if (nub_range_hit == 0xff && all_btns_tested && lid_tested && ts_tested) + fill = 3; + // clear areas for (y = 0; y < 140; y++) { - memset(fb + 800*y + 200, 0, (64+8)*2*2); - memset(fb + 800*y + 450, 0, (64+8)*2*2); + memset(fb + 800*y + 200, fill, (64+8)*2*2); + memset(fb + 800*y + 450, fill, (64+8)*2*2); } 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) range_hit |= 0x01; - if (x1 == 256) range_hit |= 0x02; - if (y1 == -256) range_hit |= 0x04; - if (y1 == 256) range_hit |= 0x08; - if (x2 == -256) range_hit |= 0x10; - if (x2 == 256) range_hit |= 0x20; - if (y2 == -256) range_hit |= 0x40; - if (y2 == 256) range_hit |= 0x80; + 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; snprintf(buff, sizeof(buff), "%3i", x1/8); - text_out16_small(fb, 235, 130, (range_hit & 0x03) == 0x03 ? 0xce6f : 0x7bef, buff); + text_out16_small(fb, 235, 130, (nub_range_hit & 0x03) == 0x03 ? 0xce6f : 0x7bef, buff); snprintf(buff, sizeof(buff), "%3i", y1/8); - text_out16_small(fb, 270, 130, (range_hit & 0x0c) == 0x0c ? 0xce6f : 0x7bef, buff); + text_out16_small(fb, 270, 130, (nub_range_hit & 0x0c) == 0x0c ? 0xce6f : 0x7bef, buff); snprintf(buff, sizeof(buff), "%3i", x2/8); - text_out16_small(fb, 485, 130, (range_hit & 0x30) == 0x30 ? 0xce6f : 0x7bef, buff); + text_out16_small(fb, 485, 130, (nub_range_hit & 0x30) == 0x30 ? 0xce6f : 0x7bef, buff); snprintf(buff, sizeof(buff), "%3i", y2/8); - text_out16_small(fb, 520, 130, (range_hit & 0xc0) == 0xc0 ? 0xce6f : 0x7bef, buff); + text_out16_small(fb, 520, 130, (nub_range_hit & 0xc0) == 0xc0 ? 0xce6f : 0x7bef, buff); } static void redraw_keys_lid(unsigned short *fb) @@ -243,7 +249,7 @@ static void redraw_keys_lid(unsigned short *fb) key->name); } - text_out16(fb, 10, 260, lid_closed ? 0x07e0 : 0x7bef, "LID"); + text_out16(fb, 10, 260, lid_closed ? 0x07e0 : (lid_tested ? 0xce6f : 0x7bef), "LID"); } static void set_key(int code, int val) @@ -270,6 +276,22 @@ static void set_key(int code, int val) key->tested |= !!val; printf("%c %s\n", val ? '+' : '-', key->name); } + + if (all_btns_tested) + return; + + for (i = 0; i < KI_COUNT; i++) + { + if (key_items[i].code == KEY_MENU) + continue; + if (key_items[i].code == KEY_KPPLUS || key_items[i].code == KEY_KPMINUS) + continue; + if (!key_items[i].tested) + break; + } + + if (i == KI_COUNT) + all_btns_tested = 1; } /* sound test */ @@ -423,7 +445,7 @@ int main(int argc, char *argv[]) ioctl(fd, EVIOCGNAME(sizeof(name)), name); - if (strcasestr(name, "power") != NULL) + if (strcasestr(name, "power") != NULL || strcasestr(name, "pwrbutton") != NULL) { ifd[DEV_PWRBTN] = fd; } @@ -476,17 +498,37 @@ int main(int argc, char *argv[]) if (ifd[DEV_RNUB] == -1) printf("Warning: couldn't find nub2 device\n"); #ifdef VALIDATION - text_out16_small(screen, 220, 3, 0x7bef, "press menu/pandora to shutdown, alt/start to exit"); + int early_leave_attempt = 0; + text_out16_small(screen, 220, 3, 0x7bef, + "press menu/pandora to shutdown, L+Start to exit"); #else text_out16_small(screen, 320, 3, 0x7bef, "Press L+R to exit"); #endif +#ifdef VALIDATION + while (1) +#else while (!pressed_l || !pressed_r) +#endif { struct input_event ev[64]; int fd = -1, rd, which, ret; fd_set fdset; +#ifdef VALIDATION + if (early_leave_attempt) { + 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", + lid_tested ? "" : " lid_switch", ts_tested ? "" : " touchscreen"); + 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"); + else + text_out16_small(screen, 4, 3, 0xf800, buff); + } +#endif draw_ts_cross(screen, 0x0000, ts_old_x, ts_old_y); redraw_keys_lid(screen); redraw_nubs(screen, nubx[0], nuby[0], nubx[1], nuby[1]); @@ -541,18 +583,27 @@ int main(int argc, char *argv[]) break; case EV_KEY: set_key(ev[i].code, ev[i].value); -#ifndef VALIDATION + if (ev[i].code == KEY_RIGHTSHIFT) pressed_l = !!ev[i].value; if (ev[i].code == KEY_RIGHTCTRL) pressed_r = !!ev[i].value; -#else - if (ev[i].code == KEY_LEFTALT && !!ev[i].value) - goto end; +#ifdef VALIDATION + if (ev[i].code == KEY_LEFTALT && !!ev[i].value && pressed_l) { + 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) { - sync(); - system("poweroff -f"); - goto end; + if ((nub_range_hit == 0xff && all_btns_tested && lid_tested && ts_tested) || + (pressed_l && pressed_r)) { + sync(); + system("poweroff -f"); + goto end; + } + early_leave_attempt = 1; } #endif if (ev[i].code == KEY_LEFT) @@ -570,8 +621,10 @@ int main(int argc, char *argv[]) printf("unexpected EV_ABS code: %i\n", ev[i].code); break; case EV_SW: - if (ev[i].code == SW_LID) + if (ev[i].code == SW_LID) { lid_closed = ev[i].value; + lid_tested |= ev[i].value; + } else printf("unexpected EV_SW code: %i\n", ev[i].code); break;