#include <tscope.h>
#include <tscope/internal.h>
int main()
{
ts_debug(DEBUG0);
ts_scrsize(SIZE2);
ts_init();
int i;
for (i = KEY_A; i <= KEY_CAPSLOCK; i++)
ts_defkey(i);
int mouse = ts_defkey(M1);
ts_printf(-XMAX + 20, YMAX - 40, "testkeyboard.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 the left mouse button to exit");
int x = 0, y = 0;
for (i = KEY_A; i <= KEY_CAPSLOCK; i++) {
ts_printf(-XMAX + 20 + x, YMAX - 80 - y, "%s", _sdefkey[i]);
y += 20;
if (y > 480) {
y = 0;
x += 120;
}
}
int r;
do {
r = ts_respstatus();
if (r) {
for (i = KEY_A; i <= KEY_CAPSLOCK; i++)
if (i == r) {
ts_fgcolor(RED);
x = (r - 1) / 25 * 120;
y = ((r - 1) % 25) * 20;
ts_printf(-XMAX + 20 + x, YMAX - 80 - y, "%s",
_sdefkey[r]);
ts_wait(mtt(1000));
ts_fgcolor(WHITE);
ts_printf(-XMAX + 20 + x, YMAX - 80 - y, "%s",
_sdefkey[r]);
}
}
} while (r != mouse);
return 0;
}
END_OF_MAIN();