/*
          __
         / /_______________  ____  ___
        / __/ ___/ ___/ __ \/ __ \/ _ \
       / /_(__  ) /__/ /_/ / /_/ /  __/
       \__/____/\___/\____/ .___/\___/
                         /_/

    testmouse.c
*/

#include <tscope.h>

int main()
{
    // initialize the screen
    ts_debug(DEBUG0);
    ts_scrsize(SIZE1);
    ts_init();

    // define the response keys
    ts_defkey(M1);
    ts_defkey(M2);
    ts_defkey(M3);
    int space = ts_defkey(KEY_SPACE);

    // some instructions
    ts_printf(-XMAX + 20, YMAX - 40, "testmouse.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");

    // draw the button array
    ts_textmode(BLACK);
    ts_drawmouse();
    int i, r;
    for (i = 1; i <= 3; i++)
        ts_printf_centre(0 + i * 20 - 40, 0, "M%d", i);

    // update the button array
    do {
        r = ts_respstatus();
        if (r) {
            for (i = 1; i <= 3; i++) {
                if (i == r) {
                    ts_fgcolor(RED);
                    ts_printf_centre(0 + i * 20 - 40, 0, "M%d", i);
                    ts_wait(mtt(1000));
                    ts_fgcolor(WHITE);
                    ts_printf_centre(0 + i * 20 - 40, 0, "M%d", i);
                }
            }
        }
        ts_printf_centre(-ax(.5), -ay(.5), "X: %04d", ts_xmouse());
        ts_printf_centre(ax(.5), -ay(.5), "Y: %04d", ts_ymouse());
    } while (r != space);

    // exit
    return 0;
}

END_OF_MAIN();


top
Persoonlijke pagina Universiteit GentTscope
Allegro | Cygwin | Gcc
© See license.html for copyright information