#include <tscope.h>
int main()
{
ts_debug(DEBUG0);
ts_scrsize(SIZE1);
ts_init();
ts_defkey(J1);
ts_defkey(J2);
ts_defkey(J3);
ts_defkey(J4);
ts_defkey(J5);
ts_defkey(J6);
ts_defkey(J7);
ts_defkey(J8);
ts_defkey(J9);
ts_defkey(J10);
int space = ts_defkey(KEY_SPACE);
ts_printf(-XMAX + 20, YMAX - 40, "testjoystick.c");
ts_printf(-XMAX + 20, YMAX - 50,
"When a keypress is detected the corresponding code will be highlighted");
ts_printf(-XMAX + 20, YMAX - 60, "Press space to exit");
int i, r;
for (i = 1; i <= 10; i++)
ts_printf_centre(0 + i * 30 - 165, 0, "M%d", i);
do {
r = ts_respstatus();
if (r) {
for (i = 1; i <= 10; i++) {
if (i == r) {
ts_fgcolor(RED);
ts_printf_centre(0 + i * 30 - 165, 0, "M%d", i);
ts_wait(mtt(1000));
ts_fgcolor(WHITE);
ts_printf_centre(0 + i * 30 - 165, 0, "M%d", i);
}
}
}
} while (r != space);
return 0;
}
END_OF_MAIN();