Tscope5
timer4.c

double keypress response

#include <tscope5.h>
int main()
{
ts5_wait(2.0);
double start;
double stop1, rt1, error1;
double stop2, rt2, error2;
int i;
for (i=0; i<5; i++) {
ts5_printf(0.0, 0.0, "+");
unsigned int stim = ts5_random_integer(2);
if (stim==0) {
stim='S';
}
else {
stim='L';
}
ts5_printf(0.0, 0.0, "%c", stim);
ts5_wait(0.5);
start = ts5_flip_display();
int resp1 = ts5_wait_for_response_until(&stop1, &error1, start + 2.0);
int resp2 = ts5_wait_for_response_until(&stop2, &error2, start + 2.0);
rt1 = stop1-start;
rt2 = stop2-start;
int align = ts5_set_text_alignment(TS5_ALIGN_LEFT);
ts5_printf(-200.0, 20.0, "responses: %d %d", resp1, resp2);
ts5_printf(-200.0, 0.0, "rts: %f %f", rt1, rt2);
ts5_printf(-200.0, -20.0, "measurement errors: %f %f", error1, error2);
ts5_wait(2.0);
}
return 0;
}