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

    timer6.c
    measuring key press time
*/

#include <tscope.h>

#define BLANKTM mtt(500)
#define MAXTM   mtt(3500)

struct {
    int rt, err;
    int presstime;
    int resp;
} data;

struct {
    __int64 junk;
    __int64 t1, e1;
    __int64 t2, e2;
    __int64 t3, e3;
} tmp;

void trial()
{
    // fixation
    ts_vsync(&tmp.junk, &tmp.junk);
    ts_printf_centre(0, 0, "+");
    ts_wait(BLANKTM);

    // stimulus
    ts_vsync(&tmp.t1, &tmp.e1);
    ts_clrscr();
    ts_printf_centre(0, 0, "stimulus");

    // response
    data.resp = ts_resp(&tmp.t2, &tmp.e2, MAXTM);

    // wait until button is released
    ts_release(&tmp.t3, &tmp.e3, mtt(0));

    ts_clrscr();

    // compute time
    data.rt = ttm(tmp.t2 - tmp.t1);
    data.err = ttmu(tmp.e1 + tmp.e2 + tmp.e3);
    data.presstime = ttm(tmp.t3 - tmp.t2);
}

int main()
{
    // prepare the subject
    ts_printf_centre(0, 20, "press one of the mouse buttons");
    ts_printf_centre(0, 0, "within 1500ms after the appearance");
    ts_printf_centre(0, -20, "of the stimulus");
    ts_button(XMAX - 20, -YMAX + 20);
    ts_clrscr();

    // define response key
    ts_defkey(M1);
    ts_defkey(M2);

    // execute trial
    trial();

    // print some results
    ts_printf_centre(0, 60, "response: %d", data.resp);
    ts_printf_centre(0, 20, "rt: %4d ms", data.rt);
    ts_printf_centre(0, -20, "presstime: %4d ms", data.presstime);
    ts_printf_centre(0, -60, "error: %4d us", data.err);
    ts_mousepos(0, 0);

    ts_button(XMAX - 20, -YMAX + 20);
    return 0;
}

END_OF_MAIN();


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