int main () 
{
  int key=0;
  int n=0;
    while (key!='O') 
	{	if(keyhit())
		{	key = getchp();
			printf("Key %d is: %c\n",n, key);
		}
		n++;
	}
}
Exemple #2
0
/*
**	funkey_meta(test_list, status, ch)
**
**	Test meta key (km) (smm) (rmm)
*/
static void
funkey_meta(
	       TestList * t,
	       int *state,
	       int *ch)
{
    if (has_meta_key) {
	int i, j, k, len;
	char outbuf[256];

	put_crlf();
	if (char_mask != ALLOW_PARITY) {
	    if (tty_meta_prep()) {
		ptext("\nHit any key to continue > ");
		(void) wait_here();
		put_crlf();
	    }
	}
	ptext("Begin meta key test. (km) (smm) (rmm)  Hit any key");
	ptext(" with the meta key.  The character will be");
	ptext(" displayed in hex.  If the meta key is working");
	ptext(" then the most significant bit will be set.  Type");
	ptextln(" 'end' to exit.");
	tty_raw(1, ALLOW_PARITY);
	tc_putp(meta_on);

	for (i = j = k = len = 0; i != 'e' || j != 'n' || k != 'd';) {
	    i = j;
	    j = k;
	    k = getchp(ALLOW_PARITY);
	    if (k == EOF) {
		break;
	    }
	    if ((len += 3) >= columns) {
		put_crlf();
		len = 3;
	    }
	    sprintf(outbuf, "%02X ", k);
	    put_str(outbuf);
	    k &= STRIP_PARITY;
	}
	tc_putp(meta_off);
	put_crlf();
	tty_set();
	put_crlf();
    } else {
	ptext("(km) Has-meta-key is not set.  ");
    }
    generic_done_message(t, state, ch);
}
Exemple #3
0
/*
**	funkey_prog(test_list, status, ch)
**
**	Test program function keys (pfx)
*/
static void
funkey_prog(
	       TestList * t,
	       int *state,
	       int *ch)
{
    if (pkey_xmit) {
	int i;
	int fk = 1;
	char mm[256];

	/* test program function key */
	sprintf(temp,
		"(pfx) Set function key %d to transmit abc\\n", fk);
	ptextln(temp);
	tc_putp(TPARM_2(pkey_xmit, fk, "abc\n"));
	sprintf(temp, "Hit function key %d\n", fk);
	ptextln(temp);

	memset(mm, 0, (size_t) 4);
	for (i = 0; i < 4; ++i) {
	    int cc = getchp(STRIP_PARITY);
	    if (cc == EOF)
		break;
	    mm[i] = (char) cc;
	}
	mm[i] = '\0';

	put_crlf();
	if (mm[0] != 'a' || mm[1] != 'b' || mm[2] != 'c') {
	    sprintf(temp, "Error string received was: %s", expand(mm));
	    ptextln(temp);
	} else {
	    putln("Thank you\n");
	}
	flush_input();
	if (key_f1) {
	    tc_putp(TPARM_2(pkey_xmit, fk, key_f1));
	}
    } else {
	ptextln("Function key transmit (pfx), not present.");
    }
    generic_done_message(t, state, ch);
}
Exemple #4
0
/*
**	funkey_prog(test_list, status, ch)
**
**	Test program function keys (pfx)
*/
static void
funkey_prog(
	struct test_list *t,
	int *state,
	int *ch)
{
	int i, fk;
	char mm[256];

	fk = 1;	/* use function key 1 for now */
	if (pkey_xmit) {
		/* test program function key */
		sprintf(temp,
			"(pfx) Set function key %d to transmit abc\\n", fk);
		ptextln(temp);
		tc_putp(TPARM_2(pkey_xmit, fk, "abc\n"));
		sprintf(temp, "Hit function key %d\n", fk);
		ptextln(temp);
		for (i = 0; i < 4; ++i)
			mm[i] = (char) getchp(STRIP_PARITY);
		mm[i] = '\0';
		put_crlf();
		if (mm[0] != 'a' || mm[1] != 'b' || mm[2] != 'c') {
			sprintf(temp, "Error string received was: %s", expand(mm));
			ptextln(temp);
		} else {
			putln("Thank you\n");
		}
		flush_input();
		if (key_f1) {
			tc_putp(TPARM_2(pkey_xmit, fk, key_f1));
		}
	} else {
		ptextln("Function key transmit (pfx), not present.");
	}
	generic_done_message(t, state, ch);
}